Color

new Color(red, green, blue, alpha)

A color, specified using red, green, blue, and alpha values, which range from 0 (no intensity) to 1.0 (full intensity).
Name Type Default Description
red Number 1.0 optional The red component.
green Number 1.0 optional The green component.
blue Number 1.0 optional The blue component.
alpha Number 1.0 optional The alpha component.
See:

Members

staticconstantColor.ALICEBLUE :Color

An immutable Color instance initialized to CSS color #F0F8FF

staticconstantColor.ANTIQUEWHITE :Color

An immutable Color instance initialized to CSS color #FAEBD7

staticconstantColor.AQUA :Color

An immutable Color instance initialized to CSS color #00FFFF

staticconstantColor.AQUAMARINE :Color

An immutable Color instance initialized to CSS color #7FFFD4

staticconstantColor.AZURE :Color

An immutable Color instance initialized to CSS color #F0FFFF

staticconstantColor.BEIGE :Color

An immutable Color instance initialized to CSS color #F5F5DC

staticconstantColor.BISQUE :Color

An immutable Color instance initialized to CSS color #FFE4C4

staticconstantColor.BLACK :Color

An immutable Color instance initialized to CSS color #000000

staticconstantColor.BLANCHEDALMOND :Color

An immutable Color instance initialized to CSS color #FFEBCD

staticconstantColor.BLUE :Color

An immutable Color instance initialized to CSS color #0000FF

staticconstantColor.BLUEVIOLET :Color

An immutable Color instance initialized to CSS color #8A2BE2

staticconstantColor.BROWN :Color

An immutable Color instance initialized to CSS color #A52A2A

staticconstantColor.BURLYWOOD :Color

An immutable Color instance initialized to CSS color #DEB887

staticconstantColor.CADETBLUE :Color

An immutable Color instance initialized to CSS color #5F9EA0

staticconstantColor.CHARTREUSE :Color

An immutable Color instance initialized to CSS color #7FFF00

staticconstantColor.CHOCOLATE :Color

An immutable Color instance initialized to CSS color #D2691E

staticconstantColor.CORAL :Color

An immutable Color instance initialized to CSS color #FF7F50

staticconstantColor.CORNFLOWERBLUE :Color

An immutable Color instance initialized to CSS color #6495ED

staticconstantColor.CORNSILK :Color

An immutable Color instance initialized to CSS color #FFF8DC

staticconstantColor.CRIMSON :Color

An immutable Color instance initialized to CSS color #DC143C

staticconstantColor.CYAN :Color

An immutable Color instance initialized to CSS color #00FFFF

staticconstantColor.DARKBLUE :Color

An immutable Color instance initialized to CSS color #00008B

staticconstantColor.DARKCYAN :Color

An immutable Color instance initialized to CSS color #008B8B

staticconstantColor.DARKGOLDENROD :Color

An immutable Color instance initialized to CSS color #B8860B

staticconstantColor.DARKGRAY :Color

An immutable Color instance initialized to CSS color #A9A9A9

staticconstantColor.DARKGREEN :Color

An immutable Color instance initialized to CSS color #006400

staticconstantColor.DARKGREY :Color

An immutable Color instance initialized to CSS color #A9A9A9

staticconstantColor.DARKKHAKI :Color

An immutable Color instance initialized to CSS color #BDB76B

staticconstantColor.DARKMAGENTA :Color

An immutable Color instance initialized to CSS color #8B008B

staticconstantColor.DARKOLIVEGREEN :Color

An immutable Color instance initialized to CSS color #556B2F

staticconstantColor.DARKORANGE :Color

An immutable Color instance initialized to CSS color #FF8C00

staticconstantColor.DARKORCHID :Color

An immutable Color instance initialized to CSS color #9932CC

staticconstantColor.DARKRED :Color

An immutable Color instance initialized to CSS color #8B0000

staticconstantColor.DARKSALMON :Color

An immutable Color instance initialized to CSS color #E9967A

staticconstantColor.DARKSEAGREEN :Color

