Skip to content

Instantly share code, notes, and snippets.

View lauri-kaariainen's full-sized avatar

Lauri Kääriäinen lauri-kaariainen

View GitHub Profile
@lauri-kaariainen
lauri-kaariainen / color-conversion-algorithms.js
Last active May 27, 2018 13:41 — forked from mjackson/color-conversion-algorithms.js
RGB, HSV, and HSL color conversion algorithms in JavaScript
function betterRgbToHsl(r, g, b) {
r /= 255, g /= 255, b /= 255;
var max = Math.max(r, g, b), min = Math.min(r, g, b);
var h, s, l = (max + min) / 2;
if (max == min) {
h = s = 0; // achromatic
} else {