webgl-2d-math

Various 2d math functions.

Methods

(static) make2DProjection(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:
Type:
module:webgl-2d-math.Matrix3

a projection matrix that converts from pixels to clipspace with Y = 0 at the top.

(static) makeRotation(angleInRadians) → {module:webgl-2d-math.Matrix3}

Creates a 2D rotation matrix

Parameters:
Name Type Description
angleInRadians number

amount to rotate in radians

Returns:
Type:
module:webgl-2d-math.Matrix3

a rotation matrix that rotates by angleInRadians

(static) makeScale(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

Returns:
Type:
module:webgl-2d-math.Matrix3

a scale matrix that scales by sx and sy.

(static) makeTranslation(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

Returns:
Type:
module:webgl-2d-math.Matrix3

a translation matrix that translates by tx and ty.

(static) matrixMultiply(a, b) → {module:webgl-2d-math.Matrix3}

Takes twoMatrix3s, 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.

Returns:
Type:
module:webgl-2d-math.Matrix3

the result.

Type Definitions

Matrix3

An array or typed array with 9 values.

Type:
  • Array.<number> | TypedArray