Scene background color code

152 views
Skip to first unread message

nmyshkin

unread,
Jul 12, 2018, 5:53:57 PM7/12/18
to Tasker
Can anyone explain to me the format of the scene background color value as seen in the xml file? I'm working with an old version of Tasker (for Eclair) on an e-ink device and the interface for color picking and transparency leaves much to be desired. Therefore I've been editing the xml files to get my desired effects. But...the color "code" used for the scene background is meaningless to me. As an example, I recently got an effect I wanted by trial and error from the color picker completely by accident. When I looked at the xml file I saw"-499571599" for the background color.

What is that?

Sean Williams

unread,
Jul 12, 2018, 8:46:49 PM7/12/18
to Tasker
What is that?

Looks like a decimal colour. Try this.

nmyshkin

unread,
Jul 12, 2018, 11:17:23 PM7/12/18
to Tasker
Hmm. Seems like too many or too few digits depending on how you look at it. The hex is 1DC6DB8F. I guess that's 8 digits like the rest of the colors. So the 1D is transparency? Why is this one value different and what's with the minus sign? Sometimes the value is just -1.

Seems really odd.

Robert Ryan

unread,
Jul 13, 2018, 2:47:03 AM7/13/18
to tas...@googlegroups.com
Convert an Android decimal color to its hexadecimal representation in aRGB format. 

-16776961 (opaque blue) = ff0000ff

    A1: Variable Query 
        Variable: %color 
        Input Type: Numeric / Integer 
        Default: -16776961 
        Layout: Variable Query 
        Timeout (Seconds): 40 
        Show Over Keyguard: On 
        
    A2: Variable Convert 
        Name: %color 
        Function: Decimal to Hex 
        
    A3: Test Variable 
        Type: Length 
        Data: %color 
        Store Result In: %length 
        
    A4: Variable Section 
        Name: %color 
        From: 9 
        Length: 8 
        Adapt To Fit: On
        If %length > 8
        
    A5: Flash 
        Text: %color 
        Long: On 

Sean Williams

unread,
Jul 13, 2018, 5:54:22 AM7/13/18
to Tasker
So the 1D is transparency?

The two hexadecimal digits are for the "alpha".


Why is this one value different and what's with the minus sign?

I believe its when evaluated as a signed int.


Sometimes the value is just -1

White is -1
 

Seems really odd.


Yes, try this one instead - I tested, this time it works. 

Or Roberts converter above looks good.

Robert Ryan

unread,
Jul 13, 2018, 8:12:34 AM7/13/18
to tas...@googlegroups.com
All about android color, including some common values, can be found here. The decimal integers are the two's-complement representation of the hex color code. 

nmyshkin

unread,
Jul 13, 2018, 2:47:29 PM7/13/18
to Tasker


On Friday, July 13, 2018 at 5:12:34 AM UTC-7, Robert Ryan wrote:
All about android color, including some common values, can be found here. The decimal integers are the two's-complement representation of the hex color code. 

Wow, thank you both! It still strikes me as odd that this one color designation should be in a completely different format from the others, but there is probably some good reason not known to mere mortals.

The good news is that I employed the information you gave me and came up with exactly the result I wanted, first try!!

Thanks again.

nmyshkin

unread,
Jul 14, 2018, 7:55:03 PM7/14/18
to Tasker
Whoops...spoke too soon.

I have a translucency image from a framework-res.apk that I am trying to duplicate for a scene background. The image is black--totally, at least that's what a little utility program tells me (#000000) it also tells me that the transparency value is #99. If I am understanding this correctly, that is 60% transparent (makes sense, as this is the "dimming" overlay when a major interactive flash is displayed).

If I put this information together I have #99000000? But this gives me a decimal value of 2566914048 and Tasker is having none of that.Too many digits, and not even a negative sign.

Where did I go wrong?

Robert Ryan

unread,
Jul 14, 2018, 8:26:58 PM7/14/18
to tas...@googlegroups.com
You can't use Tasker's built in hex to decimal because it does an unsigned conversion. Here we need to do a two's complement conversion. 

Luckily, the is a Java function for this Color.parseColor().

#99000000 = -1728053248

        Test
        
    A1: Variable Query 
        Title: Hex Color 
        Variable: %hex_color 
        Input Type: Normal Text 
        Default: 99000000 
        Layout: Variable Query 
        Timeout (Seconds): 40 
        Show Over Keyguard: On 
        
    A2: Java Function 
        Return: %color 
        Class Or Object: Color 
        Function: parseColor
        {int} (String) 
        Param: #%hex_color 
        
    A3: Flash 
        Text: %color 
        Long: On 
        
    A4: Set Clipboard 
        Text: %color 
        Add: Off 


--
You received this message because you are subscribed to the Google Groups "Tasker" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tasker+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

nmyshkin

unread,
Jul 15, 2018, 4:54:36 PM7/15/18
to Tasker
Thank you! That worked perfectly, but I'm not sure I can wrap my head around these conversions. And some people think The Book of the Dead is full of arcane stuff!!
Reply all
Reply to author
Forward
0 new messages