I have successfully added a color-shift to the battery-widget.

I have successfully added a color-shift to the battery-widget. It turns from a green when full to a red when empty. I am happy with the result, but my code feels hacky.

The 16 added keeps it from becoming single digit.

Please tell me, this is not the “best practice” way to do it. 😉

So i can add this script to the wiki.

]]>

6 Commentsto I have successfully added a color-shift to the battery-widget.

  1. Anonymous says:

    < ![CDATA[

    A bit easier: Color.rgb(r,g,b)

    ]]>

  2. Anonymous says:

    < ![CDATA[

    So, in your case: p.setColor(Color.rgb(255-2.55*batperc,2.55*patperc,0));

    ]]>

  3. Anonymous says:

    < ![CDATA[

    How, could I mis that one. Thanks.

    ]]>

  4. Anonymous says:

    < ![CDATA[

    Maybe you missed it because it’s Java, not javascript 😉

    ]]>

  5. Anonymous says:

    < ![CDATA[

    That’s lime green, not green. Green is darker.

    ]]>

  6. Anonymous says:

    < ![CDATA[

    Oops, sorry. Corrected

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *