From 0ceb8f0afec23bedc7cd4ea9ad2451f54267fadf Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Fri, 24 Feb 2017 14:21:59 -0500 Subject: [PATCH] add extended palette full 256-color range: 24 full hues, with four lighter shades and two darker shades, plus low-saturation versions of the full and darker shades, and 16 levels of greyscale --- init.lua | 62 ++++++++++++++++++++++ textures/unifieddyes_palette_extended.png | Bin 0 -> 299 bytes 2 files changed, 62 insertions(+) create mode 100644 textures/unifieddyes_palette_extended.png diff --git a/init.lua b/init.lua index 76b849e..b83ee60 100644 --- a/init.lua +++ b/init.lua @@ -58,6 +58,25 @@ local HUES = { "redviolet" } +local SATS = { + "", + "_s50" +} + +local VALS = { + "", + "medium_", + "dark_" +} + +local GREYS = { + "white", + "light_grey", + "grey", + "dark_grey", + "black" +} + local HUES2 = { "Red", "Orange", @@ -91,6 +110,27 @@ local default_dyes = { "yellow" } +-- this tiles the "extended" palette sideways and then crops it to 256x1 +-- to convert it from human readable to something the engine can use as a palette. +-- +-- in machine-readable form, the selected color is: +-- 16 + [hue] - [shade]*24 for the light colors, or +-- 16 + [hue] + [saturation]*24 + [shade]*48 for the dark colors, or +-- [shade] (no math) for the greys, 0 = white. + +unifieddyes.extended_palette = "[combine:256x1" + ..":0,0=unifieddyes_palette_extended.png" + ..":16,-1=unifieddyes_palette_extended.png" + ..":40,-2=unifieddyes_palette_extended.png" + ..":64,-3=unifieddyes_palette_extended.png" + ..":88,-4=unifieddyes_palette_extended.png" + ..":112,-5=unifieddyes_palette_extended.png" + ..":136,-6=unifieddyes_palette_extended.png" + ..":160,-7=unifieddyes_palette_extended.png" + ..":184,-8=unifieddyes_palette_extended.png" + ..":208,-9=unifieddyes_palette_extended.png" + ..":232,-10=unifieddyes_palette_extended.png" + -- code borrowed from homedecor -- call this function to reset the rotation of a "wallmounted" object on place @@ -495,6 +535,28 @@ for _, color in ipairs(default_dyes) do }) end +-- build a table to convert from classic/89-color palette to extended palette + +unifieddyes.convert_classic_palette = {} + +for hue = 0, 11 do + -- light + local paletteidx = unifieddyes.getpaletteidx("dye:light_"..HUES[hue+1], false) + unifieddyes.convert_classic_palette[paletteidx] = 16 + hue*2 + 48 + for sat = 0, 1 do + for val = 0, 2 do + -- full + local paletteidx = unifieddyes.getpaletteidx("dye:"..VALS[val+1]..HUES[hue+1]..SATS[sat+1], false) + unifieddyes.convert_classic_palette[paletteidx] = 16 + hue*2 + sat*24 + (val+4)*48 + end + end +end + +for grey = 0, 4 do + local paletteidx = unifieddyes.getpaletteidx("dye:"..GREYS[grey+1], false) + unifieddyes.convert_classic_palette[paletteidx] = grey +end + -- Items/recipes needed to generate the few base colors that are not -- provided by the standard dyes mod. diff --git a/textures/unifieddyes_palette_extended.png b/textures/unifieddyes_palette_extended.png new file mode 100644 index 0000000000000000000000000000000000000000..b07c5cdc0fca7456a98a30fcacc48f2a054e2899 GIT binary patch literal 299 zcmV+`0o4A9P)Q~yD0002;NklRpGF|^b^059Q#@&rJyloS*uS_onJG1*9=$XLL@7EI#Jt-fp+L*UJR z