Watchmaker Wiki

The ultimate watch maker for Android Wear!

User Tools

Site Tools


tips:dynamiccolor

This is an old revision of the document!


Changing Color Dynamically

Examples

Change Color When Event is Approaching

 {c1bp} <= ({dtp}+(1/24)) and 'ff0000' or 'ffffff'

Transition Color As Battery Drains, From Green to Yellow to Red

 {bl} >= 66 and string.format('%x%s',(100-{bl})*7.5264,'ff00') or {bl} > 15 and string.format('%s%x%s','ff',({bl}-15)*5.12,'00') or 'ff0000'

Introduction

Changing colors dynamically could be useful for making information stand out when it is most important, or to use color in familiar ways to represent information.

When creating code that sets the color of an object, it's important to understand how that code looks and what it means. Color code is a 6 digit hexadecimal number that represents the amount of red, green and blue in that color. The first two digits are the amount of red, the middle two digits are the amount of green and the last two digits are the amount of blue. Each pair of digits has a minimum value of 00 (none of that color at all), and a maximum value of FF.

Hexadecimal is a number system that uses base 16, instead of the base 10 that our decimal number system uses. This means the numbers 0-15 can be represented by a single digit, to represent those numbers past 9, alphabet characters are used (i.e. 10 in decimal is A in hexadecimal, 11 is B, 12 is C, 13 is D, 14 is E, and 15 is F).

tips/dynamiccolor.1421873931.txt.gz · Last modified: 2015/01/21 20:58 by rahul_pawa