new Color
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
-
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
-
<static, constant> ALICEBLUE :Color
-
An immutable Color instance initialized to CSS color #F0F8FF
-
<static, constant> ANTIQUEWHITE :Color
-
An immutable Color instance initialized to CSS color #FAEBD7
-
<static, constant> AQUA :Color
-
An immutable Color instance initialized to CSS color #00FFFF
-
<static, constant> AQUAMARINE :Color
-
An immutable Color instance initialized to CSS color #7FFFD4
-
<static, constant> AZURE :Color
-
An immutable Color instance initialized to CSS color #F0FFFF
-
<static, constant> BEIGE :Color
-
An immutable Color instance initialized to CSS color #F5F5DC
-
<static, constant> BISQUE :Color
-
An immutable Color instance initialized to CSS color #FFE4C4
-
<static, constant> BLACK :Color
-
An immutable Color instance initialized to CSS color #000000
-
<static, constant> BLANCHEDALMOND :Color
-
An immutable Color instance initialized to CSS color #FFEBCD
-
<static, constant> BLUE :Color
-
An immutable Color instance initialized to CSS color #0000FF
-
<static, constant> BLUEVIOLET :Color
-
An immutable Color instance initialized to CSS color #8A2BE2
-
<static, constant> BROWN :Color
-
An immutable Color instance initialized to CSS color #A52A2A
-
<static, constant> BURLYWOOD :Color
-
An immutable Color instance initialized to CSS color #DEB887
-
<static, constant> CADETBLUE :Color
-
An immutable Color instance initialized to CSS color #5F9EA0
-
<static, constant> CHARTREUSE :Color
-
An immutable Color instance initialized to CSS color #7FFF00
-
<static, constant> CHOCOLATE :Color
-
An immutable Color instance initialized to CSS color #D2691E
-
<static, constant> CORAL :Color
-
An immutable Color instance initialized to CSS color #FF7F50
-
<static, constant> CORNFLOWERBLUE :Color
-
An immutable Color instance initialized to CSS color #6495ED
-
<static, constant> CORNSILK :Color
-
An immutable Color instance initialized to CSS color #FFF8DC
-
<static, constant> CRIMSON :Color
-
An immutable Color instance initialized to CSS color #DC143C
-
<static, constant> CYAN :Color
-
An immutable Color instance initialized to CSS color #00FFFF
-
<static, constant> DARKBLUE :Color
-
An immutable Color instance initialized to CSS color #00008B
-
<static, constant> DARKCYAN :Color
-
An immutable Color instance initialized to CSS color #008B8B
-
<static, constant> DARKGOLDENROD :Color
-
An immutable Color instance initialized to CSS color #B8860B
-
<static, constant> DARKGRAY :Color
-
An immutable Color instance initialized to CSS color #A9A9A9
-
<static, constant> DARKGREEN :Color
-
An immutable Color instance initialized to CSS color #006400
-
<static, constant> DARKGREY :Color
-
An immutable Color instance initialized to CSS color #A9A9A9
-
<static, constant> DARKKHAKI :Color
-
An immutable Color instance initialized to CSS color #BDB76B
-
<static, constant> DARKMAGENTA :Color
-
An immutable Color instance initialized to CSS color #8B008B
-
<static, constant> DARKOLIVEGREEN :Color
-
An immutable Color instance initialized to CSS color #556B2F
-
<static, constant> DARKORANGE :Color
-
An immutable Color instance initialized to CSS color #FF8C00
-
<static, constant> DARKORCHID :Color
-
An immutable Color instance initialized to CSS color #9932CC
-
<static, constant> DARKRED :Color
-
An immutable Color instance initialized to CSS color #8B0000
-
<static, constant> DARKSALMON :Color
-
An immutable Color instance initialized to CSS color #E9967A
-
<static, constant> DARKSEAGREEN :Color
-
An immutable Color instance initialized to CSS color #8FBC8F
-
<static, constant> DARKSLATEBLUE :Color
-
An immutable Color instance initialized to CSS color #483D8B
-
<static, constant> DARKSLATEGRAY :Color
-
An immutable Color instance initialized to CSS color #2F4F4F
-
<static, constant> DARKSLATEGREY :Color
-
An immutable Color instance initialized to CSS color #2F4F4F
-
<static, constant> DARKTURQUOISE :Color
-
An immutable Color instance initialized to CSS color #00CED1
-
<static, constant> DARKVIOLET :Color
-
An immutable Color instance initialized to CSS color #9400D3
-
<static, constant> DEEPPINK :Color
-
An immutable Color instance initialized to CSS color #FF1493
-
<static, constant> DEEPSKYBLUE :Color
-
An immutable Color instance initialized to CSS color #00BFFF
-
<static, constant> DIMGRAY :Color
-
An immutable Color instance initialized to CSS color #696969
-
<static, constant> DIMGREY :Color
-
An immutable Color instance initialized to CSS color #696969
-
<static, constant> DODGERBLUE :Color
-
An immutable Color instance initialized to CSS color #1E90FF
-
<static, constant> FIREBRICK :Color
-
An immutable Color instance initialized to CSS color #B22222
-
<static, constant> FLORALWHITE :Color
-
An immutable Color instance initialized to CSS color #FFFAF0
-
<static, constant> FORESTGREEN :Color
-
An immutable Color instance initialized to CSS color #228B22
-
<static, constant> FUSCHIA :Color
-
An immutable Color instance initialized to CSS color #FF00FF
-
<static, constant> GAINSBORO :Color
-
An immutable Color instance initialized to CSS color #DCDCDC
-
<static, constant> GHOSTWHITE :Color
-
An immutable Color instance initialized to CSS color #F8F8FF
-
<static, constant> GOLD :Color
-
An immutable Color instance initialized to CSS color #FFD700
-
<static, constant> GOLDENROD :Color
-
An immutable Color instance initialized to CSS color #DAA520
-
<static, constant> GRAY :Color
-
An immutable Color instance initialized to CSS color #808080
-
<static, constant> GREEN :Color
-
An immutable Color instance initialized to CSS color #008000
-
<static, constant> GREENYELLOW :Color
-
An immutable Color instance initialized to CSS color #ADFF2F
-
<static, constant> GREY :Color
-
An immutable Color instance initialized to CSS color #808080
-
<static, constant> HONEYDEW :Color
-
An immutable Color instance initialized to CSS color #F0FFF0
-
<static, constant> HOTPINK :Color
-
An immutable Color instance initialized to CSS color #FF69B4
-
<static, constant> INDIANRED :Color
-
An immutable Color instance initialized to CSS color #CD5C5C
-
<static, constant> INDIGO :Color
-
An immutable Color instance initialized to CSS color #4B0082
-
<static, constant> IVORY :Color
-
An immutable Color instance initialized to CSS color #FFFFF0
-
<static, constant> KHAKI :Color
-
An immutable Color instance initialized to CSS color #F0E68C
-
<static, constant> LAVENDAR_BLUSH :Color
-
An immutable Color instance initialized to CSS color #FFF0F5
-
<static, constant> LAVENDER :Color
-
An immutable Color instance initialized to CSS color #E6E6FA
-
<static, constant> LAWNGREEN :Color
-
An immutable Color instance initialized to CSS color #7CFC00
-
<static, constant> LEMONCHIFFON :Color
-
An immutable Color instance initialized to CSS color #FFFACD
-
<static, constant> LIGHTBLUE :Color
-
An immutable Color instance initialized to CSS color #ADD8E6
-
<static, constant> LIGHTCORAL :Color
-
An immutable Color instance initialized to CSS color #F08080
-
<static, constant> LIGHTCYAN :Color
-
An immutable Color instance initialized to CSS color #E0FFFF
-
<static, constant> LIGHTGOLDENRODYELLOW :Color
-
An immutable Color instance initialized to CSS color #FAFAD2
-
<static, constant> LIGHTGRAY :Color
-
An immutable Color instance initialized to CSS color #D3D3D3
-
<static, constant> LIGHTGREEN :Color
-
An immutable Color instance initialized to CSS color #90EE90
-
<static, constant> LIGHTGREY :Color
-
An immutable Color instance initialized to CSS color #D3D3D3
-
<static, constant> LIGHTPINK :Color
-
An immutable Color instance initialized to CSS color #FFB6C1
-
<static, constant> LIGHTSEAGREEN :Color
-
An immutable Color instance initialized to CSS color #20B2AA
-
<static, constant> LIGHTSKYBLUE :Color
-
An immutable Color instance initialized to CSS color #87CEFA
-
<static, constant> LIGHTSLATEGRAY :Color
-
An immutable Color instance initialized to CSS color #778899
-
<static, constant> LIGHTSLATEGREY :Color
-
An immutable Color instance initialized to CSS color #778899
-
<static, constant> LIGHTSTEELBLUE :Color
-
An immutable Color instance initialized to CSS color #B0C4DE
-
<static, constant> LIGHTYELLOW :Color
-
An immutable Color instance initialized to CSS color #FFFFE0
-
<static, constant> LIME :Color
-
An immutable Color instance initialized to CSS color #00FF00
-
<static, constant> LIMEGREEN :Color
-
An immutable Color instance initialized to CSS color #32CD32
-
<static, constant> LINEN :Color
-
An immutable Color instance initialized to CSS color #FAF0E6
-
<static, constant> MAGENTA :Color
-
An immutable Color instance initialized to CSS color #FF00FF
-
<static, constant> MAROON :Color
-
An immutable Color instance initialized to CSS color #800000
-
<static, constant> MEDIUMAQUAMARINE :Color
-
An immutable Color instance initialized to CSS color #66CDAA
-
<static, constant> MEDIUMBLUE :Color
-
An immutable Color instance initialized to CSS color #0000CD
-
<static, constant> MEDIUMORCHID :Color
-
An immutable Color instance initialized to CSS color #BA55D3
-
<static, constant> MEDIUMPURPLE :Color
-
An immutable Color instance initialized to CSS color #9370DB
-
<static, constant> MEDIUMSEAGREEN :Color
-
An immutable Color instance initialized to CSS color #3CB371
-
<static, constant> MEDIUMSLATEBLUE :Color
-
An immutable Color instance initialized to CSS color #7B68EE
-
<static, constant> MEDIUMSPRINGGREEN :Color
-
An immutable Color instance initialized to CSS color #00FA9A
-
<static, constant> MEDIUMTURQUOISE :Color
-
An immutable Color instance initialized to CSS color #48D1CC
-
<static, constant> MEDIUMVIOLETRED :Color
-
An immutable Color instance initialized to CSS color #C71585
-
<static, constant> MIDNIGHTBLUE :Color
-
An immutable Color instance initialized to CSS color #191970
-
<static, constant> MINTCREAM :Color
-
An immutable Color instance initialized to CSS color #F5FFFA
-
<static, constant> MISTYROSE :Color
-
An immutable Color instance initialized to CSS color #FFE4E1
-
<static, constant> MOCCASIN :Color
-
An immutable Color instance initialized to CSS color #FFE4B5
-
<static, constant> NAVAJOWHITE :Color
-
An immutable Color instance initialized to CSS color #FFDEAD
-
<static, constant> NAVY :Color
-
An immutable Color instance initialized to CSS color #000080
-
<static, constant> OLDLACE :Color
-
An immutable Color instance initialized to CSS color #FDF5E6
-
<static, constant> OLIVE :Color
-
An immutable Color instance initialized to CSS color #808000
-
<static, constant> OLIVEDRAB :Color
-
An immutable Color instance initialized to CSS color #6B8E23
-
<static, constant> ORANGE :Color
-
An immutable Color instance initialized to CSS color #FFA500
-
<static, constant> ORANGERED :Color
-
An immutable Color instance initialized to CSS color #FF4500
-
<static, constant> ORCHID :Color
-
An immutable Color instance initialized to CSS color #DA70D6
-
<static> packedLength :Number
-
The number of elements used to pack the object into an array.
-
<static, constant> PALEGOLDENROD :Color
-
An immutable Color instance initialized to CSS color #EEE8AA
-
<static, constant> PALEGREEN :Color
-
An immutable Color instance initialized to CSS color #98FB98
-
<static, constant> PALETURQUOISE :Color
-
An immutable Color instance initialized to CSS color #AFEEEE
-
<static, constant> PALEVIOLETRED :Color
-
An immutable Color instance initialized to CSS color #DB7093
-
<static, constant> PAPAYAWHIP :Color
-
An immutable Color instance initialized to CSS color #FFEFD5
-
<static, constant> PEACHPUFF :Color
-
An immutable Color instance initialized to CSS color #FFDAB9
-
<static, constant> PERU :Color
-
An immutable Color instance initialized to CSS color #CD853F
-
<static, constant> PINK :Color
-
An immutable Color instance initialized to CSS color #FFC0CB
-
<static, constant> PLUM :Color
-
An immutable Color instance initialized to CSS color #DDA0DD
-
<static, constant> POWDERBLUE :Color
-
An immutable Color instance initialized to CSS color #B0E0E6
-
<static, constant> PURPLE :Color
-
An immutable Color instance initialized to CSS color #800080
-
<static, constant> RED :Color
-
An immutable Color instance initialized to CSS color #FF0000
-
<static, constant> ROSYBROWN :Color
-
An immutable Color instance initialized to CSS color #BC8F8F
-
<static, constant> ROYALBLUE :Color
-
An immutable Color instance initialized to CSS color #4169E1
-
<static, constant> SADDLEBROWN :Color
-
An immutable Color instance initialized to CSS color #8B4513
-
<static, constant> SALMON :Color
-
An immutable Color instance initialized to CSS color #FA8072
-
<static, constant> SANDYBROWN :Color
-
An immutable Color instance initialized to CSS color #F4A460
-
<static, constant> SEAGREEN :Color
-
An immutable Color instance initialized to CSS color #2E8B57
-
<static, constant> SEASHELL :Color
-
An immutable Color instance initialized to CSS color #FFF5EE
-
<static, constant> SIENNA :Color
-
An immutable Color instance initialized to CSS color #A0522D
-
<static, constant> SILVER :Color
-
An immutable Color instance initialized to CSS color #C0C0C0
-
<static, constant> SKYBLUE :Color
-
An immutable Color instance initialized to CSS color #87CEEB
-
<static, constant> SLATEBLUE :Color
-
An immutable Color instance initialized to CSS color #6A5ACD
-
<static, constant> SLATEGRAY :Color
-
An immutable Color instance initialized to CSS color #708090
-
<static, constant> SLATEGREY :Color
-
An immutable Color instance initialized to CSS color #708090
-
<static, constant> SNOW :Color
-
An immutable Color instance initialized to CSS color #FFFAFA
-
<static, constant> SPRINGGREEN :Color
-
An immutable Color instance initialized to CSS color #00FF7F
-
<static, constant> STEELBLUE :Color
-
An immutable Color instance initialized to CSS color #4682B4
-
<static, constant> TAN :Color
-
An immutable Color instance initialized to CSS color #D2B48C
-
<static, constant> TEAL :Color
-
An immutable Color instance initialized to CSS color #008080
-
<static, constant> THISTLE :Color
-
An immutable Color instance initialized to CSS color #D8BFD8
-
<static, constant> TOMATO :Color
-
An immutable Color instance initialized to CSS color #FF6347
-
<static, constant> TURQUOISE :Color
-
An immutable Color instance initialized to CSS color #40E0D0
-
<static, constant> VIOLET :Color
-
An immutable Color instance initialized to CSS color #EE82EE
-
<static, constant> WHEAT :Color
-
An immutable Color instance initialized to CSS color #F5DEB3
-
<static, constant> WHITE :Color
-
An immutable Color instance initialized to CSS color #FFFFFF
-
<static, constant> WHITESMOKE :Color
-
An immutable Color instance initialized to CSS color #F5F5F5
-
<static, constant> YELLOW :Color
-
An immutable Color instance initialized to CSS color #FFFF00
-
<static, constant> YELLOWGREEN :Color
-
An immutable Color instance initialized to CSS color #9ACD32
Methods
-
clone
-
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. -
equals
-
Returns true if this Color equals other.
Parameters:
Name Type Description other
Color The Color to compare for equality. Returns:
Booleantrue
if the Colors are equal; otherwise,false
. -
equalsEpsilon
-
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:
Booleantrue
if the Colors are equal within the specified epsilon; otherwise,false
. -
toBytes
-
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. -
toCssColorString
-
Creates a string containing the CSS color value for this color.
Returns:
String The CSS equivalent of this color. -
toRgba
-
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 = Color.BLUE.toRgba();
See:
-
toString
-
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> byteToFloat
-
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> clone
-
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> equals
-
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:
Booleantrue
if the Colors are equal; otherwise,false
. -
<static> floatToByte
-
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> fromBytes
-
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> fromCssColorString
-
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. Throws:
DeveloperError : color is required.Returns:
Color The color object, or undefined if the string was not a valid CSS color.Example
var cesiumBlue = Color.fromCssColorString('#67ADDF'); var green = Color.fromCssColorString('green');
See:
-
<static> fromHsl
-
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> fromRandom
-
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 = Color.fromRandom(); //Create a random shade of yellow. var color = Color.fromRandom({ red : 1.0, green : 1.0, alpha : 1.0 }); //Create a random bright color. var color = Color.fromRandom({ minimumRed : 0.75, minimumGreen : 0.75, minimumBlue : 0.75, alpha : 1.0 });
-
-
<static> fromRgba
-
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 = Color.fromRgba(0x67ADDFFF);
See:
-
<static> pack
-
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. Throws:
-
DeveloperError : value is required.
-
DeveloperError : array is required.
-
-
<static> unpack
-
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. Throws:
DeveloperError : array is required.