Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Color

Color is a subclass of Pt. You can think of a color as a point in a color space. The Color class provides support for many color spaces.

Hierarchy

  • Pt
    • Color

Implements

  • IPt
  • Iterable<number>

Indexable

[index: number]: number

Color is a subclass of Pt. You can think of a color as a point in a color space. The Color class provides support for many color spaces.

Index

Constructors

constructor

  • new Color(...args: any[]): Color
  • Create a Color. Same as creating a Pt.

    Parameters

    • Rest ...args: any[]

      Pt-like parameters which can be a list of numeric parameters, an array of numbers, or an object with {x,y,z,w} properties

    Returns Color

Properties

Protected _id

_id: string

Private _isNorm

_isNorm: boolean = false

Protected _mode

_mode: ColorType = "rgb"

Static BYTES_PER_ELEMENT

BYTES_PER_ELEMENT: number

The size in bytes of each element in the array.

Static Private D65

D65: PtLike = new Pt(95.047, 100, 108.883, 1)

Static buffer

buffer: ArrayBuffer

The ArrayBuffer instance referenced by the array.

Static byteLength

byteLength: number

The length in bytes of the array.

Static byteOffset

byteOffset: number

The offset in bytes of the array.

Static length

length: number

The length of the array.

Accessors

a

  • get a(): number
  • set a(n: number): void

alpha

  • get alpha(): number

b

  • get b(): number
  • set b(n: number): void

c

  • get c(): number
  • set c(n: number): void

g

  • get g(): number
  • set g(n: number): void

h

  • get h(): number
  • set h(n: number): void

hex

  • get hex(): string
  • Get a hex string such as "#FF0000". Same as toString("hex")

    Returns string

id

  • get id(): string
  • set id(s: string): void
  • Returns string

  • Parameters

    • s: string

    Returns void

l

  • get l(): number
  • set l(n: number): void

mode

r

  • get r(): number
  • set r(n: number): void

rgb

  • get rgb(): string
  • Get a rgb string such as "rgb(255,0,0)". Same as toString("rgb")

    Returns string

rgba

  • get rgba(): string
  • Get a rgba string such as "rgb(255,0,0,0.5)". Same as toString("rgba")

    Returns string

s

  • get s(): number
  • set s(n: number): void

u

  • get u(): number
  • set u(n: number): void

v

  • get v(): number
  • set v(n: number): void

w

  • get w(): number
  • set w(n: number): void
  • Returns number

  • Parameters

    • n: number

    Returns void

x

  • get x(): number
  • set x(n: number): void
  • Returns number

  • Parameters

    • n: number

    Returns void

y

  • get y(): number
  • set y(n: number): void
  • Returns number

  • Parameters

    • n: number

    Returns void

z

  • get z(): number
  • set z(n: number): void
  • Returns number

  • Parameters

    • n: number

    Returns void

Methods

$abs

  • $abs(): Pt
  • Get a new Pt with absolute values of this Pt

    Returns Pt

$add

  • $add(...args: any[]): Pt
  • Like add, but returns result as a new Pt

    Parameters

    • Rest ...args: any[]

    Returns Pt

$ceil

  • $ceil(): Pt
  • Get a new Pt with ceil values of this Pt

    Returns Pt

$concat

  • $concat(...args: any[]): Pt
  • Concatenate this Pt with addition dimensional values and return as a new Pt

    Parameters

    • Rest ...args: any[]

      a list of numbers, an array of number, or an object with {x,y,z,w} properties

    Returns Pt

$cross

  • $cross(...args: any[]): Pt
  • 3D Cross product of this Pt and another Pt. Return results as a new Pt.

    Parameters

    • Rest ...args: any[]

      a list of numbers, an array of number, or an object with {x,y,z,w} properties

    Returns Pt

$divide

  • $divide(...args: any[]): Pt
  • Like divide, but returns result as a new Pt

    Parameters

    • Rest ...args: any[]

    Returns Pt

$floor

  • $floor(): Pt
  • Get a new Pt with floor values of this Pt

    Returns Pt