An immutable Color instance initialized to CSS color #8FBC8F

staticconstantColor.DARKSLATEBLUE :Color

An immutable Color instance initialized to CSS color #483D8B

staticconstantColor.DARKSLATEGRAY :Color

An immutable Color instance initialized to CSS color #2F4F4F

staticconstantColor.DARKSLATEGREY :Color

An immutable Color instance initialized to CSS color #2F4F4F

staticconstantColor.DARKTURQUOISE :Color

An immutable Color instance initialized to CSS color #00CED1

staticconstantColor.DARKVIOLET :Color

An immutable Color instance initialized to CSS color #9400D3

staticconstantColor.DEEPPINK :Color

An immutable Color instance initialized to CSS color #FF1493

staticconstantColor.DEEPSKYBLUE :Color

An immutable Color instance initialized to CSS color #00BFFF

staticconstantColor.DIMGRAY :Color

An immutable Color instance initialized to CSS color #696969

staticconstantColor.DIMGREY :Color

An immutable Color instance initialized to CSS color #696969

staticconstantColor.DODGERBLUE :Color

An immutable Color instance initialized to CSS color #1E90FF

staticconstantColor.FIREBRICK :Color

An immutable Color instance initialized to CSS color #B22222

staticconstantColor.FLORALWHITE :Color

An immutable Color instance initialized to CSS color #FFFAF0

staticconstantColor.FORESTGREEN :Color

An immutable Color instance initialized to CSS color #228B22

staticconstantColor.FUSCHIA :Color

An immutable Color instance initialized to CSS color #FF00FF

staticconstantColor.GAINSBORO :Color

An immutable Color instance initialized to CSS color #DCDCDC

staticconstantColor.GHOSTWHITE :Color

An immutable Color instance initialized to CSS color #F8F8FF

staticconstantColor.GOLD :Color

An immutable Color instance initialized to CSS color #FFD700

staticconstantColor.GOLDENROD :Color

An immutable Color instance initialized to CSS color #DAA520

staticconstantColor.GRAY :Color

An immutable Color instance initialized to CSS color #808080

staticconstantColor.GREEN :Color

An immutable Color instance initialized to CSS color #008000

staticconstantColor.GREENYELLOW :Color

An immutable Color instance initialized to CSS color #ADFF2F

staticconstantColor.GREY :Color

An immutable Color instance initialized to CSS color #808080

staticconstantColor.HONEYDEW :Color

An immutable Color instance initialized to CSS color #F0FFF0

staticconstantColor.HOTPINK :Color

An immutable Color instance initialized to CSS color #FF69B4

staticconstantColor.INDIANRED :Color

An immutable Color instance initialized to CSS color #CD5C5C

staticconstantColor.INDIGO :Color

An immutable Color instance initialized to CSS color #4B0082

staticconstantColor.IVORY :Color

An immutable Color instance initialized to CSS color #FFFFF0

staticconstantColor.KHAKI :Color

An immutable Color instance initialized to CSS color #F0E68C

staticconstantColor.LAVENDAR_BLUSH :Color

An immutable Color instance initialized to CSS color #FFF0F5

staticconstantColor.LAVENDER :Color

An immutable Color instance initialized to CSS color #E6E6FA

staticconstantColor.LAWNGREEN :Color

An immutable Color instance initialized to CSS color #7CFC00

staticconstantColor.LEMONCHIFFON :Color

An immutable Color instance initialized to CSS color #FFFACD

staticconstantColor.LIGHTBLUE :Color

An immutable Color instance initialized to CSS color #ADD8E6

staticconstantColor.LIGHTCORAL :Color

An immutable Color instance initialized to CSS color #F08080

staticconstantColor.LIGHTCYAN :Color

An immutable Color instance initialized to CSS color #E0FFFF

staticconstantColor.LIGHTGOLDENRODYELLOW :Color

An immutable Color instance initialized to CSS color #FAFAD2

staticconstantColor.LIGHTGRAY :Color

An immutable Color instance initialized to CSS color #D3D3D3

