Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Needs HTML Color

Not a Bug 1.0.2

Color options need to be in html color code format (ex: #08FF00) instead of RGB so that they're more easily changeable.

Share this comment


Link to comment
On 6/2/2021 at 2:15 PM, NubbbZ said:

I get your point but no, because then the opacity is gone.

Here's the method I use to accept either an RGBA or hex while still allowing an opacity to be specified.

            public static string Color(string hexColor, float alpha)
            {
                if (hexColor.StartsWith("#"))
                    hexColor = hexColor.Substring(1);
                int red = int.Parse(hexColor.Substring(0, 2), NumberStyles.AllowHexSpecifier);
                int green = int.Parse(hexColor.Substring(2, 2), NumberStyles.AllowHexSpecifier);
                int blue = int.Parse(hexColor.Substring(4, 2), NumberStyles.AllowHexSpecifier);
                return $"{(double)red / 255} {(double)green / 255} {(double)blue / 255} {alpha}";
            }

 

Share this comment


Link to comment

About Us

Codefling is a forward-thinking platform for developers to share and monetize their work from plugins to game assets and everything in-between.

6,253 files sold to 575 customers and $91,267 of payments processed this year!

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.