Color

Color

new

A color, specified using red, green, blue, and alpha values, which range from 0 (no intensity) to 1.0 (full intensity).

Parameters:
Name Type Argument Default Description
red Number <optional>
1.0 The red component.
green Number <optional>
1.0 The green component.
blue Number <optional>
1.0 The blue component.
alpha Number <optional>
1.0 The alpha component.
See:
Source:

Members

:Number

The alpha component.
Default Value:
  • 1.0

:Number

The blue component.
Default Value:
  • 1.0

:Number

The green component.
Default Value:
  • 1.0

:Number

The red component.
Default Value:
  • 1.0

<static, constant> :Color

An immutable Color instance initialized to CSS color #F0F8FF

<static, constant> :Color

An immutable Color instance initialized to CSS color #FAEBD7

<static, constant> :Color

An immutable Color instance initialized to CSS color #00FFFF

<static, constant> :Color

An immutable Color instance initialized to CSS color #7FFFD4

<static, constant> :Color

An immutable Color instance initialized to CSS color #F0FFFF

<static, constant> :Color

An immutable Color instance initialized to CSS color #F5F5DC

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFE4C4

<static, constant> :Color

An immutable Color instance initialized to CSS color #000000

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFEBCD

<static, constant> :Color

An immutable Color instance initialized to CSS color #0000FF

<static, constant> :Color

An immutable Color instance initialized to CSS color #8A2BE2

<static, constant> :Color

An immutable Color instance initialized to CSS color #A52A2A

<static, constant> :Color

An immutable Color instance initialized to CSS color #DEB887

<static, constant> :Color

An immutable Color instance initialized to CSS color #5F9EA0

<static, constant> :Color

An immutable Color instance initialized to CSS color #7FFF00

<static, constant> :Color

An immutable Color instance initialized to CSS color #D2691E

<static, constant> :Color

An immutable Color instance initialized to CSS color #FF7F50

<static, constant> :Color

An immutable Color instance initialized to CSS color #6495ED

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFF8DC

<static, constant> :Color

An immutable Color instance initialized to CSS color #DC143C

<static, constant> :Color

An immutable Color instance initialized to CSS color #00FFFF

<static, constant> :Color

An immutable Color instance initialized to CSS color #00008B

<static, constant> :Color

An immutable Color instance initialized to CSS color #008B8B

<static, constant> :Color

An immutable Color instance initialized to CSS color #B8860B

<static, constant> :Color

An immutable Color instance initialized to CSS color #A9A9A9

<static, constant> :Color

An immutable Color instance initialized to CSS color #006400

<static, constant> :Color

An immutable Color instance initialized to CSS color #A9A9A9

<static, constant> :Color

An immutable Color instance initialized to CSS color #BDB76B

<static, constant> :Color

An immutable Color instance initialized to CSS color #8B008B

<static, constant> :Color

An immutable Color instance initialized to CSS color #556B2F

<static, constant> :Color

An immutable Color instance initialized to CSS color #FF8C00

<static, constant> :Color

An immutable Color instance initialized to CSS color #9932CC

<static, constant> :Color

An immutable Color instance initialized to CSS color #8B0000

<static, constant> :Color

An immutable Color instance initialized to CSS color #E9967A

<static, constant> :Color

An immutable Color instance initialized to CSS color #8FBC8F

<static, constant> :Color

An immutable Color instance initialized to CSS color #483D8B

<static, constant> :Color

An immutable Color instance initialized to CSS color #2F4F4F

<static, constant> :Color

An immutable Color instance initialized to CSS color #2F4F4F

<static, constant> :Color

An immutable Color instance initialized to CSS color #00CED1

<static, constant> :Color

An immutable Color instance initialized to CSS color #9400D3

<static, constant> :Color

An immutable Color instance initialized to CSS color #FF1493

<static, constant> :Color

An immutable Color instance initialized to CSS color #00BFFF

<static, constant> :Color

An immutable Color instance initialized to CSS color #696969

<static, constant> :Color

An immutable Color instance initialized to CSS color #696969

<static, constant> :Color

An immutable Color instance initialized to CSS color #1E90FF

<static, constant> :Color

An immutable Color instance initialized to CSS color #B22222

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFFAF0

<static, constant> :Color

An immutable Color instance initialized to CSS color #228B22

<static, constant> :Color

An immutable Color instance initialized to CSS color #FF00FF

<static, constant> :Color

An immutable Color instance initialized to CSS color #DCDCDC

<static, constant> :Color

An immutable Color instance initialized to CSS color #F8F8FF

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFD700

