melonJS
    Preparing search index...

    Class ColorMatrix

    A 4x4 color transformation matrix extending Matrix3d. Provides chainable methods for common color adjustments.

    // grayscale
    const cm = new ColorMatrix().saturate(0.0);
    // combine brightness + contrast
    const cm = new ColorMatrix().brightness(1.3).contrast(1.5);

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    val: Float32Array

    The matrix values

    Accessors

    Methods

    • Apply a brightness adjustment.

      Parameters

      • amount: number

        brightness multiplier (1.0 = normal, >1 brighter, <1 darker)

      Returns this

      this instance for chaining

    • Apply a contrast adjustment.

      Parameters

      • amount: number

        contrast multiplier (1.0 = normal, >1 more contrast, <1 less)

      Returns this

      this instance for chaining

    • Apply a color inversion.

      Parameters

      • amount: number = 1.0

        inversion amount (0.0 = original, 1.0 = fully inverted)

      Returns this

      this instance for chaining

    • generate an orthogonal projection matrix, with the result replacing the current matrix

      Parameters

      • left: number

        farthest left on the x-axis

      • right: number

        farthest right on the x-axis

      • bottom: number

        farthest down on the y-axis

      • top: number

        farthest up on the y-axis

      • near: number

        distance to the near clipping plane along the -Z axis

      • far: number

        distance to the far clipping plane along the -Z axis

      Returns ColorMatrix

      Reference to this object for method chaining

    • generate a perspective projection matrix, with the result replacing the current matrix

      Parameters

      • fov: number

        vertical field of view in radians

      • aspect: number

        aspect ratio (width / height)

      • near: number

        distance to the near clipping plane along the -Z axis

      • far: number

        distance to the far clipping plane along the -Z axis

      Returns ColorMatrix

      Reference to this object for method chaining

    • Apply a saturation adjustment.

      Parameters

      • amount: number

        saturation level (0.0 = grayscale, 1.0 = normal, >1 over-saturated)

      Returns this

      this instance for chaining

    • scale the matrix

      Parameters

      • x: number

        a number representing the abscissa of the scaling vector.

      • Optionaly: number = x

        a number representing the ordinate of the scaling vector.

      • Optionalz: number = 1

        a number representing the depth vector

      Returns ColorMatrix

      Reference to this object for method chaining

    • Multiplies the current transformation with a 2D affine matrix (a, b, c, d, e, f). The 2D matrix is promoted to 4x4 internally.

      Parameters

      • a: number

        a component (scale x / cos)

      • b: number

        b component (skew y / sin)

      • c: number

        c component (skew x / -sin)

      • d: number

        d component (scale y / cos)

      • e: number

        e component (translate x)

      • f: number

        f component (translate y)

      Returns this

      Reference to this object for method chaining

    • Multiplies the current transformation with a full 4x4 matrix specified as 16 individual values (column-major).

      Parameters

      • b00: number
      • b01: number
      • b02: number
      • b03: number
      • b10: number
      • b11: number
      • b12: number
      • b13: number
      • b20: number
      • b21: number
      • b22: number
      • b23: number
      • b30: number
      • b31: number
      • b32: number
      • b33: number

      Returns this

      Reference to this object for method chaining