active_frontend 16.1.6 → 16.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e90a2406bcba564eec85d7b8acfd7e482fe8dccc1c2eebc66b88e1450157c48d
4
- data.tar.gz: f705c1fe4d7283de29cab24ae18b137197ab5c3c7e595aceada1a908c7a74bc4
3
+ metadata.gz: ab420a9e6b904ee93686a276f84a3479cc9c0be7b04f9aa17c731199c6301140
4
+ data.tar.gz: 0e56e89daf58a7a5a4e611f8aa0ed38d775269a9c3ae0dea6a2b07c6c6f3ff80
5
5
  SHA512:
6
- metadata.gz: fa5d70cc862a2e4ce84c2be30b68ca7ddcdc22b6ea08c03cc3f10aca0bbbb33fd5b3684f1bc5d6f302cbcbca631b463859b9c28be4fb4d0dde039f5f92f90b4c
7
- data.tar.gz: c3647a4aea92f198d960fd8d9247a85365345d583467998bb38ed75f6253087bf55633fbd3f0218bebcf602ee7e6c2630296dd57a9785f293fa15068f2682f4e
6
+ metadata.gz: 998fb098d3d7f2956dc0b720958ebacaa46b22c6f9ae61e8b0be3a1ef9eb89951221916ca76fb7d7dd8a104a982e32544f1762080399d72e9ef11af22fe8b205
7
+ data.tar.gz: 0ce326f5e72c804832ca650a2e9e452082260412f88e008ae4360f87f14bb120af415e8ffac94d6d0864296cd97a52b7985edfe05cc4ff90af6f00edac101284
data/.DS_Store CHANGED
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveFrontend
4
- VERSION ||= '16.1.6'
4
+ VERSION ||= '16.1.7'
5
5
  end
@@ -11,6 +11,7 @@
11
11
  autoDetect: this.$element.data('auto-detect') || Layout.DEFAULTS.autoDetect,
12
12
  direction: this.$element.data('direction') || Layout.DEFAULTS.direction,
13
13
  effect: this.$element.data('effect') || Layout.DEFAULTS.effect,
14
+ mobileWidth: this.$element.data('mobile-width') || Layout.DEFAULTS.mobileWidth,
14
15
  target: this.$element.data('target') || Layout.DEFAULTS.target
15
16
  };
16
17
  this.options = $.extend({}, Layout.DEFAULTS, this.settings, options);
@@ -28,6 +29,7 @@
28
29
  autoDetect: true,
29
30
  direction: 'left',
30
31
  effect: 'slide',
32
+ mobileWidth: 813,
31
33
  onToggleCallback: function (toggle) {},
32
34
  target: '#layout-target'
33
35
  };
@@ -71,7 +73,7 @@
71
73
 
