Reference Source
import {Color} from '@adobe/coral-spectrum'
public class | source

Color

Color is used to get a color in different color spaces, calculate tints and shades etc.

Member Summary

Public Members
public

The alpha value of the color (value between 0-1).

public

The cmyk values of the color (all values between 0-100).

public

The serialized cmyk values of the color (all values between 0-100).

public

The hex value of the color.

public

The serialized hex value of the color.

public

The hsb values of the color.

public

The serialized hsb values of the color (s and b values between 0-100, h between 0-360).

public

hsl: *

null

public

The serialized hsl values of the color (s and l values between 0-100 in percent, h between 0-360).

public

The hsla values of the color.

public

The serialized hsla values of the color.

public

The rgb values of the color (value between 0-255).

public

The serialized rgb values of the color (r,g,b values between 0-255).

public

The rgba values of the color (r,g,b values between 0-255 and a between 0-1).

public

The serialized rgba values of the color (r,g,b values between 0-255 and alpha between 0-1).

public

The value of the color.

Method Summary

Public Methods
public

calculateShadeColors(amount: Number): *: Array<Coral.Color>

Calculates an array of darker colors.

public

calculateTintColors(amount: Number): *: Array<Coral.Color>

Calculates an array of lighter colors.

public

clone(): *: Color

Clone this color.

public

isSimilarTo(compareColor: Color, allowSlightColorDifference: Boolean): boolean: Boolean

Test if this Color is similar to another color.

Public Members

public alpha: Number source

The alpha value of the color (value between 0-1).

  • 1 by default.

public cmyk: Object source

The cmyk values of the color (all values between 0-100). e.g: {c:0, m:100, y:0, k:100}

  • null by default.

public cmykValue: String source

The serialized cmyk values of the color (all values between 0-100). e.g: 'cmyk(100,100,100,100)'

  • "" by default.

public hex: Number source

The hex value of the color.

  • null by default.

public hexValue: String source

The serialized hex value of the color. e.g: '#94CD4B'

  • "" by default.

public hsb: Object source

The hsb values of the color. h (hue has value between 0-360 degree) s (saturation has a value between 0-100 percent) b (brightness has a value between 0-100 percent)

  • null by default.

public hsbValue: String source

The serialized hsb values of the color (s and b values between 0-100, h between 0-360). e.g: 'hsb(360,100,100)'

  • "" by default.

public hsl: * source

null

public hslValue: String source

The serialized hsl values of the color (s and l values between 0-100 in percent, h between 0-360). e.g: 'hsl(360,100%,100%)'

  • "" by default.

public hsla: Object source

The hsla values of the color. h (hue has value between 0-360 degree) s (saturation has a value between 0-100 percent) l (lightness has a value between 0-100 percent) a (alpha has a value between 0-1)

  • null by default.

public hslaValue: String source

The serialized hsla values of the color. h (hue has value between 0-360 degree) s (saturation has a value between 0-100 percent) l (lightness has a value between 0-100 percent) a (alpha has a value between 0-1) e.g: 'hsla(360,50%,50%,0.9)'

  • "" by default.

public rgb: Object source

The rgb values of the color (value between 0-255). e.g.: {r:0, g:0, b:0}

  • null by default.

public rgbValue: String source

The serialized rgb values of the color (r,g,b values between 0-255). e.g: 'rgb(0,0,0)'

  • "" by default.

public rgba: Object source

The rgba values of the color (r,g,b values between 0-255 and a between 0-1). e.g: {r:0, g:0, b:0, a:1}

  • null by default.

public rgbaValue: String source

The serialized rgba values of the color (r,g,b values between 0-255 and alpha between 0-1). e.g: 'rgba(0,0,0,1)'

  • "" by default.

public value: String source

The value of the color. This value can be set in different formats (HEX, RGB, RGBA, HSB, HSL, HSLA and CMYK). Corrects a hex value, if it is represented by 3 or 6 characters with or without '#'.

e.g: HEX: #FFFFFF RGB: rgb(16,16,16) RGBA: rgba(215,40,40,0.9) HSB: hsb(360,100,100) HSL: hsl(360,100%,100%) HSLA: hsla(360,100%,100%,0.9) CMYK: cmyk(0,100,50,0)

  • "" by default.

Public Methods

public calculateShadeColors(amount: Number): *: Array<Coral.Color> source

Calculates an array of darker colors.

Params:

NameTypeAttributeDescription
amount Number

Amount of shade colors to generate.

Return:

*

public calculateTintColors(amount: Number): *: Array<Coral.Color> source

Calculates an array of lighter colors.

Params:

NameTypeAttributeDescription
amount Number

Amount of tint colors to generate.

Return:

*

public clone(): *: Color source

Clone this color.

Return:

*

public isSimilarTo(compareColor: Color, allowSlightColorDifference: Boolean): boolean: Boolean source

Test if this Color is similar to another color.

Params:

NameTypeAttributeDescription
compareColor Color

The color to compare this color too.

allowSlightColorDifference Boolean
  • optional
  • default: true

While converting between color spaces slight loses might happen => we should normally consider colors equal, even if they are minimally different.

Return:

boolean