Represents a color. See also ColorUtils.

see https://github.com/mrdoob/three.js/blob/master/src/math/Color.js|src/math/Color.js

Example

const color = new THREE.Color( 0xff0000 );

Hierarchy

  • Color

Constructors

  • Parameters

    Returns Color

  • Parameters

    • r: number
    • g: number
    • b: number

    Returns Color

Properties

b: number

Blue channel value between 0 and 1. Default is 1.

Default

1

g: number

Green channel value between 0 and 1. Default is 1.

Default

1

isColor: true
r: number

Red channel value between 0 and 1. Default is 1.

Default

1

NAMES: Record<string, number>

List of X11 color names.

Methods

  • Returns Generator<number, void, unknown>

  • Parameters

    Returns Color

  • Parameters

    Returns Color

  • Parameters

    • s: number

    Returns Color

  • Clones this color.

    Returns Color

  • Converts this color from linear to sRGB space.

    Returns Color

  • Converts this color from sRGB to linear space.

    Returns Color

  • Copies given color.

    Parameters

    • color: Color

      Color to copy.

    Returns Color

  • Copies given color making conversion from linear to sRGB space.

    Parameters

    • color: Color

      Color to copy.

    Returns Color

  • Copies given color making conversion from sRGB to linear space.

    Parameters

    • color: Color

      Color to copy.

    Returns Color

  • Parameters

    Returns boolean

  • Sets this color's red, green and blue value from the provided array or array-like.

    Parameters

    • array: number[] | ArrayLike<number>

      the source array or array-like.

    • Optional offset: number

      (optional) offset into the array-like. Default is 0.

    Returns Color

  • Parameters

    Returns HSL

  • Returns the hexadecimal value of this color.

    Parameters

    Returns number

  • Returns the string formated hexadecimal value of this color.

    Parameters

    Returns string

  • Parameters

    Returns RGB

  • Returns the value of this color in CSS context style. Example: rgb(r, g, b)

    Parameters

    Returns string

  • Parameters

    • color: Color
    • alpha: number

    Returns Color

  • Parameters

    Returns Color

  • Parameters

    • color: Color
    • alpha: number

    Returns Color

  • Parameters

    Returns Color

  • Parameters

    • s: number

    Returns Color

  • Parameters

    • h: number
    • s: number
    • l: number

    Returns Color

  • Sets this color from a color name. Faster than .setStyle() method if you don't need the other CSS-style formats.

    Parameters

    • style: string

      Color name in X11 format.

    • Optional colorSpace: ColorSpace

    Returns Color

  • Sets this color from HSL values. Based on MochiKit implementation by Bob Ippolito.

    Parameters

    • h: number

      Hue channel value between 0 and 1.

    • s: number

      Saturation value channel between 0 and 1.

    • l: number

      Value channel value between 0 and 1.

    • Optional colorSpace: ColorSpace

    Returns Color

  • Parameters

    Returns Color

  • Sets this color from RGB values.

    Parameters

    • r: number

      Red channel value between 0 and 1.

    • g: number

      Green channel value between 0 and 1.

    • b: number

      Blue channel value between 0 and 1.

    • Optional colorSpace: ColorSpace

    Returns Color

  • Parameters

    • scalar: number

    Returns Color

  • Sets this color from a CSS context style string.

    Parameters

    Returns Color

  • Parameters

    Returns Color

  • Returns an array [red, green, blue], or copies red, green and blue into the provided array.

    Returns

    The created or provided array.

    Parameters

    • Optional array: number[]

      (optional) array to store the color to. If this is not provided, a new array will be created.

    • Optional offset: number

      (optional) optional offset into the array.

    Returns number[]

  • Copies red, green and blue into the provided array-like.

    Returns

    The provided array-like.

    Parameters

    • xyz: ArrayLike<number>
    • Optional offset: number

      (optional) optional offset into the array-like.

    Returns ArrayLike<number>

Generated using TypeDoc