Color

class Communicator.Color()

An object representing an RGB Color. Values are specified in the 0-255 range.

Constructors

Properties


Constructors

Color.constructor(r, g, b)

Creates a new color object. Values are specified in the 0-255 range.

Arguments
  • r (number()) –

  • g (number()) –

  • b (number()) –

Return type

Color()

Properties

Color.b
Type

number

Color.g
Type

number

Color.r
Type

number

Methods

assign

Color.assign(color)

Sets this color equal to another color

Arguments
  • color (Color()) – the point whose values will be used to set this color

Return type

Color()

Returns

the color object

copy

Color.copy()

Creates a copy of this color

Return type

Color()

Returns

Copy of this color

equals

Color.equals(color)

Compares this color with another color

Arguments
  • color (Color()) – the color to compare with

Return type

boolean

Returns

True if the values of this color equal the other. False otherwise.

forJson

Color.forJson()
Deprecated

Use toJson instead.

Return type

Object

fromFloatArray

Color.fromFloatArray(arr)

Sets this color from an array of normalized floating point values

Arguments
  • arr ([number]()) –

Return type

void

getFloatArray

Color.getFloatArray()

Gets an array of floating point values representing this color. Values are clamped in the 0.0 - 1.0 range.

Return type

(number, number, number)

Returns

array of floating point values for this color.

set

Color.set(r, g, b)

Sets the color object. Values are specified in the 0-255 range.

Arguments
  • r (number()) – red color component

  • g (number()) – green color component

  • b (number()) – blue color component

Return type

void

setFromFloat

Color.setFromFloat(r, g, b)

Sets the color object from floating point values. Values are specified in the 0.0-1.0 range.

Arguments
  • r (number()) – red color component

  • g (number()) – green color component

  • b (number()) – blue color component

Return type

void

toFloatArray

Color.toFloatArray(arr)

Populates an array with floating point values for this color. Values are clamped in the 0.0 - 1.0 range.

Arguments
  • arr ([number]()) – array whose first three elements will be populated with the r,g, and b values of this color respectively.

Return type

void

toJson

Color.toJson()

Creates an object ready for JSON serialization.

Return type

Object

Returns

The prepared object.

static black

Color.black()

Creates a new color object initialized to black.

Return type

Color()

Returns

new color object

static blue

Color.blue()

Creates a new color object initialized to blue.

Return type

Color()

Returns

new color object

static createFromFloat

Color.createFromFloat(r, g, b)

Creates a color object from floating point values. Values are specified in the 0.0-1.0 range.

Arguments
  • r (number()) – red color component

  • g (number()) – green color component

  • b (number()) – blue color component

Return type

Color()

Returns

new color object

static createFromFloatArray

Color.createFromFloatArray(values)

Creates a color object from an array of floating point values. Values are specified in the 0.0-1.0 range.

Arguments
  • values ([number]()) –

Return type

Color()

static fromJson

Color.fromJson(objData)

Creates a new Color from an object given by toJson

Arguments
  • objData (any()) – An object given by toJson

Return type

Color()

Returns

The prepared object.

static green

Color.green()

Creates a new color object initialized to green.

Return type

Color()

Returns

new color object

static red

Color.red()

Creates a new color object initialized to red.

Return type

Color()

Returns

new color object

static white

Color.white()

Creates a new color object initialized to white.

Return type

Color()

Returns

new color object

static yellow

Color.yellow()

Creates a new color object initialized to yellow.

Return type

Color()

Returns

new color object