$max

  • $max(...args: any[]): Pt
  • Get a new Pt that has the maximum dimensional values of this Pt and another Pt

    Parameters

    • Rest ...args: any[]

      a list of numbers, an array of number, or an object with {x,y,z,w} properties

    Returns Pt

$min

  • $min(...args: any[]): Pt
  • Get a new Pt that has the minimum dimensional values of this Pt and another Pt

    Parameters

    • Rest ...args: any[]

      a list of numbers, an array of number, or an object with {x,y,z,w} properties

    Returns Pt

$multiply

  • $multiply(...args: any[]): Pt
  • Like multiply, but returns result as a new Pt

    Parameters

    • Rest ...args: any[]

    Returns Pt

$normalize

  • $normalize(toNorm?: boolean): Color
  • Like normalize() but returns as a new Color

    Parameters

    • Default value toNorm: boolean = true

      a boolean value specifying whether to normalize (true) or revert (false)

    Returns Color

    new Color

$project

  • $project(...args: any[]): Pt
  • Calculate vector projection of this Pt on another Pt.

    Parameters

    • Rest ...args: any[]

    Returns Pt

    the projection vector as a Pt

$round

  • $round(): Pt
  • Get a new Pt with round values of this Pt

    Returns Pt

$subtract

  • $subtract(...args: any[]): Pt
  • Like subtract, but returns result as a new Pt

    Parameters

    • Rest ...args: any[]

    Returns Pt

$take

  • $take(axis: string | number[]): Pt
  • Take specific dimensional values from this Pt and create a new Pt

    Parameters

    • axis: string | number[]

      a string such as "xy" (use Const.xy) or an array to specify index for two dimensions

    Returns Pt

$to

  • $to(...args: any[]): Pt
  • Like to() but returns a new Pt

    Parameters

    • Rest ...args: any[]

      a list of numbers, an array of number, or an object with {x,y,z,w} properties

    Returns Pt

$unit

  • $unit(magnitude?: number): Pt
  • Get a unit vector from this Pt

    Parameters

    • Default value magnitude: number = undefined

    Returns Pt

abs

  • abs(): Pt
  • Absolute values for all values in this pt

    Returns Pt

add

  • add(...args: any[]): this
  • Add scalar or vector values to this Pt

    Parameters

    • Rest ...args: any[]

      a list of numbers, an array of number, or an object with {x,y,z,w} properties

    Returns this

angle

  • angle(axis?: string | number[]): number
  • Get angle of this vector from origin

    Parameters

    • Default value axis: string | number[] = Const.xy

      a string such as "xy" (use Const.xy) or an array to specify index for two dimensions

    Returns number

angleBetween

  • angleBetween(p: Pt, axis?: string | number[]): number
  • Get the angle between this and another Pt

    Parameters

    • p: Pt

      the other Pt

    • Default value axis: string | number[] = Const.xy

      a string such as "xy" (use Const.xy) or an array to specify index for two dimensions

    Returns number

ceil

  • ceil(): Pt
  • Ceil values for all values in this pt

    Returns Pt

clone

cross2D

  • cross2D(...args: any[]): number
  • 2D Cross product of this Pt and another Pt. Return results as a new Pt.

    Parameters

    • Rest ...args: any[]

      a list of numbers, an array of number, or an object with {x,y,z,w} properties

    Returns number

divide

  • divide(...args: any[]): this
  • Divide this Pt over scalar or vector values (as element-wise)

    Parameters

    • Rest ...args: any[]

      a list of numbers, an array of number, or an object with {x,y,z,w} properties

    Returns this

dot

  • dot(...args: any[]): number
  • Dot product of this Pt and another Pt

    Parameters

    • Rest ...args: any[]

      a list of numbers, an array of number, or an object with {x,y,z,w} properties

    Returns number

equals

  • equals(p: PtLike, threshold?: number): boolean
  • Check if another Pt is equal to this Pt, within a threshold

    Parameters

    • p: PtLike

      another Pt to compare with

    • Default value threshold: number = 0.000001

      a threshold value within which the two Pts are considered equal. Default is 0.000001.

    Returns boolean

floor

  • floor(): Pt
  • Floor values for all values in this pt

    Returns Pt

