Comparing version 1.0.1 to 1.0.2
@@ -18,3 +18,4 @@ { | ||
"parserOptions": { | ||
"ecmaVersion": 2018 | ||
"ecmaVersion": 2018, | ||
"sourceType": "module" | ||
}, | ||
@@ -25,3 +26,5 @@ "plugins": [ | ||
"rules": { | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/no-unused-vars": "error" | ||
} | ||
} | ||
} |
@@ -10,2 +10,7 @@ # Changelog | ||
## [1.0.2] - 2019-12-31 | ||
- Refined some regex. (073832a8ef0a74503cc30cfe89489fbefbc1d160) | ||
- Update docs. (6ebd08963b19bc8a0fceb062d17a11fe7eb70144) | ||
## [1.0.0] - 2019-10-17 | ||
@@ -58,3 +63,4 @@ | ||
[Unreleased]: https://github.com/archco/moo-color/compare/v1.0.0...HEAD | ||
[Unreleased]: https://github.com/archco/moo-color/compare/v1.0.2...HEAD | ||
[1.0.2]: https://github.com/archco/moo-color/compare/v1.0.0...v1.0.2 | ||
[1.0.0]: https://github.com/archco/moo-color/compare/v0.2.2...v1.0.0 | ||
@@ -61,0 +67,0 @@ [0.2.2]: https://github.com/archco/moo-color/compare/v0.2.0...v0.2.2 |
@@ -904,5 +904,5 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var shortHex = /^#?([a-f0-9]{3})([a-f0-9]{1})?$/i; | ||
var rgba = /^rgba?\s*\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/; | ||
var rgba = /^rgba?\s*\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/; | ||
// tslint:disable-next-line:max-line-length | ||
var percent = /^rgba?\s*\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/; | ||
var percent = /^rgba?\s*\(\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/; | ||
var hexToAlpha = function (num) { return Math.round((parseInt(num, 16) / 255) * 100) / 100; }; | ||
@@ -942,3 +942,3 @@ var values; | ||
// tslint:disable-next-line:max-line-length | ||
var hsl = /^hsla?\s*\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i; | ||
var hsl = /^hsla?\s*\(\s*([+-]?\d*[.]?\d+)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/i; | ||
if (hsl.test(input)) { | ||
@@ -962,3 +962,3 @@ var _a = input.match(hsl), h = _a[1], s = _a[2], l = _a[3], a = _a[4]; | ||
// tslint:disable-next-line:max-line-length | ||
var hwb = /^hwba?\s*\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i; | ||
var hwb = /^hwba?\s*\(\s*([+-]?\d*[.]?\d+)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/i; | ||
if (hwb.test(input)) { | ||
@@ -978,3 +978,3 @@ var _a = input.match(hwb), h = _a[1], w = _a[2], b = _a[3], a = _a[4]; | ||
// tslint:disable-next-line:max-line-length | ||
var hsv = /^hsva?\s*\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i; | ||
var hsv = /^hsva?\s*\(\s*([+-]?\d*[.]?\d+)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/i; | ||
if (hsv.test(input)) { | ||
@@ -998,3 +998,3 @@ var _a = input.match(hsv), h = _a[1], s = _a[2], v = _a[3], a = _a[4]; | ||
// tslint:disable-next-line:max-line-length | ||
var cmyk = /^cmyk\s*\(\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i; | ||
var cmyk = /^cmyk\s*\(\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/i; | ||
if (cmyk.test(input)) { | ||
@@ -1001,0 +1001,0 @@ var _a = input.match(cmyk), c = _a[1], m = _a[2], y = _a[3], k = _a[4], a = _a[5]; |
@@ -21,3 +21,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: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return u}));var n=r(/*! ./color-converter */"./src/color-converter.ts"),o=r(/*! ./color-names */"./src/color-names.ts"),a=r(/*! ./util/util */"./src/util/util.ts");function u(t){if(t in o.default)return{model:"rgb",values:o.default[t],alpha:1};if("transparent"===t)return{model:"rgb",values:[0,0,0],alpha:0};switch(t.substr(0,3).toLowerCase()){case"hwb":return function(t){var e=/^hwba?\s*\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i;if(e.test(t)){var r=t.match(e),o=r[1],u=r[2],s=r[3],c=r[4];return{model:"hwb",values:Object(n.resolveHwb)(Object(a.degree)(o),Object(a.clamp)(parseFloat(u),0,100),Object(a.clamp)(parseFloat(s),0,100)),alpha:Object(a.resolveAlpha)(c)}}return null}(t);case"hsl":return function(t){var e=/^hsla?\s*\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i;if(e.test(t)){var r=t.match(e),n=r[1],o=r[2],u=r[3],s=r[4];return{model:"hsl",values:[Object(a.degree)(n),Object(a.clamp)(parseFloat(o),0,100),Object(a.clamp)(parseFloat(u),0,100)],alpha:Object(a.resolveAlpha)(s)}}return null}(t);case"hsv":return function(t){var e=/^hsva?\s*\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i;if(e.test(t)){var r=t.match(e),n=r[1],o=r[2],u=r[3],s=r[4];return{model:"hsv",values:[Object(a.degree)(n),Object(a.clamp)(parseFloat(o),0,100),Object(a.clamp)(parseFloat(u),0,100)],alpha:Object(a.resolveAlpha)(s)}}return null}(t);case"cmy":return function(t){var e=/^cmyk\s*\(\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i;if(e.test(t)){var r=t.match(e),n=r[1],o=r[2],u=r[3],s=r[4],c=r[5];return{model:"cmyk",values:[Object(a.clamp)(parseFloat(n),0,100),Object(a.clamp)(parseFloat(o),0,100),Object(a.clamp)(parseFloat(u),0,100),Object(a.clamp)(parseFloat(s),0,100)],alpha:Object(a.resolveAlpha)(c)}}return null}(t);default:return function(t){var e,r,n=/^#?([a-f0-9]{6})([a-f0-9]{2})?$/i,o=/^#?([a-f0-9]{3})([a-f0-9]{1})?$/i,u=/^rgba?\s*\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/,s=/^rgba?\s*\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/,c=function(t){return Math.round(parseInt(t,16)/255*100)/100};if(n.test(t)){var i=t.match(n),l=i[1],h=i[2];e=l.match(/.{2}/g).map((function(t){return parseInt(t,16)})),r=h?c(h):1}else if(o.test(t)){var p=t.match(o);l=p[1],h=p[2];e=l.match(/.{1}/g).map((function(t){return parseInt(t+t,16)})),r=h?c(h):1}else if(u.test(t)){var f=t.match(u),d=f[1],b=f[2],m=f[3];h=f[4];e=[d,b,m].map((function(t){return parseInt(t,0)})),r=Object(a.resolveAlpha)(h)}else{if(!s.test(t))return null;var g=t.match(s);d=g[1],b=g[2],m=g[3],h=g[4];e=[d,b,m].map((function(t){return Math.round(2.55*parseFloat(t))})),r=Object(a.resolveAlpha)(h)}return{model:"rgb",values:e.map((function(t){return Object(a.clamp)(t,0,255)})),alpha:Object(a.clamp)(r,0,1)}}(t)}}},"./src/moo-color.ts": | ||
/*! exports provided: default */function(t,e,r){"use strict";r.r(e),r.d(e,"default",(function(){return u}));var n=r(/*! ./color-converter */"./src/color-converter.ts"),o=r(/*! ./color-names */"./src/color-names.ts"),a=r(/*! ./util/util */"./src/util/util.ts");function u(t){if(t in o.default)return{model:"rgb",values:o.default[t],alpha:1};if("transparent"===t)return{model:"rgb",values:[0,0,0],alpha:0};switch(t.substr(0,3).toLowerCase()){case"hwb":return function(t){var e=/^hwba?\s*\(\s*([+-]?\d*[.]?\d+)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/i;if(e.test(t)){var r=t.match(e),o=r[1],u=r[2],s=r[3],c=r[4];return{model:"hwb",values:Object(n.resolveHwb)(Object(a.degree)(o),Object(a.clamp)(parseFloat(u),0,100),Object(a.clamp)(parseFloat(s),0,100)),alpha:Object(a.resolveAlpha)(c)}}return null}(t);case"hsl":return function(t){var e=/^hsla?\s*\(\s*([+-]?\d*[.]?\d+)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/i;if(e.test(t)){var r=t.match(e),n=r[1],o=r[2],u=r[3],s=r[4];return{model:"hsl",values:[Object(a.degree)(n),Object(a.clamp)(parseFloat(o),0,100),Object(a.clamp)(parseFloat(u),0,100)],alpha:Object(a.resolveAlpha)(s)}}return null}(t);case"hsv":return function(t){var e=/^hsva?\s*\(\s*([+-]?\d*[.]?\d+)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/i;if(e.test(t)){var r=t.match(e),n=r[1],o=r[2],u=r[3],s=r[4];return{model:"hsv",values:[Object(a.degree)(n),Object(a.clamp)(parseFloat(o),0,100),Object(a.clamp)(parseFloat(u),0,100)],alpha:Object(a.resolveAlpha)(s)}}return null}(t);case"cmy":return function(t){var e=/^cmyk\s*\(\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/i;if(e.test(t)){var r=t.match(e),n=r[1],o=r[2],u=r[3],s=r[4],c=r[5];return{model:"cmyk",values:[Object(a.clamp)(parseFloat(n),0,100),Object(a.clamp)(parseFloat(o),0,100),Object(a.clamp)(parseFloat(u),0,100),Object(a.clamp)(parseFloat(s),0,100)],alpha:Object(a.resolveAlpha)(c)}}return null}(t);default:return function(t){var e,r,n=/^#?([a-f0-9]{6})([a-f0-9]{2})?$/i,o=/^#?([a-f0-9]{3})([a-f0-9]{1})?$/i,u=/^rgba?\s*\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/,s=/^rgba?\s*\(\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/,c=function(t){return Math.round(parseInt(t,16)/255*100)/100};if(n.test(t)){var i=t.match(n),l=i[1],h=i[2];e=l.match(/.{2}/g).map((function(t){return parseInt(t,16)})),r=h?c(h):1}else if(o.test(t)){var p=t.match(o);l=p[1],h=p[2];e=l.match(/.{1}/g).map((function(t){return parseInt(t+t,16)})),r=h?c(h):1}else if(u.test(t)){var f=t.match(u),d=f[1],b=f[2],m=f[3];h=f[4];e=[d,b,m].map((function(t){return parseInt(t,0)})),r=Object(a.resolveAlpha)(h)}else{if(!s.test(t))return null;var g=t.match(s);d=g[1],b=g[2],m=g[3],h=g[4];e=[d,b,m].map((function(t){return Math.round(2.55*parseFloat(t))})),r=Object(a.resolveAlpha)(h)}return{model:"rgb",values:e.map((function(t){return Object(a.clamp)(t,0,255)})),alpha:Object(a.clamp)(r,0,1)}}(t)}}},"./src/moo-color.ts": | ||
/*!**************************!*\ | ||
@@ -24,0 +24,0 @@ !*** ./src/moo-color.ts ***! |
@@ -34,11 +34,11 @@ # Formatter | ||
- Syntax | ||
Syntax | ||
``` js | ||
const str = mooColor.toString(model = '', ...args); | ||
``` | ||
``` ts | ||
mooColor.toString(model?: string, ...args?: any[]): string; | ||
``` | ||
- Param `string` model - Specify color model. If not specifying this value, then returns current color model. `rgb`|`hwb`|`hsl`|`hsv`|`cmyk`|`hex` | ||
- Param `...any[]` args - Arguments for the represent methods. | ||
- Returns `string` | ||
- @param `string` model - Specify color model. If not specifying this value, then returns current color model. `rgb`|`hwb`|`hsl`|`hsv`|`cmyk`|`hex` | ||
- @param `...any[]` args - Arguments for the represent methods. | ||
- @returns `string` | ||
@@ -49,10 +49,10 @@ ### toHex | ||
- Syntax | ||
Syntax | ||
``` js | ||
const str = mooColor.toHex(mode = 'full'); | ||
``` | ||
``` ts | ||
mooColor.toHex(mode?: HexMode): string; | ||
``` | ||
- Param [`HexMode`](#hex-mode) [mode = 'full'] - `full`|`short`|`name` | ||
- Returns `string` - e.g. `#ff0000` or `#f00` or `red` | ||
- @param [`HexMode`](#hex-mode) [mode = 'full'] - `full`|`short`|`name` | ||
- @returns `string` - e.g. `#ff0000` or `#f00` or `red` | ||
@@ -63,10 +63,10 @@ ### toRgb | ||
- Syntax | ||
Syntax | ||
``` js | ||
const str = mooColor.toRgb(mode = 'default'); | ||
``` | ||
``` ts | ||
mooColor.toRgb(mode?: RgbMode): string; | ||
``` | ||
- Param [`RgbMode`](#rgb-mode) [mode = 'default'] - `default`|`percent` | ||
- Returns `string` - e.g. `rgb(255, 0, 0)` or `rgb(100%, 0%, 0%)` | ||
- @param [`RgbMode`](#rgb-mode) [mode = 'default'] - `default`|`percent` | ||
- @returns `string` - e.g. `rgb(255, 0, 0)` or `rgb(100%, 0%, 0%)` | ||
@@ -77,9 +77,9 @@ ### toHwb | ||
- Syntax | ||
Syntax | ||
``` js | ||
const str = mooColor.toHwb(); | ||
``` | ||
``` ts | ||
mooColor.toHwb(): string; | ||
``` | ||
- Returns `string` - e.g. `hwb(0, 0%, 0%)` | ||
- @returns `string` - e.g. `hwb(0, 0%, 0%)` | ||
@@ -90,9 +90,9 @@ ### toHsl | ||
- Syntax | ||
Syntax | ||
``` js | ||
const str = mooColor.toHsl(); | ||
``` | ||
``` ts | ||
mooColor.toHsl(): string; | ||
``` | ||
- Returns `string` - e.g. `hsl(0, 100%, 50%)` | ||
- @returns `string` - e.g. `hsl(0, 100%, 50%)` | ||
@@ -103,9 +103,9 @@ ### toHsv | ||
- Syntax | ||
Syntax | ||
``` js | ||
const str = mooColor.toHsv(); | ||
``` | ||
``` ts | ||
mooColor.toHsv(): string; | ||
``` | ||
- Returns `string` - e.g. `hsv(0, 100%, 100%)` | ||
- @returns `string` - e.g. `hsv(0, 100%, 100%)` | ||
@@ -116,8 +116,8 @@ ### toCmyk | ||
- Syntax | ||
Syntax | ||
``` js | ||
const str = mooColor.toCmyk(); | ||
``` | ||
``` ts | ||
mooColor.toCmyk(): string; | ||
``` | ||
- Returns `string` - e.g. `cmyk(0%, 100%, 100%, 0%)` | ||
- @returns `string` - e.g. `cmyk(0%, 100%, 100%, 0%)` |
@@ -9,10 +9,10 @@ # Modification | ||
- Syntax | ||
Syntax | ||
``` js | ||
mooColor.lighten(amount); | ||
``` | ||
``` ts | ||
mooColor.lighten(amount: number): this; | ||
``` | ||
- Param `number` amount - The amount from 0 to 100. | ||
- Returns `this` | ||
- @param `number` amount - The amount from 0 to 100. | ||
- @returns `this` | ||
@@ -23,10 +23,10 @@ ### darken | ||
- Syntax | ||
Syntax | ||
``` js | ||
mooColor.darken(amount); | ||
``` | ||
``` ts | ||
mooColor.darken(amount: number): this; | ||
``` | ||
- Param `number` amount - The amount from 0 to 100. | ||
- Returns `this` | ||
- @param `number` amount - The amount from 0 to 100. | ||
- @returns `this` | ||
@@ -37,10 +37,10 @@ ### saturate | ||
- Syntax | ||
Syntax | ||
``` js | ||
mooColor.saturate(amount); | ||
``` | ||
``` ts | ||
mooColor.saturate(amount: number): this; | ||
``` | ||
- Param `number` amount - The amount from 0 to 100. | ||
- Returns `this` | ||
- @param `number` amount - The amount from 0 to 100. | ||
- @returns `this` | ||
@@ -51,10 +51,10 @@ ### desaturate | ||
- Syntax | ||
Syntax | ||
``` js | ||
mooColor.desaturate(amount); | ||
``` | ||
``` ts | ||
mooColor.desaturate(amount: number): this; | ||
``` | ||
- Param `number` amount - The amount from 0 to 100. | ||
- Returns `this` | ||
- @param `number` amount - The amount from 0 to 100. | ||
- @returns `this` | ||
@@ -65,9 +65,9 @@ ### grayscale | ||
- Syntax | ||
Syntax | ||
``` js | ||
mooColor.grayscale(); | ||
``` | ||
``` ts | ||
mooColor.grayscale(): this; | ||
``` | ||
- Returns `this` | ||
- @returns `this` | ||
@@ -78,10 +78,10 @@ ### whiten | ||
- Syntax | ||
Syntax | ||
``` js | ||
mooColor.whiten(amount); | ||
``` | ||
``` ts | ||
mooColor.whiten(amount: number): this; | ||
``` | ||
- Param `number` amount - The amount from -100 to 100. | ||
- Returns `this` | ||
- @param `number` amount - The amount from -100 to 100. | ||
- @returns `this` | ||
@@ -92,10 +92,10 @@ ### blacken | ||
- Syntax | ||
Syntax | ||
``` js | ||
mooColor.blacken(amount); | ||
``` | ||
``` ts | ||
mooColor.blacken(amount: number): this; | ||
``` | ||
- Param `number` amount - The amount from -100 to 100. | ||
- Returns `this` | ||
- @param `number` amount - The amount from -100 to 100. | ||
- @returns `this` | ||
@@ -106,10 +106,10 @@ ### rotate | ||
- Syntax | ||
Syntax | ||
``` js | ||
mooColor.rotate(degree); | ||
``` | ||
``` ts | ||
mooColor.rotate(degree: number): this; | ||
``` | ||
- Param `number` degree - The degree value from 0 to 360. | ||
- Returns `this` | ||
- @param `number` degree - The degree value from 0 to 360. | ||
- @returns `this` | ||
@@ -120,11 +120,11 @@ ### mix | ||
- Syntax | ||
Syntax | ||
``` js | ||
const mixedColor = mooColor.mix(color, percent = 50); | ||
``` | ||
``` ts | ||
const mixedColor = mooColor.mix(color: MooColor, percent?: number): MooColor; | ||
``` | ||
- Param `MooColor` color - The color to mixed. | ||
- Param `number` [percent = 50] - The percentage value of color to be mixed. | ||
- Returns `MooColor` - The mixed color that as a new instance of `MooColor`. | ||
- @param `MooColor` color - The color to mixed. | ||
- @param `number` [percent = 50] - The percentage value of color to be mixed. | ||
- @returns `MooColor` - The mixed color that as a new instance of `MooColor`. | ||
@@ -135,9 +135,9 @@ ### complement | ||
- Syntax | ||
Syntax | ||
``` js | ||
mooColor.complement(); | ||
``` | ||
``` ts | ||
mooColor.complement(): this; | ||
``` | ||
- Returns `this` | ||
- @returns `this` | ||
@@ -148,9 +148,9 @@ ### invert | ||
- Syntax | ||
Syntax | ||
``` js | ||
mooColor.invert(); | ||
``` | ||
``` ts | ||
mooColor.invert(percent?: number): this; | ||
``` | ||
- Param `number` [percent = 100] - The relative percent of the color that inverse. | ||
- Returns `this` | ||
- @param `number` [percent = 100] - The relative percent of the color that inverse. | ||
- @returns `this` |
@@ -18,10 +18,10 @@ # MooColor API | ||
- Syntax | ||
Syntax | ||
``` js | ||
const color = new MooColor(str = ''); | ||
``` | ||
``` js | ||
const color = new MooColor(str = ''); | ||
``` | ||
- Param `string` str - [parsable color string](#parsable-color-string). If not specify this value, then color set to `#000` (black). | ||
- Return `MooColor` - Instance of `MooColor` | ||
- @param `string` str - [parsable color string](#parsable-color-string). If not specify this value, then color set to `#000` (black). | ||
- @returns `MooColor` - Instance of `MooColor` | ||
@@ -57,19 +57,19 @@ ### Parsable color string | ||
- [setColor](setter.md#setcolor): Set color data. | ||
- [getColor](setter.md#getcolor): Get color data. | ||
- [getColorAs](setter.md#getcoloras): Get color data as specific color model. | ||
- [getModel](setter.md#getmodel): Get color model name. | ||
- [changeModel](setter.md#changemodel): Converts color data to given color model. | ||
- [getAlpha](setter.md#getalpha): Get alpha value from `Color`. | ||
- [setAlpha](setter.md#setalpha): Set alpha value to `Color`. | ||
- [setColor](setter.md#setColor): Set color data. | ||
- [getColor](setter.md#getColor): Get color data. | ||
- [getColorAs](setter.md#getColorAs): Get color data as specific color model. | ||
- [getModel](setter.md#getModel): Get color model name. | ||
- [changeModel](setter.md#changeModel): Converts color data to given color model. | ||
- [getAlpha](setter.md#getAlpha): Get alpha value from `Color`. | ||
- [setAlpha](setter.md#setAlpha): Set alpha value to `Color`. | ||
## [Formatter](formatter.md) | ||
- [toString](formatter.md#tostring): Represents color as notation of specific color model. | ||
- [toHex](formatter.md#tohex): Represents color as HEX notation. | ||
- [toRgb](formatter.md#torgb): Represents color as RGB notation. | ||
- [toHwb](formatter.md#tohwb): Represents color as HWB notation. | ||
- [toHsl](formatter.md#tohsl): Represents color as HSL notation. | ||
- [toHsv](formatter.md#tohsv): Represents color as HSV notation. This format is similar to HSL. | ||
- [toCmyk](formatter.md#tocmyk): Represents color as CMYK notation. | ||
- [toString](formatter.md#toString): Represents color as notation of specific color model. | ||
- [toHex](formatter.md#toHex): Represents color as HEX notation. | ||
- [toRgb](formatter.md#toRgb): Represents color as RGB notation. | ||
- [toHwb](formatter.md#toHwb): Represents color as HWB notation. | ||
- [toHsl](formatter.md#toHsl): Represents color as HSL notation. | ||
- [toHsv](formatter.md#toHsv): Represents color as HSV notation. This format is similar to HSL. | ||
- [toCmyk](formatter.md#toCmyk): Represents color as CMYK notation. | ||
@@ -79,7 +79,7 @@ ## [State access](state-access.md) | ||
- [brightness](state-access.md#brightness): `readonly` Returns color brightness from 0 to 255. | ||
- [isLight](state-access.md#islight): `readonly` Returns whether color is light or not. | ||
- [isDark](state-access.md#isdark): `readonly` Returns whether color is dark or not. | ||
- [isLight](state-access.md#isLight): `readonly` Returns whether color is light or not. | ||
- [isDark](state-access.md#isDark): `readonly` Returns whether color is dark or not. | ||
- [luminance](state-access.md#luminance): `readonly` Returns luminance value of the color. range from 0 to 1. | ||
- [contrastRatioWith](state-access.md#contrastratiowith): Returns contrast ratio with other color. range from 0 to 21. | ||
- [isContrastEnough](state-access.md#iscontrastenough): Return true if contrast ratio >= 4.5 | ||
- [contrastRatioWith](state-access.md#contrastRatioWith): Returns contrast ratio with other color. range from 0 to 21. | ||
- [isContrastEnough](state-access.md#isContrastEnough): Return true if contrast ratio >= 4.5 | ||
@@ -86,0 +86,0 @@ ## [Modification](modification.md) |
@@ -24,10 +24,10 @@ # Setter | ||
- Syntax | ||
Syntax | ||
``` js | ||
mooColor.setColor(color); | ||
``` | ||
``` ts | ||
mooColor.setColor(color: Color): this; | ||
``` | ||
- Param `Color` color - [Color data](#color-data) | ||
- Returns `this` | ||
- @param `Color` color - [Color data](#color-data) | ||
- @returns `this` | ||
@@ -38,9 +38,9 @@ ### getColor | ||
- Syntax | ||
Syntax | ||
``` js | ||
const color = mooColor.getColor(); | ||
``` | ||
``` ts | ||
mooColor.getColor(): Color; | ||
``` | ||
- Returns `Color` - [Color data](#color-data) | ||
- @returns `Color` - [Color data](#color-data) | ||
@@ -51,10 +51,10 @@ ### getColorAs | ||
- Syntax | ||
Syntax | ||
``` js | ||
const color = mooColor.getColorAs(model); | ||
``` | ||
``` ts | ||
mooColor.getColorAs(model: string): Color; | ||
``` | ||
- Param `string` model - accepted model name. `rgb`|`hwb`|`hsl`|`hsv`|`cmyk` | ||
- Returns `Color` - [Color data](#color-data) | ||
- @param `string` model - accepted model name. `rgb`|`hwb`|`hsl`|`hsv`|`cmyk` | ||
- @returns `Color` - [Color data](#color-data) | ||
@@ -65,9 +65,9 @@ ### getModel | ||
- Syntax | ||
Syntax | ||
``` js | ||
const model = mooColor.getModel(); | ||
``` | ||
``` ts | ||
mooColor.getModel(): string; | ||
``` | ||
- Returns `string` - model name. `rgb`|`hwb`|`hsl`|`hsv`|`cmyk` | ||
- @returns `string` - model name. `rgb`|`hwb`|`hsl`|`hsv`|`cmyk` | ||
@@ -78,10 +78,10 @@ ### changeModel | ||
- Syntax | ||
Syntax | ||
``` js | ||
mooColor.changeModel(model); | ||
``` | ||
``` ts | ||
mooColor.changeModel(model: string): this; | ||
``` | ||
- Param `string` model - accepted model name. `rgb`|`hwb`|`hsl`|`hsv`|`cmyk` | ||
- Returns `this` | ||
- @param `string` model - accepted model name. `rgb`|`hwb`|`hsl`|`hsv`|`cmyk` | ||
- @returns `this` | ||
@@ -92,9 +92,9 @@ ### getAlpha | ||
- Syntax | ||
Syntax | ||
``` js | ||
const alpha = mooColor.getAlpha(); | ||
``` | ||
``` ts | ||
mooColor.getAlpha(): number; | ||
``` | ||
- Returns `number` - alpha value from 0 to 1. | ||
- @returns `number` - alpha value from 0 to 1. | ||
@@ -105,9 +105,9 @@ ### setAlpha | ||
- Syntax | ||
Syntax | ||
``` js | ||
mooColor.setAlpha(alpha); | ||
``` | ||
``` ts | ||
mooColor.setAlpha(alpha: number): this; | ||
``` | ||
- Param `number` alpha - alpha value from 0 to 1. | ||
- Returns `this` | ||
- @param `number` alpha - alpha value from 0 to 1. | ||
- @returns `this` |
@@ -11,9 +11,9 @@ # State access | ||
- Syntax | ||
Syntax | ||
``` js | ||
const val = mooColor.brightness; | ||
``` | ||
``` ts | ||
mooColor.brightness: number; | ||
``` | ||
- Returns `number` - 0-255 | ||
- @returns `number` - 0-255 | ||
@@ -24,9 +24,9 @@ ### isLight | ||
- Syntax | ||
Syntax | ||
``` js | ||
const bool = mooColor.isLight; | ||
``` | ||
``` ts | ||
mooColor.isLight: boolean; | ||
``` | ||
- Returns `boolean` | ||
- @returns `boolean` | ||
@@ -37,9 +37,9 @@ ### isDark | ||
- Syntax | ||
Syntax | ||
``` js | ||
const bool = mooColor.isDark; | ||
``` | ||
``` ts | ||
mooColor.isDark: boolean; | ||
``` | ||
- Returns `boolean` | ||
- @returns `boolean` | ||
@@ -52,9 +52,9 @@ ### luminance | ||
- Syntax | ||
Syntax | ||
``` js | ||
const val = mooColor.luminance; | ||
``` | ||
``` ts | ||
mooColor.luminance: number; | ||
``` | ||
- Returns `number` - 0 to 1. | ||
- @returns `number` - 0 to 1. | ||
@@ -69,10 +69,10 @@ ## Methods | ||
- Syntax | ||
Syntax | ||
``` js | ||
const ratio = mooColor.contrastRatioWith(color); | ||
``` | ||
``` ts | ||
mooColor.contrastRatioWith(color: Color): number; | ||
``` | ||
- Param [`Color`](setter.md#color-data) color - The target color for compare. | ||
- Returns `number` - 0 to 21. | ||
- @param [`Color`](setter.md#color-data) color - The target color for compare. | ||
- @returns `number` - 0 to 21. | ||
@@ -85,9 +85,9 @@ ### isContrastEnough | ||
- Syntax | ||
Syntax | ||
``` js | ||
const bool = mooColor.isContrastEnough(color); | ||
``` | ||
``` ts | ||
mooColor.isContrastEnough(color: Color): boolean; | ||
``` | ||
- Param [`Color`](setter.md#color-data) color - The target color for compare. | ||
- Returns `boolean` | ||
- @param [`Color`](setter.md#color-data) color - The target color for compare. | ||
- @returns `boolean` |
@@ -27,13 +27,31 @@ # Static | ||
- Syntax | ||
Syntax | ||
``` js | ||
const mixedColor = MooColor.mix(color1, color2, percentOf1 = 50); | ||
``` | ||
``` ts | ||
MooColor.mix( | ||
color1: MooColor|string|Color, | ||
color2: MooColor|string|Color, | ||
percentOf1?: number | ||
): MooColor; | ||
``` | ||
- Param `MooColor|string|Color` color1 | ||
- Param `MooColor|string|Color` color2 | ||
- Param `number` [percentOf1=50] - percentage of the first color. | ||
- Returns `MooColor` - mixed color. | ||
- @param `MooColor|string|Color` color1 | ||
- @param `MooColor|string|Color` color2 | ||
- @param `number` [percentOf1=50] - percentage of the first color. | ||
- @returns `MooColor` - mixed color. | ||
Examples | ||
``` js | ||
const color1 = new MooColor('#f00'); | ||
const color2 = new MooColor('#f80'); | ||
const mixedColor = MooColor.mix(color1, color2); | ||
// or simply | ||
const newColor = MooColor.mix('#f00', '#f80'); | ||
// If you want to getting mixed as unbalanced, use `percentOf1` parameter. | ||
const myColor = MooColor.mix('green', 'blue', 75); | ||
``` | ||
### random | ||
@@ -43,23 +61,23 @@ | ||
- Syntax | ||
Syntax | ||
``` js | ||
const randomColor = MooColor.random({ hue, white, black } = {}); | ||
``` | ||
``` ts | ||
MooColor.random(arg?: RandomArguments): MooColor; | ||
``` | ||
- Param [`RandomArguments`](#randomarguments) [{ hue, white, black } = {}] | ||
- @param [`RandomArguments`](#randomArguments) [{ hue, white, black } = {}] | ||
- `hue` - The hue value from 0 to 360. Also you can give this as range. e.g. [0, 180] | ||
- `white` - The whiteness value from 0 to 100. Also you can give this as range. e.g. [0, 50] | ||
- `black` - The blackness value from 0 to 100. Also you can give this as range. e.g. [0, 50] | ||
- Returns `MooColor` | ||
- @returns `MooColor` | ||
### Examples | ||
Examples | ||
``` js | ||
// Make random color. (default) | ||
const color1 = MooColor.random(); | ||
// Make random color that specify whiteness and blackness values. | ||
const color2 = MooColor.random({ white: 0, black: 50 }); | ||
// Make random color that range between red and yellow (hue value from 0 to 60). | ||
const color3 = MooColor.random({ hue: [0, 60] }); | ||
``` | ||
``` js | ||
// Make random color. (default) | ||
const color1 = MooColor.random(); | ||
// Make random color that specify whiteness and blackness values. | ||
const color2 = MooColor.random({ white: 0, black: 50 }); | ||
// Make random color that range between red and yellow (hue value from 0 to 60). | ||
const color3 = MooColor.random({ hue: [0, 60] }); | ||
``` |
{ | ||
"name": "moo-color", | ||
"version": "1.0.1", | ||
"description": "The simple javascript library that provides convenient methods for color parsing and manipulation.", | ||
"version": "1.0.2", | ||
"description": "A javascript class that provides convenience for color parsing and manipulating.", | ||
"main": "dist/moo-color.js", | ||
@@ -34,6 +34,6 @@ "types": "types/moo-color.d.ts", | ||
"@types/color-name": "^1.1.1", | ||
"@types/jest": "^24.0.23", | ||
"@typescript-eslint/eslint-plugin": "^2.11.0", | ||
"@typescript-eslint/parser": "^2.11.0", | ||
"eslint": "^6.7.2", | ||
"@types/jest": "^24.0.25", | ||
"@typescript-eslint/eslint-plugin": "^2.14.0", | ||
"@typescript-eslint/parser": "^2.14.0", | ||
"eslint": "^6.8.0", | ||
"jest": "^24.9.0", | ||
@@ -43,4 +43,4 @@ "source-map-loader": "^0.2.4", | ||
"ts-loader": "^6.2.1", | ||
"typescript": "^3.7.3", | ||
"webpack": "^4.41.2", | ||
"typescript": "^3.7.4", | ||
"webpack": "^4.41.5", | ||
"webpack-cli": "^3.3.10", | ||
@@ -47,0 +47,0 @@ "webpack-merge": "^4.2.2", |
@@ -7,3 +7,3 @@ # MooColor | ||
The simple javascript library that provides convenient methods for color parsing and manipulation. | ||
A javascript class that provides convenience for color parsing and manipulating. | ||
@@ -10,0 +10,0 @@ ## Install |
@@ -37,5 +37,5 @@ import { Color } from './color'; | ||
const shortHex = /^#?([a-f0-9]{3})([a-f0-9]{1})?$/i; | ||
const rgba = /^rgba?\s*\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/; | ||
const rgba = /^rgba?\s*\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/; | ||
// tslint:disable-next-line:max-line-length | ||
const percent = /^rgba?\s*\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/; | ||
const percent = /^rgba?\s*\(\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/; | ||
const hexToAlpha = (num: string) => Math.round((parseInt(num, 16) / 255) * 100) / 100; | ||
@@ -73,3 +73,3 @@ let values: number[]; | ||
// tslint:disable-next-line:max-line-length | ||
const hsl = /^hsla?\s*\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i; | ||
const hsl = /^hsla?\s*\(\s*([+-]?\d*[.]?\d+)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/i; | ||
@@ -94,3 +94,3 @@ if (hsl.test(input)) { | ||
// tslint:disable-next-line:max-line-length | ||
const hwb = /^hwba?\s*\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i; | ||
const hwb = /^hwba?\s*\(\s*([+-]?\d*[.]?\d+)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/i; | ||
@@ -115,3 +115,3 @@ if (hwb.test(input)) { | ||
// tslint:disable-next-line:max-line-length | ||
const hsv = /^hsva?\s*\(\s*([+-]?\d*[\.]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i; | ||
const hsv = /^hsva?\s*\(\s*([+-]?\d*[.]?\d+)(?:deg)?\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/i; | ||
@@ -136,3 +136,3 @@ if (hsv.test(input)) { | ||
// tslint:disable-next-line:max-line-length | ||
const cmyk = /^cmyk\s*\(\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/i; | ||
const cmyk = /^cmyk\s*\(\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*,\s*([+-]?[\d.]+)%\s*(?:,\s*([+-]?[\d.]+)\s*)?\)$/i; | ||
@@ -139,0 +139,0 @@ if (cmyk.test(input)) { |
@@ -13,3 +13,2 @@ import { | ||
clamp, | ||
decimal, | ||
degree, | ||
@@ -16,0 +15,0 @@ getRandom, |
@@ -14,3 +14,6 @@ import { | ||
export { ColorFormatter }; | ||
export { | ||
AcceptedModel, | ||
ColorFormatter, | ||
}; | ||
@@ -17,0 +20,0 @@ type manipulateFn = (...args: number[]) => number[]; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
229368
38
3416