Comparing version
@@ -721,4 +721,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
ColorFormatter.prototype.toRgb = function (mode) { | ||
if (mode === void 0) { mode = 'default'; } | ||
var _a; | ||
if (mode === void 0) { mode = 'default'; } | ||
var color = this.getColorAs('rgb'); | ||
@@ -1081,5 +1081,5 @@ var _b = color.values.map(function (x) { return Math.round(x); }), r = _b[0], g = _b[1], b = _b[2]; | ||
MooColor.random = function (_a) { | ||
var _b; | ||
var _c = _a === void 0 ? {} : _a, hue = _c.hue, white = _c.white, black = _c.black; | ||
_b = [hue, white, black].map(function (x, i) { | ||
var _b = _a === void 0 ? {} : _a, hue = _b.hue, white = _b.white, black = _b.black; | ||
var _c; | ||
_c = [hue, white, black].map(function (x, i) { | ||
if (typeof x === 'number') { | ||
@@ -1095,3 +1095,3 @@ return x; | ||
} | ||
}), hue = _b[0], white = _b[1], black = _b[2]; | ||
}), hue = _c[0], white = _c[1], black = _c[2]; | ||
return new MooColor({ | ||
@@ -1098,0 +1098,0 @@ model: 'hwb', |
@@ -25,3 +25,3 @@ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.MooColor=e():t.MooColor=e()}(this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},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 n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},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="./src/moo-color.ts")}({"./node_modules/color-name/index.js": | ||
\**************************/ | ||
/*! exports provided: ColorFormatter, MooColor, default */function(t,e,r){"use strict";r.r(e),r.d(e,"MooColor",function(){return i});var n=r(/*! ./color-converter */"./src/color-converter.ts"),o=r(/*! ./color-formatter */"./src/color-formatter.ts");r.d(e,"ColorFormatter",function(){return o.default});var a,u=r(/*! ./input-parser */"./src/input-parser.ts"),s=r(/*! ./util/util */"./src/util/util.ts"),c=(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},function(t,e){function r(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=function(t){function e(e){var r=t.call(this)||this;return"object"==typeof e&&null!==e?r.setColor(e):"string"!=typeof e&&void 0!==e||(e=e||"#000",r.setColorByParser(e)),r}return c(e,t),e.mix=function(t,r,n){void 0===n&&(n=50);var o=t instanceof e?t:new e(t);return(r instanceof e?r:new e(r)).mix(o,n)},e.random=function(t){var r,o=void 0===t?{}:t,a=o.hue,u=o.white,c=o.black;return a=(r=[a,u,c].map(function(t,e){if("number"==typeof t)return t;if(Array.isArray(t)){var r=0===e?0:2;return Object(s.getRandom)(Math.min.apply(Math,t),Math.max.apply(Math,t),r)}return 0===e?Object(s.getRandom)(0,360):Object(s.getRandom)(0,100,2)}))[0],u=r[1],c=r[2],new e({model:"hwb",values:Object(n.resolveHwb)(Object(s.degree)(a),Object(s.clamp)(u,0,100),Object(s.clamp)(c,0,100)),alpha:1})},e.prototype.setColorByParser=function(t){var e=Object(u.default)(t);if(!e)throw new Error("parsing error!");return this.setColor(e)},e.prototype.clone=function(){return new e(this.color)},Object.defineProperty(e.prototype,"brightness",{get:function(){var t=this.getColorAs("rgb").values;return(299*t[0]+587*t[1]+114*t[2])/1e3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isLight",{get:function(){return this.brightness>=128},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isDark",{get:function(){return this.brightness<128},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"luminance",{get:function(){var t=this.getColorAs("rgb").values.map(function(t){return t/255});return.2126*t[0]+.7152*t[1]+.0722*t[2]},enumerable:!0,configurable:!0}),e.prototype.contrastRatioWith=function(t){return(Math.max(this.luminance,t.luminance)+.05)/(Math.min(this.luminance,t.luminance)+.05)},e.prototype.isContrastEnough=function(t){return this.contrastRatioWith(t)>=4.5},e.prototype.lighten=function(t){return this.manipulate("hsl",function(e,r,n){return[e,r,n=Object(s.clamp)(n+t,0,100)]})},e.prototype.darken=function(t){return this.manipulate("hsl",function(e,r,n){return[e,r,n=Object(s.clamp)(n-t,0,100)]})},e.prototype.saturate=function(t){return this.manipulate("hsl",function(e,r,n){return[e,r=Object(s.clamp)(r+t,0,100),n]})},e.prototype.desaturate=function(t){return this.manipulate("hsl",function(e,r,n){return[e,r=Object(s.clamp)(r-t,0,100),n]})},e.prototype.grayscale=function(){return this.manipulate("hsl",function(t,e,r){return[t,0,r]})},e.prototype.whiten=function(t){var e=this;return this.manipulate("hwb",function(r,n,o){return e.resolveHwb(r,Object(s.clamp)(n+t,0,100),o)})},e.prototype.blacken=function(t){var e=this;return this.manipulate("hwb",function(r,n,o){return e.resolveHwb(r,n,Object(s.clamp)(o+t,0,100))})},e.prototype.rotate=function(t){return this.manipulate("hsl",function(e,r,n){return[Object(s.degree)(e+t),r,n]})},e.prototype.mix=function(t,r){void 0===r&&(r=50),r/=100;var n=this.getModel(),o=this.getColorAs("rgb"),a=t.getColorAs("rgb");return new e({model:"rgb",values:o.values.map(function(t,e){return t+(a.values[e]-t)*r}),alpha:o.alpha+(a.alpha-o.alpha)*r}).changeModel(n)},e.prototype.complement=function(){return this.manipulate("hsl",function(t,e,r){return[Object(s.degree)(t+180),e,r]})},e.prototype.invert=function(t){void 0===t&&(t=100),t/=100;return this.manipulate("rgb",function(e,r,n){return[e,r,n].map(function(e){return function(t){return Math.round(Math.abs(t))}(255*t-e)})})},e.prototype.manipulate=function(t,e){var r=this.color.model,n=this.getColorAs(t);return n.values=e.apply(void 0,n.values),this.setColor(n).changeModel(r)},e}(o.default);e.default=i},"./src/util/util.ts": | ||
/*! exports provided: ColorFormatter, MooColor, default */function(t,e,r){"use strict";r.r(e),r.d(e,"MooColor",function(){return c});var n=r(/*! ./color-converter */"./src/color-converter.ts"),o=r(/*! ./color-formatter */"./src/color-formatter.ts");r.d(e,"ColorFormatter",function(){return o.default});var a=r(/*! ./input-parser */"./src/input-parser.ts"),u=r(/*! ./util/util */"./src/util/util.ts"),s=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),c=function(t){function e(e){var r=t.call(this)||this;return"object"==typeof e&&null!==e?r.setColor(e):"string"!=typeof e&&void 0!==e||(e=e||"#000",r.setColorByParser(e)),r}return s(e,t),e.mix=function(t,r,n){void 0===n&&(n=50);var o=t instanceof e?t:new e(t);return(r instanceof e?r:new e(r)).mix(o,n)},e.random=function(t){var r,o=void 0===t?{}:t,a=o.hue,s=o.white,c=o.black;return a=(r=[a,s,c].map(function(t,e){if("number"==typeof t)return t;if(Array.isArray(t)){var r=0===e?0:2;return Object(u.getRandom)(Math.min.apply(Math,t),Math.max.apply(Math,t),r)}return 0===e?Object(u.getRandom)(0,360):Object(u.getRandom)(0,100,2)}))[0],s=r[1],c=r[2],new e({model:"hwb",values:Object(n.resolveHwb)(Object(u.degree)(a),Object(u.clamp)(s,0,100),Object(u.clamp)(c,0,100)),alpha:1})},e.prototype.setColorByParser=function(t){var e=Object(a.default)(t);if(!e)throw new Error("parsing error!");return this.setColor(e)},e.prototype.clone=function(){return new e(this.color)},Object.defineProperty(e.prototype,"brightness",{get:function(){var t=this.getColorAs("rgb").values;return(299*t[0]+587*t[1]+114*t[2])/1e3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isLight",{get:function(){return this.brightness>=128},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isDark",{get:function(){return this.brightness<128},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"luminance",{get:function(){var t=this.getColorAs("rgb").values.map(function(t){return t/255});return.2126*t[0]+.7152*t[1]+.0722*t[2]},enumerable:!0,configurable:!0}),e.prototype.contrastRatioWith=function(t){return(Math.max(this.luminance,t.luminance)+.05)/(Math.min(this.luminance,t.luminance)+.05)},e.prototype.isContrastEnough=function(t){return this.contrastRatioWith(t)>=4.5},e.prototype.lighten=function(t){return this.manipulate("hsl",function(e,r,n){return[e,r,n=Object(u.clamp)(n+t,0,100)]})},e.prototype.darken=function(t){return this.manipulate("hsl",function(e,r,n){return[e,r,n=Object(u.clamp)(n-t,0,100)]})},e.prototype.saturate=function(t){return this.manipulate("hsl",function(e,r,n){return[e,r=Object(u.clamp)(r+t,0,100),n]})},e.prototype.desaturate=function(t){return this.manipulate("hsl",function(e,r,n){return[e,r=Object(u.clamp)(r-t,0,100),n]})},e.prototype.grayscale=function(){return this.manipulate("hsl",function(t,e,r){return[t,0,r]})},e.prototype.whiten=function(t){var e=this;return this.manipulate("hwb",function(r,n,o){return e.resolveHwb(r,Object(u.clamp)(n+t,0,100),o)})},e.prototype.blacken=function(t){var e=this;return this.manipulate("hwb",function(r,n,o){return e.resolveHwb(r,n,Object(u.clamp)(o+t,0,100))})},e.prototype.rotate=function(t){return this.manipulate("hsl",function(e,r,n){return[Object(u.degree)(e+t),r,n]})},e.prototype.mix=function(t,r){void 0===r&&(r=50),r/=100;var n=this.getModel(),o=this.getColorAs("rgb"),a=t.getColorAs("rgb");return new e({model:"rgb",values:o.values.map(function(t,e){return t+(a.values[e]-t)*r}),alpha:o.alpha+(a.alpha-o.alpha)*r}).changeModel(n)},e.prototype.complement=function(){return this.manipulate("hsl",function(t,e,r){return[Object(u.degree)(t+180),e,r]})},e.prototype.invert=function(t){void 0===t&&(t=100),t/=100;return this.manipulate("rgb",function(e,r,n){return[e,r,n].map(function(e){return function(t){return Math.round(Math.abs(t))}(255*t-e)})})},e.prototype.manipulate=function(t,e){var r=this.color.model,n=this.getColorAs(t);return n.values=e.apply(void 0,n.values),this.setColor(n).changeModel(r)},e}(o.default);e.default=c},"./src/util/util.ts": | ||
/*!**************************!*\ | ||
@@ -28,0 +28,0 @@ !*** ./src/util/util.ts ***! |
{ | ||
"name": "moo-color", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "A simple color library.", | ||
@@ -34,11 +34,11 @@ "main": "dist/moo-color.js", | ||
"@types/color-name": "^1.1.0", | ||
"@types/jest": "^23.0.0", | ||
"jest": "^23.1.0", | ||
"@types/jest": "^23.3.0", | ||
"jest": "^23.4.1", | ||
"source-map-loader": "^0.2.3", | ||
"ts-jest": "^22.4.6", | ||
"ts-loader": "^4.4.1", | ||
"typescript": "^2.9.1", | ||
"webpack": "^4.12.0", | ||
"webpack-cli": "^3.0.3", | ||
"webpack-merge": "^4.1.2", | ||
"ts-jest": "^23.0.1", | ||
"ts-loader": "^4.4.2", | ||
"typescript": "^2.9.2", | ||
"webpack": "^4.16.2", | ||
"webpack-cli": "^3.1.0", | ||
"webpack-merge": "^4.1.3", | ||
"webpack-notifier": "^1.6.0" | ||
@@ -45,0 +45,0 @@ }, |
Sorry, the diff of this file is not supported yet
227117
0.01%