User Tools

Site Tools


script_random_drawer_colors

====== About the script ====== * Purpose : Set a random color to the background of the apps in the app drawer * Author : [[http://www.google.com/+BogdanTautuTBog|TBog]] * Link: [[https://plus.google.com/113157980543803349502/posts/6LmZGtuyW5d|request post]] ====== How to use the script ====== - Copy the script and paste it using the Script Editor - Choose the script to appear in the Lightning menu - Close Script Editor and from the Lightning menu run the script ====== Script code ====== <code> var alpha=0x40; function hslToRgb(h, s, l) { var r, g, b; if(s == 0){ r = g = b = l; }else{ function hue2rgb(p, q, t){ if(t < 0) t += 1; if(t > 1) t -= 1; if(t < 1/6) return p + (q - p) * 6 * t; if(t < 1/2) return q; if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; return p; } var q = l < 0.5 ? l * (1 + s) : l + s - l * s; var p = 2 * l - q; r = hue2rgb(p, q, h + 1/3); g = hue2rgb(p, q, h); b = hue2rgb(p, q, h - 1/3); } return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; } var items= LL.getContainerById(99).getItems(); for(var idx=items.getLength()-1; idx>=0; idx-=1) { var c=hslToRgb( Math.random(), Math.random()*0.4+0.6, Math.random() * 0.6 ); var item=items.getAt(idx); var e=item.getProperties().edit(); e.getBox('i.box').setColor('c', 'n', alpha<<24|c[0]<<16|c[1]<<8|c[2]); e.commit(); } </code>

script_random_drawer_colors.txt · Last modified: 2014/05/03 20:29 by tbog