Class: EdgeOffsets
Defined in: index.ts:1006
EdgeOffsets represents insets or outsets from rectangle edges.
Remarks
EdgeOffsets are used with Rect.inset() to shrink or expand rectangles. Positive values shrink the rectangle, negative values expand it.
Constructors
Constructor
new EdgeOffsets(
top
,right?
,bottom?
,left?
):EdgeOffsets
Defined in: index.ts:1139
Creates EdgeOffsets with CSS-style parameters.
Parameters
top
number
Top offset
right?
number
Right offset (defaults to top)
bottom?
number
Bottom offset (defaults to top)
left?
number
Left offset (defaults to right)
Returns
EdgeOffsets
A new EdgeOffsets instance
Constructor
new EdgeOffsets(
topLeft
,bottomRight
):EdgeOffsets
Defined in: index.ts:1140
Parameters
topLeft
bottomRight
Returns
EdgeOffsets
Properties
topLeft
topLeft:
Vec2
Defined in: index.ts:1007
bottomRight
bottomRight:
Vec2
Defined in: index.ts:1008
zero
readonly
static
zero:EdgeOffsets
Defined in: index.ts:1113
Zero edge offsets.
Accessors
left
Get Signature
get left():
number
Defined in: index.ts:1014
Gets the left offset.
Returns
number
The left offset value
top
Get Signature
get top():
number
Defined in: index.ts:1022
Gets the top offset.
Returns
number
The top offset value
right
Get Signature
get right():
number
Defined in: index.ts:1030
Gets the right offset.
Returns
number
The right offset value
bottom
Get Signature
get bottom():
number
Defined in: index.ts:1038
Gets the bottom offset.
Returns
number
The bottom offset value
neg
Get Signature
get neg():
EdgeOffsets
Defined in: index.ts:1046
Gets the negated edge offsets.
Returns
EdgeOffsets
New EdgeOffsets with negated values
horizontal
Get Signature
get horizontal():
number
Defined in: index.ts:1119
Gets the total horizontal offset (left + right).
Returns
number
The sum of left and right offsets
vertical
Get Signature
get vertical():
number
Defined in: index.ts:1127
Gets the total vertical offset (top + bottom).
Returns
number
The sum of top and bottom offsets
Methods
equals()
equals(
other
):boolean
Defined in: index.ts:1055
Checks if this EdgeOffsets equals another.
Parameters
other
EdgeOffsets
The EdgeOffsets to compare with
Returns
boolean
True if all offsets are equal
toString()
toString():
string
Defined in: index.ts:1066
Returns a string representation of this EdgeOffsets.
Returns
string
A string in the format "EdgeOffsets(left,top,right,bottom)"
from()
static
from(options
):EdgeOffsets
Defined in: index.ts:1081
Creates EdgeOffsets from various input formats.
Parameters
options
A number (uniform), or object with offsets
number
| { left
: number
; top
: number
; right
: number
; bottom
: number
; } | { topLeft
: Vec2
; bottomRight
: Vec2
; }
Returns
EdgeOffsets
A new EdgeOffsets instance
Example
EdgeOffsets.from(10) // All sides: 10
EdgeOffsets.from({ left: 5, top: 10, right: 15, bottom: 20 })
EdgeOffsets.from({ topLeft: new Vec2(5, 10), bottomRight: new Vec2(15, 20) })
add()
add(
other
):EdgeOffsets
Defined in: index.ts:1165
Adds two EdgeOffsets.
Parameters
other
EdgeOffsets
The EdgeOffsets to add
Returns
EdgeOffsets
A new EdgeOffsets with summed values
mul()
mul(
scale
):EdgeOffsets
Defined in: index.ts:1177
Multiplies EdgeOffsets by a scalar.
Parameters
scale
number
The scale factor
Returns
EdgeOffsets
A new scaled EdgeOffsets