Jump to content

Needs HTML Color

Not a Bug 1.0.2

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
1.1m

Downloads

Total number of downloads.

5.5k

Customers

Total customers served.

78.5k

Files Sold

Total number of files sold.

1.5m

Payments Processed

Total payments processed.

×
×
  • 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.