Rename "tohsv" and "torgb" operations to allow for possible future color space additions

master
cheapie 2021-01-29 20:46:13 -06:00
parent 5c2cb60815
commit 813ada878e
2 changed files with 8 additions and 8 deletions

12
gpu.lua
View File

@ -16,7 +16,7 @@ local function implodebits(input)
return output
end
local function tohsv(r,g,b)
local function rgbtohsv(r,g,b)
r = r/255
g = g/255
b = b/255
@ -44,7 +44,7 @@ local function tohsv(r,g,b)
return math.floor(hue*255),math.floor(sat*255),math.floor(max*255)
end
local function torgb(h,s,v)
local function hsvtorgb(h,s,v)
h = h/255*360
s = s/255
v = v/255
@ -159,10 +159,10 @@ local function blend(src,dst,mode,transparent)
return string.format("%02X%02X%02X",r,g,b)
elseif op == "and" or op == "or" or op == "xor" or op == "xnor" or op == "not" or op == "nand" or op == "nor" then
return bitwiseblend(srcr,dstr,srcg,dstg,srcb,dstb,op)
elseif op == "tohsv" then
return string.format("%02X%02X%02X",tohsv(srcr,srcg,srcb))
elseif op == "torgb" then
return string.format("%02X%02X%02X",torgb(srcr,srcg,srcb))
elseif op == "tohsv" or op == "rgbtohsv" then
return string.format("%02X%02X%02X",rgbtohsv(srcr,srcg,srcb))
elseif op == "torgb" or op == "hsvtorgb" then
return string.format("%02X%02X%02X",hsvtorgb(srcr,srcg,srcb))
else
return src
end

View File

@ -92,8 +92,8 @@ nor: Perform a bitwise NOR of the source and destination and write the result to
xor: Perform a bitwise XOR of the source and destination and write the result to the destination.
xnor: Perform a bitwise XNOR of the source and destination and write the result to the destination.
not: Perform a bitwise NOT of the source and write the result to the destination.
tohsv: Convert the source from the RGB color system to the HSV color system and write the result to the destination, storing hue as "red", saturation as "green", and value as "blue".
torgb: Convert the source from the HSV color system to the RGB color system, reading hue from the red channel, saturation from the green channel, and value from the blue channel, and write the result to the destination.
rgbtohsv: Convert the source from the RGB color system to the HSV color system and write the result to the destination, storing hue as "red", saturation as "green", and value as "blue".
hsvtorgb: Convert the source from the HSV color system to the RGB color system, reading hue from the red channel, saturation from the green channel, and value from the blue channel, and write the result to the destination.
Command: load
-------------