Various 2d math functions.
Methods
(static) multiply(a, b) → {module:webgl-2d-math.Matrix3}
Takes two Matrix3s, a and b, and computes the product in the order
that pre-composes b with a. In other words, the matrix returned will
Parameters:
Name | Type | Description |
---|---|---|
a |
module:webgl-2d-math.Matrix3
|
A matrix. |
b |
module:webgl-2d-math.Matrix3
|
A matrix. |
(static) project(the, width, height) → {module:webgl-2d-math.Matrix3}
Multiplies by a 2D projection matrix
Parameters:
Name | Type | Description |
---|---|---|
the |
module:webgl-2d-math.Matrix3
|
matrix to be multiplied |
width |
number
|
width in pixels |
height |
number
|
height in pixels |
(static) projection(width, height) → {module:webgl-2d-math.Matrix3}
Creates a 2D projection matrix
Parameters:
Name | Type | Description |
---|---|---|
width |
number
|
width in pixels |
height |
number
|
height in pixels |
Returns:
a projection matrix that converts from pixels to clipspace with Y = 0 at the top.
(static) rotate(the, angleInRadians) → {module:webgl-2d-math.Matrix3}
Multiplies by a 2D rotation matrix
Parameters:
Name | Type | Description |
---|---|---|
the |
module:webgl-2d-math.Matrix3
|
matrix to be multiplied |
angleInRadians |
number
|
amount to rotate in radians |
(static) rotation(angleInRadians) → {module:webgl-2d-math.Matrix3}
Creates a 2D rotation matrix
Parameters:
Name | Type | Description |
---|---|---|
angleInRadians |
number
|
amount to rotate in radians |
(static) scale(the, sx, sy) → {module:webgl-2d-math.Matrix3}
Multiplies by a 2D scaling matrix
Parameters:
Name | Type | Description |
---|---|---|
the |
module:webgl-2d-math.Matrix3
|
matrix to be multiplied |
sx |
number
|
amount to scale in x |
sy |
number
|
amount to scale in y |
(static) scaling(sx, sy) → {module:webgl-2d-math.Matrix3}
Creates a 2D scaling matrix
Parameters:
Name | Type | Description |
---|---|---|
sx |
number
|
amount to scale in x |
sy |
number
|
amount to scale in y |
(static) translate(the, tx, ty) → {module:webgl-2d-math.Matrix3}
Multiplies by a 2D translation matrix
Parameters:
Name | Type | Description |
---|---|---|
the |
module:webgl-2d-math.Matrix3
|
matrix to be multiplied |
tx |
number
|
amount to translate in x |
ty |
number
|
amount to translate in y |
(static) translation(tx, ty) → {module:webgl-2d-math.Matrix3}
Creates a 2D translation matrix
Parameters:
Name | Type | Description |
---|---|---|
tx |
number
|
amount to translate in x |
ty |
number
|
amount to translate in y |
Type Definitions
Matrix3
An array or typed array with 9 values.
Type:
-
Array.<number>
|TypedArray