magnitude

  • magnitude(): number
  • Get the distance (magnitude) of this Pt from origin

    Returns number

magnitudeSq

  • magnitudeSq(): number
  • Get the sqaured distance (magnitude) of this Pt from origin

    Returns number

maxValue

  • maxValue(): object
  • Find the maximum value across all dimensions in this Pt

    Returns object

    an object with value and index which returns the maximum value and its dimensional index

    • index: number
    • value: number

minValue

  • minValue(): object
  • Find the minimum value across all dimensions in this Pt

    Returns object

    an object with value and index which returns the minimum value and its dimensional index

    • index: number
    • value: number

multiply

  • multiply(...args: any[]): this
  • Multiply scalar or vector values (as element-wise) with this Pt.

    Parameters

    • Rest ...args: any[]

      a list of numbers, an array of number, or an object with {x,y,z,w} properties

    Returns this

normalize

  • normalize(toNorm?: boolean): Color
  • Normalize the color values to between 0 to 1, or revert it back to the min/max values in current color mode

    Parameters

    • Default value toNorm: boolean = true

      a boolean value specifying whether to normalize (true) or revert (false)

    Returns Color

op

  • op(fn: function): function
  • Create an operation using this Pt, passing this Pt into a custom function's first parameter. See the Op guide for details. For example: let myOp = pt.op( fn ); let result = myOp( [1,2,3] );

    Parameters

    • fn: function

      any function that takes a Pt as its first parameter

        • (p1: PtLike, ...rest: any[]): any
        • Parameters

          • p1: PtLike
          • Rest ...rest: any[]

          Returns any

    Returns function

    a resulting function that takes other parameters required in fn

      • (...rest: any[]): any
      • Parameters

        • Rest ...rest: any[]

        Returns any

ops

  • ops(fns: function[]): function[]
  • This combines a series of operations into an array. See op() for details. For example: let myOps = pt.ops([fn1, fn2, fn3]); let results = myOps.map( (op) => op([1,2,3]) );

    Parameters

    • fns: function[]

      an array of functions for op

    Returns function[]

    an array of resulting functions

projectScalar

  • projectScalar(...args: any[]): number
  • Calculate scalar projection

    Parameters

    • Rest ...args: any[]

    Returns number

reflect2D

  • reflect2D(line: GroupLike, axis?: string): this
  • Reflect this Pt along a 2D line

    Parameters

    • line: GroupLike

      a Group of 2 Pts that defines a line for reflection

    • Optional axis: string

      optional axis such as "yz" to define a 2D plane of reflection

    Returns this

rotate2D

  • rotate2D(angle: number, anchor?: PtLike, axis?: string): this
  • Rotate this Pt from origin or from an anchor point in 2D

    Parameters

    • angle: number

      rotate angle

    • Optional anchor: PtLike

      optional anchor point to scale from

    • Optional axis: string

      optional string such as "yz" to specify a 2D plane

    Returns this

round

  • round(): Pt
  • Round values for all values in this pt

    Returns Pt

scale

  • scale(scale: number | number[] | PtLike, anchor?: PtLike): this
  • Scale this Pt from origin or from an anchor point

    Parameters

    • scale: number | number[] | PtLike

      scale ratio

    • Optional anchor: PtLike

      optional anchor point to scale from

    Returns this

shear2D

  • shear2D(scale: number | number[] | PtLike, anchor?: PtLike, axis?: string): this
  • Shear this Pt from origin or from an anchor point in 2D

    Parameters

    • scale: number | number[] | PtLike
    • Optional anchor: PtLike

      optional anchor point to scale from

    • Optional axis: string

      optional string such as "yz" to specify a 2D plane

    Returns this

subtract

  • subtract(...args: any[]): this
  • Subtract scalar or vector values from this Pt

    Parameters

    • Rest ...args: any[]

      a list of numbers, an array of number, or an object with {x,y,z,w} properties

    Returns this

to

  • to(...args: any[]): this
  • Update the values of this Pt

    Parameters

    • Rest ...args: any[]

      a list of numbers, an array of number, or an object with {x,y,z,w} properties

    Returns this

