Skip to content

Instantly share code, notes, and snippets.

View kazuma0129's full-sized avatar
♨️
ONSEN LOVER

Kazuma Ohashi kazuma0129

♨️
ONSEN LOVER
View GitHub Profile
@kazuma0129
kazuma0129 / hex2hsl.js
Last active May 4, 2020 05:27 — forked from xenozauros/hex2hsl.js
Javascript: HEX to RGB to HSL
fucntion hexToHSL(hex) {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
const r = parseInt(result[1], 16) / 255
const g = parseInt(result[2], 16) / 255
const b = parseInt(result[3], 16) / 255
const max = Math.max(r, g, b)
const min = Math.min(r, g, b)
let h = 0
let s = 0
const l = (max + min) / 2