staticconstantColor.LIGHTGREEN :Color

An immutable Color instance initialized to CSS color #90EE90

staticconstantColor.LIGHTGREY :Color

An immutable Color instance initialized to CSS color #D3D3D3

staticconstantColor.LIGHTPINK :Color

An immutable Color instance initialized to CSS color #FFB6C1

staticconstantColor.LIGHTSEAGREEN :Color

An immutable Color instance initialized to CSS color #20B2AA

staticconstantColor.LIGHTSKYBLUE :Color

An immutable Color instance initialized to CSS color #87CEFA

staticconstantColor.LIGHTSLATEGRAY :Color

An immutable Color instance initialized to CSS color #778899

staticconstantColor.LIGHTSLATEGREY :Color

An immutable Color instance initialized to CSS color #778899

staticconstantColor.LIGHTSTEELBLUE :Color

An immutable Color instance initialized to CSS color #B0C4DE

staticconstantColor.LIGHTYELLOW :Color

An immutable Color instance initialized to CSS color #FFFFE0

staticconstantColor.LIME :Color

An immutable Color instance initialized to CSS color #00FF00

staticconstantColor.LIMEGREEN :Color

An immutable Color instance initialized to CSS color #32CD32

staticconstantColor.LINEN :Color

An immutable Color instance initialized to CSS color #FAF0E6

staticconstantColor.MAGENTA :Color

An immutable Color instance initialized to CSS color #FF00FF

staticconstantColor.MAROON :Color

An immutable Color instance initialized to CSS color #800000

staticconstantColor.MEDIUMAQUAMARINE :Color

An immutable Color instance initialized to CSS color #66CDAA

staticconstantColor.MEDIUMBLUE :Color

An immutable Color instance initialized to CSS color #0000CD

staticconstantColor.MEDIUMORCHID :Color

An immutable Color instance initialized to CSS color #BA55D3

staticconstantColor.MEDIUMPURPLE :Color

An immutable Color instance initialized to CSS color #9370DB

staticconstantColor.MEDIUMSEAGREEN :Color

An immutable Color instance initialized to CSS color #3CB371

staticconstantColor.MEDIUMSLATEBLUE :Color

An immutable Color instance initialized to CSS color #7B68EE

staticconstantColor.MEDIUMSPRINGGREEN :Color

An immutable Color instance initialized to CSS color #00FA9A

staticconstantColor.MEDIUMTURQUOISE :Color

An immutable Color instance initialized to CSS color #48D1CC

staticconstantColor.MEDIUMVIOLETRED :Color

An immutable Color instance initialized to CSS color #C71585

staticconstantColor.MIDNIGHTBLUE :Color

An immutable Color instance initialized to CSS color #191970

staticconstantColor.MINTCREAM :Color

An immutable Color instance initialized to CSS color #F5FFFA

staticconstantColor.MISTYROSE :Color

An immutable Color instance initialized to CSS color #FFE4E1

staticconstantColor.MOCCASIN :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

staticconstantColor.OLDLACE :Color

An immutable Color instance initialized to CSS color #FDF5E6

staticconstantColor.OLIVE :Color

An immutable Color instance initialized to CSS color #808000

staticconstantColor.OLIVEDRAB :Color

An immutable Color instance initialized to CSS color #6B8E23

staticconstantColor.ORANGE :Color

An immutable Color instance initialized to CSS color #FFA500

staticconstantColor.ORANGERED :Color

An immutable Color instance initialized to CSS color #FF4500

staticconstantColor.ORCHID :Color

An immutable Color instance initialized to CSS color #DA70D6

staticColor.packedLength :Number

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

staticconstantColor.PALEGOLDENROD :Color

An immutable Color instance initialized to CSS color #EEE8AA

staticconstantColor.PALEGREEN :Color

An immutable Color instance initialized to CSS color #98FB98

staticconstantColor.PALETURQUOISE :Color

An immutable Color instance initialized to CSS color #AFEEEE

staticconstantColor.PALEVIOLETRED :Color