toAngle

  • toAngle(radian: number, magnitude?: number, anchorFromPt?: boolean): this
  • Update the values of this Pt to point at a specific angle

    Parameters

    • radian: number

      target angle in radian

    • Optional magnitude: number

      Optional magnitude if known. If not provided, it'll calculate and use this Pt's magnitude.

    • Default value anchorFromPt: boolean = false

      If true, translate to new position from current position. Default is false which update the position from origin (0,0);

    Returns this

toArray

  • toArray(): number[]
  • Convert this Pt to a javascript Array

    Returns number[]

toMode

  • toMode(mode: ColorType, convert?: boolean): this
  • Convert this color from current color space to another color space

    Parameters

    • mode: ColorType

      a ColorType string: "rgb" "hsl" "hsb" "lab" "lch" "luv" "xyz";

    • Default value convert: boolean = false

      if true, convert this Color to the new color space specified in mode. Default is false, which only sets the color mode without converting color values.

    Returns this

toString

  • toString(format?: "rgb" | "hex" | "rgba" | "mode"): string
  • Convert this Color to a string. It can be used to get a hex or rgb string for use in rendering

    Parameters

    • Default value format: "rgb" | "hex" | "rgba" | "mode" = "mode"

      "hex", "rgb", "rgba", or "mode" which means using current color mode label. Default is "mode".

    Returns string

unit

  • unit(magnitude?: number): Pt
  • Convert to a unit vector, which is a normalized vector whose magnitude equals 1.

    Parameters

    • Default value magnitude: number = undefined

      Optional: if the magnitude is known, pass it as a parameter to avoid duplicate calculation.

    Returns Pt

