Behavior:
Sets the Instance with the BrickColor property to a generated Color3
(Pseudo) Backend:
Inherited from BrickColor, so it can be used in the same way as the BrickColor class, but the difference is that it will simply store the Hex Value- and when ROBLOXs shaders come in to save the day- they will pick up on the Hex and use a Color3 value generated from the hex rather than a BrickColor value picked from the pallet.
function color3FromHex(n)
n = math.floor(n)
if (n < 0 or n > 16777215) then error("Color3FromHex: Number out of range") end
local b = n % 256
local g = ((n-b)/256)%256
local r = (n-b-g*256)/65536
return Color3.new(r/255,g/255,b/255)
end
If I’m not mistaken, RGB bricks are already on the way, and Color3 already covers the entire range. Use the above script to convert hex to Color3 if you really need to:
I was going to add fromHex when I added fromRGB but I don’t really see the use case. Any software that gives you a hex color is going to display the RGB right next to it.
Would still be great to have it natively supported like Color3.fromRGB. Hex is used a lot in web design, specifically color schemes – these schemes are also used in in-game UI design, so it’s not uncommon to copy paste hex colors that helper sites provide into ROBLOX while designing UI. OP actually happens to be designing UI for his game atm, so I imagine this is what he’s needing it for.
Edit @Sharksie: Software might, but websites usually don’t. Google’s material design page doesn’t offer RGB for instance.
Wait I think we’re misinterpreting the post, I’m not saying let’s get a Color3 from RGB/Hex generation method, I’m saying we need to expand the BrickColor class to include more colors, and i thought hex would be the best way, but I don’t want to break old items using BrickColor.new(int), so I thought this class would be a solution.
EDIT: or maybe not i have no idea how you guys are reading the post >.<
Well, if expanding color selection is the only reason then the point is moot. As VolcanoINC mentioned, Parts will soon be colorable with Color3, and your palette will be unlimited.