Represents an ARGB (alpha, red, green, blue) encoded color object.
Inheritance Hierarchy
Implemented Interfaces
This is a convertible type that can be used with the following notation(s) in parameter lists, parameter objects or setters.
CSS color strings are converted to Colors. For example:
'blue'
'#369'
'#336699'
'rgb(51, 102, 153)'
'rgba(51, 102, 153, 0.5)'
'hsl(225, 98%, 60%)'
'hsla(225, 98%, 60%, 0.5)'
Initializes a new instance of the Color class.
options - Object
A map of options to pass to the method.
- r - number
The red value; 0
by default.
- g - number
The green value; 0
by default
- b - number
The blue value; 0
by default.
- a - number
The alpha value; 255
by default.
Gets the value of the alpha component of the color.
The value is between 0 and 255. If this component is 0, then the color will be transparent.
Gets the value of the blue component of the color.
The value is between 0 and 255. A higher value represents a higher part of the color is made up of this component.
Gets the value of the green component of the color.
The value is between 0 and 255. A higher value represents a higher part of the color is made up of this component.
Gets the value of the red component of the color.
The value is between 0 and 255. A higher value represents a higher part of the color is made up of this component.
Assigns the fill defined by this instance to the given SVG element
.
If this Fill is a gradient and implements the ISvgDefsCreator interface, it will be added to the defs
section of the SVG document per the context
. The fill of the given element will be set to a reference to the gradient element.
This method is very similar in functionality to its static method counterpart setFill. However since this method is an instance method, it cannot be called on empty/null
fills. If you are unsure whether the reference actually points to an instance, use the static helper method instead.
options - Object
A map of options to pass to the method.
- element - SVGElement
The element whose fill should be set.
- context - ICanvasContext
The context.
Clones this instance by returning a memberwise clone, or by returning this
if this instance is frozen.
- ↪Object
An instance of the same type as this instance.
Determines whether this color is equal to the specified object.
options - Object
A map of options to pass to the method.
- obj - any
The other.
- ↪boolean
true
, if this color is equal to the other object; false
, otherwise.
Freezes and returns this instance.
Freezing an object makes it immutable, which can result in performance enhancements.
- ↪Fill
This instance, made immutable.
Returns a hash code for this instance.
- ↪number
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
Determines whether this Color is equal to the specified object.
options - Object
A map of options to pass to the method.
- fill - Fill
The other
Fill instance to compare.
- ↪boolean
true
, if this
Color is equal to the other object;
false
, otherwise.
Determines if this instance is frozen.
- ↪boolean
true
if this instance is frozen; otherwise, false
.
Yields a new Color for the wellknown name AliceBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name AntiqueWhite.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Aqua.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Aquamarine.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Azure.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Beige.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Bisque.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Black.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name BlanchedAlmond.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Blue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name BlueViolet.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Brown.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name BurlyWood.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name CadetBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Chartreuse.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Chocolate.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Coral.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name CornflowerBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Cornsilk.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Crimson.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Cyan.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkCyan.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkGoldenrod.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkGray.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkGreen.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkKhaki.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkMagenta.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkOliveGreen.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkOrange.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkOrchid.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkRed.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkSalmon.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkSeaGreen.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkSlateBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkSlateGray.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkTurquoise.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DarkViolet.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DeepPink.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DeepSkyBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DimGray.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name DodgerBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Firebrick.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name FloralWhite.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name ForestGreen.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Fuchsia.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Gainsboro.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name GhostWhite.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Gold.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Goldenrod.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Gray.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Green.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name GreenYellow.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Honeydew.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name HotPink.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name IndianRed.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Indigo.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Ivory.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Khaki.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Lavender.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LavenderBlush.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LawnGreen.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LemonChiffon.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LightBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LightCoral.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LightCyan.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LightGoldenrodYellow.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LightGray.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LightGreen.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LightPink.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LightSalmon.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LightSeaGreen.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LightSkyBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LightSlateGray.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LightSteelBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LightYellow.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Lime.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name LimeGreen.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Linen.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Magenta.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Maroon.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name MediumAquamarine.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name MediumBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name MediumOrchid.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name MediumPurple.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name MediumSeaGreen.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name MediumSlateBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name MediumSpringGreen.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name MediumTurquoise.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name MediumVioletRed.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name MidnightBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name MintCream.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name MistyRose.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Moccasin.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name NavajoWhite.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Navy.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name OldLace.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Olive.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name OliveDrab.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Orange.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name OrangeRed.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Orchid.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name PaleGoldenrod.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name PaleGreen.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name PaleTurquoise.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name PaleVioletRed.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name PapayaWhip.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name PeachPuff.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Peru.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Pink.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Plum.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name PowderBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Purple.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Red.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name RosyBrown.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name RoyalBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name SaddleBrown.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Salmon.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name SandyBrown.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name SeaGreen.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name SeaShell.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Sienna.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Silver.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name SkyBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name SlateBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name SlateGray.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Snow.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name SpringGreen.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name SteelBlue.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Tan.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Teal.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Thistle.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Tomato.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Transparent.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Turquoise.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Violet.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Wheat.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name White.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name WhiteSmoke.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name Yellow.
This method will yield the same value for every call because it is immutable.
Yields a new Color for the wellknown name YellowGreen.
This method will yield the same value for every call because it is immutable.
Creates a Color instance from the given color-like object by performing automatic type conversion.
options - Object
A map of options to pass to the method.
- colorLike - Color
The object to convert to a
Color.
- ↪Color
The given
colorLike
if it is already a
Color, or a new instance initialized to the values found in
colorLike
.
Creates a new color instance from HSL and A values.
This works similar to the CSS hsla function.
options - Object
A map of options to pass to the method.
- h - number
The hue value between 0 and 1.
- s - number
The saturation value between 0 and 1.
- l - number
The lightness value between 0 and 1.
- a - number
The alpha value between 0 and 1. 1 if omitted
- ↪Color
A new color instance with the given values.
Creates a new color instance from RGB and A values.
This works similar to the CSS rgba function.
options - Object
A map of options to pass to the method.
- r - number
The red value between 0 and 255.
- g - number
The green value between 0 and 255.
- b - number
The blue value between 0 and 255.
- a - number
The alpha fractional value between 0 and 1. 1 if omitted
- ↪Color
A new color instance with the given values.