JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 37
  • Score
    100M100P100Q74430F
  • License MIT

Color utilities for the pex library

Package Exports

  • pex-color

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pex-color) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pex- color

Color utilities for the pex library

Color

Reference

## copy(color, out) Copies color #### Parameters | Name | Type | Description | | --- | --- | --- | |color|`Array`|color to copy| |out|`Array`|color to copy values into| #### Returns | Type | Description | | --- | --- | |`Array`|new RGBA color array [r,g,b,a] (0..1) or updated out color| ## create(r, g, b, a) RGBA color constructor function #### Parameters | Name | Type | Description | | --- | --- | --- | |r|`Number`|red component (0..1)| |g|`Number`|green component (0..1)| |b|`Number`|blue component (0..1)| |a|`Number`|alpha component (0..1)| #### Returns | Type | Description | | --- | --- | |`Array`|RGBA color array [r,g,b,a] (0..1)| ## fromHSL(h, s, l, a) Creates new color from hue, saturation, lightness and alpha #### Parameters | Name | Type | Description | | --- | --- | --- | |h|`Number`|hue (0..1)| |s|`Number`|saturation (0..1)| |l|`Number`|lightness (0..1)| |a|`Number`|alpha (0..1)| #### Returns | Type | Description | | --- | --- | |`Array`|RGBA color array [r,g,b,a] (0..1)| ## fromHSV(h, s, v, a) Creates new color from hue, saturation and value #### Parameters | Name | Type | Description | | --- | --- | --- | |h|`Number`|hue (0..1)| |s|`Number`|saturation (0..1)| |v|`Number`|value (0..1)| |a|`Number`|alpha (0..1)| #### Returns | Type | Description | | --- | --- | |`Array`|RGBA color array [r,g,b,a] (0..1)| ## fromHex(hex) Creates new color from html hex string #### Parameters | Name | Type | Description | | --- | --- | --- | |hex|`String`|html hex string #RRGGBB (# is optional)| #### Returns | Type | Description | | --- | --- | |`Array`|RGBA color array [r,g,b,a] (0..1)| ## fromLab(l, a, b) Creates new color from l,a,b component values #### Parameters | Name | Type | Description | | --- | --- | --- | |l|`Number`|l component (0..100)| |a|`Number`|a component (-128..127)| |b|`Number`|b component (-128..127)| #### Returns | Type | Description | | --- | --- | |`Array`|RGBA color array [r,g,b,a] (0..1)| ## fromRGB(r, g, b, a) Creates new color from RGBA values. Alias for create(r, g, b, a) #### Parameters | Name | Type | Description | | --- | --- | --- | |r|`Number`|red component (0..1)| |g|`Number`|green component (0..1)| |b|`Number`|blue component (0..1)| |a|`Number`|alpha component (0..1)| #### Returns | Type | Description | | --- | --- | |`Array`|RGBA color array [r,g,b,a] (0..1)| ## fromRGBBytes(bytes) Creates new color from array of 4 byte (0..255) values [r, g, b, a] #### Parameters | Name | Type | Description | | --- | --- | --- | |bytes|`Array`|RGB color byte array [r,g,b,a] (0..255)| #### Returns | Type | Description | | --- | --- | |`Array`|RGBA color array [r,g,b,a] (0..1)| ## fromXYZ(x, y, z) Creates new color from XYZ values #### Parameters | Name | Type | Description | | --- | --- | --- | |x|`Number`|x component (0..95)| |y|`Number`|y component (0..100)| |z|`Number`|z component (0..108)| #### Returns | Type | Description | | --- | --- | |`Array`|RGBA color array [r,g,b,a] (0..1)| ## getHSL(color) Returns hue, saturation, lightness and alpha of given color. #### Parameters | Name | Type | Description | | --- | --- | --- | |color|`Array`|RGBA color array [r,g,b,a]| #### Returns | Type | Description | | --- | --- | |`Array`|HSLA values array [h,s,l,a] (0..1)| ## getHSV(color) Get hue, saturation, value and alpha of given color #### Parameters | Name | Type | Description | | --- | --- | --- | |color|`Array`|RGBA color array [r,g,b,a]| #### Returns | Type | Description | | --- | --- | |`Array`|HSVA values array [h,s,v,a] (0..1)| ## getHex(color) Returns html hex representation of given color #### Parameters | Name | Type | Description | | --- | --- | --- | |color|`Array`|RGBA color array [r,g,b,a]| #### Returns | Type | Description | | --- | --- | |`String`|html hex color including leading hash e.g. #FF0000| ## getLab(color) Returns LAB color components #### Parameters | Name | Type | Description | | --- | --- | --- | |color|`Array`|RGBA color array [r,g,b,a]| #### Returns | Type | Description | | --- | --- | |`Array`|LAB values array [h,s,l] (l:0..100, a:-128..127, b:-128..127)| ## getRGBBytes(color, out) Returns RGB color components as bytes (0..255) #### Parameters | Name | Type | Description | | --- | --- | --- | |color|`Array`|RGBA color array [r,g,b,a]| |out|`Array`|array to copy values into| #### Returns | Type | Description | | --- | --- | |`Array`|RGB color byte array [r,g,b] (0..255) or updated out array| ## getXYZ(color) Returns XYZ representation of given color #### Parameters | Name | Type | Description | | --- | --- | --- | |color|`Array`|RGBA color array [r,g,b,a]| #### Returns | Type | Description | | --- | --- | |`Array`|[x,y,z] (x:0..95, y:0..100, z:0..108)| ## lerp Float (0..1) RGBA Color utility class ## set(color, r, g, b, a)

