logo
Search
showing results for - "javascript color green to red"
Valery
11 Jun 2020
1 function perc2color(perc) {
2            var r, g, b = 0;
3            if (perc < 50) {
4                r = 255;
5                g = Math.round(5.1 * perc);
6            }
7            else {
8                g = 255;
9                r = Math.round(510 - 5.10 * perc);
10            }
11            var h = r * 0x10000 + g * 0x100 + b * 0x1;
12            return '#' + ('000000' + h.toString(16)).slice(-6);
13        }
similar questions
node js colorsbright red in javascriptjavascript set color in hexjavascript colorjavascript change background colorjs element text colorhow to change body color in javascriptjavascript change colorprint colored text javascriptchange text color according to background jshow to get contrast from a color using jsjavascript ligten a colorjavascript get black or white text base on colorbright green in javascripthow to change background color using jshow to use javascript so the color box change color and then change backjavascript change background colorhow to change the color using jsjavascript style background colorhow to change color on js
queries leading to this page
javascript color rgb greenjavascript red to greenhow to generate color code from red to green javascriptjavascript green colorcode for changing green background jswhat is green in javascriptjavascript color green to redjavascript color green to red
privacy policyterms of useinstagram
Crafted with  ♥  for everyone

sign in to continue
your answer for
you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content
please ensure to add code which is syntactically corrent and executes properly
sign in to continue
ask question on maxinterview
you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content
please be clear, to the point and respectful
sign in to continue