New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

color-interfaces

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-interfaces - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

3

dist/index.d.ts
import Color from './Color';
export default Color;
export { default as RGBInterface } from './RGBInterface';

@@ -6,2 +7,2 @@ export { default as HSLInterface } from './HSLInterface';

export { default as HexInterface } from './HexInterface';
export default Color;
export { RGB, RGBA, HSL, HSLA, HSV, HSVA, HEX } from './ColorInterface';

@@ -440,2 +440,3 @@ module.exports =

var Color_1 = __importDefault(__webpack_require__(7));
exports.default = Color_1.default;
var RGBInterface_1 = __webpack_require__(1);

@@ -449,3 +450,2 @@ Object.defineProperty(exports, "RGBInterface", { enumerable: true, get: function () { return RGBInterface_1.default; } });

Object.defineProperty(exports, "HexInterface", { enumerable: true, get: function () { return HexInterface_1.default; } });
exports.default = Color_1.default;

@@ -452,0 +452,0 @@

@@ -1,1 +0,1 @@

module.exports=function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=6)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RE_HEX_3=e.RE_HEX_6=e.GREY=e.WHITE=e.BLACK=e.DEFAULT_COLOR=e.ColorType=void 0,function(t){t[t.KEYWORD=1]="KEYWORD",t[t.HEX=2]="HEX",t[t.RGB=3]="RGB",t[t.RGBA=4]="RGBA",t[t.HSL=5]="HSL",t[t.HSLA=6]="HSLA",t[t.HSV=7]="HSV"}(e.ColorType||(e.ColorType={})),e.DEFAULT_COLOR="black",e.BLACK=[0,0,0],e.WHITE=[255,255,255],e.GREY=[127.5,127.5,127.5],e.RE_HEX_6=new RegExp("^[0-9a-fA-F]{6}$"),e.RE_HEX_3=new RegExp("^[0-9a-fA-F]{3}$")},function(t,e,r){"use strict";var o=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,n,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)u.push(o.value)}catch(t){n={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return u};Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.color=t}return Object.defineProperty(t.prototype,"r",{get:function(){return this.color.getRed()},set:function(t){this.color.setRed(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this.color.getGreen()},set:function(t){this.color.setGreen(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this.color.getBlue()},set:function(t){this.color.setBlue(t)},enumerable:!1,configurable:!0}),t.prototype.get=function(){return[this.r,this.g,this.b]},t.prototype.set=function(t){var e;e=o(t,3),this.r=e[0],this.g=e[1],this.b=e[2]},t.prototype.toCss=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},t}();e.default=n},function(t,e,r){"use strict";var o=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,n,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)u.push(o.value)}catch(t){n={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return u};Object.defineProperty(e,"__esModule",{value:!0});var n=r(3),i=function(){function t(t){this.color=t}return Object.defineProperty(t.prototype,"h",{get:function(){return this.color.getHue()},set:function(t){this.color.setHue(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"s",{get:function(){return this.color.getSaturation()},set:function(t){this.color.setSaturation(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"l",{get:function(){return this.color.getLightness()},set:function(t){this.color.setLightness(t)},enumerable:!1,configurable:!0}),t.prototype.get=function(){return[this.h,this.s,this.l]},t.prototype.set=function(t){var e;e=o(t,3),this.h=e[0],this.s=e[1],this.l=e[2]},t.prototype.toCss=function(){var t=n.toPercent(this.s),e=n.toPercent(this.l);return"hsl("+this.h+", "+t+", "+e+")"},t}();e.default=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getTestSpan=e.parseInt10=e.hueToRgb=e.toPercent=e.mixRgbColors=e.clamp=void 0;var o=r(0);e.clamp=function(t,e,r){return Math.min(Math.max(t,e),r)},e.mixRgbColors=function(t,e,r){return[t[0]+r*(e[0]-t[0]),t[1]+r*(e[1]-t[1]),t[2]+r*(e[2]-t[2])]},e.toPercent=function(t){return Math.round(100*t)+"%"},e.hueToRgb=function(t){var e=(t%=360)%60;switch(t-=e,e=Math.round(4.25*e),t){case 0:return[255,e,0];case 60:return[255-e,255,0];case 120:return[0,255,e];case 180:return[0,255-e,255];case 240:return[e,0,255];case 300:return[255,0,255-e]}return[0,0,0]},e.parseInt10=function(t){return Number.parseInt(t,10)},e.getTestSpan=function(){var t=n;return t&&t.parentNode||((t=n=document.createElement("span")).style.display="none",document.body.appendChild(t)),t.style.setProperty("color",o.DEFAULT_COLOR,"important"),t};var n=null},function(t,e,r){"use strict";var o=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,n,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)u.push(o.value)}catch(t){n={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return u};Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.color=t}return Object.defineProperty(t.prototype,"h",{get:function(){return this.color.getHue()},set:function(t){this.color.setHue(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"s",{get:function(){return this.color.getSaturationV()},set:function(t){this.color.setSaturationV(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"v",{get:function(){return this.color.getValue()},set:function(t){this.color.setValue(t)},enumerable:!1,configurable:!0}),t.prototype.get=function(){return[this.h,this.s,this.v]},t.prototype.set=function(t){var e;e=o(t,3),this.h=e[0],this.s=e[1],this.v=e[2]},t.prototype.toCss=function(){return this.color.hsl.toCss()},t}();e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=r(0),n=function(){function t(t){this.color=t}return t.prototype.set=function(t){if(!o.RE_HEX_3.test(t)&&!o.RE_HEX_6.test(t))throw Error("Not valid hex color");o.RE_HEX_3.test(t)&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]);var e=Number.parseInt(t,16);this.color.rgb.set([e>>16,e>>8&255,255&e])},t.prototype.get=function(){var t=this.color.rgb,e=(t.r<<16|t.g<<8|t.b).toString(16);return""+"0".repeat(6-e.length)+e},t.prototype.toCss=function(){var t=this.get();return t[0]===t[1]&&t[2]===t[3]&&t[4]===t[5]&&(t=""+t[0]+t[2]+t[4]),"#"+t},t}();e.default=n},function(t,e,r){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var n=o(r(7)),i=r(1);Object.defineProperty(e,"RGBInterface",{enumerable:!0,get:function(){return i.default}});var u=r(2);Object.defineProperty(e,"HSLInterface",{enumerable:!0,get:function(){return u.default}});var s=r(4);Object.defineProperty(e,"HSVInterface",{enumerable:!0,get:function(){return s.default}});var a=r(5);Object.defineProperty(e,"HexInterface",{enumerable:!0,get:function(){return a.default}}),e.default=n.default},function(t,e,r){"use strict";var o=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,n,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)u.push(o.value)}catch(t){n={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return u},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var i=n(r(1)),u=n(r(2)),s=n(r(4)),a=n(r(5)),l=r(0),c=r(3),h=function(){function t(t,e){if(this._alpha=1,this.red=0,this.green=0,this.blue=0,this.hue=0,this.saturation=0,this.lightness=0,this.saturationV=0,this.value=0,this._rgb=null,this._hsl=null,this._hsv=null,this._hex=null,"string"==typeof t&&this.parseCSSColor(t),Array.isArray(t))switch(e){case void 0:case l.ColorType.RGB:this.rgb.set(t);break;case l.ColorType.HSL:this.hsl.set(t);break;case l.ColorType.HSV:this.hsv.set(t)}}return t.prototype.parseCSSColor=function(t){var e=c.getTestSpan();e.style.setProperty("color",t,"important");var r=window.getComputedStyle(e).color.split(/rgba?\(|,s*|\)$/).filter(Boolean);4===r.length&&(this.alpha=parseFloat(r.pop())),this.rgb.set(r.map(c.parseInt10))},Object.defineProperty(t.prototype,"rgb",{get:function(){return null===this._rgb&&(this._rgb=new i.default(this)),this._rgb},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hsl",{get:function(){return this._hsl||(this._hsl=new u.default(this)),this._hsl},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hsv",{get:function(){return this._hsv||(this._hsv=new s.default(this)),this._hsv},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hex",{get:function(){return this._hex||(this._hex=new a.default(this)),this._hex},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alpha",{get:function(){return Math.round(c.clamp(this._alpha,0,1))},set:function(t){this._alpha=t},enumerable:!1,configurable:!0}),t.prototype.setRed=function(t){this.red=c.clamp(t,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},t.prototype.getRed=function(){return Math.round(c.clamp(this.red,0,255))},t.prototype.setGreen=function(t){this.green=c.clamp(t,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},t.prototype.getGreen=function(){return Math.round(c.clamp(this.green,0,255))},t.prototype.setBlue=function(t){this.blue=c.clamp(t,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},t.prototype.getBlue=function(){return Math.round(c.clamp(this.blue,0,255))},t.prototype.setHue=function(t){this.hue=c.clamp(t,0,360),this.updateRgbFromHsl()},t.prototype.getHue=function(){return Math.round(c.clamp(this.hue,0,360))},t.prototype.setSaturation=function(t){this.saturation=c.clamp(t,0,1),this.updateRgbFromHsl(),this.updateHsvFromHsl()},t.prototype.getSaturation=function(){return c.clamp(this.saturation,0,1)},t.prototype.setSaturationV=function(t){this.saturationV=c.clamp(t,0,1),this.updateHslFromHsv(),this.updateRgbFromHsl()},t.prototype.getSaturationV=function(){return c.clamp(this.saturationV,0,1)},t.prototype.setLightness=function(t){this.lightness=c.clamp(t,0,1),this.updateRgbFromHsl(),this.updateHsvFromHsl()},t.prototype.getLightness=function(){return c.clamp(this.lightness,0,1)},t.prototype.setValue=function(t){this.value=c.clamp(t,0,1),this.updateHslFromHsv(),this.updateRgbFromHsl()},t.prototype.getValue=function(){return c.clamp(this.value,0,1)},t.prototype.getGreyValue=function(){return.2126*this.red+.7152*this.green+.0722*this.blue},t.prototype.invert=function(){return this.setHue((this.hue+180)%360),this},t.prototype.getLuminance=function(){var t=this.rgb.get().map((function(t){var e=t/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}));return.2126*t[0]+.7152*t[1]+.0722*t[2]},t.prototype.getContrastRatio=function(t){var e=this.getLuminance(),r=t.getLuminance();return e>r?(e+.05)/(r+.05):(r+.05)/(e+.05)},t.prototype.copy=function(){var e=new t;return e.setRed(this.red),e.setGreen(this.green),e.setBlue(this.blue),e.alpha=this.alpha,e},t.prototype.updateHslFromRgb=function(){var t=this.red/255,e=this.green/255,r=this.blue/255,o=Math.max(t,e,r),n=Math.min(t,e,r),i=o+n,u=o-n;if(this.hue=0,this.saturation=0,this.lightness=i/2,0!==u){this.saturation=u/(1-Math.abs(i-1));var s=60/u;switch(o){case t:this.hue=(360+(e-r)*s)%360;break;case e:this.hue=120+(r-t)*s;break;case r:this.hue=240+(t-e)*s}}},t.prototype.updateRgbFromHsl=function(){var t,e=c.hueToRgb(this.hue),r=c.mixRgbColors(e,l.GREY,1-this.saturation),n=this.lightness<=.5?l.BLACK:l.WHITE,i=1-Math.abs(2*this.lightness-1);t=o(c.mixRgbColors(n,r,i),3),this.red=t[0],this.green=t[1],this.blue=t[2]},t.prototype.updateHsvFromHsl=function(){var t=this.lightness,e=(2*t+this.saturation*(1-Math.abs(2*t-1)))/2;this.saturationV=2*(e-t)/e||0,this.value=e},t.prototype.updateHslFromHsv=function(){var t=this.value,e=this.saturationV,r=.5*t*(2-e);this.saturation=e*t/(1-Math.abs(2*r-1))||0,this.lightness=r},t}();e.default=h}]);
module.exports=function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=6)}([function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.RE_HEX_3=e.RE_HEX_6=e.GREY=e.WHITE=e.BLACK=e.DEFAULT_COLOR=e.ColorType=void 0,function(t){t[t.KEYWORD=1]="KEYWORD",t[t.HEX=2]="HEX",t[t.RGB=3]="RGB",t[t.RGBA=4]="RGBA",t[t.HSL=5]="HSL",t[t.HSLA=6]="HSLA",t[t.HSV=7]="HSV"}(e.ColorType||(e.ColorType={})),e.DEFAULT_COLOR="black",e.BLACK=[0,0,0],e.WHITE=[255,255,255],e.GREY=[127.5,127.5,127.5],e.RE_HEX_6=new RegExp("^[0-9a-fA-F]{6}$"),e.RE_HEX_3=new RegExp("^[0-9a-fA-F]{3}$")},function(t,e,r){"use strict";var o=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,n,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)u.push(o.value)}catch(t){n={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return u};Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.color=t}return Object.defineProperty(t.prototype,"r",{get:function(){return this.color.getRed()},set:function(t){this.color.setRed(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this.color.getGreen()},set:function(t){this.color.setGreen(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this.color.getBlue()},set:function(t){this.color.setBlue(t)},enumerable:!1,configurable:!0}),t.prototype.get=function(){return[this.r,this.g,this.b]},t.prototype.set=function(t){var e;e=o(t,3),this.r=e[0],this.g=e[1],this.b=e[2]},t.prototype.toCss=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},t}();e.default=n},function(t,e,r){"use strict";var o=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,n,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)u.push(o.value)}catch(t){n={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return u};Object.defineProperty(e,"__esModule",{value:!0});var n=r(3),i=function(){function t(t){this.color=t}return Object.defineProperty(t.prototype,"h",{get:function(){return this.color.getHue()},set:function(t){this.color.setHue(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"s",{get:function(){return this.color.getSaturation()},set:function(t){this.color.setSaturation(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"l",{get:function(){return this.color.getLightness()},set:function(t){this.color.setLightness(t)},enumerable:!1,configurable:!0}),t.prototype.get=function(){return[this.h,this.s,this.l]},t.prototype.set=function(t){var e;e=o(t,3),this.h=e[0],this.s=e[1],this.l=e[2]},t.prototype.toCss=function(){var t=n.toPercent(this.s),e=n.toPercent(this.l);return"hsl("+this.h+", "+t+", "+e+")"},t}();e.default=i},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getTestSpan=e.parseInt10=e.hueToRgb=e.toPercent=e.mixRgbColors=e.clamp=void 0;var o=r(0);e.clamp=function(t,e,r){return Math.min(Math.max(t,e),r)},e.mixRgbColors=function(t,e,r){return[t[0]+r*(e[0]-t[0]),t[1]+r*(e[1]-t[1]),t[2]+r*(e[2]-t[2])]},e.toPercent=function(t){return Math.round(100*t)+"%"},e.hueToRgb=function(t){var e=(t%=360)%60;switch(t-=e,e=Math.round(4.25*e),t){case 0:return[255,e,0];case 60:return[255-e,255,0];case 120:return[0,255,e];case 180:return[0,255-e,255];case 240:return[e,0,255];case 300:return[255,0,255-e]}return[0,0,0]},e.parseInt10=function(t){return Number.parseInt(t,10)},e.getTestSpan=function(){var t=n;return t&&t.parentNode||((t=n=document.createElement("span")).style.display="none",document.body.appendChild(t)),t.style.setProperty("color",o.DEFAULT_COLOR,"important"),t};var n=null},function(t,e,r){"use strict";var o=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,n,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)u.push(o.value)}catch(t){n={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return u};Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.color=t}return Object.defineProperty(t.prototype,"h",{get:function(){return this.color.getHue()},set:function(t){this.color.setHue(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"s",{get:function(){return this.color.getSaturationV()},set:function(t){this.color.setSaturationV(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"v",{get:function(){return this.color.getValue()},set:function(t){this.color.setValue(t)},enumerable:!1,configurable:!0}),t.prototype.get=function(){return[this.h,this.s,this.v]},t.prototype.set=function(t){var e;e=o(t,3),this.h=e[0],this.s=e[1],this.v=e[2]},t.prototype.toCss=function(){return this.color.hsl.toCss()},t}();e.default=n},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=r(0),n=function(){function t(t){this.color=t}return t.prototype.set=function(t){if(!o.RE_HEX_3.test(t)&&!o.RE_HEX_6.test(t))throw Error("Not valid hex color");o.RE_HEX_3.test(t)&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]);var e=Number.parseInt(t,16);this.color.rgb.set([e>>16,e>>8&255,255&e])},t.prototype.get=function(){var t=this.color.rgb,e=(t.r<<16|t.g<<8|t.b).toString(16);return""+"0".repeat(6-e.length)+e},t.prototype.toCss=function(){var t=this.get();return t[0]===t[1]&&t[2]===t[3]&&t[4]===t[5]&&(t=""+t[0]+t[2]+t[4]),"#"+t},t}();e.default=n},function(t,e,r){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var n=o(r(7));e.default=n.default;var i=r(1);Object.defineProperty(e,"RGBInterface",{enumerable:!0,get:function(){return i.default}});var u=r(2);Object.defineProperty(e,"HSLInterface",{enumerable:!0,get:function(){return u.default}});var s=r(4);Object.defineProperty(e,"HSVInterface",{enumerable:!0,get:function(){return s.default}});var a=r(5);Object.defineProperty(e,"HexInterface",{enumerable:!0,get:function(){return a.default}})},function(t,e,r){"use strict";var o=this&&this.__read||function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,n,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)u.push(o.value)}catch(t){n={error:t}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return u},n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});var i=n(r(1)),u=n(r(2)),s=n(r(4)),a=n(r(5)),l=r(0),c=r(3),h=function(){function t(t,e){if(this._alpha=1,this.red=0,this.green=0,this.blue=0,this.hue=0,this.saturation=0,this.lightness=0,this.saturationV=0,this.value=0,this._rgb=null,this._hsl=null,this._hsv=null,this._hex=null,"string"==typeof t&&this.parseCSSColor(t),Array.isArray(t))switch(e){case void 0:case l.ColorType.RGB:this.rgb.set(t);break;case l.ColorType.HSL:this.hsl.set(t);break;case l.ColorType.HSV:this.hsv.set(t)}}return t.prototype.parseCSSColor=function(t){var e=c.getTestSpan();e.style.setProperty("color",t,"important");var r=window.getComputedStyle(e).color.split(/rgba?\(|,s*|\)$/).filter(Boolean);4===r.length&&(this.alpha=parseFloat(r.pop())),this.rgb.set(r.map(c.parseInt10))},Object.defineProperty(t.prototype,"rgb",{get:function(){return null===this._rgb&&(this._rgb=new i.default(this)),this._rgb},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hsl",{get:function(){return this._hsl||(this._hsl=new u.default(this)),this._hsl},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hsv",{get:function(){return this._hsv||(this._hsv=new s.default(this)),this._hsv},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hex",{get:function(){return this._hex||(this._hex=new a.default(this)),this._hex},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alpha",{get:function(){return Math.round(c.clamp(this._alpha,0,1))},set:function(t){this._alpha=t},enumerable:!1,configurable:!0}),t.prototype.setRed=function(t){this.red=c.clamp(t,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},t.prototype.getRed=function(){return Math.round(c.clamp(this.red,0,255))},t.prototype.setGreen=function(t){this.green=c.clamp(t,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},t.prototype.getGreen=function(){return Math.round(c.clamp(this.green,0,255))},t.prototype.setBlue=function(t){this.blue=c.clamp(t,0,255),this.updateHslFromRgb(),this.updateHsvFromHsl()},t.prototype.getBlue=function(){return Math.round(c.clamp(this.blue,0,255))},t.prototype.setHue=function(t){this.hue=c.clamp(t,0,360),this.updateRgbFromHsl()},t.prototype.getHue=function(){return Math.round(c.clamp(this.hue,0,360))},t.prototype.setSaturation=function(t){this.saturation=c.clamp(t,0,1),this.updateRgbFromHsl(),this.updateHsvFromHsl()},t.prototype.getSaturation=function(){return c.clamp(this.saturation,0,1)},t.prototype.setSaturationV=function(t){this.saturationV=c.clamp(t,0,1),this.updateHslFromHsv(),this.updateRgbFromHsl()},t.prototype.getSaturationV=function(){return c.clamp(this.saturationV,0,1)},t.prototype.setLightness=function(t){this.lightness=c.clamp(t,0,1),this.updateRgbFromHsl(),this.updateHsvFromHsl()},t.prototype.getLightness=function(){return c.clamp(this.lightness,0,1)},t.prototype.setValue=function(t){this.value=c.clamp(t,0,1),this.updateHslFromHsv(),this.updateRgbFromHsl()},t.prototype.getValue=function(){return c.clamp(this.value,0,1)},t.prototype.getGreyValue=function(){return.2126*this.red+.7152*this.green+.0722*this.blue},t.prototype.invert=function(){return this.setHue((this.hue+180)%360),this},t.prototype.getLuminance=function(){var t=this.rgb.get().map((function(t){var e=t/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}));return.2126*t[0]+.7152*t[1]+.0722*t[2]},t.prototype.getContrastRatio=function(t){var e=this.getLuminance(),r=t.getLuminance();return e>r?(e+.05)/(r+.05):(r+.05)/(e+.05)},t.prototype.copy=function(){var e=new t;return e.setRed(this.red),e.setGreen(this.green),e.setBlue(this.blue),e.alpha=this.alpha,e},t.prototype.updateHslFromRgb=function(){var t=this.red/255,e=this.green/255,r=this.blue/255,o=Math.max(t,e,r),n=Math.min(t,e,r),i=o+n,u=o-n;if(this.hue=0,this.saturation=0,this.lightness=i/2,0!==u){this.saturation=u/(1-Math.abs(i-1));var s=60/u;switch(o){case t:this.hue=(360+(e-r)*s)%360;break;case e:this.hue=120+(r-t)*s;break;case r:this.hue=240+(t-e)*s}}},t.prototype.updateRgbFromHsl=function(){var t,e=c.hueToRgb(this.hue),r=c.mixRgbColors(e,l.GREY,1-this.saturation),n=this.lightness<=.5?l.BLACK:l.WHITE,i=1-Math.abs(2*this.lightness-1);t=o(c.mixRgbColors(n,r,i),3),this.red=t[0],this.green=t[1],this.blue=t[2]},t.prototype.updateHsvFromHsl=function(){var t=this.lightness,e=(2*t+this.saturation*(1-Math.abs(2*t-1)))/2;this.saturationV=2*(e-t)/e||0,this.value=e},t.prototype.updateHslFromHsv=function(){var t=this.value,e=this.saturationV,r=.5*t*(2-e);this.saturation=e*t/(1-Math.abs(2*r-1))||0,this.lightness=r},t}();e.default=h}]);
import Color from './dist/index';
export default Color;
export { default as RGBInterface } from './dist/RGBInterface';

@@ -6,2 +7,2 @@ export { default as HSLInterface } from './dist/HSLInterface';

export { default as HexInterface } from './dist/HexInterface';
export default Color;
export { RGB, RGBA, HSL, HSLA, HSV, HSVA, HEX } from './ColorInterface';
{
"name": "color-interfaces",
"version": "0.0.8",
"version": "0.0.9",
"description": "interfaces for color spaces",

@@ -5,0 +5,0 @@ "repository": "https://github.com/chriskr/color-interfaces",

import Color from './Color';
export default Color;
export { default as RGBInterface } from './RGBInterface';

@@ -6,2 +7,2 @@ export { default as HSLInterface } from './HSLInterface';

export { default as HexInterface } from './HexInterface';
export default Color;
export { RGB, RGBA, HSL, HSLA, HSV, HSVA, HEX } from './ColorInterface';
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc