tips:dynamiccolor
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tips:dynamiccolor [2015/01/22 03:02] – [Transition Color As Battery Drains, From Green to Yellow to Red] rahul_pawa | tips:dynamiccolor [2015/01/22 03:08] – [Gradually Transition Color As Battery Drains, From Green to Yellow to Red] rahul_pawa | ||
---|---|---|---|
Line 61: | Line 61: | ||
Let's talk about that first argument, you always need something like this when you use string.format. It always needs the single quotes (' '), and in those quotes is a code that tells LUA what our string will look like. In this case, %x tells it the first thing in our string will be a hexadecimal number, and %s tells us it will be followed by a string (some letters or numbers). The formatting here is also important, note that there is no space between %x and %s, this tells LUA that there shouldn' | Let's talk about that first argument, you always need something like this when you use string.format. It always needs the single quotes (' '), and in those quotes is a code that tells LUA what our string will look like. In this case, %x tells it the first thing in our string will be a hexadecimal number, and %s tells us it will be followed by a string (some letters or numbers). The formatting here is also important, note that there is no space between %x and %s, this tells LUA that there shouldn' | ||
- | The second argument is a bit of code that uses the battery level, it correlates to the %x in the first argument. The code itself is: (100-{bl})*255/ | + | The second argument is a linear formula |
The third argument is a string that is simply the rest of the color code, in this case I want maximum green and no blue. | The third argument is a string that is simply the rest of the color code, in this case I want maximum green and no blue. | ||
Line 72: | Line 72: | ||
And finally, if the battery is below 16 the color will be bright red. | And finally, if the battery is below 16 the color will be bright red. | ||
+ | |||
+ | or ' | ||
+ | |||
I put this code into a circle that is shaded using the segment shader option, with the code {bl}*3.6 for " | I put this code into a circle that is shaded using the segment shader option, with the code {bl}*3.6 for " |
tips/dynamiccolor.txt · Last modified: 2016/07/05 19:32 by wmissimer