Add an RGBA Color type (Color4)

As a Roblox developer, it is currently too hard to apply RGBA values to GuiObjects.

I’m working on something that can load in RGBA values from a JSON file, however, to assign the alpha channel, I have to do extra work to just assign the transparency, instead of mapping it cleanly to one property.

Currently, in theory, this is what I have to do to split the RGB from the RGBA and have it map properly

text.TextColor3 = Color3.new(c4.R, c4.G, c4.B)
text.TextTransparency = 1 - c4.A

This requires a lot of extra work to extract the alpha channel when it would be cleaner to have a single property that accepts an RGBA datatype:

text.TextColor4 = c4 -- c4 = Color4

If Roblox is able to address this issue, it would improve my development experience because I would then be able to use RGBA values without needing to do loads of extra work to assign the transparency channel.

11 Likes

Another use case for an RGBA type would be EditableImages.

The API for EditableImages seems to be rushed and lacks any sort of type safety, as pixels are simply referred to the documentation as 4 numbers representing RGBA respectively.

Implementing an RGBA type would allow EditableImages to specify it as a type, making things more safe (and less confusing).

6 Likes

Highly support this. It would make EditableImage be a little bit more user friendly too. Even though I personally much prefer working with pure RGBA numbers, having this option would be great too!

3 Likes

+1, this would be so helpful!!! :pray:

Color3.fromRGBA
3 Likes

Your use case is really weak; I do not see how having to add in an extra line of code to account for transparency is “loads of extra work.”

I’m not entirely opposed to an implementation like this given that other languages/engines have native RGBA classes/libraries, but in Roblox’s case this just feels like API bloat.

2 Likes

I don’t see a reason why bringing Roblox to industry-standard APIs is bloat and can justify why this isn’t a good idea. Adding more classes isn’t going to slow down the engine, and along as Color3 remains unaltered, backwards compatibility is also guaranteed.

In fact, by not adding Color4 (and maybe Quaternions), one could argue that this would require us to add unnecessary bloat to our own games.

3 Likes

I didn’t say it was a bad idea, I said that OP’s use case was terrible.

These properties are separated by Roblox convention and should they be merged into a single datatype, all instances with a color and transparency property would adopt an RGBA datatype property to represent them. Given that most Color3 properties have a respective transparency property, an RGBA datatype would supersede Color3 and deprecate it.

Again, I agree that this should’ve been how it was from the start, but I think a stronger use case needs to be presented for Roblox to consider restructuring our interface for assigning color and transparency.

Not only that but it would also solve a lot of personal inefficiencies I’m having with the API, current bottleneck I’m running into with DynamicImages is the act of reading/writing to/from 4 different table values and constructing a Color3 + alpha with them. If DynamicImage supported a Color4 datatype, I would end up needing to do somewhat less work regarding the keys in the table and, as a result, be able to render effects at higher resolutions.

1 Like