Static HSBtoRGB

  • HSBtoRGB(hsb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert HSB to RGB

    Parameters

    • hsb: Color

      a HSB Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new RGB Color

Static HSLtoRGB

  • HSLtoRGB(hsl: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert HSL to RGB

    Parameters

    • hsl: Color

      a HSL Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new RGB Color

Static LABtoLCH

  • LABtoLCH(lab: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert LAB to LCH

    Parameters

    • lab: Color

      a LAB Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new LCH Color

Static LABtoRGB

  • LABtoRGB(lab: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert LAB to RGB

    Parameters

    • lab: Color

      a LAB Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new RGB Color

Static LABtoXYZ

  • LABtoXYZ(lab: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert LAB to XYZ

    Parameters

    • lab: Color

      a LAB Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new XYZ Color

Static LCHtoLAB

  • LCHtoLAB(lch: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert LCH to LAB

    Parameters

    • lch: Color

      a LCH Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new LAB Color

Static LCHtoRGB

  • LCHtoRGB(lch: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert LCH to RGB

    Parameters

    • lch: Color

      a LCH Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new RGB Color

Static LUVtoRGB

  • LUVtoRGB(luv: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert LUV to RGB

    Parameters

    • luv: Color
    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new RGB Color

Static LUVtoXYZ

  • LUVtoXYZ(luv: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert LUV to XYZ

    Parameters

    • luv: Color

      a LUV Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new XYZ Color

Static RGBtoHSB

  • RGBtoHSB(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert RGB to HSB

    Parameters

    • rgb: Color

      a RGB Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new HSB Color

Static RGBtoHSL

  • RGBtoHSL(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert RGB to HSL

    Parameters

    • rgb: Color

      a RGB Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new HSL Color

Static RGBtoLAB

  • RGBtoLAB(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert RGB to LAB

    Parameters

    • rgb: Color

      a RGB Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new LAB Color

Static RGBtoLCH

  • RGBtoLCH(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert RGB to LCH

    Parameters

    • rgb: Color

      a RGB Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new LCH Color

Static RGBtoLUV

  • RGBtoLUV(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert RGB to LUV

    Parameters

    • rgb: Color

      a RGB Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new LUV Color

Static RGBtoXYZ

  • RGBtoXYZ(rgb: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert RGB to XYZ

    Parameters

    • rgb: Color

      a RGB Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new XYZ Color

Static XYZtoLAB

  • XYZtoLAB(xyz: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert XYZ to LAB

    Parameters

    • xyz: Color

      a XYZ Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new LAB Color

Static XYZtoLUV

  • XYZtoLUV(xyz: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert XYZ to LUV

    Parameters

    • xyz: Color

      a XYZ Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new LUV Color

Static XYZtoRGB

  • XYZtoRGB(xyz: Color, normalizedInput?: boolean, normalizedOutput?: boolean): Color
  • Convert XYZ to RGB

    Parameters

    • xyz: Color

      a XYZ Color

    • Default value normalizedInput: boolean = false

      a boolean specifying whether input color is normalized. Default is not normalized: false.

    • Default value normalizedOutput: boolean = false

      a boolean specifying whether output color shoud be normalized. Default is not normalized: false.

    Returns Color

    a new RGB Color

Static copyWithin

  • copyWithin(target: number, start: number, end?: number): this
  • Returns the this object after copying a section of the array identified by start and end to the same array starting at position target

    Parameters

    • target: number

      If target is negative, it is treated as length+target where length is the length of the array.

    • start: number

      If start is negative, it is treated as length+start. If end is negative, it is treated as length+end.

    • Optional end: number

      If not specified, length of the this object is used as its default value.

    Returns this

Static every

  • every(callbackfn: function): boolean
  • every(callbackfn: function, thisArg: undefined): boolean
  • every<Z>(callbackfn: function, thisArg: Z): boolean
  • Determines whether all the members of an array satisfy the specified test.

    Parameters

    • callbackfn: function

      A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array.

        • (this: void, value: number, index: number, array: Float32Array): boolean
        • Parameters

          • this: void
          • value: number
          • index: number
          • array: Float32Array

          Returns boolean

    Returns boolean

  • Parameters

    • callbackfn: function
        • (this: void, value: number, index: number, array: Float32Array): boolean
        • Parameters

          • this: void
          • value: number
          • index: number
          • array: Float32Array

          Returns boolean

    • thisArg: undefined

    Returns boolean

  • Type parameters

    • Z

    Parameters

    • callbackfn: function
        • (this: Z, value: number, index: number, array: Float32Array): boolean
        • Parameters

          • this: Z
          • value: number
          • index: number
          • array: Float32Array

          Returns boolean

    • thisArg: Z

    Returns boolean

Static fill

  • fill(value: number, start?: number, end?: number): this
  • Returns the this object after filling the section identified by start and end with value

    Parameters

    • value: number

      value to fill array section with

    • Optional start: number

      index to start filling the array at. If start is negative, it is treated as length+start where length is the length of the array.

    • Optional end: number

      index to stop filling the array at. If end is negative, it is treated as length+end.

    Returns this

Static filter

  • filter(callbackfn: function): Float32Array
  • filter(callbackfn: function, thisArg: undefined): Float32Array
  • filter<Z>(callbackfn: function, thisArg: Z): Float32Array
  • Returns the elements of an array that meet the condition specified in a callback function.

    Parameters

    • callbackfn: function

      A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.

        • (this: void, value: number, index: number, array: Float32Array): any
        • Parameters

          • this: void
          • value: number
          • index: number
          • array: Float32Array

          Returns any

    Returns Float32Array

  • Parameters

    • callbackfn: function
        • (this: void, value: number, index: number, array: Float32Array): any
        • Parameters

          • this: void
          • value: number
          • index: number
          • array: Float32Array

          Returns any

    • thisArg: undefined

    Returns Float32Array

  • Type parameters

    • Z

    Parameters

    • callbackfn: function
        • (this: Z, value: number, index: number, array: Float32Array): any
        • Parameters

          • this: Z
          • value: number
          • index: number
          • array: Float32Array

          Returns any

    • thisArg: Z

    Returns Float32Array

Static find

  • find(predicate: function): number | undefined
  • find(predicate: function, thisArg: undefined): number | undefined
  • find<Z>(predicate: function, thisArg: Z): number | undefined
  • Returns the value of the first element in the array where predicate is true, and undefined otherwise.

    Parameters

    • predicate: function

      find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, find immediately returns that element value. Otherwise, find returns undefined.

        • (this: void, value: number, index: number, obj: Array<number>): boolean
        • Parameters

          • this: void
          • value: number
          • index: number
          • obj: Array<number>

          Returns boolean

    Returns number | undefined

  • Parameters

    • predicate: function
        • (this: void, value: number, index: number, obj: Array<number>): boolean
        • Parameters

          • this: void
          • value: number
          • index: number
          • obj: Array<number>

          Returns boolean

    • thisArg: undefined

    Returns number | undefined

  • Type parameters

    • Z

    Parameters

    • predicate: function
        • (this: Z, value: number, index: number, obj: Array<number>): boolean
        • Parameters

          • this: Z
          • value: number
          • index: number
          • obj: Array<number>

          Returns boolean

    • thisArg: Z

    Returns number | undefined

Static findIndex

  • findIndex(predicate: function): number
  • findIndex(predicate: function, thisArg: undefined): number
  • findIndex<Z>(predicate: function, thisArg: Z): number
  • Returns the index of the first element in the array where predicate is true, and -1 otherwise.

    Parameters

    • predicate: function

      find calls predicate once for each element of the array, in ascending order, until it finds one where predicate returns true. If such an element is found, findIndex immediately returns that element index. Otherwise, findIndex returns -1.

        • (this: void, value: number, index: number, obj: Array<number>): boolean
        • Parameters

          • this: void
          • value: number
          • index: number
          • obj: Array<number>

          Returns boolean

    Returns number

  • Parameters

    • predicate: function
        • (this: void, value: number, index: number, obj: Array<number>): boolean
        • Parameters

          • this: void
          • value: number
          • index: number
          • obj: Array<number>

          Returns boolean

    • thisArg: undefined

    Returns number

  • Type parameters

    • Z

    Parameters

    • predicate: function
        • (this: Z, value: number, index: number, obj: Array<number>): boolean
        • Parameters

          • this: Z
          • value: number
          • index: number
          • obj: Array<number>

          Returns boolean

    • thisArg: Z

    Returns number

Static forEach

  • forEach(callbackfn: function): void
  • forEach(callbackfn: function, thisArg: undefined): void
  • forEach<Z>(callbackfn: function, thisArg: Z): void
  • Performs the specified action for each element in an array.

    Parameters

    • callbackfn: function

      A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.

        • (this: void, value: number, index: number, array: Float32Array): void
        • Parameters

          • this: void
          • value: number
          • index: number
          • array: Float32Array

          Returns void

    Returns void

  • Parameters

    • callbackfn: function
        • (this: void, value: number, index: number, array: Float32Array): void
        • Parameters

          • this: void
          • value: number
          • index: number
          • array: Float32Array

          Returns void

    • thisArg: undefined

    Returns void

  • Type parameters

    • Z

    Parameters

    • callbackfn: function
        • (this: Z, value: number, index: number, array: Float32Array): void
        • Parameters

          • this: Z
          • value: number
          • index: number
          • array: Float32Array

          Returns void

    • thisArg: Z

    Returns void

Static from

  • from(...args: any[]): Color
  • Create a Color object with defaults to 4 dimensions

    Parameters

    • Rest ...args: any[]

      Pt-like parameters which can be a list of numeric parameters, an array of numbers, or an object with {x,y,z,w} properties

    Returns Color

Static fromHex

  • fromHex(hex: string): Color
  • Convert a rgb hex string like #FF0000 or #F00 to a Color object

    Parameters

    • hex: string

      a hex string, with optional '#' prefix

    Returns Color

Static hsb

  • hsb(...args: any[]): Color
  • Create HSB Color

    Parameters

    • Rest ...args: any[]

      Pt-like parameters which can be a list of numeric parameters, an array of numbers, or an object with {x,y,z,w} properties.

    Returns Color

Static hsl

  • hsl(...args: any[]): Color
  • Create HSL Color

    Parameters

    • Rest ...args: any[]

      Pt-like parameters which can be a list of numeric parameters, an array of numbers, or an object with {x,y,z,w} properties.

    Returns Color

Static indexOf

  • indexOf(searchElement: number, fromIndex?: number): number
  • Returns the index of the first occurrence of a value in an array.

    Parameters

    • searchElement: number

      The value to locate in the array.

    • Optional fromIndex: number

      The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.

    Returns number

Static join

  • join(separator?: string): string
  • Adds all the elements of an array separated by the specified separator string.

    Parameters

    • Optional separator: string

      A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.

    Returns string

Static lab

  • lab(...args: any[]): Color
  • Create LAB Color

    Parameters

    • Rest ...args: any[]

      Pt-like parameters which can be a list of numeric parameters, an array of numbers, or an object with {x,y,z,w} properties.

    Returns Color

Static lastIndexOf

  • lastIndexOf(searchElement: number, fromIndex?: number): number
  • Returns the index of the last occurrence of a value in an array.

    Parameters

    • searchElement: number

      The value to locate in the array.

    • Optional fromIndex: number

      The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.

    Returns number

Static lch

  • lch(...args: any[]): Color
  • Create LCH Color

    Parameters

    • Rest ...args: any[]

      Pt-like parameters which can be a list of numeric parameters, an array of numbers, or an object with {x,y,z,w} properties.

    Returns Color

Static luv

  • luv(...args: any[]): Color
  • Create LUV Color

    Parameters

    • Rest ...args: any[]

      Pt-like parameters which can be a list of numeric parameters, an array of numbers, or an object with {x,y,z,w} properties.

    Returns Color

Static make

  • make(dimensions: number, defaultValue?: number, randomize?: boolean): Pt
  • Parameters

    • dimensions: number
    • Default value defaultValue: number = 0
    • Default value randomize: boolean = false

    Returns Pt

Static map

  • map(callbackfn: function): Float32Array
  • map(callbackfn: function, thisArg: undefined): Float32Array
  • map<Z>(callbackfn: function, thisArg: Z): Float32Array
  • Calls a defined callback function on each element of an array, and returns an array that contains the results.

    Parameters

    • callbackfn: function

      A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.

        • (this: void, value: number, index: number, array: Float32Array): number
        • Parameters

          • this: void
          • value: number
          • index: number
          • array: Float32Array

          Returns number

    Returns Float32Array

  • Parameters

    • callbackfn: function
        • (this: void, value: number, index: number, array: Float32Array): number
        • Parameters

          • this: void
          • value: number
          • index: number
          • array: Float32Array

          Returns number

    • thisArg: undefined

    Returns Float32Array

  • Type parameters

    • Z

    Parameters

    • callbackfn: function
        • (this: Z, value: number, index: number, array: Float32Array): number
        • Parameters

          • this: Z
          • value: number
          • index: number
          • array: Float32Array

          Returns number

    • thisArg: Z

    Returns Float32Array

Static maxValues

  • maxValues(mode: string): Pt
  • Get a Color object whose values are the maximum of its mode

    example

    Color.maxValue("rgb") will return a rgb Color object with values (255,255,255)

    Parameters

    • mode: string

      a mode string such as "rgb" or "lab"

    Returns Pt

Static reduce

  • reduce(callbackfn: function, initialValue?: number): number
  • reduce<U>(callbackfn: function, initialValue: U): U
  • Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    Parameters

    • callbackfn: function

      A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.

        • (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array): number
        • Parameters

          • previousValue: number
          • currentValue: number
          • currentIndex: number
          • array: Float32Array

          Returns number

    • Optional initialValue: number

      If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.

    Returns number

  • Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    Type parameters

    • U

    Parameters

    • callbackfn: function

      A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.

        • (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array): U
        • Parameters

          • previousValue: U
          • currentValue: number
          • currentIndex: number
          • array: Float32Array

          Returns U

    • initialValue: U

      If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.

    Returns U

Static reduceRight

  • reduceRight(callbackfn: function, initialValue?: number): number
  • reduceRight<U>(callbackfn: function, initialValue: U): U
  • Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    Parameters

    • callbackfn: function

      A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.

        • (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array): number
        • Parameters

          • previousValue: number
          • currentValue: number
          • currentIndex: number
          • array: Float32Array

          Returns number

    • Optional initialValue: number

      If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.

    Returns number

  • Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

    Type parameters

    • U

    Parameters

    • callbackfn: function

      A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.

        • (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array): U
        • Parameters

          • previousValue: U
          • currentValue: number
          • currentIndex: number
          • array: Float32Array

          Returns U

    • initialValue: U

      If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.

    Returns U

Static reverse

  • reverse(): Float32Array
  • Reverses the elements in an Array.

    Returns Float32Array

Static rgb

  • rgb(...args: any[]): Color
  • Create RGB Color

    Parameters

    • Rest ...args: any[]

      Pt-like parameters which can be a list of numeric parameters, an array of numbers, or an object with {x,y,z,w} properties.

    Returns Color

Static set

  • set(array: ArrayLike<number>, offset?: number): void
  • Sets a value or an array of values.

    Parameters

    • array: ArrayLike<number>

      A typed or untyped array of values to set.

    • Optional offset: number

      The index in the current array at which the values are to be written.

    Returns void

Static slice

  • slice(start?: number, end?: number): Float32Array
  • Returns a section of an array.

    Parameters

    • Optional start: number

      The beginning of the specified portion of the array.

    • Optional end: number

      The end of the specified portion of the array.

    Returns Float32Array

Static some

  • some(callbackfn: function): boolean
  • some(callbackfn: function, thisArg: undefined): boolean
  • some<Z>(callbackfn: function, thisArg: Z): boolean
  • Determines whether the specified callback function returns true for any element of an array.

    Parameters

    • callbackfn: function

      A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array.

        • (this: void, value: number, index: number, array: Float32Array): boolean
        • Parameters

          • this: void
          • value: number
          • index: number
          • array: Float32Array

          Returns boolean

    Returns boolean

  • Parameters

    • callbackfn: function
        • (this: void, value: number, index: number, array: Float32Array): boolean
        • Parameters

          • this: void
          • value: number
          • index: number
          • array: Float32Array

          Returns boolean

    • thisArg: undefined

    Returns boolean

  • Type parameters

    • Z

    Parameters

    • callbackfn: function
        • (this: Z, value: number, index: number, array: Float32Array): boolean
        • Parameters

          • this: Z
          • value: number
          • index: number
          • array: Float32Array

          Returns boolean

    • thisArg: Z

    Returns boolean

Static sort

  • sort(compareFn?: function): this
  • Sorts an array.

    Parameters

    • Optional compareFn: function

      The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order.

        • (a: number, b: number): number
        • Parameters

          • a: number
          • b: number

          Returns number

    Returns this

Static subarray

  • subarray(begin: number, end?: number): Float32Array
  • Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements at begin, inclusive, up to end, exclusive.

    Parameters

    • begin: number

      The index of the beginning of the array.

    • Optional end: number

      The index of the end of the array.

    Returns Float32Array

Static toLocaleString

  • toLocaleString(): string
  • Converts a number to a string by using the current locale.

    Returns string

Static toString

  • toString(): string
  • Returns a string representation of an array.

    Returns string

Static xyz

  • xyz(...args: any[]): Color
  • Create XYZ Color

    Parameters

    • Rest ...args: any[]

      Pt-like parameters which can be a list of numeric parameters, an array of numbers, or an object with {x,y,z,w} properties.

    Returns Color

Object literals

Static ranges

ranges: object

Value range for each color space

hsb

hsb: Group = new Group( new Pt(0,360), new Pt(0,1), new Pt(0,1) )

hsl

hsl: Group = new Group( new Pt(0,360), new Pt(0,1), new Pt(0,1) )

lab

lab: Group = new Group( new Pt(0,100), new Pt(-128,127), new Pt(-128, 127) )

lch

lch: Group = new Group( new Pt(0,100), new Pt(0,100), new Pt(0,360) )

luv

luv: Group = new Group( new Pt(0,100), new Pt(-134,220), new Pt(-140,122) )

rgb

rgb: Group = new Group( new Pt(0,255), new Pt(0,255), new Pt(0,255) )

xyz

xyz: Group = new Group( new Pt(0,100), new Pt(0,100), new Pt(0,100) )

Generated using TypeDoc