<static, constant> :Color

An immutable Color instance initialized to CSS color #DAA520

<static, constant> :Color

An immutable Color instance initialized to CSS color #808080

<static, constant> :Color

An immutable Color instance initialized to CSS color #008000

<static, constant> :Color

An immutable Color instance initialized to CSS color #ADFF2F

<static, constant> :Color

An immutable Color instance initialized to CSS color #808080

<static, constant> :Color

An immutable Color instance initialized to CSS color #F0FFF0

<static, constant> :Color

An immutable Color instance initialized to CSS color #FF69B4

<static, constant> :Color

An immutable Color instance initialized to CSS color #CD5C5C

<static, constant> :Color

An immutable Color instance initialized to CSS color #4B0082

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFFFF0

<static, constant> :Color

An immutable Color instance initialized to CSS color #F0E68C

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFF0F5

<static, constant> :Color

An immutable Color instance initialized to CSS color #E6E6FA

<static, constant> :Color

An immutable Color instance initialized to CSS color #7CFC00

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFFACD

<static, constant> :Color

An immutable Color instance initialized to CSS color #ADD8E6

<static, constant> :Color

An immutable Color instance initialized to CSS color #F08080

<static, constant> :Color

An immutable Color instance initialized to CSS color #E0FFFF

<static, constant> :Color

An immutable Color instance initialized to CSS color #FAFAD2

<static, constant> :Color

An immutable Color instance initialized to CSS color #D3D3D3

<static, constant> :Color

An immutable Color instance initialized to CSS color #90EE90

<static, constant> :Color

An immutable Color instance initialized to CSS color #D3D3D3

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFB6C1

<static, constant> :Color

An immutable Color instance initialized to CSS color #20B2AA

<static, constant> :Color

An immutable Color instance initialized to CSS color #87CEFA

<static, constant> :Color

An immutable Color instance initialized to CSS color #778899

<static, constant> :Color

An immutable Color instance initialized to CSS color #778899

<static, constant> :Color

An immutable Color instance initialized to CSS color #B0C4DE

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFFFE0

<static, constant> :Color

An immutable Color instance initialized to CSS color #00FF00

<static, constant> :Color

An immutable Color instance initialized to CSS color #32CD32

<static, constant> :Color

An immutable Color instance initialized to CSS color #FAF0E6

<static, constant> :Color

An immutable Color instance initialized to CSS color #FF00FF

<static, constant> :Color

An immutable Color instance initialized to CSS color #800000

<static, constant> :Color

An immutable Color instance initialized to CSS color #66CDAA

<static, constant> :Color

An immutable Color instance initialized to CSS color #0000CD

<static, constant> :Color

An immutable Color instance initialized to CSS color #BA55D3

<static, constant> :Color

An immutable Color instance initialized to CSS color #9370DB

<static, constant> :Color

An immutable Color instance initialized to CSS color #3CB371

<static, constant> :Color

An immutable Color instance initialized to CSS color #7B68EE

<static, constant> :Color

An immutable Color instance initialized to CSS color #00FA9A

<static, constant> :Color

An immutable Color instance initialized to CSS color #48D1CC

<static, constant> :Color

An immutable Color instance initialized to CSS color #C71585

<static, constant> :Color

An immutable Color instance initialized to CSS color #191970

<static, constant> :Color

An immutable Color instance initialized to CSS color #F5FFFA

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFE4E1

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFE4B5
An immutable Color instance initialized to CSS color #FFDEAD
An immutable Color instance initialized to CSS color #000080

<static, constant> :Color

An immutable Color instance initialized to CSS color #FDF5E6

<static, constant> :Color

An immutable Color instance initialized to CSS color #808000

<static, constant> :Color

An immutable Color instance initialized to CSS color #6B8E23

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFA500

<static, constant> :Color

An immutable Color instance initialized to CSS color #FF4500

<static, constant> :Color

An immutable Color instance initialized to CSS color #DA70D6

<static> :Number

The number of elements used to pack the object into an array.

<static, constant> :Color

An immutable Color instance initialized to CSS color #EEE8AA

<static, constant> :Color

An immutable Color instance initialized to CSS color #98FB98

<static, constant> :Color

An immutable Color instance initialized to CSS color #AFEEEE

<static, constant> :Color

An immutable Color instance initialized to CSS color #DB7093

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFEFD5

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFDAB9

<static, constant> :Color

An immutable Color instance initialized to CSS color #CD853F

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFC0CB

<static, constant> :Color

An immutable Color instance initialized to CSS color #DDA0DD

