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 revisionPrevious revision
Next revision
Previous revision
tips:dynamiccolor [2015/01/28 05:43] – [Gradually Transition Color As Battery Drains, From Green to Yellow to Red] rahul_pawatips:dynamiccolor [2016/07/05 19:32] (current) – Correcting this entry to match below (which is correct) wmissimer
Line 19: Line 19:
  
  
-   {bl} > 66 and string.format('%.2x%s',(100-{bl})*256/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'
  
  
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 19:32 by wmissimer