72
74
  Layout.prototype.togglePosition = function (klass) {
73
75
  var target = $(this.options.target);
74
- var isMobile = this.$window.width() < 767;
76
+ var isMobile = this.$window.width() < this.options.mobileWidth;
75
77
 
76
78
  if (this.options.autoDetect === true) {
77
79
  if (isMobile) {
@@ -59,659 +59,659 @@
59
59
  ({
60
60
  1:[function (require, module, exports) {}, {}],
61
61
  2:[function (require, module, exports) {
62
-
63
- var colorNames = require(6);
64
-
65
- module.exports = {
66
- getRgba: getRgba,
67
- getHsla: getHsla,
68
- getRgb: getRgb,
69
- getHsl: getHsl,
70
- getHwb: getHwb,
71
- getAlpha: getAlpha,
72
- hexString: hexString,
73
- rgbString: rgbString,
74
- rgbaString: rgbaString,
75
- percentString: percentString,
76
- percentaString: percentaString,
77
- hslString: hslString,
78
- hslaString: hslaString,
79
- hwbString: hwbString,
80
- keyword: keyword
81
- };
82
-
83
- function getRgba (string) {
84
- if (!string) return;
85
-
86
- var abbr = /^#([a-fA-F0-9]{3})$/;
87
- var hex = /^#([a-fA-F0-9]{6})$/;
88
- var rgba = /^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
89
- var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
90
- var keyword = /(\w+)/;
91
- var rgb = [0, 0, 0];
92
- var a = 1;
93
- var i = 0;
94
- var match = string.match(abbr);
95
-
96
- if (match) {
97
- match = match[1];
98
-
99
- for (i = 0; i < rgb.length; i++) {
100
- rgb[i] = parseInt(match[i] + match[i], 16);
101
- }
102
- } else if (match = string.match(hex)) {
103
- match = match[1];
104
-
105
- for (i = 0; i < rgb.length; i++) {
106
- rgb[i] = parseInt(match.slice(i * 2, i * 2 + 2), 16);
107
- }
108
- }
109
- else if (match = string.match(rgba)) {
110
- for (i = 0; i < rgb.length; i++) {
111
- rgb[i] = parseInt(match[i + 1]);
112
- }
113
-
114
- a = parseFloat(match[4]);
115
- } else if (match = string.match(per)) {
116
- for (i = 0; i < rgb.length; i++) {
117
- rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
118
- }
119
-
120
- a = parseFloat(match[4]);
121
- } else if (match = string.match(keyword)) {
122
- if (match[1] === 'transparent') return [0, 0, 0, 0];
123
-
124
- rgb = colorNames[match[1]];
125
-
126
- if (!rgb) return;
127
- }
128
-
129
- for (i = 0; i < rgb.length; i++) {
130
- rgb[i] = scale(rgb[i], 0, 255);
131
- }
132
-
133
- if (!a && a !== 0) {
134
- a = 1;
135
- } else {
136
- a = scale(a, 0, 1);
137
- }
138
-
139
- rgb[3] = a;
140
- return rgb;
141
- }
142
-
143
- function getHsla(string) {
144
- if (!string) return;
145
-
146
- var hsl = /^hsla?\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/;
147
- var match = string.match(hsl);
148
-
149
- if (match) {
150
- var alpha = parseFloat(match[4]);
151
- var h = scale(parseInt(match[1]), 0, 360);
152
- var s = scale(parseFloat(match[2]), 0, 100);
153
- var l = scale(parseFloat(match[3]), 0, 100);
154
- var a = scale(isNaN(alpha) ? 1 : alpha, 0, 1);
155
-
156
- return [h, s, l, a];
157
- }
158
- }
159
-
160
- function getHwb(string) {
161
- if (!string) return;
162
-
163
- var hwb = /^hwb\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/;
164
- var match = string.match(hwb);
165
-
166
- if (match) {
167
- var alpha = parseFloat(match[4]);
168
- var h = scale(parseInt(match[1]), 0, 360);
169
- var w = scale(parseFloat(match[2]), 0, 100);
170
- var b = scale(parseFloat(match[3]), 0, 100);
171
- var a = scale(isNaN(alpha) ? 1 : alpha, 0, 1);
172
-
173
- return [h, w, b, a];
174
- }
175
- }
176
-
177
- function getRgb(string) {
178
- var rgba = getRgba(string);
179
-
180
- return rgba && rgba.slice(0, 3);
181
- }
182
-
183
- function getHsl(string) {
184
- var hsla = getHsla(string);
185
-
186
- return hsla && hsla.slice(0, 3);
187
- }
188
-
189
- function getAlpha(string) {
190
- var vals = getRgba(string);
191
-
192
- if (vals) {
193
- return vals[3];
194
- } else if (vals = getHsla(string)) {
195
- return vals[3];
196
- } else if (vals = getHwb(string)) {
197
- return vals[3];
198
- }
199
- }
200
-
201
- function hexString(rgb) {
202
- return "#" +
203
- hexDouble(rgb[0]) +
204
- hexDouble(rgb[1]) +
205
- hexDouble(rgb[2]);
206
- }
207
-
208
- function rgbString(rgba, alpha) {
209
- if (alpha < 1 || (rgba[3] && rgba[3] < 1)) return rgbaString(rgba, alpha);
210
-
211
- return 'rgb(' + rgba[0] + ', ' + rgba[1] + ', ' + rgba[2] + ')';
212
- }
213
-
214
- function rgbaString(rgba, alpha) {
215
- if (alpha === undefined) {
216
- alpha = (rgba[3] !== undefined ? rgba[3] : 1);
217
- }
218
-
219
- return 'rgba(' + rgba[0] + ', ' + rgba[1] + ', ' + rgba[2] + ', ' + alpha + ')';
220
- }
221
-
222
- function percentString(rgba, alpha) {
223
- if (alpha < 1 || (rgba[3] && rgba[3] < 1)) {
224
- return percentaString(rgba, alpha);
225
- }
226
-
227
- var r = Math.round(rgba[0]/255 * 100);
228
- var g = Math.round(rgba[1]/255 * 100);
229
- var b = Math.round(rgba[2]/255 * 100);
230
-
231
- return 'rgb(' + r + '%, ' + g + '%, ' + b + '%)';
232
- }
233
-
234
- function percentaString(rgba, alpha) {
235
- var r = Math.round(rgba[0]/255 * 100);
236
- var g = Math.round(rgba[1]/255 * 100);
237
- var b = Math.round(rgba[2]/255 * 100);
238
-
239
- return 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + (alpha || rgba[3] || 1) + ')';
240
- }
241
-
242
- function hslString(hsla, alpha) {
243
- if (alpha < 1 || (hsla[3] && hsla[3] < 1)) {
244
- return hslaString(hsla, alpha);
245
- }
246
-
247
- return 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)';
248
- }
249
-
250
- function hslaString(hsla, alpha) {
251
- if (alpha === undefined) {
252
- alpha = (hsla[3] !== undefined ? hsla[3] : 1);
253
- }
254
-
255
- return 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + alpha + ')';
256
- }
257
-
258
- function hwbString(hwb, alpha) {
259
- if (alpha === undefined) {
260
- alpha = (hwb[3] !== undefined ? hwb[3] : 1);
261
- }
262
-
263
- return 'hwb(' + hwb[0] + ', ' + hwb[1] + '%, ' + hwb[2] + '%' + (alpha !== undefined && alpha !== 1 ? ', ' + alpha : '') + ')';
264
- }
265
-
266
- function keyword(rgb) {
267
- return reverseNames[rgb.slice(0, 3)];
268
- }
269
-
270
- function scale(num, min, max) {
271
- return Math.min(Math.max(min, num), max);
272
- }
273
-
274
- function hexDouble(num) {
275
- var str = num.toString(16).toUpperCase();
276
- return (str.length < 2) ? '0' + str : str;
277
- }
278
-
279
- var reverseNames = {};
280
- for (var name in colorNames) {
281
- reverseNames[colorNames[name]] = name;
282
- }
62
+
63
+ var colorNames = require(6);
64
+
65
+ module.exports = {
66
+ getRgba: getRgba,
67
+ getHsla: getHsla,
68
+ getRgb: getRgb,
69
+ getHsl: getHsl,
70
+ getHwb: getHwb,
71
+ getAlpha: getAlpha,
72
+ hexString: hexString,
73
+ rgbString: rgbString,
74
+ rgbaString: rgbaString,
75
+ percentString: percentString,
76
+ percentaString: percentaString,
77
+ hslString: hslString,
78
+ hslaString: hslaString,
79
+ hwbString: hwbString,
80
+ keyword: keyword
81
+ };
82
+
83
+ function getRgba (string) {
84
+ if (!string) return;
85
+
86
+ var abbr = /^#([a-fA-F0-9]{3})$/;
87
+ var hex = /^#([a-fA-F0-9]{6})$/;
88
+ var rgba = /^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
89
+ var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/;
90
+ var keyword = /(\w+)/;
91
+ var rgb = [0, 0, 0];
92
+ var a = 1;
93
+ var i = 0;
94
+ var match = string.match(abbr);
95
+
96
+ if (match) {
97
+ match = match[1];
98
+
99
+ for (i = 0; i < rgb.length; i++) {
100
+ rgb[i] = parseInt(match[i] + match[i], 16);
101
+ }
102
+ } else if (match = string.match(hex)) {
103
+ match = match[1];
104
+
105
+ for (i = 0; i < rgb.length; i++) {
106
+ rgb[i] = parseInt(match.slice(i * 2, i * 2 + 2), 16);
107
+ }
108
+ }
109
+ else if (match = string.match(rgba)) {
110
+ for (i = 0; i < rgb.length; i++) {
111
+ rgb[i] = parseInt(match[i + 1]);
112
+ }
113
+
114
+ a = parseFloat(match[4]);
115
+ } else if (match = string.match(per)) {
116
+ for (i = 0; i < rgb.length; i++) {
117
+ rgb[i] = Math.round(parseFloat(match[i + 1]) * 2.55);
118
+ }
119
+
120
+ a = parseFloat(match[4]);
121
+ } else if (match = string.match(keyword)) {
122
+ if (match[1] === 'transparent') return [0, 0, 0, 0];
123
+
124
+ rgb = colorNames[match[1]];
125
+
126
+ if (!rgb) return;
127
+ }
128
+
129
+ for (i = 0; i < rgb.length; i++) {
130
+ rgb[i] = scale(rgb[i], 0, 255);
131
+ }
132
+
133
+ if (!a && a !== 0) {
134
+ a = 1;
135
+ } else {
136
+ a = scale(a, 0, 1);
137
+ }
138
+
139
+ rgb[3] = a;
140
+ return rgb;
141
+ }
142
+
143
+ function getHsla(string) {
144
+ if (!string) return;
145
+
146
+ var hsl = /^hsla?\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/;
147
+ var match = string.match(hsl);
148
+
149
+ if (match) {
150
+ var alpha = parseFloat(match[4]);
151
+ var h = scale(parseInt(match[1]), 0, 360);
152
+ var s = scale(parseFloat(match[2]), 0, 100);
153
+ var l = scale(parseFloat(match[3]), 0, 100);
154
+ var a = scale(isNaN(alpha) ? 1 : alpha, 0, 1);
155
+
156
+ return [h, s, l, a];
157
+ }
158
+ }
159
+
160
+ function getHwb(string) {
161
+ if (!string) return;
162
+
163
+ var hwb = /^hwb\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/;
164
+ var match = string.match(hwb);
165
+
166
+ if (match) {
167
+ var alpha = parseFloat(match[4]);
168
+ var h = scale(parseInt(match[1]), 0, 360);
169
+ var w = scale(parseFloat(match[2]), 0, 100);
170
+ var b = scale(parseFloat(match[3]), 0, 100);
171
+ var a = scale(isNaN(alpha) ? 1 : alpha, 0, 1);
172
+
173
+ return [h, w, b, a];
174
+ }
175
+ }
176
+
177
+ function getRgb(string) {
178
+ var rgba = getRgba(string);
179
+
180
+ return rgba && rgba.slice(0, 3);
181
+ }
182
+
183
+ function getHsl(string) {
184
+ var hsla = getHsla(string);
185
+
186
+ return hsla && hsla.slice(0, 3);
187
+ }
188
+
189
+ function getAlpha(string) {
190
+ var vals = getRgba(string);
191
+
192
+ if (vals) {
193
+ return vals[3];
194
+ } else if (vals = getHsla(string)) {
195
+ return vals[3];
196
+ } else if (vals = getHwb(string)) {
197
+ return vals[3];
198
+ }
199
+ }
200
+
201
+ function hexString(rgb) {
202
+ return "#" +
203
+ hexDouble(rgb[0]) +
204
+ hexDouble(rgb[1]) +
205
+ hexDouble(rgb[2]);
206
+ }
207
+
208
+ function rgbString(rgba, alpha) {
209
+ if (alpha < 1 || (rgba[3] && rgba[3] < 1)) return rgbaString(rgba, alpha);
210
+
211
+ return 'rgb(' + rgba[0] + ', ' + rgba[1] + ', ' + rgba[2] + ')';
212
+ }
213
+
214
+ function rgbaString(rgba, alpha) {
215
+ if (alpha === undefined) {
216
+ alpha = (rgba[3] !== undefined ? rgba[3] : 1);
217
+ }
218
+
219
+ return 'rgba(' + rgba[0] + ', ' + rgba[1] + ', ' + rgba[2] + ', ' + alpha + ')';
220
+ }
221
+
222
+ function percentString(rgba, alpha) {
223
+ if (alpha < 1 || (rgba[3] && rgba[3] < 1)) {
224
+ return percentaString(rgba, alpha);
225
+ }
226
+
227
+ var r = Math.round(rgba[0]/255 * 100);
228
+ var g = Math.round(rgba[1]/255 * 100);
229
+ var b = Math.round(rgba[2]/255 * 100);
230
+
231
+ return 'rgb(' + r + '%, ' + g + '%, ' + b + '%)';
232
+ }
233
+
234
+ function percentaString(rgba, alpha) {
235
+ var r = Math.round(rgba[0]/255 * 100);
236
+ var g = Math.round(rgba[1]/255 * 100);
237
+ var b = Math.round(rgba[2]/255 * 100);
238
+
239
+ return 'rgba(' + r + '%, ' + g + '%, ' + b + '%, ' + (alpha || rgba[3] || 1) + ')';
240
+ }
241
+
242
+ function hslString(hsla, alpha) {
243
+ if (alpha < 1 || (hsla[3] && hsla[3] < 1)) {
244
+ return hslaString(hsla, alpha);
245
+ }
246
+
247
+ return 'hsl(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%)';
248
+ }
249
+
250
+ function hslaString(hsla, alpha) {
251
+ if (alpha === undefined) {
252
+ alpha = (hsla[3] !== undefined ? hsla[3] : 1);
253
+ }
254
+
255
+ return 'hsla(' + hsla[0] + ', ' + hsla[1] + '%, ' + hsla[2] + '%, ' + alpha + ')';
256
+ }
257
+
258
+ function hwbString(hwb, alpha) {
259
+ if (alpha === undefined) {
260
+ alpha = (hwb[3] !== undefined ? hwb[3] : 1);
261
+ }
262
+
263
+ return 'hwb(' + hwb[0] + ', ' + hwb[1] + '%, ' + hwb[2] + '%' + (alpha !== undefined && alpha !== 1 ? ', ' + alpha : '') + ')';
264
+ }
265
+
266
+ function keyword(rgb) {
267
+ return reverseNames[rgb.slice(0, 3)];
268
+ }
269
+
270
+ function scale(num, min, max) {
271
+ return Math.min(Math.max(min, num), max);
272
+ }
273
+
274
+ function hexDouble(num) {
275
+ var str = num.toString(16).toUpperCase();
276
+ return (str.length < 2) ? '0' + str : str;
277
+ }
278
+
279
+ var reverseNames = {};
280
+ for (var name in colorNames) {
281
+ reverseNames[colorNames[name]] = name;
282
+ }
283
283
 
284
284
  }, { "6" : 6 }],
285
285
  3:[function (require, module, exports) {
286
-
287
- var convert = require(5);
288
- var string = require(2);
289
-
290
- var Color = function (obj) {
291
- if (obj instanceof Color) return obj;
292
- if (!(this instanceof Color)) return new Color(obj);
293
-
294
- this.values = {
295
- rgb: [0, 0, 0],
296
- hsl: [0, 0, 0],
297
- hsv: [0, 0, 0],
298
- hwb: [0, 0, 0],
299
- cmyk: [0, 0, 0, 0],
300
- alpha: 1
301
- };
302
-
303
- var vals;
304
-
305
- if (typeof obj === 'string') {
306
- vals = string.getRgba(obj);
307
-
308
- if (vals) {
309
- this.setValues('rgb', vals);
310
- } else if (vals = string.getHsla(obj)) {
311
- this.setValues('hsl', vals);
312
- } else if (vals = string.getHwb(obj)) {
313
- this.setValues('hwb', vals);
314
- } else {
315
- throw new Error('Unable to parse color from string "' + obj + '"');
316
- }
317
- } else if (typeof obj === 'object') {
318
- vals = obj;
319
-
320
- if (vals.r !== undefined || vals.red !== undefined) {
321
- this.setValues('rgb', vals);
322
- } else if (vals.l !== undefined || vals.lightness !== undefined) {
323
- this.setValues('hsl', vals);
324
- } else if (vals.v !== undefined || vals.value !== undefined) {
325
- this.setValues('hsv', vals);
326
- } else if (vals.w !== undefined || vals.whiteness !== undefined) {
327
- this.setValues('hwb', vals);
328
- } else if (vals.c !== undefined || vals.cyan !== undefined) {
329
- this.setValues('cmyk', vals);
330
- } else {
331
- throw new Error('Unable to parse color from object ' + JSON.stringify(obj));
332
- }
333
- }
334
- };
335
-
336
- Color.prototype = {
337
- rgb: function () {
338
- return this.setSpace('rgb', arguments);
339
- },
340
- hsl: function () {
341
- return this.setSpace('hsl', arguments);
342
- },
343
- hsv: function () {
344
- return this.setSpace('hsv', arguments);
345
- },
346
- hwb: function () {
347
- return this.setSpace('hwb', arguments);
348
- },
349
- cmyk: function () {
350
- return this.setSpace('cmyk', arguments);
351
- },
352
- rgbArray: function () {
353
- return this.values.rgb;
354
- },
355
- hslArray: function () {
356
- return this.values.hsl;
357
- },
358
- hsvArray: function () {
359
- return this.values.hsv;
360
- },
361
- hwbArray: function () {
362
- var values = this.values;
363
- if (values.alpha !== 1) {
364
- return values.hwb.concat([values.alpha]);
365
- }
366
- return values.hwb;
367
- },
368
- cmykArray: function () {
369
- return this.values.cmyk;
370
- },
371
- rgbaArray: function () {
372
- var values = this.values;
373
- return values.rgb.concat([values.alpha]);
374
- },
375
- hslaArray: function () {
376
- var values = this.values;
377
- return values.hsl.concat([values.alpha]);
378
- },
379
- alpha: function (val) {
380
- if (val === undefined) return this.values.alpha;
381
- this.setValues('alpha', val);
382
- return this;
383
- },
384
- red: function (val) {
385
- return this.setChannel('rgb', 0, val);
386
- },
387
- green: function (val) {
388
- return this.setChannel('rgb', 1, val);
389
- },
390
- blue: function (val) {
391
- return this.setChannel('rgb', 2, val);
392
- },
393
- hue: function (val) {
394
- if (val) {
395
- val %= 360;
396
- val = val < 0 ? 360 + val : val;
397
- }
398
-
399
- return this.setChannel('hsl', 0, val);
400
- },
401
- saturation: function (val) {
402
- return this.setChannel('hsl', 1, val);
403
- },
404
- lightness: function (val) {
405
- return this.setChannel('hsl', 2, val);
406
- },
407
- saturationv: function (val) {
408
- return this.setChannel('hsv', 1, val);
409
- },
410
- whiteness: function (val) {
411
- return this.setChannel('hwb', 1, val);
412
- },
413
- blackness: function (val) {
414
- return this.setChannel('hwb', 2, val);
415
- },
416
- value: function (val) {
417
- return this.setChannel('hsv', 2, val);
418
- },
419
- cyan: function (val) {
420
- return this.setChannel('cmyk', 0, val);
421
- },
422
- magenta: function (val) {
423
- return this.setChannel('cmyk', 1, val);
424
- },
425
- yellow: function (val) {
426
- return this.setChannel('cmyk', 2, val);
427
- },
428
- black: function (val) {
429
- return this.setChannel('cmyk', 3, val);
430
- },
431
- hexString: function () {
432
- return string.hexString(this.values.rgb);
433
- },
434
- rgbString: function () {
435
- return string.rgbString(this.values.rgb, this.values.alpha);
436
- },
437
- rgbaString: function () {
438
- return string.rgbaString(this.values.rgb, this.values.alpha);
439
- },
440
- percentString: function () {
441
- return string.percentString(this.values.rgb, this.values.alpha);
442
- },
443
- hslString: function () {
444
- return string.hslString(this.values.hsl, this.values.alpha);
445
- },
446
- hslaString: function () {
447
- return string.hslaString(this.values.hsl, this.values.alpha);
448
- },
449
- hwbString: function () {
450
- return string.hwbString(this.values.hwb, this.values.alpha);
451
- },
452
- keyword: function () {
453
- return string.keyword(this.values.rgb, this.values.alpha);
454
- },
455
- rgbNumber: function () {
456
- var rgb = this.values.rgb;
457
- return (rgb[0] << 16) | (rgb[1] << 8) | rgb[2];
458
- },
459
- luminosity: function () {
460
- var rgb = this.values.rgb;
461
- var lum = [];
462
-
463
- for (var i = 0; i < rgb.length; i++) {
464
- var chan = rgb[i] / 255;
465
- lum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4);
466
- }
467
-
468
- return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
469
- },
470
- contrast: function (color2) {
471
- var lum1 = this.luminosity();
472
- var lum2 = color2.luminosity();
473
-
474
- if (lum1 > lum2) return (lum1 + 0.05) / (lum2 + 0.05);
475
- return (lum2 + 0.05) / (lum1 + 0.05);
476
- },
477
- level: function (color2) {
478
- var contrastRatio = this.contrast(color2);
479
-
480
- if (contrastRatio >= 7.1) return 'AAA';
481
- return (contrastRatio >= 4.5) ? 'AA' : '';
482
- },
483
- dark: function () {
484
- var rgb = this.values.rgb;
485
- var yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;
486
- return yiq < 128;
487
- },
488
- light: function () {
489
- return !this.dark();
490
- },
491
- negate: function () {
492
- var rgb = [];
493
- for (var i = 0; i < 3; i++) {
494
- rgb[i] = 255 - this.values.rgb[i];
495
- }
496
-
497
- this.setValues('rgb', rgb);
498
- return this;
499
- },
500
- lighten: function (ratio) {
501
- var hsl = this.values.hsl;
502
- hsl[2] += hsl[2] * ratio;
503
- this.setValues('hsl', hsl);
504
- return this;
505
- },
506
- darken: function (ratio) {
507
- var hsl = this.values.hsl;
508
- hsl[2] -= hsl[2] * ratio;
509
- this.setValues('hsl', hsl);
510
- return this;
511
- },
512
- saturate: function (ratio) {
513
- var hsl = this.values.hsl;
514
- hsl[1] += hsl[1] * ratio;
515
- this.setValues('hsl', hsl);
516
- return this;
517
- },
518
- desaturate: function (ratio) {
519
- var hsl = this.values.hsl;
520
- hsl[1] -= hsl[1] * ratio;
521
- this.setValues('hsl', hsl);
522
- return this;
523
- },
524
- whiten: function (ratio) {
525
- var hwb = this.values.hwb;
526
- hwb[1] += hwb[1] * ratio;
527
- this.setValues('hwb', hwb);
528
- return this;
529
- },
530
- blacken: function (ratio) {
531
- var hwb = this.values.hwb;
532
- hwb[2] += hwb[2] * ratio;
533
- this.setValues('hwb', hwb);
534
- return this;
535
- },
536
- greyscale: function () {
537
- var rgb = this.values.rgb;
538
- var val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
539
- this.setValues('rgb', [val, val, val]);
540
- return this;
541
- },
542
- clearer: function (ratio) {
543
- var alpha = this.values.alpha;
544
- this.setValues('alpha', alpha - (alpha * ratio));
545
- return this;
546
- },
547
- opaquer: function (ratio) {
548
- var alpha = this.values.alpha;
549
- this.setValues('alpha', alpha + (alpha * ratio));
550
- return this;
551
- },
552
- rotate: function (degrees) {
553
- var hsl = this.values.hsl;
554
- var hue = (hsl[0] + degrees) % 360;
555
- hsl[0] = hue < 0 ? 360 + hue : hue;
556
- this.setValues('hsl', hsl);
557
- return this;
558
- },
559
- mix: function (mixinColor, weight) {
560
- var color1 = this;
561
- var color2 = mixinColor;
562
- var p = weight === undefined ? 0.5 : weight;
563
- var w = 2 * p - 1;
564
- var a = color1.alpha() - color2.alpha();
565
- var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
566
- var w2 = 1 - w1;
567
-
568
- return this
569
- .rgb(
570
- w1 * color1.red() + w2 * color2.red(),
571
- w1 * color1.green() + w2 * color2.green(),
572
- w1 * color1.blue() + w2 * color2.blue()
573
- )
574
- .alpha(color1.alpha() * p + color2.alpha() * (1 - p));
575
- },
576
- toJSON: function () {
577
- return this.rgb();
578
- },
579
- clone: function () {
580
- var result = new Color();
581
- var source = this.values;
582
- var target = result.values;
583
- var value, type;
584
-
585
- for (var prop in source) {
586
- if (source.hasOwnProperty(prop)) {
587
- value = source[prop];
588
- type = ({}).toString.call(value);
589
-
590
- if (type === '[object Array]') {
591
- target[prop] = value.slice(0);
592
- } else if (type === '[object Number]') {
593
- target[prop] = value;
594
- } else {
595
- console.error('unexpected color value:', value);
596
- }
597
- }
598
- }
599
-
600
- return result;
601
- }
602
- };
603
-
604
- Color.prototype.spaces = {
605
- rgb: ['red', 'green', 'blue'],
606
- hsl: ['hue', 'saturation', 'lightness'],
607
- hsv: ['hue', 'saturation', 'value'],
608
- hwb: ['hue', 'whiteness', 'blackness'],
609
- cmyk: ['cyan', 'magenta', 'yellow', 'black']
610
- };
611
-
612
- Color.prototype.maxes = {
613
- rgb: [255, 255, 255],
614
- hsl: [360, 100, 100],
615
- hsv: [360, 100, 100],
616
- hwb: [360, 100, 100],
617
- cmyk: [100, 100, 100, 100]
618
- };
619
-
620
- Color.prototype.getValues = function (space) {
621
- var values = this.values;
622
- var vals = {};
623
-
624
- for (var i = 0; i < space.length; i++) {
625
- vals[space.charAt(i)] = values[space][i];
626
- }
627
-
628
- if (values.alpha !== 1) {
629
- vals.a = values.alpha;
630
- }
631
-
632
- return vals;
633
- };
634
-
635
- Color.prototype.setValues = function (space, vals) {
636
- var values = this.values;
637
- var spaces = this.spaces;
638
- var maxes = this.maxes;
639
- var alpha = 1;
640
- var i;
641
-
642
- if (space === 'alpha') {
643
- alpha = vals;
644
- } else if (vals.length) {
645
- values[space] = vals.slice(0, space.length);
646
- alpha = vals[space.length];
647
- } else if (vals[space.charAt(0)] !== undefined) {
648
- for (i = 0; i < space.length; i++) {
649
- values[space][i] = vals[space.charAt(i)];
650
- }
651
-
652
- alpha = vals.a;
653
- } else if (vals[spaces[space][0]] !== undefined) {
654
- var chans = spaces[space];
655
-
656
- for (i = 0; i < space.length; i++) {
657
- values[space][i] = vals[chans[i]];
658
- }
659
-
660
- alpha = vals.alpha;
661
- }
662
-
663
- values.alpha = Math.max(0, Math.min(1, (alpha === undefined ? values.alpha : alpha)));
664
-
665
- if (space === 'alpha') return false;
666
-
667
- var capped;
668
-
669
- for (i = 0; i < space.length; i++) {
670
- capped = Math.max(0, Math.min(maxes[space][i], values[space][i]));
671
- values[space][i] = Math.round(capped);
672
- }
673
-
674
- for (var sname in spaces) {
675
- if (sname !== space) {
676
- values[sname] = convert[space][sname](values[space]);
677
- }
678
- }
679
-
680
- return true;
681
- };
682
-
683
- Color.prototype.setSpace = function (space, args) {
684
- var vals = args[0];
685
-
686
- if (vals === undefined) return this.getValues(space);
687
-
688
- if (typeof vals === 'number') {
689
- vals = Array.prototype.slice.call(args);
690
- }
691
-
692
- this.setValues(space, vals);
693
- return this;
694
- };
695
-
696
- Color.prototype.setChannel = function (space, index, val) {
697
- var svalues = this.values[space];
698
- if (val === undefined) {
699
- return svalues[index];
700
- } else if (val === svalues[index]) {
701
- return this;
702
- }
703
-
704
- svalues[index] = val;
705
- this.setValues(space, svalues);
706
-
707
- return this;
708
- };
709
-
710
- if (typeof window !== 'undefined') {
711
- window.Color = Color;
712
- }
713
-
714
- module.exports = Color;
286
+
287
+ var convert = require(5);
288
+ var string = require(2);
289
+
290
+ var Color = function (obj) {
291
+ if (obj instanceof Color) return obj;
292
+ if (!(this instanceof Color)) return new Color(obj);
293
+
294
+ this.values = {
295
+ rgb: [0, 0, 0],
296
+ hsl: [0, 0, 0],
297
+ hsv: [0, 0, 0],
298
+ hwb: [0, 0, 0],
299
+ cmyk: [0, 0, 0, 0],
300
+ alpha: 1
301
+ };
302
+
303
+ var vals;
304
+
305
+ if (typeof obj === 'string') {
306
+ vals = string.getRgba(obj);
307
+
308
+ if (vals) {
309
+ this.setValues('rgb', vals);
310
+ } else if (vals = string.getHsla(obj)) {
311
+ this.setValues('hsl', vals);
312
+ } else if (vals = string.getHwb(obj)) {
313
+ this.setValues('hwb', vals);
314
+ } else {
315
+ throw new Error('Unable to parse color from string "' + obj + '"');
316
+ }
317
+ } else if (typeof obj === 'object') {
318
+ vals = obj;
319
+
320
+ if (vals.r !== undefined || vals.red !== undefined) {
321
+ this.setValues('rgb', vals);
322
+ } else if (vals.l !== undefined || vals.lightness !== undefined) {
323
+ this.setValues('hsl', vals);
324
+ } else if (vals.v !== undefined || vals.value !== undefined) {
325
+ this.setValues('hsv', vals);
326
+ } else if (vals.w !== undefined || vals.whiteness !== undefined) {
327
+ this.setValues('hwb', vals);
328
+ } else if (vals.c !== undefined || vals.cyan !== undefined) {
329
+ this.setValues('cmyk', vals);
330
+ } else {
331
+ throw new Error('Unable to parse color from object ' + JSON.stringify(obj));
332
+ }
333
+ }
334
+ };
335
+
336
+ Color.prototype = {
337
+ rgb: function () {
338
+ return this.setSpace('rgb', arguments);
339
+ },
340
+ hsl: function () {
341
+ return this.setSpace('hsl', arguments);
342
+ },
343
+ hsv: function () {
344
+ return this.setSpace('hsv', arguments);
345
+ },
346
+ hwb: function () {
347
+ return this.setSpace('hwb', arguments);
348
+ },
349
+ cmyk: function () {
350
+ return this.setSpace('cmyk', arguments);
351
+ },
352
+ rgbArray: function () {
353
+ return this.values.rgb;
354
+ },
355
+ hslArray: function () {
356
+ return this.values.hsl;
357
+ },
358
+ hsvArray: function () {
359
+ return this.values.hsv;
360
+ },
361
+ hwbArray: function () {
362
+ var values = this.values;
363
+ if (values.alpha !== 1) {
364
+ return values.hwb.concat([values.alpha]);
365
+ }
366
+ return values.hwb;
367
+ },
368
+ cmykArray: function () {
369
+ return this.values.cmyk;
370
+ },
371
+ rgbaArray: function () {
372
+ var values = this.values;
373
+ return values.rgb.concat([values.alpha]);
374
+ },
375
+ hslaArray: function () {
376
+ var values = this.values;
377
+ return values.hsl.concat([values.alpha]);
378
+ },
379
+ alpha: function (val) {
380
+ if (val === undefined) return this.values.alpha;
381
+ this.setValues('alpha', val);
382
+ return this;
383
+ },
384
+ red: function (val) {
385
+ return this.setChannel('rgb', 0, val);
386
+ },
387
+ green: function (val) {
388
+ return this.setChannel('rgb', 1, val);
389
+ },
390
+ blue: function (val) {
391
+ return this.setChannel('rgb', 2, val);
392
+ },
393
+ hue: function (val) {
394
+ if (val) {
395
+ val %= 360;
396
+ val = val < 0 ? 360 + val : val;
397
+ }
398
+
399
+ return this.setChannel('hsl', 0, val);
400
+ },
401
+ saturation: function (val) {
402
+ return this.setChannel('hsl', 1, val);
403
+ },
404
+ lightness: function (val) {
405
+ return this.setChannel('hsl', 2, val);
406
+ },
407
+ saturationv: function (val) {
408
+ return this.setChannel('hsv', 1, val);
409
+ },
410
+ whiteness: function (val) {
411
+ return this.setChannel('hwb', 1, val);
412
+ },
413
+ blackness: function (val) {
414
+ return this.setChannel('hwb', 2, val);
415
+ },
416
+ value: function (val) {
417
+ return this.setChannel('hsv', 2, val);
418
+ },
419
+ cyan: function (val) {
420
+ return this.setChannel('cmyk', 0, val);
421
+ },
422
+ magenta: function (val) {
423
+ return this.setChannel('cmyk', 1, val);
424
+ },
425
+ yellow: function (val) {
426
+ return this.setChannel('cmyk', 2, val);
427
+ },
428
+ black: function (val) {
429
+ return this.setChannel('cmyk', 3, val);
430
+ },
431
+ hexString: function () {
432
+ return string.hexString(this.values.rgb);
433
+ },
434
+ rgbString: function () {
435
+ return string.rgbString(this.values.rgb, this.values.alpha);
436
+ },
437
+ rgbaString: function () {
438
+ return string.rgbaString(this.values.rgb, this.values.alpha);
439
+ },
440
+ percentString: function () {
441
+ return string.percentString(this.values.rgb, this.values.alpha);
442
+ },
443
+ hslString: function () {
444
+ return string.hslString(this.values.hsl, this.values.alpha);
445
+ },
446
+ hslaString: function () {
447
+ return string.hslaString(this.values.hsl, this.values.alpha);
448
+ },
449
+ hwbString: function () {
450
+ return string.hwbString(this.values.hwb, this.values.alpha);
451
+ },
452
+ keyword: function () {
453
+ return string.keyword(this.values.rgb, this.values.alpha);
454
+ },
455
+ rgbNumber: function () {
456
+ var rgb = this.values.rgb;
457
+ return (rgb[0] << 16) | (rgb[1] << 8) | rgb[2];
458
+ },
459
+ luminosity: function () {
460
+ var rgb = this.values.rgb;
461
+ var lum = [];
462
+
463
+ for (var i = 0; i < rgb.length; i++) {
464
+ var chan = rgb[i] / 255;
465
+ lum[i] = (chan <= 0.03928) ? chan / 12.92 : Math.pow(((chan + 0.055) / 1.055), 2.4);
466
+ }
467
+
468
+ return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
469
+ },
470
+ contrast: function (color2) {
471
+ var lum1 = this.luminosity();
472
+ var lum2 = color2.luminosity();
473
+
474
+ if (lum1 > lum2) return (lum1 + 0.05) / (lum2 + 0.05);
475
+ return (lum2 + 0.05) / (lum1 + 0.05);
476
+ },
477
+ level: function (color2) {
478
+ var contrastRatio = this.contrast(color2);
479
+
480
+ if (contrastRatio >= 7.1) return 'AAA';
481
+ return (contrastRatio >= 4.5) ? 'AA' : '';
482
+ },
483
+ dark: function () {
484
+ var rgb = this.values.rgb;
485
+ var yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000;
486
+ return yiq < 128;
487
+ },
488
+ light: function () {
489
+ return !this.dark();
490
+ },
491
+ negate: function () {
492
+ var rgb = [];
493
+ for (var i = 0; i < 3; i++) {
494
+ rgb[i] = 255 - this.values.rgb[i];
495
+ }
496
+
497
+ this.setValues('rgb', rgb);
498
+ return this;
499
+ },
500
+ lighten: function (ratio) {
501
+ var hsl = this.values.hsl;
502
+ hsl[2] += hsl[2] * ratio;
503
+ this.setValues('hsl', hsl);
504
+ return this;
505
+ },
506
+ darken: function (ratio) {
507
+ var hsl = this.values.hsl;
508
+ hsl[2] -= hsl[2] * ratio;
509
+ this.setValues('hsl', hsl);
510
+ return this;
511
+ },
512
+ saturate: function (ratio) {
513
+ var hsl = this.values.hsl;
514
+ hsl[1] += hsl[1] * ratio;
515
+ this.setValues('hsl', hsl);
516
+ return this;
517
+ },
518
+ desaturate: function (ratio) {
519
+ var hsl = this.values.hsl;
520
+ hsl[1] -= hsl[1] * ratio;
521
+ this.setValues('hsl', hsl);
522
+ return this;
523
+ },
524
+ whiten: function (ratio) {
525
+ var hwb = this.values.hwb;
526
+ hwb[1] += hwb[1] * ratio;
527
+ this.setValues('hwb', hwb);
528
+ return this;
529
+ },
530
+ blacken: function (ratio) {
531
+ var hwb = this.values.hwb;
532
+ hwb[2] += hwb[2] * ratio;
533
+ this.setValues('hwb', hwb);
534
+ return this;
535
+ },
536
+ greyscale: function () {
537
+ var rgb = this.values.rgb;
538
+ var val = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
539
+ this.setValues('rgb', [val, val, val]);
540
+ return this;
541
+ },
542
+ clearer: function (ratio) {
543
+ var alpha = this.values.alpha;
544
+ this.setValues('alpha', alpha - (alpha * ratio));
545
+ return this;
546
+ },
547
+ opaquer: function (ratio) {
548
+ var alpha = this.values.alpha;
549
+ this.setValues('alpha', alpha + (alpha * ratio));
550
+ return this;
551
+ },
552
+ rotate: function (degrees) {
553
+ var hsl = this.values.hsl;
554
+ var hue = (hsl[0] + degrees) % 360;
555
+ hsl[0] = hue < 0 ? 360 + hue : hue;
556
+ this.setValues('hsl', hsl);
557
+ return this;
558
+ },
559
+ mix: function (mixinColor, weight) {
560
+ var color1 = this;
561
+ var color2 = mixinColor;
562
+ var p = weight === undefined ? 0.5 : weight;
563
+ var w = 2 * p - 1;
564
+ var a = color1.alpha() - color2.alpha();
565
+ var w1 = (((w * a === -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
566
+ var w2 = 1 - w1;
567
+
568
+ return this
569
+ .rgb(
570
+ w1 * color1.red() + w2 * color2.red(),
571
+ w1 * color1.green() + w2 * color2.green(),
572
+ w1 * color1.blue() + w2 * color2.blue()
573
+ )
574
+ .alpha(color1.alpha() * p + color2.alpha() * (1 - p));
575
+ },
576
+ toJSON: function () {
577
+ return this.rgb();
578
+ },
579
+ clone: function () {
580
+ var result = new Color();
581
+ var source = this.values;
582
+ var target = result.values;
583
+ var value, type;
584
+
585
+ for (var prop in source) {
586
+ if (source.hasOwnProperty(prop)) {
587
+ value = source[prop];
588
+ type = ({}).toString.call(value);
589
+
590
+ if (type === '[object Array]') {
591
+ target[prop] = value.slice(0);
592
+ } else if (type === '[object Number]') {
593
+ target[prop] = value;
594
+ } else {
595
+ console.error('unexpected color value:', value);
596
+ }
597
+ }
598
+ }
599
+
600
+ return result;
601
+ }
602
+ };
603
+
604
+ Color.prototype.spaces = {
605
+ rgb: ['red', 'green', 'blue'],
606
+ hsl: ['hue', 'saturation', 'lightness'],
607
+ hsv: ['hue', 'saturation', 'value'],
608
+ hwb: ['hue', 'whiteness', 'blackness'],
609
+ cmyk: ['cyan', 'magenta', 'yellow', 'black']
610
+ };
611
+
612
+ Color.prototype.maxes = {
613
+ rgb: [255, 255, 255],
614
+ hsl: [360, 100, 100],
615
+ hsv: [360, 100, 100],
616
+ hwb: [360, 100, 100],
617
+ cmyk: [100, 100, 100, 100]
618
+ };
619
+
620
+ Color.prototype.getValues = function (space) {
621
+ var values = this.values;
622
+ var vals = {};
623
+
624
+ for (var i = 0; i < space.length; i++) {
625
+ vals[space.charAt(i)] = values[space][i];
626
+ }
627
+
628
+ if (values.alpha !== 1) {
629
+ vals.a = values.alpha;
630
+ }
631
+
632
+ return vals;
633
+ };
634
+
635
+ Color.prototype.setValues = function (space, vals) {
636
+ var values = this.values;
637
+ var spaces = this.spaces;
638
+ var maxes = this.maxes;
639
+ var alpha = 1;
640
+ var i;
641
+
642
+ if (space === 'alpha') {
643
+ alpha = vals;
644
+ } else if (vals.length) {
645
+ values[space] = vals.slice(0, space.length);
646
+ alpha = vals[space.length];
647
+ } else if (vals[space.charAt(0)] !== undefined) {
648
+ for (i = 0; i < space.length; i++) {
649
+ values[space][i] = vals[space.charAt(i)];
650
+ }
651
+
652
+ alpha = vals.a;
653
+ } else if (vals[spaces[space][0]] !== undefined) {
654
+ var chans = spaces[space];
655
+
656
+ for (i = 0; i < space.length; i++) {
657
+ values[space][i] = vals[chans[i]];
658
+ }
659
+
660
+ alpha = vals.alpha;
661
+ }
662
+
663
+ values.alpha = Math.max(0, Math.min(1, (alpha === undefined ? values.alpha : alpha)));
664
+
665
+ if (space === 'alpha') return false;
666
+
667
+ var capped;
668
+
669
+ for (i = 0; i < space.length; i++) {
670
+ capped = Math.max(0, Math.min(maxes[space][i], values[space][i]));
671
+ values[space][i] = Math.round(capped);
672
+ }
673
+
674
+ for (var sname in spaces) {
675
+ if (sname !== space) {
676
+ values[sname] = convert[space][sname](values[space]);
677
+ }
678
+ }
679
+
680
+ return true;
681
+ };
682
+
683
+ Color.prototype.setSpace = function (space, args) {
684
+ var vals = args[0];
685
+
686
+ if (vals === undefined) return this.getValues(space);
687
+
688
+ if (typeof vals === 'number') {
689
+ vals = Array.prototype.slice.call(args);
690
+ }
691
+
692
+ this.setValues(space, vals);
693
+ return this;
694
+ };
695
+
696
+ Color.prototype.setChannel = function (space, index, val) {
697
+ var svalues = this.values[space];
698
+ if (val === undefined) {
699
+ return svalues[index];
700
+ } else if (val === svalues[index]) {
701
+ return this;
702
+ }
703
+
704
+ svalues[index] = val;
705
+ this.setValues(space, svalues);
706
+
707
+ return this;
708
+ };
709
+
710
+ if (typeof window !== 'undefined') {
711
+ window.Color = Color;
712
+ }
713
+
714
+ module.exports = Color;
715
715
 
716
716
  },{ "2" : 2, "5" : 5 }],
717
717
  4:[function (require, module, exports){
@@ -1495,155 +1495,155 @@ Converter.prototype.getValues = function (space) {
1495
1495
  module.exports = convert;
1496
1496
  }, { '4' : 4 }],
1497
1497
  6:[function (require, module, exports){
1498
- module.exports = {
1499
- aliceblue: [240, 248, 255],
1500
- antiquewhite: [250, 235, 215],
1501
- aqua: [0, 255, 255],
1502
- aquamarine: [127, 255, 212],
1503
- azure: [240, 255, 255],
1504
- beige: [245, 245, 220],
1505
- bisque: [255, 228, 196],
1506
- black: [0, 0, 0],
1507
- blanchedalmond: [255, 235, 205],
1508
- blue: [0, 0, 255],
1509
- blueviolet: [138, 43, 226],
1510
- brown: [165, 42, 42],
1511
- burlywood: [222, 184, 135],
1512
- cadetblue: [95, 158, 160],
1513
- chartreuse: [127, 255, 0],
1514
- chocolate: [210, 105, 30],
1515
- coral: [255, 127, 80],
1516
- cornflowerblue: [100, 149, 237],
1517
- cornsilk: [255, 248, 220],
1518
- crimson: [220, 20, 60],
1519
- cyan: [0, 255, 255],
1520
- darkblue: [0, 0, 139],
1521
- darkcyan: [0, 139, 139],
1522
- darkgoldenrod: [184, 134, 11],
1523
- darkgray: [169, 169, 169],
1524
- darkgreen: [0, 100, 0],
1525
- darkgrey: [169, 169, 169],
1526
- darkkhaki: [189, 183, 107],
1527
- darkmagenta: [139, 0, 139],
1528
- darkolivegreen: [85, 107, 47],
1529
- darkorange: [255, 140, 0],
1530
- darkorchid: [153, 50, 204],
1531
- darkred: [139, 0, 0],
1532
- darksalmon: [233, 150, 122],
1533
- darkseagreen: [143, 188, 143],
1534
- darkslateblue: [72, 61, 139],
1535
- darkslategray: [47, 79, 79],
1536
- darkslategrey: [47, 79, 79],
1537
- darkturquoise: [0, 206, 209],
1538
- darkviolet: [148, 0, 211],
1539
- deeppink: [255, 20, 147],
1540
- deepskyblue: [0, 191, 255],
1541
- dimgray: [105, 105, 105],
1542
- dimgrey: [105, 105, 105],
1543
- dodgerblue: [30, 144, 255],
1544
- firebrick: [178, 34, 34],
1545
- floralwhite: [255, 250, 240],
1546
- forestgreen: [34, 139, 34],
1547
- fuchsia: [255, 0, 255],
1548
- gainsboro: [220, 220, 220],
1549
- ghostwhite: [248, 248, 255],
1550
- gold: [255, 215, 0],
1551
- goldenrod: [218, 165, 32],
1552
- gray: [128, 128, 128],
1553
- green: [0, 128, 0],
1554
- greenyellow: [173, 255, 47],
1555
- grey: [128, 128, 128],
1556
- honeydew: [240, 255, 240],
1557
- hotpink: [255, 105, 180],
1558
- indianred: [205, 92, 92],
1559
- indigo: [75, 0, 130],
1560
- ivory: [255, 255, 240],
1561
- khaki: [240, 230, 140],
1562
- lavender: [230, 230, 250],
1563
- lavenderblush: [255, 240, 245],
1564
- lawngreen: [124, 252, 0],
1565
- lemonchiffon: [255, 250, 205],
1566
- lightblue: [173, 216, 230],
1567
- lightcoral: [240, 128, 128],
1568
- lightcyan: [224, 255, 255],
1569
- lightgoldenrodyellow: [250, 250, 210],
1570
- lightgray: [211, 211, 211],
1571
- lightgreen: [144, 238, 144],
1572
- lightgrey: [211, 211, 211],
1573
- lightpink: [255, 182, 193],
1574
- lightsalmon: [255, 160, 122],
1575
- lightseagreen: [32, 178, 170],
1576
- lightskyblue: [135, 206, 250],
1577
- lightslategray: [119, 136, 153],
1578
- lightslategrey: [119, 136, 153],
1579
- lightsteelblue: [176, 196, 222],
1580
- lightyellow: [255, 255, 224],
1581
- lime: [0, 255, 0],
1582
- limegreen: [50, 205, 50],
1583
- linen: [250, 240, 230],
1584
- magenta: [255, 0, 255],
1585
- maroon: [128, 0, 0],
1586
- mediumaquamarine: [102, 205, 170],
1587
- mediumblue: [0, 0, 205],
1588
- mediumorchid: [186, 85, 211],
1589
- mediumpurple: [147, 112, 219],
1590
- mediumseagreen: [60, 179, 113],
1591
- mediumslateblue: [123, 104, 238],
1592
- mediumspringgreen: [0, 250, 154],
1593
- mediumturquoise: [72, 209, 204],
1594
- mediumvioletred: [199, 21, 133],
1595
- midnightblue: [25, 25, 112],
1596
- mintcream: [245, 255, 250],
1597
- mistyrose: [255, 228, 225],
1598
- moccasin: [255, 228, 181],
1599
- navajowhite: [255, 222, 173],
1600
- navy: [0, 0, 128],
1601
- oldlace: [253, 245, 230],
1602
- olive: [128, 128, 0],
1603
- olivedrab: [107, 142, 35],
1604
- orange: [255, 165, 0],
1605
- orangered: [255, 69, 0],
1606
- orchid: [218, 112, 214],
1607
- palegoldenrod: [238, 232, 170],
1608
- palegreen: [152, 251, 152],
1609
- paleturquoise: [175, 238, 238],
1610
- palevioletred: [219, 112, 147],
1611
- papayawhip: [255, 239, 213],
1612
- peachpuff: [255, 218, 185],
1613
- peru: [205, 133, 63],
1614
- pink: [255, 192, 203],
1615
- plum: [221, 160, 221],
1616
- powderblue: [176, 224, 230],
1617
- purple: [128, 0, 128],
1618
- rebeccapurple: [102, 51, 153],
1619
- red: [255, 0, 0],
1620
- rosybrown: [188, 143, 143],
1621
- royalblue: [65, 105, 225],
1622
- saddlebrown: [139, 69, 19],
1623
- salmon: [250, 128, 114],
1624
- sandybrown: [244, 164, 96],
1625
- seagreen: [46, 139, 87],
1626
- seashell: [255, 245, 238],
1627
- sienna: [160, 82, 45],
1628
- silver: [192, 192, 192],
1629
- skyblue: [135, 206, 235],
1630
- slateblue: [106, 90, 205],
1631
- slategray: [112, 128, 144],
1632
- slategrey: [112, 128, 144],
1633
- snow: [255, 250, 250],
1634
- springgreen: [0, 255, 127],
1635
- steelblue: [70, 130, 180],
1636
- tan: [210, 180, 140],
1637
- teal: [0, 128, 128],
1638
- thistle: [216, 191, 216],
1639
- tomato: [255, 99, 71],
1640
- turquoise: [64, 224, 208],
1641
- violet: [238, 130, 238],
1642
- wheat: [245, 222, 179],
1643
- white: [255, 255, 255],
1644
- whitesmoke: [245, 245, 245],
1645
- yellow: [255, 255, 0],
1646
- yellowgreen: [154, 205, 50]
1498
+ module.exports = {
1499
+ aliceblue: [240, 248, 255],
1500
+ antiquewhite: [250, 235, 215],
1501
+ aqua: [0, 255, 255],
1502
+ aquamarine: [127, 255, 212],
1503
+ azure: [240, 255, 255],
1504
+ beige: [245, 245, 220],
1505
+ bisque: [255, 228, 196],
1506
+ black: [0, 0, 0],
1507
+ blanchedalmond: [255, 235, 205],
1508
+ blue: [0, 0, 255],
1509
+ blueviolet: [138, 43, 226],
1510
+ brown: [165, 42, 42],
1511
+ burlywood: [222, 184, 135],
1512
+ cadetblue: [95, 158, 160],
1513
+ chartreuse: [127, 255, 0],
1514
+ chocolate: [210, 105, 30],
1515
+ coral: [255, 127, 80],
1516
+ cornflowerblue: [100, 149, 237],
1517
+ cornsilk: [255, 248, 220],
1518
+ crimson: [220, 20, 60],
1519
+ cyan: [0, 255, 255],
1520
+ darkblue: [0, 0, 139],
1521
+ darkcyan: [0, 139, 139],
1522
+ darkgoldenrod: [184, 134, 11],
1523
+ darkgray: [169, 169, 169],
1524
+ darkgreen: [0, 100, 0],
1525
+ darkgrey: [169, 169, 169],
1526
+ darkkhaki: [189, 183, 107],
1527
+ darkmagenta: [139, 0, 139],
1528
+ darkolivegreen: [85, 107, 47],
1529
+ darkorange: [255, 140, 0],
1530
+ darkorchid: [153, 50, 204],
1531
+ darkred: [139, 0, 0],
1532
+ darksalmon: [233, 150, 122],
1533
+ darkseagreen: [143, 188, 143],
1534
+ darkslateblue: [72, 61, 139],
1535
+ darkslategray: [47, 79, 79],
1536
+ darkslategrey: [47, 79, 79],
1537
+ darkturquoise: [0, 206, 209],
1538
+ darkviolet: [148, 0, 211],
1539
+ deeppink: [255, 20, 147],
1540
+ deepskyblue: [0, 191, 255],
1541
+ dimgray: [105, 105, 105],
1542
+ dimgrey: [105, 105, 105],
1543
+ dodgerblue: [30, 144, 255],
1544
+ firebrick: [178, 34, 34],
1545
+ floralwhite: [255, 250, 240],
1546
+ forestgreen: [34, 139, 34],
1547
+ fuchsia: [255, 0, 255],
1548
+ gainsboro: [220, 220, 220],
1549
+ ghostwhite: [248, 248, 255],
1550
+ gold: [255, 215, 0],
1551
+ goldenrod: [218, 165, 32],
1552
+ gray: [128, 128, 128],
1553
+ green: [0, 128, 0],
1554
+ greenyellow: [173, 255, 47],
1555
+ grey: [128, 128, 128],
1556
+ honeydew: [240, 255, 240],
1557
+ hotpink: [255, 105, 180],
1558
+ indianred: [205, 92, 92],
1559
+ indigo: [75, 0, 130],
1560
+ ivory: [255, 255, 240],
1561
+ khaki: [240, 230, 140],
1562
+ lavender: [230, 230, 250],
1563
+ lavenderblush: [255, 240, 245],
1564
+ lawngreen: [124, 252, 0],
1565
+ lemonchiffon: [255, 250, 205],
1566
+ lightblue: [173, 216, 230],
1567
+ lightcoral: [240, 128, 128],
1568
+ lightcyan: [224, 255, 255],
1569
+ lightgoldenrodyellow: [250, 250, 210],
1570
+ lightgray: [211, 211, 211],
1571
+ lightgreen: [144, 238, 144],
1572
+ lightgrey: [211, 211, 211],
1573
+ lightpink: [255, 182, 193],
1574
+ lightsalmon: [255, 160, 122],
1575
+ lightseagreen: [32, 178, 170],
1576
+ lightskyblue: [135, 206, 250],
1577
+ lightslategray: [119, 136, 153],
1578
+ lightslategrey: [119, 136, 153],
1579
+ lightsteelblue: [176, 196, 222],
1580
+ lightyellow: [255, 255, 224],
1581
+ lime: [0, 255, 0],
1582
+ limegreen: [50, 205, 50],
1583
+ linen: [250, 240, 230],
1584
+ magenta: [255, 0, 255],
1585
+ maroon: [128, 0, 0],
1586
+ mediumaquamarine: [102, 205, 170],
1587
+ mediumblue: [0, 0, 205],
1588
+ mediumorchid: [186, 85, 211],
1589
+ mediumpurple: [147, 112, 219],
1590
+ mediumseagreen: [60, 179, 113],
1591
+ mediumslateblue: [123, 104, 238],
1592
+ mediumspringgreen: [0, 250, 154],
1593
+ mediumturquoise: [72, 209, 204],
1594
+ mediumvioletred: [199, 21, 133],
1595
+ midnightblue: [25, 25, 112],
1596
+ mintcream: [245, 255, 250],
1597
+ mistyrose: [255, 228, 225],
1598
+ moccasin: [255, 228, 181],
1599
+ navajowhite: [255, 222, 173],
1600
+ navy: [0, 0, 128],
1601
+ oldlace: [253, 245, 230],
1602
+ olive: [128, 128, 0],
1603
+ olivedrab: [107, 142, 35],
1604
+ orange: [255, 165, 0],
1605
+ orangered: [255, 69, 0],
1606
+ orchid: [218, 112, 214],
1607
+ palegoldenrod: [238, 232, 170],
1608
+ palegreen: [152, 251, 152],
1609
+ paleturquoise: [175, 238, 238],
1610
+ palevioletred: [219, 112, 147],
1611
+ papayawhip: [255, 239, 213],
1612
+ peachpuff: [255, 218, 185],
1613
+ peru: [205, 133, 63],
1614
+ pink: [255, 192, 203],
1615
+ plum: [221, 160, 221],
1616
+ powderblue: [176, 224, 230],
1617
+ purple: [128, 0, 128],
1618
+ rebeccapurple: [102, 51, 153],
1619
+ red: [255, 0, 0],
1620
+ rosybrown: [188, 143, 143],
1621
+ royalblue: [65, 105, 225],
1622
+ saddlebrown: [139, 69, 19],
1623
+ salmon: [250, 128, 114],
1624
+ sandybrown: [244, 164, 96],
1625
+ seagreen: [46, 139, 87],
1626
+ seashell: [255, 245, 238],
1627
+ sienna: [160, 82, 45],
1628
+ silver: [192, 192, 192],
1629
+ skyblue: [135, 206, 235],
1630
+ slateblue: [106, 90, 205],
1631
+ slategray: [112, 128, 144],
1632
+ slategrey: [112, 128, 144],
1633
+ snow: [255, 250, 250],
1634
+ springgreen: [0, 255, 127],
1635
+ steelblue: [70, 130, 180],
1636
+ tan: [210, 180, 140],
1637
+ teal: [0, 128, 128],
1638
+ thistle: [216, 191, 216],
1639
+ tomato: [255, 99, 71],
1640
+ turquoise: [64, 224, 208],
1641
+ violet: [238, 130, 238],
1642
+ wheat: [245, 222, 179],
1643
+ white: [255, 255, 255],
1644
+ whitesmoke: [245, 245, 245],
1645
+ yellow: [255, 255, 0],
1646
+ yellowgreen: [154, 205, 50]
1647
1647
  };
1648
1648
  }, {}],
1649
1649
  7:[function (require, module, exports){