Skip to content

Commit

Permalink
adding missing Lua APIs. [skip CI]
Browse files Browse the repository at this point in the history
  • Loading branch information
pigpigyyy committed Dec 28, 2023
1 parent 7fb2248 commit c6e0419
Show file tree
Hide file tree
Showing 14 changed files with 658 additions and 6 deletions.
5 changes: 5 additions & 0 deletions Assets/Script/Lib/Dora/en/Rect.d.tl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ local record Rect
-- @return (boolean) Whether or not the rectangles intersect.
intersectsRect: function(self: Rect, rect: Rect): boolean

-- Check if two rectangles are equal.
-- @param other (Rect) The other rectangle to compare to, represented by a Rect object.
-- @return (boolean) Whether or not the two rectangles are equal.
equals: function(self: Rect, other: Rect): boolean

-- Check if two rectangles are equal.
-- @param other (Rect) The other rectangle to compare to, represented by a Rect object.
-- @return (boolean) Whether or not the two rectangles are equal.
Expand Down
12 changes: 12 additions & 0 deletions Assets/Script/Lib/Dora/en/SizeType.d.tl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ local record Size
-- @param height (number) The new height of the size.
set: function(self: Size, width: number, height: number)

-- Check if two sizes are equal.
-- @param other (Size) The other size to compare to.
-- @return (boolean) Whether or not the two sizes are equal.
-- @usage sizeA == sizeB or sizeC ~= sizeD
equals: function(self: Size, other: Size): boolean

-- Multiply the size by a vector.
-- @param vec (Vec2) The vector to multiply by.
-- @return (Size) The result of multiplying the size by the vector.
-- @usage local halfSize = size * Vec2(0.5, 0.5)
mul: function(self: Size, vec: Vec2): Size

-- Check if two sizes are equal.
-- @param other (Size) The other size to compare to.
-- @return (boolean) Whether or not the two sizes are equal.
Expand Down
36 changes: 36 additions & 0 deletions Assets/Script/Lib/Dora/en/Vec2Type.d.tl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,42 @@ local record Vec2
-- @return (Vec2) The clamped vector.
clamp: function(self: Vec2, from: Vec2, to: Vec2): Vec2

-- Adds two vectors together.
-- @param other (Vec2) The other vector to add, represented by a Vec2 object.
-- @return (Vec2) The sum of the two vectors.
add: function(self: Vec2, other: Vec2): Vec2

-- Subtracts one vector from another.
-- @param other (Vec2) The vector to subtract, represented by a Vec2 object.
-- @return (Vec2) The difference between the two vectors.
sub: function(self: Vec2, other: Vec2): Vec2

-- Multiplies two vectors component-wise.
-- @param other (Vec2) The other vector to multiply by, represented by a Vec2 object.
-- @return (Vec2) The result of multiplying the two vectors component-wise.
mul: function(self: Vec2, other: Vec2): Vec2

-- Multiplies a vector by a scalar.
-- @param other (Vec2) The scalar to multiply by, represented by a number.
-- @return (Vec2) The result of multiplying the vector by the scalar.
mul: function(self: Vec2, other: number): Vec2

-- Multiplies a vector by a Size object.
-- @param other (Size) The Size object to multiply by.
-- @return (Vec2) The result of multiplying the vector by the Size object.
-- @usage local halfVec = vec * Size(0.5, 0.5)
mul: function(self: Vec2, other: Size): Vec2

-- Divide a vector by a scalar.
-- @param other (number) The scalar to divide by, represented by a number.
-- @return (Vec2) The result of dividing the vector by the scalar.
div: function(self: Vec2, other: number): Vec2

-- Compare two vectors for equality.
-- @param other (Vec2) The other vector to compare to, represented by a Vec2 object.
-- @return (boolean) Whether or not the two vectors are equal.
equals: function(self: Vec2, other: Vec2): boolean

-- Adds two vectors together.
-- @param other (Vec2) The other vector to add, represented by a Vec2 object.
-- @return (Vec2) The sum of the two vectors.
Expand Down
5 changes: 5 additions & 0 deletions Assets/Script/Lib/Dora/zh-Hans/Rect.d.tl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ local record Rect
-- @return (boolean) 矩形是否相交。
intersectsRect: function(self: Rect, rect: Rect): boolean

-- 检查两个矩形是否相等。
-- @param other (Rect) 要比较的另一个矩形,用`Rect`对象表示。
-- @return (boolean) 两个矩形是否相等。
equals: function(self: Rect, other: Rect): boolean

-- 检查两个矩形是否相等。
-- @param other (Rect) 要比较的另一个矩形,用`Rect`对象表示。
-- @return (boolean) 两个矩形是否相等。
Expand Down
10 changes: 10 additions & 0 deletions Assets/Script/Lib/Dora/zh-Hans/SizeType.d.tl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ local record Size
-- @param height (number) 尺寸对象的新高度。
set: function(self: Size, width: number, height: number)

