Module ROT.Color
The Color Toolkit.
Color is a color handler that treats any objects intended to represent a color as a table of the following schema:
Functions
fromString (str) | Get color from string. |
add (color1, color2, ...) | Add two or more colors. |
add_ (color1, color2, ...) | Add two or more colors. |
interpolate (color1, color2, factor) | Interpolate (blend) two colors with a given factor. |
interpolateHSL (color1, color2, factor) | Interpolate (blend) two colors with a given factor in HSL mode. |
randomize (color, diff) | Create a new random color based on this one |
toRGB (color) | Convert color to RGB string. |
toHex (color) | Convert color to Hex string Get a string that can be fed to Color.fromString() |
Tables
_cache | Color cache A table of predefined color tables These keys can be passed to Color.fromString() |
Functions
- fromString (str)
-
Get color from string.
Convert one of several formats of string to what
Color interperets as a color object
Parameters:
- str string Accepted formats 'rgb(0..255, 0..255, 0..255)', '#5fe', '#5FE', '#254eff', 'goldenrod'
- add (color1, color2, ...)
-
Add two or more colors.
Parameters:
Returns:
-
table
new color
- add_ (color1, color2, ...)
-
Add two or more colors. Modifies first color in-place.
Parameters:
Returns:
-
table
modified color
- interpolate (color1, color2, factor)
-
Interpolate (blend) two colors with a given factor.
Parameters:
- color1 table A color table
- color2 table A color table
- factor float A number from 0 to 1. <0.5 favors color1, >0.5 favors color2.
Returns:
-
table
resulting color
- interpolateHSL (color1, color2, factor)
-
Interpolate (blend) two colors with a given factor in HSL mode.
Parameters:
- color1 table A color table
- color2 table A color table
- factor float A number from 0 to 1. <0.5 favors color1, >0.5 favors color2.
Returns:
-
table
resulting color
- randomize (color, diff)
-
Create a new random color based on this one
Parameters:
- toRGB (color)
-
Convert color to RGB string.
Get a string that can be fed to Color.fromString()
Parameters:
- color table A color table
- toHex (color)
-
Convert color to Hex string
Get a string that can be fed to Color.fromString()
Parameters:
- color table A color table
Tables
- _cache
-
Color cache
A table of predefined color tables
These keys can be passed to Color.fromString()
Fields:
- black { 0, 0, 0 }
- navy { 0, 0, 128 }
- darkblue { 0, 0, 139 }
- mediumblue { 0, 0, 205 }
- blue { 0, 0, 255 }
- darkgreen { 0, 100, 0 }
- green { 0, 128, 0 }
- teal { 0, 128, 128 }
- darkcyan { 0, 139, 139 }
- deepskyblue { 0, 191, 255 }
- darkturquoise { 0, 206, 209 }
- mediumspringgreen { 0, 250, 154 }
- lime { 0, 255, 0 }
- springgreen { 0, 255, 127 }
- aqua { 0, 255, 255 }
- cyan { 0, 255, 255 }
- midnightblue { 25, 25, 112 }
- dodgerblue { 30, 144, 255 }
- forestgreen { 34, 139, 34 }
- seagreen { 46, 139, 87 }
- darkslategray { 47, 79, 79 }
- darkslategrey { 47, 79, 79 }
- limegreen { 50, 205, 50 }
- mediumseagreen { 60, 179, 113 }
- turquoise { 64, 224, 208 }
- royalblue { 65, 105, 225 }
- steelblue { 70, 130, 180 }
- darkslateblue { 72, 61, 139 }
- mediumturquoise { 72, 209, 204 }
- indigo { 75, 0, 130 }
- darkolivegreen { 85, 107, 47 }
- cadetblue { 95, 158, 160 }
- cornflowerblue { 100, 149, 237 }
- mediumaquamarine { 102, 205, 170 }
- dimgray { 105, 105, 105 }
- dimgrey { 105, 105, 105 }
- slateblue { 106, 90, 205 }
- olivedrab { 107, 142, 35 }
- slategray { 112, 128, 144 }
- slategrey { 112, 128, 144 }
- lightslategray { 119, 136, 153 }
- lightslategrey { 119, 136, 153 }
- mediumslateblue { 123, 104, 238 }
- lawngreen { 124, 252, 0 }
- chartreuse { 127, 255, 0 }
- aquamarine { 127, 255, 212 }
- maroon { 128, 0, 0 }
- purple { 128, 0, 128 }
- olive { 128, 128, 0 }
- gray { 128, 128, 128 }
- grey { 128, 128, 128 }
- skyblue { 135, 206, 235 }
- lightskyblue { 135, 206, 250 }
- blueviolet { 138, 43, 226 }
- darkred { 139, 0, 0 }
- darkmagenta { 139, 0, 139 }
- saddlebrown { 139, 69, 19 }
- darkseagreen { 143, 188, 143 }
- lightgreen { 144, 238, 144 }
- mediumpurple { 147, 112, 216 }
- darkviolet { 148, 0, 211 }
- palegreen { 152, 251, 152 }
- darkorchid { 153, 50, 204 }
- yellowgreen { 154, 205, 50 }
- sienna { 160, 82, 45 }
- brown { 165, 42, 42 }
- darkgray { 169, 169, 169 }
- darkgrey { 169, 169, 169 }
- lightblue { 173, 216, 230 }
- greenyellow { 173, 255, 47 }
- paleturquoise { 175, 238, 238 }
- lightsteelblue { 176, 196, 222 }
- powderblue { 176, 224, 230 }
- firebrick { 178, 34, 34 }
- darkgoldenrod { 184, 134, 11 }
- mediumorchid { 186, 85, 211 }
- rosybrown { 188, 143, 143 }
- darkkhaki { 189, 183, 107 }
- silver { 192, 192, 192 }
- mediumvioletred { 199, 21, 133 }
- indianred { 205, 92, 92 }
- peru { 205, 133, 63 }
- chocolate { 210, 105, 30 }
- tan { 210, 180, 140 }
- lightgray { 211, 211, 211 }
- lightgrey { 211, 211, 211 }
- palevioletred { 216, 112, 147 }
- thistle { 216, 191, 216 }
- orchid { 218, 112, 214 }
- goldenrod { 218, 165, 32 }
- crimson { 220, 20, 60 }
- gainsboro { 220, 220, 220 }
- plum { 221, 160, 221 }
- burlywood { 222, 184, 135 }
- lightcyan { 224, 255, 255 }
- lavender { 230, 230, 250 }
- darksalmon { 233, 150, 122 }
- violet { 238, 130, 238 }
- palegoldenrod { 238, 232, 170 }
- lightcoral { 240, 128, 128 }
- khaki { 240, 230, 140 }
- aliceblue { 240, 248, 255 }
- honeydew { 240, 255, 240 }
- azure { 240, 255, 255 }
- sandybrown { 244, 164, 96 }
- wheat { 245, 222, 179 }
- beige { 245, 245, 220 }
- whitesmoke { 245, 245, 245 }
- mintcream { 245, 255, 250 }
- ghostwhite { 248, 248, 255 }
- salmon { 250, 128, 114 }
- antiquewhite { 250, 235, 215 }
- linen { 250, 240, 230 }
- lightgoldenrodyellow { 250, 250, 210 }
- oldlace { 253, 245, 230 }
- red { 255, 0, 0 }
- fuchsia { 255, 0, 255 }
- magenta { 255, 0, 255 }
- deeppink { 255, 20, 147 }
- orangered { 255, 69, 0 }
- tomato { 255, 99, 71 }
- hotpink { 255, 105, 180 }
- coral { 255, 127, 80 }
- darkorange { 255, 140, 0 }
- lightsalmon { 255, 160, 122 }
- orange { 255, 165, 0 }
- lightpink { 255, 182, 193 }
- pink { 255, 192, 203 }
- gold { 255, 215, 0 }
- peachpuff { 255, 218, 185 }
- navajowhite { 255, 222, 173 }
- moccasin { 255, 228, 181 }
- bisque { 255, 228, 196 }
- mistyrose { 255, 228, 225 }
- blanchedalmond { 255, 235, 205 }
- papayawhip { 255, 239, 213 }
- lavenderblush { 255, 240, 245 }
- seashell { 255, 245, 238 }
- cornsilk { 255, 248, 220 }
- lemonchiffon { 255, 250, 205 }
- floralwhite { 255, 250, 240 }
- snow { 255, 250, 250 }
- yellow { 255, 255, 0 }
- lightyellow { 255, 255, 224 }
- ivory { 255, 255, 240 }
- white { 255, 255, 255 }