An immutable Color instance initialized to CSS color #DB7093

staticconstantColor.PAPAYAWHIP :Color

An immutable Color instance initialized to CSS color #FFEFD5

staticconstantColor.PEACHPUFF :Color

An immutable Color instance initialized to CSS color #FFDAB9

staticconstantColor.PERU :Color

An immutable Color instance initialized to CSS color #CD853F

staticconstantColor.PINK :Color

An immutable Color instance initialized to CSS color #FFC0CB

staticconstantColor.PLUM :Color

An immutable Color instance initialized to CSS color #DDA0DD

staticconstantColor.POWDERBLUE :Color

An immutable Color instance initialized to CSS color #B0E0E6

staticconstantColor.PURPLE :Color

An immutable Color instance initialized to CSS color #800080

staticconstantColor.RED :Color

An immutable Color instance initialized to CSS color #FF0000

staticconstantColor.ROSYBROWN :Color

An immutable Color instance initialized to CSS color #BC8F8F

staticconstantColor.ROYALBLUE :Color

An immutable Color instance initialized to CSS color #4169E1

staticconstantColor.SADDLEBROWN :Color

An immutable Color instance initialized to CSS color #8B4513

staticconstantColor.SALMON :Color

An immutable Color instance initialized to CSS color #FA8072

staticconstantColor.SANDYBROWN :Color

An immutable Color instance initialized to CSS color #F4A460

staticconstantColor.SEAGREEN :Color

An immutable Color instance initialized to CSS color #2E8B57

staticconstantColor.SEASHELL :Color

An immutable Color instance initialized to CSS color #FFF5EE

staticconstantColor.SIENNA :Color

An immutable Color instance initialized to CSS color #A0522D

staticconstantColor.SILVER :Color

An immutable Color instance initialized to CSS color #C0C0C0

staticconstantColor.SKYBLUE :Color

An immutable Color instance initialized to CSS color #87CEEB

staticconstantColor.SLATEBLUE :Color

An immutable Color instance initialized to CSS color #6A5ACD

staticconstantColor.SLATEGRAY :Color

An immutable Color instance initialized to CSS color #708090

staticconstantColor.SLATEGREY :Color

An immutable Color instance initialized to CSS color #708090

staticconstantColor.SNOW :Color

An immutable Color instance initialized to CSS color #FFFAFA

staticconstantColor.SPRINGGREEN :Color

An immutable Color instance initialized to CSS color #00FF7F

staticconstantColor.STEELBLUE :Color

An immutable Color instance initialized to CSS color #4682B4

staticconstantColor.TAN :Color

An immutable Color instance initialized to CSS color #D2B48C

staticconstantColor.TEAL :Color

An immutable Color instance initialized to CSS color #008080

staticconstantColor.THISTLE :Color

An immutable Color instance initialized to CSS color #D8BFD8

staticconstantColor.TOMATO :Color

An immutable Color instance initialized to CSS color #FF6347

staticconstantColor.TURQUOISE :Color

An immutable Color instance initialized to CSS color #40E0D0

staticconstantColor.VIOLET :Color

An immutable Color instance initialized to CSS color #EE82EE

staticconstantColor.WHEAT :Color

An immutable Color instance initialized to CSS color #F5DEB3

staticconstantColor.WHITE :Color

An immutable Color instance initialized to CSS color #FFFFFF

staticconstantColor.WHITESMOKE :Color

An immutable Color instance initialized to CSS color #F5F5F5

staticconstantColor.YELLOW :Color

An immutable Color instance initialized to CSS color #FFFF00

staticconstantColor.YELLOWGREEN :Color

An immutable Color instance initialized to CSS color #9ACD32

alpha :Number

The alpha component.
Default Value: 1.0

blue :Number

The blue component.
Default Value: 1.0

green :Number

The green component.
Default Value: 1.0

red :Number

The red component.
Default Value: 1.0

Methods

staticColor.byteToFloat(number)Number

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.
Name Type Description
number Number The number to be converted.
Returns:
The converted number.