<static, constant> :Color

An immutable Color instance initialized to CSS color #B0E0E6

<static, constant> :Color

An immutable Color instance initialized to CSS color #800080

<static, constant> :Color

An immutable Color instance initialized to CSS color #FF0000

<static, constant> :Color

An immutable Color instance initialized to CSS color #BC8F8F

<static, constant> :Color

An immutable Color instance initialized to CSS color #4169E1

<static, constant> :Color

An immutable Color instance initialized to CSS color #8B4513

<static, constant> :Color

An immutable Color instance initialized to CSS color #FA8072

<static, constant> :Color

An immutable Color instance initialized to CSS color #F4A460

<static, constant> :Color

An immutable Color instance initialized to CSS color #2E8B57

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFF5EE

<static, constant> :Color

An immutable Color instance initialized to CSS color #A0522D

<static, constant> :Color

An immutable Color instance initialized to CSS color #C0C0C0

<static, constant> :Color

An immutable Color instance initialized to CSS color #87CEEB

<static, constant> :Color

An immutable Color instance initialized to CSS color #6A5ACD

<static, constant> :Color

An immutable Color instance initialized to CSS color #708090

<static, constant> :Color

An immutable Color instance initialized to CSS color #708090

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFFAFA

<static, constant> :Color

An immutable Color instance initialized to CSS color #00FF7F

<static, constant> :Color

An immutable Color instance initialized to CSS color #4682B4

<static, constant> :Color

An immutable Color instance initialized to CSS color #D2B48C

<static, constant> :Color

An immutable Color instance initialized to CSS color #008080

<static, constant> :Color

An immutable Color instance initialized to CSS color #D8BFD8

<static, constant> :Color

An immutable Color instance initialized to CSS color #FF6347

<static, constant> :Color

An immutable Color instance initialized to CSS color #40E0D0

<static, constant> :Color

An immutable Color instance initialized to CSS color #EE82EE

<static, constant> :Color

An immutable Color instance initialized to CSS color #F5DEB3

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFFFFF

<static, constant> :Color

An immutable Color instance initialized to CSS color #F5F5F5

<static, constant> :Color

An immutable Color instance initialized to CSS color #FFFF00

<static, constant> :Color

An immutable Color instance initialized to CSS color #9ACD32

Methods

Returns a duplicate of a Color instance.

Parameters:
Name Type Argument Description
result Color <optional>
The object to store the result in, if undefined a new instance will be created.
Returns:
Color The modified result parameter or a new instance if result was undefined.

Returns true if this Color equals other.

Parameters:
Name Type Description
other Color The Color to compare for equality.
Returns:
Boolean true if the Colors are equal; otherwise, false.

Returns true if this Color equals other componentwise within the specified epsilon.

Parameters:
Name Type Argument Default Description
other Color The Color to compare for equality.
epsilon Number <optional>
0.0 The epsilon to use for equality testing.
Returns:
Boolean true if the Colors are equal within the specified epsilon; otherwise, false.

Converts this color to an array of red, green, blue, and alpha values that are in the range of 0 to 255.

Parameters:
Name Type Argument Description
result Array <optional>
The array to store the result in, if undefined a new instance will be created.
Returns:
Array The modified result parameter or a new instance if result was undefined.

Creates a string containing the CSS color value for this color.

Returns:
String The CSS equivalent of this color.
See:

Converts this color to a single numeric unsigned 32-bit RGBA value, using the endianness of the system.

Returns:
Number A single numeric unsigned 32-bit RGBA value.
Example
var rgba = Cesium.Color.BLUE.toRgba();
See:

Creates a string representing this Color in the format '(red, green, blue, alpha)'.

Returns:
String A string representing this Color in the format '(red, green, blue, alpha)'.

<static>

Converts a 'byte' color component in the range of 0 to 255 into a 'float' color component in the range of 0 to 1.0.

Parameters:
Name Type Description
number Number The number to be converted.
Returns:
number The converted number.

<static>

Duplicates a Color.

Parameters:
Name Type Argument Description
color Color The Color to duplicate.
result Color <optional>
The object to store the result in, if undefined a new instance will be created.
Returns:
Color The modified result parameter or a new instance if result was undefined. (Returns undefined if color is undefined)

<static>

Returns true if the first Color equals the second color.

Parameters:
Name Type Description
left Color The first Color to compare for equality.
right Color The second Color to compare for equality.
Returns:
Boolean true if the Colors are equal; otherwise, false.

<static>

Converts a 'float' color component in the range of 0 to 1.0 into a 'byte' color component in the range of 0 to 255.

