MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / toHSL

Method toHSL

src/common/style/CartoCSS.js:3285–3315  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3283 }
3284
3285 toHSL() {
3286 var r = this.rgb[0] / 255,
3287 g = this.rgb[1] / 255,
3288 b = this.rgb[2] / 255,
3289 a = this.alpha;
3290
3291 var max = Math.max(r, g, b), min = Math.min(r, g, b);
3292 var h, s, l = (max + min) / 2, d = max - min;
3293
3294 if (max === min) {
3295 h = s = 0;
3296 } else {
3297 s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
3298
3299 switch (max) {
3300 case r:
3301 h = (g - b) / d + (g < b ? 6 : 0);
3302 break;
3303 case g:
3304 h = (b - r) / d + 2;
3305 break;
3306 case b:
3307 h = (r - g) / d + 4;
3308 break;
3309 default:
3310 break;
3311 }
3312 h /= 6;
3313 }
3314 return {h: h * 360, s: s, l: l, a: a};
3315 }
3316};
3317
3318CartoCSS.Tree.Comment = class Comment {

Callers 2

ColorSpec.jsFile · 0.45
CartoCSS.jsFile · 0.45

Calls 2

maxMethod · 0.80
minMethod · 0.80

Tested by

no test coverage detected