Draft: Lua colormap lib
Function | Parameters | Description | Returns |
---|---|---|---|
color.paletteToRgb |
uint8 palette_index |
Converts a palette index into RGB values | Red, green, blue values |
color.rgbToPalette |
uint8 r, uint8 g, uint8 b , table rgb , string rgb_web_color
|
Converts RGB values into a palette index | Palette index |
color.hslToRgb |
uint8 h, uint8 s, uint8 l , table hsl
|
Converts an HSL color into RGB values | Red, green, blue values |
color.rgbToHsl |
uint8 r, uint8 g, uint8 b , table rgb , string rgb_web_color
|
Converts RGB values into HSL colors | Hue, saturation, lightness values |
color.rgbToHex |
uint8 r, uint8 g, uint8 b, [uint8 a] , table rgb , table rgba , string rgb_web_color , string rgba_web_color
|
Converts an RGBA color into an HTML color | Web color string |
color.hexToRgb |
string rgb_web_color , string rgba_web_color
|
Converts an HTML color into RGBA values | Red, green, blue (and alpha) values |
Examples
local rgb = { 255, 0, 0 }
local index = color.rgbToPalette(rgb) -- Returns palette index 35
local r, g, b = color.paletteToRgb(index) -- Returns 255, 0, 0
local h, s, l = color.rgbToHsl(r, g, b) -- Returns 0, 255, 128
h = 170 -- Makes a blue-ish color
r, g, b = color.hslToRgb(h, s, l) -- Returns 1, 1, 255
index = color.rgbToPalette(r, g, b) -- Returns palette index 152
hex = color.rgbToHex(r, g, b) -- Returns #0101FF
hex = color.rgbToHex(r, g, b, 128) -- Returns #0101FF80
hex = "#09C" -- Some very light blue
r, g, b = color.hexToRgb(hex) -- Returns 0, 153, 204
index = color.rgbToPalette(hex) -- Returns palette index 135
index = color.rgbToPalette("#0099CC") -- Same as above
index = color.rgbToPalette("#FA0") -- Some orange-ish color
index = color.rgbToPalette("FA0") -- Same as above
index = color.rgbToPalette("FFAA00") -- Same as above
Function | Parameters | Description | Returns |
---|---|---|---|
colormap.create |
"default" , "skin", string name , "skincolor", enum skincolor , "rgb", uint8 r, uint8 g, uint8 b/table rgb/string web_color
|
Creates a colormap | Colormap |
colormap.generate or colormap:generate
|
colormap map, "default" , colormap map, "skin", string name , colormap map, "skincolor", enum skincolor , colormap map, "rgb", uint8 r, uint8 g, uint8 b/table rgb/string rgb_web_color
|
Same as above over an existing colormap | Colormap |
colormap.mix or colormap:mix
|
colormap mapA, colormap/translation mapB, uint8 amount, [alphastyle mode, int start, int length] |
Mixes two colormaps together | Nothing |
colormap.blend or colormap:blend
|
colormap map, uint8 palette_index/table rgb/table rgba/string rgba_web_color, uint8 amount, [alphastyle mode, int start, int length] |
Blends a color into a colormap | Nothing |
colormap.tint or colormap:tint
|
colormap map, uint8 palette_index/table rgb/table rgba/string rgba_web_color, [uint8 amount, int start, int length] |
Tints a colormap | Nothing |
colormap.copy or colormap:copy
|
colormap mapA, colormap/translation mapB, [int start, int length] |
Copies a colormap into another | Nothing |
colormap.copySkincolor or colormap:copySkincolor
|
colormap mapA, enum skincolor, [int start, int length] |
Copies a skin color into a colormap | Nothing |
If functions are called like this colmap:func(...)
, the first colormap parameter can be omitted.
Access | Description | Returns | Accepts |
---|---|---|---|
map[i] |
Gets and sets a color index from a colormap | Palette index | Palette index |
v.getColormap
returns a translation
(immutable by Lua), colormap.create
creates a colormap (mutable by Lua)
====
extra_colormap
now accessible from sectors
Field | Description | Returns | Accepts |
---|---|---|---|
r |
Red color channel | uint8 |
uint8 |
g |
Green color channel | uint8 |
uint8 |
b |
Blue color channel | uint8 |
uint8 |
a |
Alpha channel | uint8 |
uint8 |
rgba |
RGBA channels | uint8 r, uint8 g, uint8 b, uint8 a |
table rgb , table rgba , string rgb_web_color , string rgba_web_color
|
fade_r |
Red fade color channel | uint8 |
uint8 |
fade_g |
Green fade color channel | uint8 |
uint8 |
fade_b |
Blue fade color channel | uint8 |
uint8 |
fade_a |
Fade color alpha | uint8 |
uint8 |
fade_rgba |
Fade color channels | uint8 r, uint8 g, uint8 b, uint8 a |
table rgb , table rgba , string rgb_web_color , string rgba_web_color
|
fade_start |
Fade start | uint8 |
uint8 |
fade_end |
Fade end | uint8 |
uint8 |
colormap |
Light table | lighttable |
Cannot be set |
Access | Description | Returns |
---|---|---|
lighttable table[row] |
Gets a row (indexes range from 1 to 34) from a light table | Translation for the specified row |
====
Function | Parameters | Description | Returns |
---|---|---|---|
P_GetSectorColormapAt |
sector sec, fixed x, fixed y, fixed z |
Returns the sector sec 's color at the specified XYZ coordinates. sec can be nil , making the call equivalent to P_GetSectorColormapAt(R_PointInSubsector(x, y).sector, x, y, z)
|
Sector colormap (extracolormap_t ) |
Edited by Lactozilla