summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-01-26 13:42:36 -0500
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-01-26 13:42:36 -0500
commit1c5d79800fc82b2c257945394337d56dcb9b1b4d (patch)
treecc68237816ec4fdc562864d630a50f1a28457314
parentb1ad76ab7266558205e41777e5a11c6b1d1b5777 (diff)
downloadunifieddyes-1c5d79800fc82b2c257945394337d56dcb9b1b4d.tar
unifieddyes-1c5d79800fc82b2c257945394337d56dcb9b1b4d.tar.gz
unifieddyes-1c5d79800fc82b2c257945394337d56dcb9b1b4d.tar.bz2
unifieddyes-1c5d79800fc82b2c257945394337d56dcb9b1b4d.tar.xz
unifieddyes-1c5d79800fc82b2c257945394337d56dcb9b1b4d.zip
add an alternate "find HSV" function.
Note that if the result is greyscale, the name ("black", "grey", ...) is returned in the "hue" field, sat is empty string, and val is "light", "dark", or empty string.
-rw-r--r--init.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/init.lua b/init.lua
index c6a03ae..e7eea42 100644
--- a/init.lua
+++ b/init.lua
@@ -97,6 +97,33 @@ function unifieddyes.is_buildable_to(placer_name, ...)
return true
end
+function unifieddyes.get_hsv(name)
+ local hue = ""
+ local a,b
+ for _, i in ipairs(HUES) do
+ a,b = string.find(name, "_"..i)
+ if a and not ( string.find(name, "_redviolet") and i == "red" ) then
+ hue = i
+ break
+ end
+ end
+
+ if string.find(name, "grey") then hue = "grey"
+ elseif string.find(name, "white") then hue = "white"
+ elseif string.find(name, "black") then hue = "black"
+ end
+
+ local sat = ""
+ if string.find(name, "_s50") then sat = "_s50" end
+
+ local val = ""
+ if string.find(name, "dark_") then val = "dark_" end
+ if string.find(name, "medium_") then val = "medium_" end
+ if string.find(name, "light_") then val = "light_" end
+
+ return hue, sat, val
+end
+
-- code borrowed from cheapie's plasticbox mod
function unifieddyes.getpaletteidx(color, colorfdir)