Skip to content

Instantly share code, notes, and snippets.

Avatar

Marlon Tiedt TiedtTech

View GitHub Profile
@mlocati
mlocati / color-scale.js
Last active Jul 18, 2022
Javascript color scale from 0% to 100%, rendering it from red to yellow to green
View color-scale.js
// License: MIT - https://opensource.org/licenses/MIT
// Author: Michele Locati <michele@locati.it>
// 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 {