Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript color green to red

 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);
        }
Comment

PREVIOUS NEXT
Code Example
Javascript :: async function in variable 
Javascript :: button disable in js 
Javascript :: how to count seconds in javascript 
Javascript :: reactjs get one document from firestore 
Javascript :: pdfjs get all the text present 
Javascript :: javascript number if .00 truncate 
Javascript :: call a function of another component vue 
Javascript :: math js 
Javascript :: save file javascript 
Javascript :: shadow class angular 
Javascript :: javascript array some 
Javascript :: javascript array sorting 
Javascript :: js match img 
Javascript :: Javascript using forEach loop to loop through an array 
Javascript :: object assign 
Javascript :: prettier printWidth 
Javascript :: nestjs Error: Cannot find module 
Javascript :: expo dependencies 
Javascript :: setstate in react 
Javascript :: javascript math ceiling function 
Javascript :: npm paypal express checkout 
Javascript :: curl post request 
Javascript :: javascript player movement 
Javascript :: javscript rename property name 
Javascript :: how to check characters inside a string javascript 
Javascript :: html show password 
Javascript :: js get selected value by id 
Javascript :: add two float numbers in javascript 
Javascript :: react native update state array of objects 
Javascript :: nodejs mysql query 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =