hsvLib
simple yet efficient color manipulation
hsvLib is a really simple library to manipulate color.
you should be able to understand its source code with ease. I think that even a beginner can understand its code.
Docs:
colorLib.opacity(color: Color3 | BrickColor, amount: number)
change the opacity of a color or a brickColor
if the parameter amount if 1 its going to error as it need to be between 1 and 0
colorLib.saturate(color: Color3 | BrickColor, amount: number)
saturate the color
if 1 is putted, its going to be fully saturated.
!!!: if the parameter amount if 1 its going to error as it need to be between 1 and 0
colorLib.hue(color: Color3 | BrickColor, amount: number)
change the hue of a color while keeping its saturation and brightness
the parameter amount must between 0 and 360
Download
You can find my module here:
local colorLib = {}
function colorLib.opacity(color: Color3 | BrickColor, amount: number)
if amount < 0 or amount > 1 then error("The amount parameter should have a number between 0 or 1") end
local isBrickColor = false
if typeof(color) == "BrickColor" then
isBrickColor = true
color = Color3.fromRGB(color.R, color.G, color.B)
end
local h, s, v = color:ToHSV()
local converted = Color3.fromHSV(h, s, amount)
if isBrickColor then
return BrickColor.new(converted)
else
return converted
end
end
function colorLib.saturate(color: Color3 | BrickColor, amount: number)
if amount < 0 or amount > 1 then error("The amount parameter should have a number between 0 or 1") end
local isBrickColor = false
if typeof(color) == "BrickColor" then
isBrickColor = true
color = Color3.fromRGB(color.R, color.G, color.B)
end
local h, s, v = color:ToHSV()
local converted = Color3.fromHSV(h, amount, v)
if isBrickColor then
return BrickColor.new(converted)
else
return converted
end
end
-- change the hue
function colorLib.hue(color: Color3 | BrickColor, amount: number)
if amount < 0 or amount > 360 then error("The amount parameter should have a number between 0 or 360") end
amount = amount / 100 * 360
local isBrickColor = false
if typeof(color) == "BrickColor" then
isBrickColor = true
color = Color3.fromRGB(color.R, color.G, color.B)
end
local h, s, v = color:ToHSV()
local converted = Color3.fromHSV(amount, s, v)
if isBrickColor then
return BrickColor.new(converted)
else
return converted
end
end
return colorLib