forked from Mirrorlandia_minetest/digistuff
Rename "tohsv" and "torgb" operations to allow for possible future color space additions
This commit is contained in:
parent
5c2cb60815
commit
813ada878e
12
gpu.lua
12
gpu.lua
@ -16,7 +16,7 @@ local function implodebits(input)
|
|||||||
return output
|
return output
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tohsv(r,g,b)
|
local function rgbtohsv(r,g,b)
|
||||||
r = r/255
|
r = r/255
|
||||||
g = g/255
|
g = g/255
|
||||||
b = b/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)
|
return math.floor(hue*255),math.floor(sat*255),math.floor(max*255)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function torgb(h,s,v)
|
local function hsvtorgb(h,s,v)
|
||||||
h = h/255*360
|
h = h/255*360
|
||||||
s = s/255
|
s = s/255
|
||||||
v = v/255
|
v = v/255
|
||||||
@ -159,10 +159,10 @@ local function blend(src,dst,mode,transparent)
|
|||||||
return string.format("%02X%02X%02X",r,g,b)
|
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
|
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)
|
return bitwiseblend(srcr,dstr,srcg,dstg,srcb,dstb,op)
|
||||||
elseif op == "tohsv" then
|
elseif op == "tohsv" or op == "rgbtohsv" then
|
||||||
return string.format("%02X%02X%02X",tohsv(srcr,srcg,srcb))
|
return string.format("%02X%02X%02X",rgbtohsv(srcr,srcg,srcb))
|
||||||
elseif op == "torgb" then
|
elseif op == "torgb" or op == "hsvtorgb" then
|
||||||
return string.format("%02X%02X%02X",torgb(srcr,srcg,srcb))
|
return string.format("%02X%02X%02X",hsvtorgb(srcr,srcg,srcb))
|
||||||
else
|
else
|
||||||
return src
|
return src
|
||||||
end
|
end
|
||||||
|
4
gpu.txt
4
gpu.txt
@ -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.
|
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.
|
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.
|
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".
|
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".
|
||||||
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.
|
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
|
Command: load
|
||||||
-------------
|
-------------
|
||||||
|
Loading…
Reference in New Issue
Block a user