| 1181 | ----------------------*/ |
| 1182 | window.folderColorMap = window.folderColorMap || {}; |
| 1183 | function hexToHsl(hex) { |
| 1184 | hex = hex.replace('#', ''); |
| 1185 | if (hex.length === 3) hex = hex.split('').map(c => c + c).join(''); |
| 1186 | const r = parseInt(hex.substr(0, 2), 16) / 255; |
| 1187 | const g = parseInt(hex.substr(2, 2), 16) / 255; |
| 1188 | const b = parseInt(hex.substr(4, 2), 16) / 255; |
| 1189 | const max = Math.max(r, g, b), min = Math.min(r, g, b); |
| 1190 | let h, s, l = (max + min) / 2; |
| 1191 | if (max === min) { h = s = 0; } |
| 1192 | else { |
| 1193 | const d = max - min; |
| 1194 | s = l > 0.5 ? d / (2 - max - min) : d / (max + min); |
| 1195 | switch (max) { |
| 1196 | case r: h = (g - b) / d + (g < b ? 6 : 0); break; |
| 1197 | case g: h = (b - r) / d + 2; break; |
| 1198 | case b: h = (r - g) / d + 4; break; |
| 1199 | } |
| 1200 | h /= 6; |
| 1201 | } |
| 1202 | return { h: h * 360, s: s * 100, l: l * 100 }; |
| 1203 | } |
| 1204 | function hslToHex(h, s, l) { |
| 1205 | h /= 360; s /= 100; l /= 100; |
| 1206 | const f = n => { |