You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Harbs <ha...@gmail.com> on 2016/10/27 08:32:40 UTC

CSSUtils.toColorWithAlpha

Alex, I think this question is for you since I think you wrote the code last July.

The handling of rgba seems odd to me:

            else if ((c = stringValue.indexOf("rgba(")) != -1)
            {
                c2 = stringValue.indexOf(")");
                stringValue = stringValue.substring(c + 4, c2);
                var parts4:Array = stringValue.split(",");
                return (uint(parts4[3]) << 24 + 
                    uint(parts3[0]) << 16 +
                    uint(parts3[1]) << 8 +
                    uint(parts3[2]));
            }

Besides a typo where parts3 is being used instead of parts4, there’s two issues I can see:
1. The uint is being saved as ARGB rather than RGBA.
2. RGB values are values between 0 and 255, while A values are between 0 and 1.

It does not look to me like this code ever worked. Any objection to me changing it to standardize on RGBA instead of ARGB?

Thanks,
Harbs

Re: CSSUtils.toColorWithAlpha

Posted by Alex Harui <ah...@adobe.com>.

On 10/27/16, 1:32 AM, "Harbs" <ha...@gmail.com> wrote:

>Alex, I think this question is for you since I think you wrote the code
>last July.
>
>The handling of rgba seems odd to me:
>
>            else if ((c = stringValue.indexOf("rgba(")) != -1)
>            {
>                c2 = stringValue.indexOf(")");
>                stringValue = stringValue.substring(c + 4, c2);
>                var parts4:Array = stringValue.split(",");
>                return (uint(parts4[3]) << 24 +
>                    uint(parts3[0]) << 16 +
>                    uint(parts3[1]) << 8 +
>                    uint(parts3[2]));
>            }
>
>Besides a typo where parts3 is being used instead of parts4, there’s two
>issues I can see:
>1. The uint is being saved as ARGB rather than RGBA.
>2. RGB values are values between 0 and 255, while A values are between 0
>and 1.
>
>It does not look to me like this code ever worked. Any objection to me
>changing it to standardize on RGBA instead of ARGB?

Quite possible.  Doesn't have to stay that way for it to work in Flash?  I
started a separate thread about color handling.  Let's finish the
discussion there.

-Alex