xcolor.js
is a JavaScript implementation of LaTeX package xcolor
. It is a very complex package, so it only supports some features.
- Models supported :
rgb
,RGB
,cmy
,cmyk
,HTML
,gray
,Gray
,hsb
,Hsb
,HSB
andwave
. - Named colors (default colors, colors from DVIPS, colors from SVG and colors from X11)
- Blended colors (e.g.
yellow!20
oryellow!40!black!30!red
) - Inverted colors (e.g.
-yellow
or-yellow!20
)
Syntax : Array window.xcolor(String color, Optional String model, Optional Boolean dvips)
Returns an Array
that represents the RGB value of the color where all numbers are part of [0,255]
.
color
: String. The definition of the color.model
(Optional) : String. The model of the color (e.g.rgb
,RGB
,cmyk
,HTML
). Leaving this argument empty means that your color is a named color.dvips
(Optional) : Boolean. Iftrue
,dvips
name colors have a higher priority thanSVG
colors. Default :false
.
Example :
window.xcolor("-yellow!20");
window.xcolor("0,255,255", "rgb");
window.xcolor("Green", "rgb", true);
Syntax : Array window.xcolor.register(String name, Number red, Number green, Number blue)
Alternative syntax : Array window.xcolor.register(String name, Array RGB)
Register a named color.
Syntax : Boolean window.xcolor.remove(String name)
Remove the named color. Returns true
is the color named name
existed and false
otherwise.
Syntax : Boolean window.xcolor.erase(String name)
Remove all named colors.
Licensed under MIT.