Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // License: MIT - https://opensource.org/licenses/MIT
- // Author: Michele Locati <[email protected]>
- // Source: https://gist.github.com/mlocati/7210513
- function perc2color(perc) {
- var r, g, b = 0;
- if(perc < 50) {
- r = 255;
- g = Math.round(5.1 * perc);
- }
- else {
- g = 255;
- r = Math.round(510 - 5.10 * perc);
- }
- var h = r * 0x10000 + g * 0x100 + b * 0x1;
- return '#' + ('000000' + h.toString(16)).slice(-6);
- }
Advertisement
Add Comment
Please, Sign In to add comment