Watchmaker Wiki

The ultimate watch maker for Android Wear!

User Tools

Site Tools


tips:dynamiccolor

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
tips:dynamiccolor [2015/01/28 06:43]
rahul_pawa [Gradually Transition Color As Battery Drains, From Green to Yellow to Red]
tips:dynamiccolor [2015/01/28 06:43]
rahul_pawa [Gradually Transition Color As Battery Drains, From Green to Yellow to Red]
Line 53: Line 53:
  
  
-   {bl} > 66 and string.format('%x.2%s',(100-{bl})*255/33,'FF00') or {bl} > 16 and string.format('%s%.2x%s','FF',({bl}-16)*255/50,'00') or 'FF0000'+   {bl} > 66 and string.format('%.2x%s',(100-{bl})*255/33,'FF00') or {bl} > 16 and string.format('%s%.2x%s','FF',({bl}-16)*255/50,'00') or 'FF0000'
  
 Here again we are using a condition to set the color value of an object, this time the condition is {bl} > 66, and the value we get is a function of the battery level: string.format('%.2x%s',(100-{bl})*255/33,'FF00'). I will explain what that means, but the idea is the amount of red increases as the battery lowers from 100 to 66, effectively transitioning the color from a bright green to a bright yellow. Here again we are using a condition to set the color value of an object, this time the condition is {bl} > 66, and the value we get is a function of the battery level: string.format('%.2x%s',(100-{bl})*255/33,'FF00'). I will explain what that means, but the idea is the amount of red increases as the battery lowers from 100 to 66, effectively transitioning the color from a bright green to a bright yellow.
tips/dynamiccolor.txt ยท Last modified: 2016/07/05 21:32 by wmissimer