@ctrl/tinycolor 3.6.1 → 4.0.0

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