This module contains some color dictionaries and algorithms to parse a string into a hex RGB color value.s
Members
MATHEMATICA_COLORS →Object.<string, string>staticconstant
First 10 predefined colors used for plotting by Mathematica.
Also known as indexed color scheme #97.
Type
- Object.<string, string>
NAMED_COLORS →Object.<string, string>staticconstant
68 colors (+ white) known to dvips used in LaTeX.
The color names are based on the names of the Crayola Crayon box of 64 crayons.
See:
Type
- Object.<string, string>
Methods
stringToColor(s: string) → stringprivatestatic
Return a CSS color (#rrggbb) from a string.
Possible formats include:
- named colors from the DVI color set: 'Yellow', 'red'... Case insensitive.
- colors from the Mathematica set: 'm1'...'m9'
- 3-digit hex:
'#d50' - 6-digit hex:
'#dd5500' - RGB functional:
'rgb(240, 20, 10)'
In addition, colors can be mixed using the following syntax:
<mix> = <color>![<value>][!<mix>]
For example:
'blue!20'= 20% blue + 80% white'blue!20!black'= 20% + 80% black'blue!20!black!30!green'= (20% + 80% black) * 30 % + 70% green
If the input string is prefixed with a dash, the complementary color of the expression is returned.
This creative syntax is defined by the xcolor LaTeX package.
s
string
An expression representing a color value
An RGB color expressed as a hex-triplet preceded by #