staticColor.clone(color, result)Color

Duplicates a Color.
Name Type 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:
The modified result parameter or a new instance if result was undefined. (Returns undefined if color is undefined)

staticColor.equals(left, right)Boolean

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

staticColor.floatToByte(number)Number

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.
Name Type Description
number Number The number to be converted.
Returns:
The converted number.

staticColor.fromBytes(red, green, blue, alpha)Color

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.
Name Type Default Description
red Number 255 optional The red component.
green Number 255 optional The green component.
blue Number 255 optional The blue component.
alpha Number 255 optional The alpha component.
Returns:
A new color instance.

staticColor.fromCartesian4(cartesian, result)Color

Creates a Color instance from a Cartesian4. x, y, z, and w map to red, green, blue, and alpha, respectively.
Name Type Description
cartesian Cartesian4 The source cartesian.
result Color optional The object onto which to store the result.
Returns:
The modified result parameter or a new Color instance if one was not provided.

staticColor.fromCssColorString(color)Color

Creates a Color instance from a CSS color value.
Name Type Description
color String The CSS color value in #rgb, #rrggbb, rgb(), rgba(), hsl(), or hsla() format.
Returns:
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:

staticColor.fromHsl(hue, saturation, lightness, alpha)Color

Creates a Color instance from hue, saturation, and lightness.
Name Type Default Description
hue Number 0 optional The hue angle 0...1
saturation Number 0 optional The saturation value 0...1
lightness Number 0 optional The lightness value 0...1
alpha Number 1.0 optional The alpha component 0...1
Returns:
The color object.
See:

staticColor.fromRandom(options, result)Color

Creates a random color using the provided options. For reproducible random colors, you should call CesiumMath#setRandomNumberSeed once at the beginning of your application.
Name Type Description
options Object optional Object containing the options.
Name Type Default Description
red Number optional If specified, the red component to use instead of a randomized value.
minimumRed Number 0.0 optional The maximum red value to generate if none was specified.
maximumRed Number 1.0 optional 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 0.0 optional The maximum green value to generate if none was specified.
maximumGreen Number 1.0 optional 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 0.0 optional The maximum blue value to generate if none was specified.
maximumBlue Number 1.0 optional 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 0.0 optional The maximum alpha value to generate if none was specified.
maximumAlpha Number 1.0 optional 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.
Returns:
The modified result parameter or a new instance if result was undefined.
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.
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
});

staticColor.fromRgba(rgba)Color

Creates a new Color from a single numeric unsigned 32-bit RGBA value, using the endianness of the system.
Name Type Description
rgba Number A single numeric unsigned 32-bit RGBA value.
Returns:
A new color instance.
Example:
var color = Cesium.Color.fromRgba(0x67ADDFFF);
See:

staticColor.pack(value, array, startingIndex)

Stores the provided instance into the provided array.
Name Type Default Description
value Color The value to pack.
array Number[] The array to pack into.
startingIndex Number 0 optional The index into the array at which to start packing the elements.

staticColor.unpack(array, startingIndex, result)

Retrieves an instance from a packed array.
Name Type Default Description
array Number[] The packed array.
startingIndex Number 0 optional The starting index of the element to be unpacked.
result Color optional The object into which to store the result.

clone(result)Color

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

equals(other)Boolean

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

equalsEpsilon(other, epsilon)Boolean

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

toBytes(result)Number[]

Converts this color to an array of red, green, blue, and alpha values that are in the range of 0 to 255.
Name Type Description
result Number[] optional The array to store the result in, if undefined a new instance will be created.
Returns:
The modified result parameter or a new instance if result was undefined.

toCssColorString()String

Creates a string containing the CSS color value for this color.
Returns:
The CSS equivalent of this color.
See:

toRgba()Number

Converts this color to a single numeric unsigned 32-bit RGBA value, using the endianness of the system.
Returns:
A single numeric unsigned 32-bit RGBA value.
Example:
var rgba = Cesium.Color.BLUE.toRgba();
See:

toString()String

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