mirror of
https://github.com/AR2000AR/openComputers_codes.git
synced 2025-09-09 07:01:14 +02:00
[yawl] rgb to color util function
This commit is contained in:
@@ -363,7 +363,7 @@
|
|||||||
["yawl"] = {
|
["yawl"] = {
|
||||||
["manifestVersion"] = "1.0",
|
["manifestVersion"] = "1.0",
|
||||||
["package"] = "yawl",
|
["package"] = "yawl",
|
||||||
["version"] = "1.6.0",
|
["version"] = "1.6.1",
|
||||||
["name"] = "Yet Another Widget Library",
|
["name"] = "Yet Another Widget Library",
|
||||||
["repo"] = "tree/master/yawl",
|
["repo"] = "tree/master/yawl",
|
||||||
["description"] = "New version of libgui, but using libclass2 and cleaner code and interface.",
|
["description"] = "New version of libgui, but using libclass2 and cleaner code and interface.",
|
||||||
|
Binary file not shown.
@@ -375,7 +375,7 @@
|
|||||||
dependencies = {
|
dependencies = {
|
||||||
["libclass2"] = "/"
|
["libclass2"] = "/"
|
||||||
},
|
},
|
||||||
version = "1.6.0",
|
version = "1.6.1",
|
||||||
name = "Yet Another Widget Library",
|
name = "Yet Another Widget Library",
|
||||||
description = "New version of libgui, but using libclass2 and cleaner code and interface.";
|
description = "New version of libgui, but using libclass2 and cleaner code and interface.";
|
||||||
authors = "AR2000AR,Renno231",
|
authors = "AR2000AR,Renno231",
|
||||||
|
36
yawl/lib/yawl/utils.lua
Normal file
36
yawl/lib/yawl/utils.lua
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
---@class yawlUtils
|
||||||
|
|
||||||
|
local utils = {}
|
||||||
|
|
||||||
|
---Take a color int (hex) and return it's red green and blue components
|
||||||
|
---@param hex number
|
||||||
|
---@return number
|
||||||
|
---@return number
|
||||||
|
---@return number
|
||||||
|
function utils.colorToRGB(hex)
|
||||||
|
assert(hex >= 0 and hex <= 0xffffff)
|
||||||
|
local r = (hex & 0xff0000) >> 16
|
||||||
|
local g = (hex & 0x00ff00) >> 8
|
||||||
|
local b = (hex & 0x0000ff)
|
||||||
|
return r, g, b
|
||||||
|
end
|
||||||
|
|
||||||
|
---Take a RGB value and convert it to a color value
|
||||||
|
---@param r number
|
||||||
|
---@param g number
|
||||||
|
---@param b number
|
||||||
|
---@return number
|
||||||
|
---@overload fun(rgb:table):number
|
||||||
|
function utils.RGBtoColor(r, g, b)
|
||||||
|
assert(r >= 0x00 and r <= 0xff)
|
||||||
|
assert(g >= 0x00 and g <= 0xff)
|
||||||
|
assert(b >= 0x00 and b <= 0xff)
|
||||||
|
if (type(r) == "table") then
|
||||||
|
b = r[3]
|
||||||
|
g = r[2]
|
||||||
|
r = r[1]
|
||||||
|
end
|
||||||
|
return b + (g << 8) + (r << 16)
|
||||||
|
end
|
||||||
|
|
||||||
|
return utils
|
Reference in New Issue
Block a user