Code: Select all
--sets the saturation of an rgba table. amount is 0-100.
function saturation(rgba, amount)
local increase = (255 - ((amount / 100) * 255))
local t = {}
t.r = (max((rgba.r + increase)));
t.g = (max((rgba.g + increase)));
t.b = (max((rgba.b + increase)));
t.a = rgba.a;
return t
end
--sets the brightness of an rgba table. amount is 0-100.
function brightness(rgba, amount)
local decrease = 255 - ((amount / 100) * 255)
local t = {}
t.r = (max((rgba.r - decrease)));
t.g = (max((rgba.g - decrease)));
t.b = (max((rgba.b - decrease)));
t.a = rgba.a;
return t
end
--see example of this being used below.
function saturation_and_brightness(rgb,sat,brightness)
local _saturation = saturation(rgb,sat)
local result = brightness(_saturation,brightness)
return result
end
--but if I do this, it does not work. I will not just be using 50%. 50% is an example.
local desired_result = saturation_and_brightness({r=127,g=0,b=255},50,50)
The idea is to add 50% white to purple then add 50% black. The result should be the above. This is what would happen in photoshop or Gimp (as seen below) while adding a plain purple layer (or any other color), then above it, a white layer 50% transparent, then above that, a black layer 50% transparent. I want to re-produce this effect on a rgb table.