Skip to content

Latest commit

 

History

History
106 lines (62 loc) · 2.84 KB

Color.md

File metadata and controls

106 lines (62 loc) · 2.84 KB

Color

Kind: class


new Color(value, opacity)

Create a new color instance.

Param Type Description
value ! string | number | {r:number, g:number, b:number, a:?number}` One of:
  • String in CSS color format (hex, rgb, rgba, hsl, hsla, hsv, hsva, or color name)
  • ARGB numeric value (unsigned 32-bit integer)
  • Object with r, g, b, a keys all set to integers from 0 - 255 (if a is omitted, 255 is used)
opacity ?number Optional, floating-point value from 0 - 1. Use when value parameter doesn't specify an opacity and you don't want the default 1.0 (100%) opacity.

color.a : number

Integer 0-255. Get/set the alpha channel value.

Kind: instance property of Color


color.r : number

Integer 0-255. Get/set the red channel value.

Kind: instance property of Color


color.g : number

Integer 0-255. Get/set the green channel value.

Kind: instance property of Color


color.b : number

Integer 0-255. Get/set the blue channel value.

Kind: instance property of Color


color.toRgba()

Convert to an object with r, g, b, a keys where r, g, b, a range from 0 - 255.

Kind: instance method of Color
Returns: !{r:number, g:number, b:number, a:number}


color.toHex(forceSixDigits) ⇒ string

Convert to hex string with "#" prefix. Ignores the Color's alpha value. Returns a 3-digit string if possible, otherwise returns a 6-digit string.

Kind: instance method of Color
Returns: string - Hex color string in the form #123 or #456ABC.

Param Type Description
forceSixDigits boolean True if you want the result to always have 6 digits.

color.clone() ⇒ !Color

Returns a clone of the current color object

Kind: instance method of Color