Module: webgl-2d-math

webgl-2d-math

Various 2d math functions.

Methods

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:

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

Type
module:webgl-2d-math.Matrix3

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

Creates a 2D rotation matrix

Parameters:
Name Type Description
angleInRadians number

amount to rotate in radians

Returns:

a rotation matrix that rotates by angleInRadians

Type
module:webgl-2d-math.Matrix3

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:

a scale matrix that scales by sx and sy.

Type
module:webgl-2d-math.Matrix3

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:

a translation matrix that translates by tx and ty.

Type
module:webgl-2d-math.Matrix3

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:

the result.

Type
module:webgl-2d-math.Matrix3

Type Definitions

Matrix3

An array or typed array with 9 values.

Type:
  • Array.<number>| TypedArray
copyright Gregg Tavares