Parameters:
Name Type Description
number Number The number to be converted.
Returns:
number The converted number.

<static>

Creates a new Color specified using red, green, blue, and alpha values that are in the range of 0 to 255, converting them internally to a range of 0.0 to 1.0.

Parameters:
Name Type Argument Default Description
red Number <optional>
255 The red component.
green Number <optional>
255 The green component.
blue Number <optional>
255 The blue component.
alpha Number <optional>
255 The alpha component.
Returns:
Color A new color instance.

<static>

Creates a Color instance from a Cartesian4. x, y, z, and w map to red, green, blue, and alpha, respectively.

Parameters:
Name Type Argument Description
cartesian Cartesian4 The source cartesian.
result Color <optional>
The object onto which to store the result.
Returns:
Color The modified result parameter or a new Color instance if one was not provided.

<static>

Creates a Color instance from a CSS color value.

Parameters:
Name Type Description
color String The CSS color value in #rgb, #rrggbb, rgb(), rgba(), hsl(), or hsla() format.
Returns:
Color The color object, or undefined if the string was not a valid CSS color.
Example
var cesiumBlue = Cesium.Color.fromCssColorString('#67ADDF');
var green = Cesium.Color.fromCssColorString('green');
See:

<static>

Creates a Color instance from hue, saturation, and lightness.

Parameters:
Name Type Argument Default Description
hue Number <optional>
0 The hue angle 0...1
saturation Number <optional>
0 The saturation value 0...1
lightness Number <optional>
0 The lightness value 0...1
alpha Number <optional>
1.0 The alpha component 0...1
Returns:
Color The color object.
See:

<static>

Creates a random color using the provided options. For reproducible random colors, you should call CesiumMath#setRandomNumberSeed once at the beginning of your application.

Parameters:
Name Type Argument Description
options Object <optional>
Object containing the options.
Properties
Name Type Argument Default Description
red Number <optional>
If specified, the red component to use instead of a randomized value.
minimumRed Number <optional>
0.0 The maximum red value to generate if none was specified.
maximumRed Number <optional>
1.0 The minimum red value to generate if none was specified.
green Number <optional>
If specified, the green component to use instead of a randomized value.
minimumGreen Number <optional>
0.0 The maximum green value to generate if none was specified.
maximumGreen Number <optional>
1.0 The minimum green value to generate if none was specified.
blue Number <optional>
If specified, the blue component to use instead of a randomized value.
minimumBlue Number <optional>
0.0 The maximum blue value to generate if none was specified.
maximumBlue Number <optional>
1.0 The minimum blue value to generate if none was specified.
alpha Number <optional>
If specified, the alpha component to use instead of a randomized value.
minimumAlpha Number <optional>
0.0 The maximum alpha value to generate if none was specified.
maximumAlpha Number <optional>
1.0 The minimum alpha value to generate if none was specified.
result Color <optional>
The object to store the result in, if undefined a new instance will be created.
Throws:
  • DeveloperError : minimumRed must be less than or equal to maximumRed.
  • DeveloperError : minimumGreen must be less than or equal to maximumGreen.
  • DeveloperError : minimumBlue must be less than or equal to maximumBlue.
  • DeveloperError : minimumAlpha must be less than or equal to maximumAlpha.
Returns:
Color The modified result parameter or a new instance if result was undefined.
Example
//Create a completely random color
var color = Cesium.Color.fromRandom();

//Create a random shade of yellow.
var color = Cesium.Color.fromRandom({
    red : 1.0,
    green : 1.0,
    alpha : 1.0
});

//Create a random bright color.
var color = Cesium.Color.fromRandom({
    minimumRed : 0.75,
    minimumGreen : 0.75,
    minimumBlue : 0.75,
    alpha : 1.0
});

<static>

Creates a new Color from a single numeric unsigned 32-bit RGBA value, using the endianness of the system.

Parameters:
Name Type Description
rgba Number A single numeric unsigned 32-bit RGBA value.
Returns:
Color A new color instance.
Example
var color = Cesium.Color.fromRgba(0x67ADDFFF);
See:

<static>

Stores the provided instance into the provided array.

Parameters:
Name Type Argument Default Description
value Color The value to pack.
array Array The array to pack into.
startingIndex Number <optional>
0 The index into the array at which to start packing the elements.

<static>

Retrieves an instance from a packed array.

Parameters:
Name Type Argument Default Description
array Array The packed array.
startingIndex Number <optional>
0 The starting index of the element to be unpacked.
result Color <optional>
The object into which to store the result.