@ctrl/tinycolor 3.2.0 → 3.3.2

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.
package/dist/index.js CHANGED
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tinycolor = exports.TinyColor = void 0;
4
- const conversion_1 = require("./conversion");
5
- const css_color_names_1 = require("./css-color-names");
6
- const format_input_1 = require("./format-input");
7
- const util_1 = require("./util");
8
- class TinyColor {
9
- constructor(color = '', opts = {}) {
4
+ var conversion_1 = require("./conversion");
5
+ var css_color_names_1 = require("./css-color-names");
6
+ var format_input_1 = require("./format-input");
7
+ var util_1 = require("./util");
8
+ var TinyColor = /** @class */ (function () {
9
+ function TinyColor(color, opts) {
10
+ if (color === void 0) { color = ''; }
11
+ if (opts === void 0) { opts = {}; }
10
12
  var _a;
11
13
  // If input is already a tinycolor, return itself
12
14
  if (color instanceof TinyColor) {
@@ -17,7 +19,7 @@ class TinyColor {
17
19
  color = conversion_1.numberInputToObject(color);
18
20
  }
19
21
  this.originalInput = color;
20
- const rgb = format_input_1.inputToRGB(color);
22
+ var rgb = format_input_1.inputToRGB(color);
21
23
  this.originalInput = color;
22
24
  this.r = rgb.r;
23
25
  this.g = rgb.g;
@@ -41,203 +43,211 @@ class TinyColor {
41
43
  }
42
44
  this.isValid = rgb.ok;
43
45
  }
44
- isDark() {
46
+ TinyColor.prototype.isDark = function () {
45
47
  return this.getBrightness() < 128;
46
- }
47
- isLight() {
48
+ };
49
+ TinyColor.prototype.isLight = function () {
48
50
  return !this.isDark();
49
- }
51
+ };
50
52
  /**
51
53
  * Returns the perceived brightness of the color, from 0-255.
52
54
  */
53
- getBrightness() {
55
+ TinyColor.prototype.getBrightness = function () {
54
56
  // http://www.w3.org/TR/AERT#color-contrast
55
- const rgb = this.toRgb();
57
+ var rgb = this.toRgb();
56
58
  return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
57
- }
59
+ };
58
60
  /**
59
61
  * Returns the perceived luminance of a color, from 0-1.
60
62
  */
61
- getLuminance() {
63
+ TinyColor.prototype.getLuminance = function () {
62
64
  // http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
63
- const rgb = this.toRgb();
64
- let R;
65
- let G;
66
- let B;
67
- const RsRGB = rgb.r / 255;
68
- const GsRGB = rgb.g / 255;
69
- const BsRGB = rgb.b / 255;
65
+ var rgb = this.toRgb();
66
+ var R;
67
+ var G;
68
+ var B;
69
+ var RsRGB = rgb.r / 255;
70
+ var GsRGB = rgb.g / 255;
71
+ var BsRGB = rgb.b / 255;
70
72
  if (RsRGB <= 0.03928) {
71
73
  R = RsRGB / 12.92;
72
74
  }
73
75
  else {
74
- R = ((RsRGB + 0.055) / 1.055) ** 2.4;
76
+ // eslint-disable-next-line prefer-exponentiation-operator
77
+ R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
75
78
  }
76
79
  if (GsRGB <= 0.03928) {
77
80
  G = GsRGB / 12.92;
78
81
  }
79
82
  else {
80
- G = ((GsRGB + 0.055) / 1.055) ** 2.4;
83
+ // eslint-disable-next-line prefer-exponentiation-operator
84
+ G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
81
85
  }
82
86
  if (BsRGB <= 0.03928) {
83
87
  B = BsRGB / 12.92;
84
88
  }
85
89
  else {
86
- B = ((BsRGB + 0.055) / 1.055) ** 2.4;
90
+ // eslint-disable-next-line prefer-exponentiation-operator
91
+ B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
87
92
  }
88
93
  return 0.2126 * R + 0.7152 * G + 0.0722 * B;
89
- }
94
+ };
90
95
  /**
91
96
  * Returns the alpha value of a color, from 0-1.
92
97
  */
93
- getAlpha() {
98
+ TinyColor.prototype.getAlpha = function () {
94
99
  return this.a;
95
- }
100
+ };
96
101
  /**
97
102
  * Sets the alpha value on the current color.
98
103
  *
99
104
  * @param alpha - The new alpha value. The accepted range is 0-1.
100
105
  */
101
- setAlpha(alpha) {
106
+ TinyColor.prototype.setAlpha = function (alpha) {
102
107
  this.a = util_1.boundAlpha(alpha);
103
108
  this.roundA = Math.round(100 * this.a) / 100;
104
109
  return this;
105
- }
110
+ };
106
111
  /**
107
112
  * Returns the object as a HSVA object.
108
113
  */
109
- toHsv() {
110
- const hsv = conversion_1.rgbToHsv(this.r, this.g, this.b);
114
+ TinyColor.prototype.toHsv = function () {
115
+ var hsv = conversion_1.rgbToHsv(this.r, this.g, this.b);
111
116
  return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this.a };
112
- }
117
+ };
113
118
  /**
114
119
  * Returns the hsva values interpolated into a string with the following format:
115
120
  * "hsva(xxx, xxx, xxx, xx)".
116
121
  */
117
- toHsvString() {
118
- const hsv = conversion_1.rgbToHsv(this.r, this.g, this.b);
119
- const h = Math.round(hsv.h * 360);
120
- const s = Math.round(hsv.s * 100);
121
- const v = Math.round(hsv.v * 100);
122
- return this.a === 1 ? `hsv(${h}, ${s}%, ${v}%)` : `hsva(${h}, ${s}%, ${v}%, ${this.roundA})`;
123
- }
122
+ TinyColor.prototype.toHsvString = function () {
123
+ var hsv = conversion_1.rgbToHsv(this.r, this.g, this.b);
124
+ var h = Math.round(hsv.h * 360);
125
+ var s = Math.round(hsv.s * 100);
126
+ var v = Math.round(hsv.v * 100);
127
+ return this.a === 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this.roundA + ")";
128
+ };
124
129
  /**
125
130
  * Returns the object as a HSLA object.
126
131
  */
127
- toHsl() {
128
- const hsl = conversion_1.rgbToHsl(this.r, this.g, this.b);
132
+ TinyColor.prototype.toHsl = function () {
133
+ var hsl = conversion_1.rgbToHsl(this.r, this.g, this.b);
129
134
  return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this.a };
130
- }
135
+ };
131
136
  /**
132
137
  * Returns the hsla values interpolated into a string with the following format:
133
138
  * "hsla(xxx, xxx, xxx, xx)".
134
139
  */
135
- toHslString() {
136
- const hsl = conversion_1.rgbToHsl(this.r, this.g, this.b);
137
- const h = Math.round(hsl.h * 360);
138
- const s = Math.round(hsl.s * 100);
139
- const l = Math.round(hsl.l * 100);
140
- return this.a === 1 ? `hsl(${h}, ${s}%, ${l}%)` : `hsla(${h}, ${s}%, ${l}%, ${this.roundA})`;
141
- }
140
+ TinyColor.prototype.toHslString = function () {
141
+ var hsl = conversion_1.rgbToHsl(this.r, this.g, this.b);
142
+ var h = Math.round(hsl.h * 360);
143
+ var s = Math.round(hsl.s * 100);
144
+ var l = Math.round(hsl.l * 100);
145
+ return this.a === 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this.roundA + ")";
146
+ };
142
147
  /**
143
148
  * Returns the hex value of the color.
144
149
  * @param allow3Char will shorten hex value to 3 char if possible
145
150
  */
146
- toHex(allow3Char = false) {
151
+ TinyColor.prototype.toHex = function (allow3Char) {
152
+ if (allow3Char === void 0) { allow3Char = false; }
147
153
  return conversion_1.rgbToHex(this.r, this.g, this.b, allow3Char);
148
- }
154
+ };
149
155
  /**
150
156
  * Returns the hex value of the color -with a # appened.
151
157
  * @param allow3Char will shorten hex value to 3 char if possible
152
158
  */
153
- toHexString(allow3Char = false) {
159
+ TinyColor.prototype.toHexString = function (allow3Char) {
160
+ if (allow3Char === void 0) { allow3Char = false; }
154
161
  return '#' + this.toHex(allow3Char);
155
- }
162
+ };
156
163
  /**
157
164
  * Returns the hex 8 value of the color.
158
165
  * @param allow4Char will shorten hex value to 4 char if possible
159
166
  */
160
- toHex8(allow4Char = false) {
167
+ TinyColor.prototype.toHex8 = function (allow4Char) {
168
+ if (allow4Char === void 0) { allow4Char = false; }
161
169
  return conversion_1.rgbaToHex(this.r, this.g, this.b, this.a, allow4Char);
162
- }
170
+ };
163
171
  /**
164
172
  * Returns the hex 8 value of the color -with a # appened.
165
173
  * @param allow4Char will shorten hex value to 4 char if possible
166
174
  */
167
- toHex8String(allow4Char = false) {
175
+ TinyColor.prototype.toHex8String = function (allow4Char) {
176
+ if (allow4Char === void 0) { allow4Char = false; }
168
177
  return '#' + this.toHex8(allow4Char);
169
- }
178
+ };
170
179
  /**
171
180
  * Returns the object as a RGBA object.
172
181
  */
173
- toRgb() {
182
+ TinyColor.prototype.toRgb = function () {
174
183
  return {
175
184
  r: Math.round(this.r),
176
185
  g: Math.round(this.g),
177
186
  b: Math.round(this.b),
178
187
  a: this.a,
179
188
  };
180
- }
189
+ };
181
190
  /**
182
191
  * Returns the RGBA values interpolated into a string with the following format:
183
192
  * "RGBA(xxx, xxx, xxx, xx)".
184
193
  */
185
- toRgbString() {
186
- const r = Math.round(this.r);
187
- const g = Math.round(this.g);
188
- const b = Math.round(this.b);
189
- return this.a === 1 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${this.roundA})`;
190
- }
194
+ TinyColor.prototype.toRgbString = function () {
195
+ var r = Math.round(this.r);
196
+ var g = Math.round(this.g);
197
+ var b = Math.round(this.b);
198
+ return this.a === 1 ? "rgb(" + r + ", " + g + ", " + b + ")" : "rgba(" + r + ", " + g + ", " + b + ", " + this.roundA + ")";
199
+ };
191
200
  /**
192
201
  * Returns the object as a RGBA object.
193
202
  */
194
- toPercentageRgb() {
195
- const fmt = (x) => `${Math.round(util_1.bound01(x, 255) * 100)}%`;
203
+ TinyColor.prototype.toPercentageRgb = function () {
204
+ var fmt = function (x) { return Math.round(util_1.bound01(x, 255) * 100) + "%"; };
196
205
  return {
197
206
  r: fmt(this.r),
198
207
  g: fmt(this.g),
199
208
  b: fmt(this.b),
200
209
  a: this.a,
201
210
  };
202
- }
211
+ };
203
212
  /**
204
213
  * Returns the RGBA relative values interpolated into a string
205
214
  */
206
- toPercentageRgbString() {
207
- const rnd = (x) => Math.round(util_1.bound01(x, 255) * 100);
215
+ TinyColor.prototype.toPercentageRgbString = function () {
216
+ var rnd = function (x) { return Math.round(util_1.bound01(x, 255) * 100); };
208
217
  return this.a === 1
209
- ? `rgb(${rnd(this.r)}%, ${rnd(this.g)}%, ${rnd(this.b)}%)`
210
- : `rgba(${rnd(this.r)}%, ${rnd(this.g)}%, ${rnd(this.b)}%, ${this.roundA})`;
211
- }
218
+ ? "rgb(" + rnd(this.r) + "%, " + rnd(this.g) + "%, " + rnd(this.b) + "%)"
219
+ : "rgba(" + rnd(this.r) + "%, " + rnd(this.g) + "%, " + rnd(this.b) + "%, " + this.roundA + ")";
220
+ };
212
221
  /**
213
222
  * The 'real' name of the color -if there is one.
214
223
  */
215
- toName() {
224
+ TinyColor.prototype.toName = function () {
216
225
  if (this.a === 0) {
217
226
  return 'transparent';
218
227
  }
219
228
  if (this.a < 1) {
220
229
  return false;
221
230
  }
222
- const hex = '#' + conversion_1.rgbToHex(this.r, this.g, this.b, false);
223
- for (const [key, value] of Object.entries(css_color_names_1.names)) {
231
+ var hex = '#' + conversion_1.rgbToHex(this.r, this.g, this.b, false);
232
+ for (var _i = 0, _a = Object.entries(css_color_names_1.names); _i < _a.length; _i++) {
233
+ var _b = _a[_i], key = _b[0], value = _b[1];
224
234
  if (hex === value) {
225
235
  return key;
226
236
  }
227
237
  }
228
238
  return false;
229
- }
239
+ };
230
240
  /**
231
241
  * String representation of the color.
232
242
  *
233
243
  * @param format - The format to be used when displaying the string representation.
234
244
  */
235
- toString(format) {
236
- const formatSet = Boolean(format);
245
+ TinyColor.prototype.toString = function (format) {
246
+ var formatSet = Boolean(format);
237
247
  format = format !== null && format !== void 0 ? format : this.format;
238
- let formattedString = false;
239
- const hasAlpha = this.a < 1 && this.a >= 0;
240
- const needsAlphaFormat = !formatSet && hasAlpha && (format.startsWith('hex') || format === 'name');
248
+ var formattedString = false;
249
+ var hasAlpha = this.a < 1 && this.a >= 0;
250
+ var needsAlphaFormat = !formatSet && hasAlpha && (format.startsWith('hex') || format === 'name');
241
251
  if (needsAlphaFormat) {
242
252
  // Special case for "transparent", all other non-alpha formats
243
253
  // will return rgba when there is transparency.
@@ -274,203 +284,217 @@ class TinyColor {
274
284
  formattedString = this.toHsvString();
275
285
  }
276
286
  return formattedString || this.toHexString();
277
- }
278
- toNumber() {
287
+ };
288
+ TinyColor.prototype.toNumber = function () {
279
289
  return (Math.round(this.r) << 16) + (Math.round(this.g) << 8) + Math.round(this.b);
280
- }
281
- clone() {
290
+ };
291
+ TinyColor.prototype.clone = function () {
282
292
  return new TinyColor(this.toString());
283
- }
293
+ };
284
294
  /**
285
295
  * Lighten the color a given amount. Providing 100 will always return white.
286
296
  * @param amount - valid between 1-100
287
297
  */
288
- lighten(amount = 10) {
289
- const hsl = this.toHsl();
298
+ TinyColor.prototype.lighten = function (amount) {
299
+ if (amount === void 0) { amount = 10; }
300
+ var hsl = this.toHsl();
290
301
  hsl.l += amount / 100;
291
302
  hsl.l = util_1.clamp01(hsl.l);
292
303
  return new TinyColor(hsl);
293
- }
304
+ };
294
305
  /**
295
306
  * Brighten the color a given amount, from 0 to 100.
296
307
  * @param amount - valid between 1-100
297
308
  */
298
- brighten(amount = 10) {
299
- const rgb = this.toRgb();
309
+ TinyColor.prototype.brighten = function (amount) {
310
+ if (amount === void 0) { amount = 10; }
311
+ var rgb = this.toRgb();
300
312
  rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
301
313
  rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
302
314
  rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
303
315
  return new TinyColor(rgb);
304
- }
316
+ };
305
317
  /**
306
318
  * Darken the color a given amount, from 0 to 100.
307
319
  * Providing 100 will always return black.
308
320
  * @param amount - valid between 1-100
309
321
  */
310
- darken(amount = 10) {
311
- const hsl = this.toHsl();
322
+ TinyColor.prototype.darken = function (amount) {
323
+ if (amount === void 0) { amount = 10; }
324
+ var hsl = this.toHsl();
312
325
  hsl.l -= amount / 100;
313
326
  hsl.l = util_1.clamp01(hsl.l);
314
327
  return new TinyColor(hsl);
315
- }
328
+ };
316
329
  /**
317
330
  * Mix the color with pure white, from 0 to 100.
318
331
  * Providing 0 will do nothing, providing 100 will always return white.
319
332
  * @param amount - valid between 1-100
320
333
  */
321
- tint(amount = 10) {
334
+ TinyColor.prototype.tint = function (amount) {
335
+ if (amount === void 0) { amount = 10; }
322
336
  return this.mix('white', amount);
323
- }
337
+ };
324
338
  /**
325
339
  * Mix the color with pure black, from 0 to 100.
326
340
  * Providing 0 will do nothing, providing 100 will always return black.
327
341
  * @param amount - valid between 1-100
328
342
  */
329
- shade(amount = 10) {
343
+ TinyColor.prototype.shade = function (amount) {
344
+ if (amount === void 0) { amount = 10; }
330
345
  return this.mix('black', amount);
331
- }
346
+ };
332
347
  /**
333
348
  * Desaturate the color a given amount, from 0 to 100.
334
349
  * Providing 100 will is the same as calling greyscale
335
350
  * @param amount - valid between 1-100
336
351
  */
337
- desaturate(amount = 10) {
338
- const hsl = this.toHsl();
352
+ TinyColor.prototype.desaturate = function (amount) {
353
+ if (amount === void 0) { amount = 10; }
354
+ var hsl = this.toHsl();
339
355
  hsl.s -= amount / 100;
340
356
  hsl.s = util_1.clamp01(hsl.s);
341
357
  return new TinyColor(hsl);
342
- }
358
+ };
343
359
  /**
344
360
  * Saturate the color a given amount, from 0 to 100.
345
361
  * @param amount - valid between 1-100
346
362
  */
347
- saturate(amount = 10) {
348
- const hsl = this.toHsl();
363
+ TinyColor.prototype.saturate = function (amount) {
364
+ if (amount === void 0) { amount = 10; }
365
+ var hsl = this.toHsl();
349
366
  hsl.s += amount / 100;
350
367
  hsl.s = util_1.clamp01(hsl.s);
351
368
  return new TinyColor(hsl);
352
- }
369
+ };
353
370
  /**
354
371
  * Completely desaturates a color into greyscale.
355
372
  * Same as calling `desaturate(100)`
356
373
  */
357
- greyscale() {
374
+ TinyColor.prototype.greyscale = function () {
358
375
  return this.desaturate(100);
359
- }
376
+ };
360
377
  /**
361
378
  * Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
362
379
  * Values outside of this range will be wrapped into this range.
363
380
  */
364
- spin(amount) {
365
- const hsl = this.toHsl();
366
- const hue = (hsl.h + amount) % 360;
381
+ TinyColor.prototype.spin = function (amount) {
382
+ var hsl = this.toHsl();
383
+ var hue = (hsl.h + amount) % 360;
367
384
  hsl.h = hue < 0 ? 360 + hue : hue;
368
385
  return new TinyColor(hsl);
369
- }
386
+ };
370
387
  /**
371
388
  * Mix the current color a given amount with another color, from 0 to 100.
372
389
  * 0 means no mixing (return current color).
373
390
  */
374
- mix(color, amount = 50) {
375
- const rgb1 = this.toRgb();
376
- const rgb2 = new TinyColor(color).toRgb();
377
- const p = amount / 100;
378
- const rgba = {
391
+ TinyColor.prototype.mix = function (color, amount) {
392
+ if (amount === void 0) { amount = 50; }
393
+ var rgb1 = this.toRgb();
394
+ var rgb2 = new TinyColor(color).toRgb();
395
+ var p = amount / 100;
396
+ var rgba = {
379
397
  r: (rgb2.r - rgb1.r) * p + rgb1.r,
380
398
  g: (rgb2.g - rgb1.g) * p + rgb1.g,
381
399
  b: (rgb2.b - rgb1.b) * p + rgb1.b,
382
400
  a: (rgb2.a - rgb1.a) * p + rgb1.a,
383
401
  };
384
402
  return new TinyColor(rgba);
385
- }
386
- analogous(results = 6, slices = 30) {
387
- const hsl = this.toHsl();
388
- const part = 360 / slices;
389
- const ret = [this];
403
+ };
404
+ TinyColor.prototype.analogous = function (results, slices) {
405
+ if (results === void 0) { results = 6; }
406
+ if (slices === void 0) { slices = 30; }
407
+ var hsl = this.toHsl();
408
+ var part = 360 / slices;
409
+ var ret = [this];
390
410
  for (hsl.h = (hsl.h - ((part * results) >> 1) + 720) % 360; --results;) {
391
411
  hsl.h = (hsl.h + part) % 360;
392
412
  ret.push(new TinyColor(hsl));
393
413
  }
394
414
  return ret;
395
- }
415
+ };
396
416
  /**
397
417
  * taken from https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js
398
418
  */
399
- complement() {
400
- const hsl = this.toHsl();
419
+ TinyColor.prototype.complement = function () {
420
+ var hsl = this.toHsl();
401
421
  hsl.h = (hsl.h + 180) % 360;
402
422
  return new TinyColor(hsl);
403
- }
404
- monochromatic(results = 6) {
405
- const hsv = this.toHsv();
406
- const { h } = hsv;
407
- const { s } = hsv;
408
- let { v } = hsv;
409
- const res = [];
410
- const modification = 1 / results;
423
+ };
424
+ TinyColor.prototype.monochromatic = function (results) {
425
+ if (results === void 0) { results = 6; }
426
+ var hsv = this.toHsv();
427
+ var h = hsv.h;
428
+ var s = hsv.s;
429
+ var v = hsv.v;
430
+ var res = [];
431
+ var modification = 1 / results;
411
432
  while (results--) {
412
- res.push(new TinyColor({ h, s, v }));
433
+ res.push(new TinyColor({ h: h, s: s, v: v }));
413
434
  v = (v + modification) % 1;
414
435
  }
415
436
  return res;
416
- }
417
- splitcomplement() {
418
- const hsl = this.toHsl();
419
- const { h } = hsl;
437
+ };
438
+ TinyColor.prototype.splitcomplement = function () {
439
+ var hsl = this.toHsl();
440
+ var h = hsl.h;
420
441
  return [
421
442
  this,
422
443
  new TinyColor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }),
423
444
  new TinyColor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l }),
424
445
  ];
425
- }
446
+ };
426
447
  /**
427
448
  * Compute how the color would appear on a background
428
449
  */
429
- onBackground(background) {
430
- const fg = this.toRgb();
431
- const bg = new TinyColor(background).toRgb();
450
+ TinyColor.prototype.onBackground = function (background) {
451
+ var fg = this.toRgb();
452
+ var bg = new TinyColor(background).toRgb();
432
453
  return new TinyColor({
433
454
  r: bg.r + (fg.r - bg.r) * fg.a,
434
455
  g: bg.g + (fg.g - bg.g) * fg.a,
435
456
  b: bg.b + (fg.b - bg.b) * fg.a,
436
457
  });
437
- }
458
+ };
438
459
  /**
439
460
  * Alias for `polyad(3)`
440
461
  */
441
- triad() {
462
+ TinyColor.prototype.triad = function () {
442
463
  return this.polyad(3);
443
- }
464
+ };
444
465
  /**
445
466
  * Alias for `polyad(4)`
446
467
  */
447
- tetrad() {
468
+ TinyColor.prototype.tetrad = function () {
448
469
  return this.polyad(4);
449
- }
470
+ };
450
471
  /**
451
472
  * Get polyad colors, like (for 1, 2, 3, 4, 5, 6, 7, 8, etc...)
452
473
  * monad, dyad, triad, tetrad, pentad, hexad, heptad, octad, etc...
453
474
  */
454
- polyad(n) {
455
- const hsl = this.toHsl();
456
- const { h } = hsl;
457
- const result = [this];
458
- const increment = 360 / n;
459
- for (let i = 1; i < n; i++) {
475
+ TinyColor.prototype.polyad = function (n) {
476
+ var hsl = this.toHsl();
477
+ var h = hsl.h;
478
+ var result = [this];
479
+ var increment = 360 / n;
480
+ for (var i = 1; i < n; i++) {
460
481
  result.push(new TinyColor({ h: (h + i * increment) % 360, s: hsl.s, l: hsl.l }));
461
482
  }
462
483
  return result;
463
- }
484
+ };
464
485
  /**
465
486
  * compare color vs current color
466
487
  */
467
- equals(color) {
488
+ TinyColor.prototype.equals = function (color) {
468
489
  return this.toRgbString() === new TinyColor(color).toRgbString();
469
- }
470
- }
490
+ };
491
+ return TinyColor;
492
+ }());
471
493
  exports.TinyColor = TinyColor;
472
494
  // kept for backwards compatability with v1
473
- function tinycolor(color = '', opts = {}) {
495
+ function tinycolor(color, opts) {
496
+ if (color === void 0) { color = ''; }
497
+ if (opts === void 0) { opts = {}; }
474
498
  return new TinyColor(color, opts);
475
499
  }
476
500
  exports.tinycolor = tinycolor;
@@ -70,19 +70,22 @@ var TinyColor = /** @class */ (function () {
70
70
  R = RsRGB / 12.92;
71
71
  }
72
72
  else {
73
- R = Math.pow(((RsRGB + 0.055) / 1.055), 2.4);
73
+ // eslint-disable-next-line prefer-exponentiation-operator
74
+ R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
74
75
  }
75
76
  if (GsRGB <= 0.03928) {
76
77
  G = GsRGB / 12.92;
77
78
  }
78
79
  else {
79
- G = Math.pow(((GsRGB + 0.055) / 1.055), 2.4);
80
+ // eslint-disable-next-line prefer-exponentiation-operator
81
+ G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
80
82
  }
81
83
  if (BsRGB <= 0.03928) {
82
84
  B = BsRGB / 12.92;
83
85
  }
84
86
  else {
85
- B = Math.pow(((BsRGB + 0.055) / 1.055), 2.4);
87
+ // eslint-disable-next-line prefer-exponentiation-operator
88
+ B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
86
89
  }
87
90
  return 0.2126 * R + 0.7152 * G + 0.0722 * B;
88
91
  };
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- const index_1 = require("./index");
13
+ var index_1 = require("./index");
14
14
  __exportStar(require("./index"), exports);
15
15
  __exportStar(require("./css-color-names"), exports);
16
16
  __exportStar(require("./readability"), exports);