Parameters

Name Type Description
color Array RGBA color array [r,g,b,a] to update
r Number red component (0..1)
g Number green component (0..1)
b Number blue component (0..1)
a Number alpha component (0..1)

Returns

Type Description
Array updated RGBA color array [r,g,b,a] (0..1)

setHSL(color, h, s, l, a)

Updates a color based on hue, saturation, lightness and alpha

Parameters

Name Type Description
color Array RGBA color array [r,g,b,a] to update
h Number hue (0..1)
s Number saturation (0..1)
l Number lightness (0..1)
a Number alpha (0..1)

Returns

Type Description
Array updated RGBA color array [r,g,b,a] (0..1)

setHSV(color, h, s, v, a)

Updates a color based on hue, saturation, value and alpha

Parameters

Name Type Description
color Array RGBA color array [r,g,b,a] to update
h Number hue (0..1)
s Number saturation (0..1)
v Number value (0..1)
a Number alpha (0..1)

Returns

Type Description
Array updated RGBA color array [r,g,b,a] (0..1)

setHex(color, hex)

Updates a color based on html hex string e.g. #FF0000 -> 1,0,0,1

Parameters

Name Type Description
color Array RGBA color array [r,g,b,a] to update
hex String html hex string #RRGGBB (# is optional)

Returns

Type Description
Array updated RGBA color array [r,g,b,a] (0..1)

setLab(color, l, a, b)

Updates a color based on l, a, b, component values

Parameters

Name Type Description
color Array RGBA color array [r,g,b,a] to update
l Number l component (0..100)
a Number a component (-128..127)
b Number b component (-128..127)

Returns

Type Description
Array updated RGBA color array [r,g,b,a] (0..1)

setRGB(color, r, g, b, a)

Updates a color based on r, g, b, a component values

Parameters

Name Type Description
color Array RGBA color array [r,g,b,a] to update
r Number red component (0..1)
g Number green component (0..1)
b Number blue component (0..1)
a Number alpha component (0..1)

Returns

Type Description
Array updated RGBA color array [r,g,b,a] (0..1)

setXYZ(color, x, y, z)

Updates a color based on x, y, z component values

Parameters

Name Type Description
color Array RGBA color array [r,g,b,a] to update
x Number x component (0..95)
y Number y component (0..100)
z Number z component (0..108)

Returns

Type Description
Array updated RGBA color array [r,g,b,a] (0..1)

Color.Black

Black color [0, 0, 0, 1]

Color.Blue

Blue color [0, 0, 1, 1]

Color.Cyan

Cyan color [0, 1, 1, 1]

Color.DarkGrey

Dark Grey color [0, 0, 0, 1]

Color.Green

Green color [0, 1, 0, 1]

Color.Grey

Grey color [0.5, 0.5, 0.5, 1]

Color.LightGrey

Light Grey color [0.75, 0.75, 0.75, 1]

Color.Orange

Orange color [1, 0.5, 0, 1]

Color.Pink

Pink color [1, 0, 1, 1]

Color.Red

Red color [1, 0, 0, 1]

Color.Transparent

Transparent color [0, 0, 0, 0]

Color.White

White color [0, 0, 0, 1]

Color.Yellow

Yellow color [1, 1, 0, 1]