Class: Transform2D
Defined in: src/sdk/math/Transform2D.ts:9
A 2D affine transformation. By default, Transform2D objects are initially created as identity transformations.
Constructors
Constructor
new Transform2D():
Transform2D
Returns
Transform2D
Methods
addReflection()
Call Signature
addReflection(
theta
,order?
):this
Defined in: src/sdk/math/Transform2D.ts:411
Adds a reflection across a line passing through the origin (0, 0) to this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
theta | number | The angle of the reflection line, in radians, with respect to the positive x axis. |
order? | "after" | "before" | The order in which to add the reflection, relative to this existing transformation, either 'before' or 'after' . Defaults to 'after' . |
Returns
this
This transformation, after it has been changed.
Call Signature
addReflection(
theta
,originX
,originY
,order?
):this
Defined in: src/sdk/math/Transform2D.ts:421
Adds a reflection across a line passing through an arbitrary origin to this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
theta | number | The angle of the reflection line, in radians, with respect to the positive x axis. |
originX | number | The x-coordinate of the reflection origin. |
originY | number | The y-coordinate of the reflection origin. |
order? | "after" | "before" | The order in which to add the reflection, relative to this existing transformation, either 'before' or 'after' . Defaults to 'after' . |
Returns
this
This transformation, after it has been changed.
addRotation()
Call Signature
addRotation(
theta
,order?
):this
Defined in: src/sdk/math/Transform2D.ts:370
Adds a rotation about the origin (0, 0) to this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
theta | number | The rotation angle, in radians. |
order? | "after" | "before" | The order in which to add the rotation, relative to this existing transformation, either 'before' or 'after' . Defaults to 'after' . |
Returns
this
This transformation, after it has been changed.
Call Signature
addRotation(
theta
,originX
,originY
,order?
):this
Defined in: src/sdk/math/Transform2D.ts:380
Adds a rotation about an arbitrary origin to this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
theta | number | The rotation angle, in radians. |
originX | number | The x-coordinate of the rotation origin. |
originY | number | The y-coordinate of the rotation origin. |
order? | "after" | "before" | The order in which to add the rotation, relative to this existing transformation, either 'before' or 'after' . Defaults to 'after' . |
Returns
this
This transformation, after it has been changed.
addScale()
Call Signature
addScale(
x
,y
,order?
):this
Defined in: src/sdk/math/Transform2D.ts:328
Adds a scaling about the origin (0, 0) to this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
x | number | The x scaling factor. |
y | number | The y scaling factor. |
order? | "after" | "before" | The order in which to add the scaling, relative to this existing transformation, either 'before' or 'after' . Defaults to 'after' . |
Returns
this
This transformation, after it has been changed.
Call Signature
addScale(
x
,y
,originX
,originY
,order?
):this
Defined in: src/sdk/math/Transform2D.ts:339
Adds a scaling about an arbitrary origin to this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
x | number | The x scaling factor. |
y | number | The y scaling factor. |
originX | number | The x-coordinate of the scaling origin. |
originY | number | The y-coordinate of the scaling origin. |
order? | "after" | "before" | The order in which to add the scaling, relative to this existing transformation, either 'before' or 'after' . Defaults to 'after' . |
Returns
this
This transformation, after it has been changed.
addTranslation()
addTranslation(
x
,y
,order
):this
Defined in: src/sdk/math/Transform2D.ts:308
Adds a translation to this transformation.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
x | number | undefined | The x translation. |
y | number | undefined | The y translation. |
order | "after" | "before" | 'after' | The order in which to add the translation, relative to this existing transformation, either 'before' or 'after' . Defaults to 'after' . |
Returns
this
This transformation, after it has been changed.
apply()
apply(
vec
,out
):Float64Array
Defined in: src/sdk/math/Transform2D.ts:179
Applies this transformation to a 2D vector.
Parameters
Parameter | Type | Description |
---|---|---|
vec | ReadonlyFloat64Array | A 2D vector. |
out | Float64Array | The vector to which to write the result. |
Returns
Float64Array
The result of applying this transformation to vec
.
copy()
copy():
Transform2D
Defined in: src/sdk/math/Transform2D.ts:169
Copies this transformation.
Returns
Transform2D
A copy of this transformation.
getParameters()
getParameters():
ReadonlyFloat64Array
Defined in: src/sdk/math/Transform2D.ts:16
Gets the parameters of this transformation as a 6-tuple: [scaleX, skewX, translateX, skewY, scaleY, translateY]
.
Returns
The parameters of this transformation.
invert()
invert():
this
Defined in: src/sdk/math/Transform2D.ts:141
Inverts this transformation.
Returns
this
This transformation, after it has been inverted.
offsetOrigin()
offsetOrigin(
x
,y
):this
Defined in: src/sdk/math/Transform2D.ts:195
Changes this transformation to the one that is the result of offsetting this transformation's origin.
Parameters
Parameter | Type | Description |
---|---|---|
x | number | The x-coordinate of the offset origin. |
y | number | The y-coordinate of the offset origin. |
Returns
this
This transformation, after it has been changed.
set()
Call Signature
set(
scaleX
,skewX
,translateX
,skewY
,scaleY
,translateY
):this
Defined in: src/sdk/math/Transform2D.ts:30
Sets the parameters of this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
scaleX | number | The x scaling factor. |
skewX | number | The x skew factor. |
translateX | number | The x translation. |
skewY | number | The y skew factor. |
scaleY | number | The y scaling factor. |
translateY | number | The y translation. |
Returns
this
This transformation, after it has been changed.
Call Signature
set(
transform
):this
Defined in: src/sdk/math/Transform2D.ts:35
Sets the parameters of this transformation from another transformation.
Parameters
Parameter | Type | Description |
---|---|---|
transform | ReadonlyTransform2D | The transformation from which to take parameters. |
Returns
this
setScale()
setScale(
x
,y
):this
Defined in: src/sdk/math/Transform2D.ts:79
Sets the x and y scaling factors of this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
x | number | The new x scaling factor. |
y | number | The new y scaling factor. |
Returns
this
This transformation, after it has been changed.
setScaleX()
setScaleX(
value
):this
Defined in: src/sdk/math/Transform2D.ts:58
Sets the x scaling factor of this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
value | number | The new x scaling factor. |
Returns
this
This transformation, after it has been changed.
setScaleY()
setScaleY(
value
):this
Defined in: src/sdk/math/Transform2D.ts:68
Sets the y scaling factor of this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
value | number | The new y scaling factor. |
Returns
this
This transformation, after it has been changed.
setSkewX()
setSkewX(
value
):this
Defined in: src/sdk/math/Transform2D.ts:90
Sets the x skew factor of this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
value | number | The new x skew factor. |
Returns
this
This transformation, after it has been changed.
setSkewY()
setSkewY(
value
):this
Defined in: src/sdk/math/Transform2D.ts:100
Sets the y skew factor of this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
value | number | The new y skew factor. |
Returns
this
This transformation, after it has been changed.
setTranslate()
setTranslate(
x
,y
):this
Defined in: src/sdk/math/Transform2D.ts:131
Sets the x and y translations of this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
x | number | The new x translation. |
y | number | The new y translation. |
Returns
this
This transformation, after it has been changed.
setTranslateX()
setTranslateX(
value
):this
Defined in: src/sdk/math/Transform2D.ts:110
Sets the x translation of this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
value | number | The new x translation. |
Returns
this
This transformation, after it has been changed.
setTranslateY()
setTranslateY(
value
):this
Defined in: src/sdk/math/Transform2D.ts:120
Sets the y translation of this transformation.
Parameters
Parameter | Type | Description |
---|---|---|
value | number | The new y translation. |
Returns
this
This transformation, after it has been changed.
toIdentity()
toIdentity():
this
Defined in: src/sdk/math/Transform2D.ts:207
Sets this transformation to the identity transformation.
Returns
this
This transformation, after it has been changed.
toReflection()
Call Signature
toReflection(
theta
):this
Defined in: src/sdk/math/Transform2D.ts:277
Sets this transformation to a reflection across a line passing through the origin (0, 0).
Parameters
Parameter | Type | Description |
---|---|---|
theta | number | The angle of the reflection line, in radians, with respect to the positive x axis. |
Returns
this
This transformation, after it has been changed.
Call Signature
toReflection(
theta
,originX
,originY
):this
Defined in: src/sdk/math/Transform2D.ts:285
Sets this transformation to a reflection across a line passing through an arbitrary origin.
Parameters
Parameter | Type | Description |
---|---|---|
theta | number | The angle of the reflection line, in radians, with respect to the positive x axis. |
originX | number | The x-coordinate of the reflection origin. |
originY | number | The y-coordinate of the reflection origin. |
Returns
this
This transformation, after it has been changed.
toRotation()
Call Signature
toRotation(
theta
):this
Defined in: src/sdk/math/Transform2D.ts:251
Sets this transformation to a rotation about the origin (0, 0).
Parameters
Parameter | Type | Description |
---|---|---|
theta | number | The rotation angle, in radians. |
Returns
this
This transformation, after it has been changed.
Call Signature
toRotation(
theta
,originX
,originY
):this
Defined in: src/sdk/math/Transform2D.ts:259
Sets this transformation to a rotation about an arbitrary origin.
Parameters
Parameter | Type | Description |
---|---|---|
theta | number | The rotation angle, in radians. |
originX | number | The x-coordinate of the rotation origin. |
originY | number | The y-coordinate of the rotation origin. |
Returns
this
This transformation, after it has been changed.
toScale()
Call Signature
toScale(
x
,y
):this
Defined in: src/sdk/math/Transform2D.ts:227
Sets this transformation to a scaling about the origin (0, 0).
Parameters
Parameter | Type | Description |
---|---|---|
x | number | The x scaling factor. |
y | number | The y scaling factor. |
Returns
this
This transformation, after it has been changed.
Call Signature
toScale(
x
,y
,originX
,originY
):this
Defined in: src/sdk/math/Transform2D.ts:236
Sets this transformation to a scaling about an arbitrary origin.
Parameters
Parameter | Type | Description |
---|---|---|
x | number | The x scaling factor. |
y | number | The y scaling factor. |
originX | number | The x-coordinate of the scaling origin. |
originY | number | The y-coordinate of the scaling origin. |
Returns
this
This transformation, after it has been changed.
toTranslation()
toTranslation(
x
,y
):this
Defined in: src/sdk/math/Transform2D.ts:217
Sets this transformation to a translation.
Parameters
Parameter | Type | Description |
---|---|---|
x | number | The x translation. |
y | number | The y translation. |
Returns
this
This transformation, after it has been changed.
concat()
static
concat<T
>(out
,transforms
):T
Defined in: src/sdk/math/Transform2D.ts:458
Concatenates one or more transformations and returns the result. Concatenating transformations [A, B, ...]
results in a transformation that is equivalent to first applying A
, then applying B
, etc. Note that this order
is the opposite of the one resulting from multiplying the individual transformation matrices
M_A * M_B * ...
.
If the number of transformations to concatenate equals zero, the identity matrix is returned.
Type Parameters
Type Parameter |
---|
T extends Transform2D |
Parameters
Parameter | Type | Description |
---|---|---|
out | T | The transformation to which to write the result. |
transforms | readonly ReadonlyTransform2D [] | The transformations to concatenate, in order. |
Returns
T
The result of concatenating all transformations in transforms
.