platypush/platypush/backend/http/dist/static/js/chunk-014e8b04.7f400c2d.js

2 lines
36 KiB
JavaScript
Raw Normal View History

2020-12-14 02:13:55 +01:00
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-014e8b04"],{"07ac":function(e,t,n){var o=n("23e7"),r=n("6f53").values;o({target:"Object",stat:!0},{values:function(e){return r(e)}})},1804:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));n("99af"),n("d81d"),n("b680"),n("b64b");var o=n("2909");function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function c(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}var a=function(){function e(t){if(r(this,e),this.ranges={hue:[0,360],sat:[0,100],bri:[0,100],ct:[154,500]},t)for(var n=0,o=Object.keys(this.ranges);n<o.length;n++){var i=o[n];t[i]&&(this.ranges[i]=t[i])}}return c(e,[{key:"normalize",value:function(e,t,n){return n[0]+(e-t[0])*(n[1]-n[0])/(t[1]-t[0])}},{key:"hslToRgb",value:function(e,t,n){var o=[this.normalize(e,this.ranges.hue,[0,360]),this.normalize(t,this.ranges.sat,[0,100]),this.normalize(n,this.ranges.bri,[0,100])];e=o[0],t=o[1],n=o[2],n/=100;var r=t*Math.min(n,1-n)/100,i=function(t){var o=(t+e/30)%12,i=n-r*Math.max(Math.min(o-3,9-o,1),-1);return Math.round(255*i)};return[i(0),i(8),i(4)]}},{key:"rgbToHsl",value:function(e,t,n){e/=255,t/=255,n/=255;var o,r,i=Math.max(e,t,n),c=Math.min(e,t,n),a=(i+c)/2;if(i===c)o=r=0;else{var l=i-c;switch(r=a>.5?l/(2-i-c):l/(i+c),i){case e:o=(t-n)/l+(t<n?6:0);break;case t:o=(n-e)/l+2;break;case n:o=(e-t)/l+4;break}o/=6}return[parseInt(this.normalize(o,[0,1],this.ranges.hue)),parseInt(this.normalize(r,[0,1],this.ranges.sat)),parseInt(this.normalize(a,[0,1],this.ranges.bri))]}},{key:"xyToRgb",value:function(e,t,n){null==n&&(n=this.ranges.bri[1]);var o=1-e-t,r=(n/(this.ranges.bri[1]-1)).toFixed(2),i=r/t*e,c=r/t*o,a=1.656492*i-.354851*r-.255038*c,l=.707196*-i+1.655397*r+.036152*c,s=.051713*i-.121364*r+1.01153*c;return a>s&&a>l&&a>1?(l/=a,s/=a,a=1):l>s&&l>a&&l>1?(a/=l,s/=l,l=1):s>a&&s>l&&s>1&&(a/=s,l/=s,s=1),a=a<=.0031308?12.92*a:1.055*Math.pow(a,1/2.4)-.055,l=l<=.0031308?12.92*l:1.055*Math.pow(l,1/2.4)-.055,s=s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055,a=Math.round(255*a),l=Math.round(255*l),s=Math.round(255*s),isNaN(a)&&(a=0),isNaN(l)&&(l=0),isNaN(s)&&(s=0),[a,l,s].map((function(e){return Math.min(Math.max(0,e),255)}))}},{key:"rgbToXY",value:function(e,t,n){e>1&&(e/=255),t>1&&(t/=255),n>1&&(n/=255),e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var o=.664511*e+.154324*t+.162028*n,r=.283881*e+.668433*t+.047685*n,i=88e-6*e+.07231*t+.986039*n,c=parseFloat((o/(o+r+i)).toFixed(4)),a=parseFloat((r/(o+r+i)).toFixed(4));return isNaN(c)&&(c=0),isNaN(a)&&(a=0),[c,a]}},{key:"rgbToBri",value:function(e,t,n){return Math.min(2*this.rgbToHsl(e,t,n)[2],this.ranges.bri[1])}},{key:"getRGB",value:function(e){return null!=e.red&&null!=e.green&&null!=e.blue?[e.red,e.green,e.blue]:null!=e.r&&null!=e.g&&null!=e.b?[e.r,e.g,e.b]:e.rgb?e.rgb:void 0}},{key:"getXY",value:function(e){return null!=e.x&&null!=e.y?[e.x,e.y]:e.xy?e.xy:void 0}},{key:"toRGB",value:function(e){var t=this.getRGB(e);if(t)return t;var n=this.getXY(e);return n&&e.bri?this.xyToRgb.apply(this,Object(o["a"])(n).concat([e.bri])):e.hue&&e.sat&&e.bri?this.hslToRgb(e.hue,e.sat,e.bri):(console.debug("Could not determine color space"),void console.debug(e))}},{key:"toXY",value:function(e){var t=this.getXY(e);if(t&&e.bri)return[t[0],t[1],e.bri];var n=this.getRGB(e);if(n)return this.rgbToXY.apply(this,Object(o["a"])(n));if(e.hue&&e.sat&&e.bri){var r=this.hslToRgb(e.hue,e.sat,e.bri);return this.rgbToXY.apply(this,Object(o["a"])(r))}console.debug("Could not determine color space"),console.debug(e)}},{key:"toHSL",value:function(e){if(e.hue&&e.sat&&e.bri)return[e.hue,e.sat,e.bri];var t=this.getRGB(e);if(t)return this.rgbToHsl.apply(this,Object(o["a"])(t));var n=this.getXY(e);if(n&&e.bri){var r=this.xyToRgb.apply(this,Object(o["a"])(n).concat([e.bri]));return this.rgbToHsl.apply(t
//# sourceMappingURL=chunk-014e8b04.7f400c2d.js.map