-- 检查两个尺寸对象是否相等。
-- @param other (Size) 要比较的另一个尺寸对象。
-- @return (boolean) 两个尺寸对象是否相等。
equals: function(self: Size, other: Size): boolean

-- 将尺寸对象乘以向量。
-- @param vec (Vec2) 要乘以的向量,用一个Vec2对象表示。
-- @return (Size) 将尺寸对象乘以向量的结果。
mul: function(self: Size, vec: Vec2): Size

-- 检查两个尺寸对象是否相等。
-- @param other (Size) 要比较的另一个尺寸对象。
-- @return (boolean) 两个尺寸对象是否相等。
Expand Down
35 changes: 35 additions & 0 deletions Assets/Script/Lib/Dora/zh-Hans/Vec2Type.d.tl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,41 @@ local record Vec2
-- @return (Vec2) 限定在范围内的向量。
clamp: function(self: Vec2, from: Vec2, to: Vec2): Vec2

-- 将两个向量相加的元方法。
-- @param other (Vec2) 要相加的另一个向量。
-- @return (Vec2) 两个向量之和。
add: function(self: Vec2, other: Vec2): Vec2

-- 从一个向量中减去另一个向量的元方法。
-- @param other (Vec2) 要减去的向量。
-- @return (Vec2) 两个向量之间的差。
sub: function(self: Vec2, other: Vec2): Vec2

-- 逐分量相乘两个向量的元方法。
-- @param other (Vec2) 要相乘的另一个向量。
-- @return (Vec2) 逐分量相乘两个向量的结果。
mul: function(self: Vec2, other: Vec2): Vec2

-- 将向量乘以标量的元方法。
-- @param other (number) 要乘以的标量,用数字表示。
mul: function(self: Vec2, other: number): Vec2

-- 将向量乘以尺寸对象的元方法。
-- @param other (Size) 要乘以的尺寸对象。
-- @return (Vec2) 将向量乘以尺寸对象的结果。
-- @usage local halfVec = vec * Size(0.5, 0.5)
mul: function(self: Vec2, other: Size): Vec2

-- 将向量除以标量的元方法。
-- @param other (number) 要除以的标量。
-- @return (Vec2) 将向量除以标量的结果。
div: function(self: Vec2, other: number): Vec2

-- 比较两个向量是否相等的元方法。
-- @param other (Vec2) 要进行比较的另一个向量。
-- @return (boolean) 两个向量是否相等。
equals: function(self: Vec2, other: Vec2): boolean

-- 将两个向量相加的元方法。
-- @param other (Vec2) 要相加的另一个向量。
-- @return (Vec2) 两个向量之和。
Expand Down
25 changes: 25 additions & 0 deletions Site/docs/api/Class/Rect.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,31 @@ intersectsRect: function(self: Rect, rect: Rect): boolean
| --- | --- |
| boolean | Whether or not the rectangles intersect. |

## equals

**Type:** Function.

**Description:**

  Check if two rectangles are equal.

**Signature:**
```tl
equals: function(self: Rect, other: Rect): boolean
```

**Parameters:**

| Parameter | Type | Description |
| --- | --- | --- |
| other | Rect | The other rectangle to compare to, represented by a Rect object. |

**Returns:**

| Return Type | Description |
| --- | --- |
| boolean | Whether or not the two rectangles are equal. |

## __eq

**Type:** Metamethod.
Expand Down
60 changes: 60 additions & 0 deletions Site/docs/api/Class/Size.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,66 @@ set: function(self: Size, width: number, height: number)
| width | number | The new width of the size. |
| height | number | The new height of the size. |

## equals

**Type:** Function.

**Description:**

  Check if two sizes are equal.

**Signature:**
```tl
equals: function(self: Size, other: Size): boolean
```

**Usage:**
```tl
sizeA == sizeB or sizeC ~= sizeD
```

**Parameters:**

| Parameter | Type | Description |
| --- | --- | --- |
| other | Size | The other size to compare to. |

**Returns:**

| Return Type | Description |
| --- | --- |
| boolean | Whether or not the two sizes are equal. |

## mul

**Type:** Function.

**Description:**

  Multiply the size by a vector.

**Signature:**
```tl
mul: function(self: Size, vec: Vec2): Size
```

**Usage:**
```tl
local halfSize = size * Vec2(0.5, 0.5)
```

**Parameters:**

| Parameter | Type | Description |
| --- | --- | --- |
| vec | Vec2 | The vector to multiply by. |

**Returns:**

| Return Type | Description |
| --- | --- |
| Size | The result of multiplying the size by the vector. |

## __eq

**Type:** Metamethod.
Expand Down
Loading

0 comments on commit c6e0419

Please sign in to comment.