diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2016-09-01 17:38:42 -0400 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2016-09-01 17:38:42 -0400 |
commit | b017f48eaa7f36495afa1057b79a557a2fbb73a7 (patch) | |
tree | 64e78c133421a5b70fa5c38a77581adc450d5500 /src/leap/bitmask_js/app/lib/color.js | |
parent | 122fe50ebc6c0f87bc1390228315faa236f3d038 (diff) |
[pkg] move bitmask.js to new path
Diffstat (limited to 'src/leap/bitmask_js/app/lib/color.js')
-rw-r--r-- | src/leap/bitmask_js/app/lib/color.js | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/src/leap/bitmask_js/app/lib/color.js b/src/leap/bitmask_js/app/lib/color.js deleted file mode 100644 index 5b1dfee9..00000000 --- a/src/leap/bitmask_js/app/lib/color.js +++ /dev/null @@ -1,65 +0,0 @@ -// -// Color.hsv().css -// -// RGB values are 0..255 -// HSV values are 0..1 -// - -function compose(value) - return [ - Math.round(value * 255), - Math.round(value * 255), - Math.round(value * 255) - } -} - -class Color { - - constructor(r, g, b, a) { - this.r = r - this.g = g - this.b = b - this.a = a - } - - // - // alternate hsv factory - // - static hsv(h,s,v) { - let out = null - h = h % 360; - s = Math.max(0, Math.min(1, s)) - v = Math.max(0, Math.min(1, v)) - - if (s == 0) { - let grey = Math.ceil(v*255) - out = [grey, grey, grey] - } - - let b = ((1 - s) * v); - let vb = v - b; - let hm = h % 60; - switch((h/60)|0) { - case 0: - out = compose(v, vb * h / 60 + b, b); break - case 1: - out = compose(vb * (60 - hm) / 60 + b, v, b); break - case 2: - out = compose(b, v, vb * hm / 60 + b); break - case 3: - out = compose(b, vb * (60 - hm) / 60 + b, v); break - case 4: - out = compose(vb * hm / 60 + b, b, v); break - case 5: - out = compose(v, b, vb * (60 - hm) / 60 + b); break - } - - return new Color(...out) - } - - css() { - return `rgba(${this.r}, ${this.g}, ${this.b}, ${this.a})` - } -} - -export default Color
\ No newline at end of file |