toosoon-utils 4.3.0 → 4.4.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.
- package/README.md +55 -58
- package/lib/colors.d.ts +3 -3
- package/lib/colors.js +3 -3
- package/lib/dom.d.ts +2 -2
- package/lib/dom.js +5 -5
- package/lib/extras/colors/Color.d.ts +12 -17
- package/lib/extras/colors/Color.js +12 -17
- package/lib/extras/colors/ColorScale.d.ts +1 -1
- package/lib/extras/frame-rate/FrameRate.d.ts +11 -8
- package/lib/extras/frame-rate/FrameRate.js +8 -5
- package/lib/extras/paths/Path.js +4 -7
- package/lib/extras/paths/PathContext.d.ts +10 -8
- package/lib/extras/paths/PathContext.js +19 -13
- package/lib/files.d.ts +25 -4
- package/lib/files.js +43 -4
- package/lib/functions.d.ts +2 -2
- package/lib/functions.js +2 -2
- package/lib/geometry.d.ts +13 -13
- package/lib/geometry.js +19 -19
- package/lib/maths.d.ts +25 -25
- package/lib/maths.js +25 -25
- package/lib/prng.d.ts +10 -10
- package/lib/prng.js +10 -10
- package/lib/query.d.ts +1 -1
- package/lib/query.js +1 -1
- package/lib/random.d.ts +3 -3
- package/lib/random.js +3 -3
- package/lib/strings.d.ts +5 -5
- package/lib/strings.js +5 -5
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -333,36 +333,36 @@ toRadians(degrees: number): number;
|
|
|
333
333
|
|
|
334
334
|
##### angle(x1, y1, x2, y2)
|
|
335
335
|
|
|
336
|
-
Calculate the angle from a point to another.
|
|
336
|
+
Calculate the angle (in radians) from a point to another.
|
|
337
337
|
|
|
338
|
-
- `x1`: X
|
|
339
|
-
- `y1`: Y
|
|
340
|
-
- `x2`: X
|
|
341
|
-
- `y2`: Y
|
|
338
|
+
- `x1`: X-axis coordinate of the start point.
|
|
339
|
+
- `y1`: Y-axis coordinate of the start point.
|
|
340
|
+
- `x2`: X-axis coordinate of the end point.
|
|
341
|
+
- `y2`: Y-axis coordinate of the end point.
|
|
342
342
|
|
|
343
343
|
```ts
|
|
344
344
|
angle(x1: number, y1: number, x2: number, y2: number): number;
|
|
345
345
|
```
|
|
346
346
|
|
|
347
|
-
##### closestAngle(
|
|
347
|
+
##### closestAngle(startAngle, endAngle)
|
|
348
348
|
|
|
349
|
-
Find the closest angle between
|
|
349
|
+
Find the closest angle (in radians) between two angles.
|
|
350
350
|
|
|
351
|
-
- `
|
|
352
|
-
- `
|
|
351
|
+
- `startAngle`: Start angle (in radians).
|
|
352
|
+
- `endAngle`: End angle (in radians).
|
|
353
353
|
|
|
354
354
|
```ts
|
|
355
|
-
closestAngle(
|
|
355
|
+
closestAngle(startAngle: number, endAngle: number): number;
|
|
356
356
|
```
|
|
357
357
|
|
|
358
358
|
##### distance(x1, y1, x2, y2)
|
|
359
359
|
|
|
360
360
|
Calculate the distance between two points.
|
|
361
361
|
|
|
362
|
-
- `x1`: X-axis coordinate of the
|
|
363
|
-
- `y1`: Y-axis coordinate of the
|
|
364
|
-
- `x2`: X-axis coordinate of the
|
|
365
|
-
- `y2`: Y-axis coordinate of the
|
|
362
|
+
- `x1`: X-axis coordinate of the start point.
|
|
363
|
+
- `y1`: Y-axis coordinate of the start point.
|
|
364
|
+
- `x2`: X-axis coordinate of the end point.
|
|
365
|
+
- `y2`: Y-axis coordinate of the end point.
|
|
366
366
|
|
|
367
367
|
```ts
|
|
368
368
|
distance(x1: number, y1: number, x2: number, y2: number): number;
|
|
@@ -534,9 +534,9 @@ hsbToRgb([h, s, b]: [number, number, number]): [number, number, number];
|
|
|
534
534
|
|
|
535
535
|
##### labToHcl(lab)
|
|
536
536
|
|
|
537
|
-
Convert
|
|
537
|
+
Convert L*a*b\* to HCL.
|
|
538
538
|
|
|
539
|
-
- `lab`:
|
|
539
|
+
- `lab`: L*a*b\* color.
|
|
540
540
|
|
|
541
541
|
```ts
|
|
542
542
|
labToHcl([l, a, b]: [number, number, number]): [number, number, number];
|
|
@@ -544,7 +544,7 @@ labToHcl([l, a, b]: [number, number, number]): [number, number, number];
|
|
|
544
544
|
|
|
545
545
|
##### hclToLab(hcl)
|
|
546
546
|
|
|
547
|
-
Convert HCL to
|
|
547
|
+
Convert HCL to L\*a\*b\*.
|
|
548
548
|
|
|
549
549
|
- `hcl`: HCL color.
|
|
550
550
|
|
|
@@ -554,9 +554,9 @@ hclToLab([h, c, l]: [number, number, number]): [number, number, number];
|
|
|
554
554
|
|
|
555
555
|
##### labToRgb(lab)
|
|
556
556
|
|
|
557
|
-
Convert
|
|
557
|
+
Convert L\*a\*b\* to RGB.
|
|
558
558
|
|
|
559
|
-
- `lab`:
|
|
559
|
+
- `lab`: L\*a\*b\* color.
|
|
560
560
|
|
|
561
561
|
```ts
|
|
562
562
|
labToRgb([l, a, b]: [number, number, number]): [number, number, number];
|
|
@@ -564,7 +564,7 @@ labToRgb([l, a, b]: [number, number, number]): [number, number, number];
|
|
|
564
564
|
|
|
565
565
|
##### rgbToLab(rgb)
|
|
566
566
|
|
|
567
|
-
Convert RGB to
|
|
567
|
+
Convert RGB to L\*a\*b\*.
|
|
568
568
|
|
|
569
569
|
- `rgb`: RGB color.
|
|
570
570
|
|
|
@@ -574,10 +574,10 @@ rgbToLab([r, g, b]: [number, number, number]): [number, number, number];
|
|
|
574
574
|
|
|
575
575
|
##### deltaE(labA, labB)
|
|
576
576
|
|
|
577
|
-
Get the delta from two
|
|
577
|
+
Get the delta from two L\*a\*b\* colors.
|
|
578
578
|
|
|
579
|
-
- `labA`: First
|
|
580
|
-
- `labB`: Second
|
|
579
|
+
- `labA`: First L\*a\*b\* color.
|
|
580
|
+
- `labB`: Second L\*a\*b\* color.
|
|
581
581
|
|
|
582
582
|
```ts
|
|
583
583
|
deltaE(labA: [number, number, number], labB: [number, number, number]): number;
|
|
@@ -846,15 +846,26 @@ injectStyles(styles: string): void;
|
|
|
846
846
|
|
|
847
847
|
### Files <a id="files-functions"></a>
|
|
848
848
|
|
|
849
|
+
##### load(file)
|
|
850
|
+
|
|
851
|
+
Load a file.
|
|
852
|
+
|
|
853
|
+
- `file`: File to load.
|
|
854
|
+
|
|
855
|
+
```ts
|
|
856
|
+
async load(file: File): Promise<string>;
|
|
857
|
+
```
|
|
858
|
+
|
|
849
859
|
##### download(blob, filename)
|
|
850
860
|
|
|
851
861
|
Download a Blob object into user files.
|
|
852
862
|
|
|
853
863
|
- `blob`: Blob object to download.
|
|
854
|
-
- `
|
|
864
|
+
- `params`: Download parameters.
|
|
865
|
+
- `params.filename`: Downloaded file name.
|
|
855
866
|
|
|
856
867
|
```ts
|
|
857
|
-
download(blob: Blob, filename: string): void;
|
|
868
|
+
download(blob: Blob, { filename }: { filename: string }): void;
|
|
858
869
|
```
|
|
859
870
|
|
|
860
871
|
##### upload(onLoad)
|
|
@@ -868,6 +879,18 @@ Upload a file from user files.
|
|
|
868
879
|
upload(onLoad: (dataUrl: string) => void, accept?: string): void;
|
|
869
880
|
```
|
|
870
881
|
|
|
882
|
+
##### share(blob)
|
|
883
|
+
|
|
884
|
+
Share a Blob object with the user's device.
|
|
885
|
+
|
|
886
|
+
- `blob`: Blob object to share.
|
|
887
|
+
- `params`: Share parameters.
|
|
888
|
+
- `params.filename`: Shared file name.
|
|
889
|
+
|
|
890
|
+
```ts
|
|
891
|
+
async share(blob: Blob, { filename, ...data }: { filename: string } & ShareData): Promise<void>;
|
|
892
|
+
```
|
|
893
|
+
|
|
871
894
|
### Random <a id="random-functions"></a>
|
|
872
895
|
|
|
873
896
|
##### randomBoolean(probability)
|
|
@@ -1242,39 +1265,11 @@ See Colors utility classes documentation [here](./docs/COLORS.md).
|
|
|
1242
1265
|
|
|
1243
1266
|
#### [ColorScale](./docs/COLORS.md#color-scale)
|
|
1244
1267
|
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
Utility class for controlling FPS calls.
|
|
1248
|
-
|
|
1249
|
-
- [new FrameRate()](#frame-rate-constructor)
|
|
1250
|
-
- [.fps](#frame-rate-fps): `number`
|
|
1251
|
-
- [.update()](#frame-rate-update-method): `boolean`
|
|
1252
|
-
|
|
1253
|
-
#### Constructor <a id="frame-rate-constructor"></a>
|
|
1268
|
+
#### [ColorPalette](./docs/COLORS.md#color-palette)
|
|
1254
1269
|
|
|
1255
|
-
|
|
1256
|
-
| --------- | -------- | ------- | ----------------------- |
|
|
1257
|
-
| [fps] | `number` | `60` | Frame per second limit. |
|
|
1258
|
-
|
|
1259
|
-
#### Properties
|
|
1260
|
-
|
|
1261
|
-
##### fps <a id="frame-rate-fps"></a>
|
|
1262
|
-
|
|
1263
|
-
Frame per second limit.
|
|
1264
|
-
|
|
1265
|
-
```ts
|
|
1266
|
-
FrameRate.fps: number;
|
|
1267
|
-
```
|
|
1268
|
-
|
|
1269
|
-
#### Methods
|
|
1270
|
-
|
|
1271
|
-
##### update() <a id="frame-rate-update-method"></a>
|
|
1272
|
-
|
|
1273
|
-
Return true if elapsed time since last update is higher than current FPS.
|
|
1270
|
+
### Frame rate <a id="frame-rate-class"></a>
|
|
1274
1271
|
|
|
1275
|
-
|
|
1276
|
-
FrameRate.update(): boolean;
|
|
1277
|
-
```
|
|
1272
|
+
See `FrameRate` utility class documentation [here](./docs/FRAME_RATE.md).
|
|
1278
1273
|
|
|
1279
1274
|
## Constants
|
|
1280
1275
|
|
|
@@ -1285,9 +1280,11 @@ FrameRate.update(): boolean;
|
|
|
1285
1280
|
### Geometry
|
|
1286
1281
|
|
|
1287
1282
|
`PI`
|
|
1288
|
-
|
|
1289
|
-
`TAU`
|
|
1283
|
+
|
|
1284
|
+
`TWO_PI` / `TAU`
|
|
1285
|
+
|
|
1290
1286
|
`HALF_PI`
|
|
1287
|
+
|
|
1291
1288
|
`QUARTER_PI`
|
|
1292
1289
|
|
|
1293
1290
|
### Colors
|
package/lib/colors.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export declare function hexToRgb(hex: ColorHex | string): ColorRgb;
|
|
|
46
46
|
/**
|
|
47
47
|
* Lighten a color
|
|
48
48
|
*
|
|
49
|
-
* @param {string} hex
|
|
49
|
+
* @param {string} hex Hexadecimal string
|
|
50
50
|
* @param {number} [amount=0] Amount of the color offset
|
|
51
51
|
* @returns {string} Computed hexadecimal
|
|
52
52
|
*/
|
|
@@ -54,7 +54,7 @@ export declare function lighten(hex: string, amount?: number): string;
|
|
|
54
54
|
/**
|
|
55
55
|
* Darken a color
|
|
56
56
|
*
|
|
57
|
-
* @param {string} hex
|
|
57
|
+
* @param {string} hex Hexadecimal string
|
|
58
58
|
* @param {number} [amount=0] Amount of the color offset
|
|
59
59
|
* @returns {string} Computed hexadecimal
|
|
60
60
|
*/
|
|
@@ -142,7 +142,7 @@ export declare function hsbToRgb([h, s, b]: ColorHsb): ColorRgb;
|
|
|
142
142
|
* - Chroma: [0, ~150]
|
|
143
143
|
* - Lightness: [0, 100]
|
|
144
144
|
*
|
|
145
|
-
* @param {ColorLab} lab
|
|
145
|
+
* @param {ColorLab} lab L*a*b* color
|
|
146
146
|
* @returns {ColorHcl} HCL color
|
|
147
147
|
*/
|
|
148
148
|
export declare function labToHcl([l, a, b]: ColorLab): ColorHcl;
|
package/lib/colors.js
CHANGED
|
@@ -98,7 +98,7 @@ export function hexToRgb(hex) {
|
|
|
98
98
|
/**
|
|
99
99
|
* Lighten a color
|
|
100
100
|
*
|
|
101
|
-
* @param {string} hex
|
|
101
|
+
* @param {string} hex Hexadecimal string
|
|
102
102
|
* @param {number} [amount=0] Amount of the color offset
|
|
103
103
|
* @returns {string} Computed hexadecimal
|
|
104
104
|
*/
|
|
@@ -121,7 +121,7 @@ export function lighten(hex, amount = 0) {
|
|
|
121
121
|
/**
|
|
122
122
|
* Darken a color
|
|
123
123
|
*
|
|
124
|
-
* @param {string} hex
|
|
124
|
+
* @param {string} hex Hexadecimal string
|
|
125
125
|
* @param {number} [amount=0] Amount of the color offset
|
|
126
126
|
* @returns {string} Computed hexadecimal
|
|
127
127
|
*/
|
|
@@ -247,7 +247,7 @@ export function hsbToRgb([h, s, b]) {
|
|
|
247
247
|
* - Chroma: [0, ~150]
|
|
248
248
|
* - Lightness: [0, 100]
|
|
249
249
|
*
|
|
250
|
-
* @param {ColorLab} lab
|
|
250
|
+
* @param {ColorLab} lab L*a*b* color
|
|
251
251
|
* @returns {ColorHcl} HCL color
|
|
252
252
|
*/
|
|
253
253
|
export function labToHcl([l, a, b]) {
|
package/lib/dom.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Find the closest parent that matches a selector
|
|
3
3
|
*
|
|
4
|
-
* @param {Element|null}
|
|
4
|
+
* @param {Element|null} element Target element
|
|
5
5
|
* @param {Element|string} selector Selector or parent to match
|
|
6
6
|
* @returns {Element|null}
|
|
7
7
|
*/
|
|
@@ -9,7 +9,7 @@ export declare function closest(element: Element | null, selector: Element | str
|
|
|
9
9
|
/**
|
|
10
10
|
* Create a canvas and 2d context
|
|
11
11
|
*
|
|
12
|
-
* @param {number} width
|
|
12
|
+
* @param {number} width Width of the canvas
|
|
13
13
|
* @param {number} height Height of the canvas
|
|
14
14
|
* @returns {{ canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D }}
|
|
15
15
|
*/
|
package/lib/dom.js
CHANGED
|
@@ -2,7 +2,7 @@ const DOCUMENT_NODE_TYPE = 9;
|
|
|
2
2
|
/**
|
|
3
3
|
* Find the closest parent that matches a selector
|
|
4
4
|
*
|
|
5
|
-
* @param {Element|null}
|
|
5
|
+
* @param {Element|null} element Target element
|
|
6
6
|
* @param {Element|string} selector Selector or parent to match
|
|
7
7
|
* @returns {Element|null}
|
|
8
8
|
*/
|
|
@@ -19,7 +19,7 @@ export function closest(element, selector) {
|
|
|
19
19
|
/**
|
|
20
20
|
* Create a canvas and 2d context
|
|
21
21
|
*
|
|
22
|
-
* @param {number} width
|
|
22
|
+
* @param {number} width Width of the canvas
|
|
23
23
|
* @param {number} height Height of the canvas
|
|
24
24
|
* @returns {{ canvas: HTMLCanvasElement, ctx: CanvasRenderingContext2D }}
|
|
25
25
|
*/
|
|
@@ -38,9 +38,9 @@ export function createCanvas(width, height) {
|
|
|
38
38
|
export function injectStyles(styles) {
|
|
39
39
|
const $style = document.createElement('style');
|
|
40
40
|
$style.innerHTML = styles;
|
|
41
|
-
const $
|
|
42
|
-
if ($
|
|
43
|
-
document.head.insertBefore($style, $
|
|
41
|
+
const $headStyle = document.querySelector('head link[rel=stylesheet], head style');
|
|
42
|
+
if ($headStyle)
|
|
43
|
+
document.head.insertBefore($style, $headStyle);
|
|
44
44
|
else
|
|
45
45
|
document.head.appendChild($style);
|
|
46
46
|
}
|
|
@@ -60,7 +60,6 @@ export default class Color {
|
|
|
60
60
|
setColorName(colorName: ColorName): this;
|
|
61
61
|
/**
|
|
62
62
|
* Set this color values from a given RGB color
|
|
63
|
-
*
|
|
64
63
|
* Note:
|
|
65
64
|
* - RGB values are contained in the interval [0, 1]
|
|
66
65
|
*
|
|
@@ -77,7 +76,6 @@ export default class Color {
|
|
|
77
76
|
setHex(hex: ColorHex): this;
|
|
78
77
|
/**
|
|
79
78
|
* Set this color values from a given HSL color
|
|
80
|
-
*
|
|
81
79
|
* Note:
|
|
82
80
|
* - HSL values are contained in the intervals:
|
|
83
81
|
* - Hue: [0, 360]
|
|
@@ -90,7 +88,6 @@ export default class Color {
|
|
|
90
88
|
setHsl(hsl: ColorHsl | string): this;
|
|
91
89
|
/**
|
|
92
90
|
* Set this color values from a given HSB color
|
|
93
|
-
*
|
|
94
91
|
* Note:
|
|
95
92
|
* - HSB values are contained in the intervals:
|
|
96
93
|
* - Hue: [0, 360]
|
|
@@ -103,7 +100,6 @@ export default class Color {
|
|
|
103
100
|
setHsb(hsb: ColorHsb): this;
|
|
104
101
|
/**
|
|
105
102
|
* Set this color values from a given L*a*b* color
|
|
106
|
-
*
|
|
107
103
|
* Note:
|
|
108
104
|
* - L*a*b* values are contained in the intervals:
|
|
109
105
|
* - Lightness: [0 à 100]
|
|
@@ -116,7 +112,6 @@ export default class Color {
|
|
|
116
112
|
setLab(lab: ColorLab): this;
|
|
117
113
|
/**
|
|
118
114
|
* Set this color values from a given HCL color
|
|
119
|
-
*
|
|
120
115
|
* Note:
|
|
121
116
|
* - HCL values are contained in the intervals:
|
|
122
117
|
* - Hue: [0, 360]
|
|
@@ -140,7 +135,7 @@ export default class Color {
|
|
|
140
135
|
*
|
|
141
136
|
* @param {number} t Normalized time value to interpolate
|
|
142
137
|
* @param {ColorRgb} rgb RGB values to interpolate towards
|
|
143
|
-
* @param {
|
|
138
|
+
* @param {Object} [params] Interpolation parameters
|
|
144
139
|
* @param {number} [params.power] Interpolation exponent
|
|
145
140
|
* @returns {this}
|
|
146
141
|
*/
|
|
@@ -150,7 +145,7 @@ export default class Color {
|
|
|
150
145
|
*
|
|
151
146
|
* @param {number} t Normalized time value to interpolate
|
|
152
147
|
* @param {ColorHsl} hsl HSL values to interpolate towards
|
|
153
|
-
* @param {
|
|
148
|
+
* @param {Object} [params] Interpolation parameters
|
|
154
149
|
* @param {number|number[]} [params.power] Interpolation exponent(s) : [h, s, l]
|
|
155
150
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
156
151
|
* @returns {this}
|
|
@@ -161,7 +156,7 @@ export default class Color {
|
|
|
161
156
|
*
|
|
162
157
|
* @param {number} t Normalized time value to interpolate
|
|
163
158
|
* @param {ColorHsb} hsb HSB values to interpolate towards
|
|
164
|
-
* @param {
|
|
159
|
+
* @param {Object} [params] Interpolation parameters
|
|
165
160
|
* @param {number|number[]} [params.power] Interpolation exponent(s) : [h, s, b]
|
|
166
161
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
167
162
|
* @returns {this}
|
|
@@ -172,7 +167,7 @@ export default class Color {
|
|
|
172
167
|
*
|
|
173
168
|
* @param {number} t Normalized time value to interpolate
|
|
174
169
|
* @param {ColorHcl} hcl HCL values to interpolate towards
|
|
175
|
-
* @param {
|
|
170
|
+
* @param {Object} [params] Interpolation parameters
|
|
176
171
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
177
172
|
* @returns {this}
|
|
178
173
|
*/
|
|
@@ -182,7 +177,7 @@ export default class Color {
|
|
|
182
177
|
*
|
|
183
178
|
* @param {number} t Normalized time value to interpolate
|
|
184
179
|
* @param {ColorHcl} hcl HCL values to interpolate towards
|
|
185
|
-
* @param {
|
|
180
|
+
* @param {Object} [params] Interpolation parameters
|
|
186
181
|
* @param {number|number[]} [params.power] Interpolation exponent(s) : [c, l]
|
|
187
182
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
188
183
|
* @param {number} [params.chromaMax] Maximum chroma value
|
|
@@ -194,7 +189,7 @@ export default class Color {
|
|
|
194
189
|
*
|
|
195
190
|
* @param {number} t Normalized time value to interpolate
|
|
196
191
|
* @param {ColorHcl} hcl HCL values to interpolate towards
|
|
197
|
-
* @param {
|
|
192
|
+
* @param {Object} [params] Interpolation parameters
|
|
198
193
|
* @param {number|number[]} [params.power] Interpolation exponent(s) : ([c, l])
|
|
199
194
|
* @returns {this}
|
|
200
195
|
*/
|
|
@@ -276,7 +271,7 @@ export default class Color {
|
|
|
276
271
|
* @param {number} t Normalized time value to interpolate
|
|
277
272
|
* @param {Color|ColorRgb} rgb1 Start color
|
|
278
273
|
* @param {Color|ColorRgb} rgb2 End color
|
|
279
|
-
* @param {
|
|
274
|
+
* @param {Object} [params] Interpolation parameters
|
|
280
275
|
* @param {number} [params.power=1] Interpolation exponent
|
|
281
276
|
* @returns {ColorRgb} Interpolated RGB color
|
|
282
277
|
*/
|
|
@@ -289,7 +284,7 @@ export default class Color {
|
|
|
289
284
|
* @param {number} t Normalized time value to interpolate
|
|
290
285
|
* @param {ColorHsl} hsl1 Start color
|
|
291
286
|
* @param {ColorHsl} hsl2 End color
|
|
292
|
-
* @param {
|
|
287
|
+
* @param {Object} [params] Interpolation parameters
|
|
293
288
|
* @param {number|number[]} [params.power=1] Interpolation exponent(s) : [h, s, l]
|
|
294
289
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
295
290
|
* @returns {ColorHsl} Interpolated HSL color
|
|
@@ -304,7 +299,7 @@ export default class Color {
|
|
|
304
299
|
* @param {number} t Normalized time value to interpolate
|
|
305
300
|
* @param {ColorHsb} hsb1 Start color
|
|
306
301
|
* @param {ColorHsb} hsb2 End color
|
|
307
|
-
* @param {
|
|
302
|
+
* @param {Object} [params] Interpolation parameters
|
|
308
303
|
* @param {number|number[]} [params.power=1] Interpolation exponent(s) : [h, s, b]
|
|
309
304
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
310
305
|
* @returns {ColorHsb} Interpolated HSB color
|
|
@@ -329,7 +324,7 @@ export default class Color {
|
|
|
329
324
|
* @param {number} t Normalized time value to interpolate
|
|
330
325
|
* @param {ColorHcl} hcl1 Start color
|
|
331
326
|
* @param {ColorHcl} hcl2 End color
|
|
332
|
-
* @param {
|
|
327
|
+
* @param {Object} [params] Interpolation parameters
|
|
333
328
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
334
329
|
* @returns {ColorHcl} Interpolated HCL color
|
|
335
330
|
*/
|
|
@@ -352,7 +347,7 @@ export default class Color {
|
|
|
352
347
|
* @param {number} t Normalized time value to interpolate
|
|
353
348
|
* @param {ColorHcl} hcl1 Start color
|
|
354
349
|
* @param {ColorHcl} hcl2 End color
|
|
355
|
-
* @param {
|
|
350
|
+
* @param {Object} [params] Interpolation parameters
|
|
356
351
|
* @param {number|number[]} [params.power=1] Interpolation exponent(s) : [c, l]
|
|
357
352
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
358
353
|
* @param {number} [params.chromaMax] Maximum chroma value
|
|
@@ -378,7 +373,7 @@ export default class Color {
|
|
|
378
373
|
* @param {number} t Normalized time value to interpolate
|
|
379
374
|
* @param {ColorHcl} hcl1 Start color
|
|
380
375
|
* @param {ColorHcl} hcl2 End color
|
|
381
|
-
* @param {
|
|
376
|
+
* @param {Object} [params] Interpolation parameters
|
|
382
377
|
* @param {number|number[]} [params.power=1] Interpolation exponent(s) : ([c, l])
|
|
383
378
|
* @returns {ColorHcl} Interpolated HCL color
|
|
384
379
|
*/
|
|
@@ -64,7 +64,6 @@ export default class Color {
|
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* Set this color values from a given RGB color
|
|
67
|
-
*
|
|
68
67
|
* Note:
|
|
69
68
|
* - RGB values are contained in the interval [0, 1]
|
|
70
69
|
*
|
|
@@ -89,7 +88,6 @@ export default class Color {
|
|
|
89
88
|
}
|
|
90
89
|
/**
|
|
91
90
|
* Set this color values from a given HSL color
|
|
92
|
-
*
|
|
93
91
|
* Note:
|
|
94
92
|
* - HSL values are contained in the intervals:
|
|
95
93
|
* - Hue: [0, 360]
|
|
@@ -108,7 +106,6 @@ export default class Color {
|
|
|
108
106
|
}
|
|
109
107
|
/**
|
|
110
108
|
* Set this color values from a given HSB color
|
|
111
|
-
*
|
|
112
109
|
* Note:
|
|
113
110
|
* - HSB values are contained in the intervals:
|
|
114
111
|
* - Hue: [0, 360]
|
|
@@ -124,7 +121,6 @@ export default class Color {
|
|
|
124
121
|
}
|
|
125
122
|
/**
|
|
126
123
|
* Set this color values from a given L*a*b* color
|
|
127
|
-
*
|
|
128
124
|
* Note:
|
|
129
125
|
* - L*a*b* values are contained in the intervals:
|
|
130
126
|
* - Lightness: [0 à 100]
|
|
@@ -140,7 +136,6 @@ export default class Color {
|
|
|
140
136
|
}
|
|
141
137
|
/**
|
|
142
138
|
* Set this color values from a given HCL color
|
|
143
|
-
*
|
|
144
139
|
* Note:
|
|
145
140
|
* - HCL values are contained in the intervals:
|
|
146
141
|
* - Hue: [0, 360]
|
|
@@ -172,7 +167,7 @@ export default class Color {
|
|
|
172
167
|
*
|
|
173
168
|
* @param {number} t Normalized time value to interpolate
|
|
174
169
|
* @param {ColorRgb} rgb RGB values to interpolate towards
|
|
175
|
-
* @param {
|
|
170
|
+
* @param {Object} [params] Interpolation parameters
|
|
176
171
|
* @param {number} [params.power] Interpolation exponent
|
|
177
172
|
* @returns {this}
|
|
178
173
|
*/
|
|
@@ -184,7 +179,7 @@ export default class Color {
|
|
|
184
179
|
*
|
|
185
180
|
* @param {number} t Normalized time value to interpolate
|
|
186
181
|
* @param {ColorHsl} hsl HSL values to interpolate towards
|
|
187
|
-
* @param {
|
|
182
|
+
* @param {Object} [params] Interpolation parameters
|
|
188
183
|
* @param {number|number[]} [params.power] Interpolation exponent(s) : [h, s, l]
|
|
189
184
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
190
185
|
* @returns {this}
|
|
@@ -197,7 +192,7 @@ export default class Color {
|
|
|
197
192
|
*
|
|
198
193
|
* @param {number} t Normalized time value to interpolate
|
|
199
194
|
* @param {ColorHsb} hsb HSB values to interpolate towards
|
|
200
|
-
* @param {
|
|
195
|
+
* @param {Object} [params] Interpolation parameters
|
|
201
196
|
* @param {number|number[]} [params.power] Interpolation exponent(s) : [h, s, b]
|
|
202
197
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
203
198
|
* @returns {this}
|
|
@@ -210,7 +205,7 @@ export default class Color {
|
|
|
210
205
|
*
|
|
211
206
|
* @param {number} t Normalized time value to interpolate
|
|
212
207
|
* @param {ColorHcl} hcl HCL values to interpolate towards
|
|
213
|
-
* @param {
|
|
208
|
+
* @param {Object} [params] Interpolation parameters
|
|
214
209
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
215
210
|
* @returns {this}
|
|
216
211
|
*/
|
|
@@ -222,7 +217,7 @@ export default class Color {
|
|
|
222
217
|
*
|
|
223
218
|
* @param {number} t Normalized time value to interpolate
|
|
224
219
|
* @param {ColorHcl} hcl HCL values to interpolate towards
|
|
225
|
-
* @param {
|
|
220
|
+
* @param {Object} [params] Interpolation parameters
|
|
226
221
|
* @param {number|number[]} [params.power] Interpolation exponent(s) : [c, l]
|
|
227
222
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
228
223
|
* @param {number} [params.chromaMax] Maximum chroma value
|
|
@@ -236,7 +231,7 @@ export default class Color {
|
|
|
236
231
|
*
|
|
237
232
|
* @param {number} t Normalized time value to interpolate
|
|
238
233
|
* @param {ColorHcl} hcl HCL values to interpolate towards
|
|
239
|
-
* @param {
|
|
234
|
+
* @param {Object} [params] Interpolation parameters
|
|
240
235
|
* @param {number|number[]} [params.power] Interpolation exponent(s) : ([c, l])
|
|
241
236
|
* @returns {this}
|
|
242
237
|
*/
|
|
@@ -365,7 +360,7 @@ export default class Color {
|
|
|
365
360
|
* @param {number} t Normalized time value to interpolate
|
|
366
361
|
* @param {Color|ColorRgb} rgb1 Start color
|
|
367
362
|
* @param {Color|ColorRgb} rgb2 End color
|
|
368
|
-
* @param {
|
|
363
|
+
* @param {Object} [params] Interpolation parameters
|
|
369
364
|
* @param {number} [params.power=1] Interpolation exponent
|
|
370
365
|
* @returns {ColorRgb} Interpolated RGB color
|
|
371
366
|
*/
|
|
@@ -382,7 +377,7 @@ export default class Color {
|
|
|
382
377
|
* @param {number} t Normalized time value to interpolate
|
|
383
378
|
* @param {ColorHsl} hsl1 Start color
|
|
384
379
|
* @param {ColorHsl} hsl2 End color
|
|
385
|
-
* @param {
|
|
380
|
+
* @param {Object} [params] Interpolation parameters
|
|
386
381
|
* @param {number|number[]} [params.power=1] Interpolation exponent(s) : [h, s, l]
|
|
387
382
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
388
383
|
* @returns {ColorHsl} Interpolated HSL color
|
|
@@ -405,7 +400,7 @@ export default class Color {
|
|
|
405
400
|
* @param {number} t Normalized time value to interpolate
|
|
406
401
|
* @param {ColorHsb} hsb1 Start color
|
|
407
402
|
* @param {ColorHsb} hsb2 End color
|
|
408
|
-
* @param {
|
|
403
|
+
* @param {Object} [params] Interpolation parameters
|
|
409
404
|
* @param {number|number[]} [params.power=1] Interpolation exponent(s) : [h, s, b]
|
|
410
405
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
411
406
|
* @returns {ColorHsb} Interpolated HSB color
|
|
@@ -438,7 +433,7 @@ export default class Color {
|
|
|
438
433
|
* @param {number} t Normalized time value to interpolate
|
|
439
434
|
* @param {ColorHcl} hcl1 Start color
|
|
440
435
|
* @param {ColorHcl} hcl2 End color
|
|
441
|
-
* @param {
|
|
436
|
+
* @param {Object} [params] Interpolation parameters
|
|
442
437
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
443
438
|
* @returns {ColorHcl} Interpolated HCL color
|
|
444
439
|
*/
|
|
@@ -464,7 +459,7 @@ export default class Color {
|
|
|
464
459
|
* @param {number} t Normalized time value to interpolate
|
|
465
460
|
* @param {ColorHcl} hcl1 Start color
|
|
466
461
|
* @param {ColorHcl} hcl2 End color
|
|
467
|
-
* @param {
|
|
462
|
+
* @param {Object} [params] Interpolation parameters
|
|
468
463
|
* @param {number|number[]} [params.power=1] Interpolation exponent(s) : [c, l]
|
|
469
464
|
* @param {string} [params.hueMode] Hue interpolation mode. Can be 'direct' | 'shortest' | 'longest'
|
|
470
465
|
* @param {number} [params.chromaMax] Maximum chroma value
|
|
@@ -495,7 +490,7 @@ export default class Color {
|
|
|
495
490
|
* @param {number} t Normalized time value to interpolate
|
|
496
491
|
* @param {ColorHcl} hcl1 Start color
|
|
497
492
|
* @param {ColorHcl} hcl2 End color
|
|
498
|
-
* @param {
|
|
493
|
+
* @param {Object} [params] Interpolation parameters
|
|
499
494
|
* @param {number|number[]} [params.power=1] Interpolation exponent(s) : ([c, l])
|
|
500
495
|
* @returns {ColorHcl} Interpolated HCL color
|
|
501
496
|
*/
|
|
@@ -253,5 +253,5 @@ export default class ColorScale {
|
|
|
253
253
|
* @returns {ColorScale} Processed color scale
|
|
254
254
|
*/
|
|
255
255
|
static process(scale: ColorScale, params?: ColorScaleProcessingParameters): ColorScale;
|
|
256
|
-
|
|
256
|
+
protected static _getInterpolateFunction<I extends ColorInterpolation>(interpolation: I, color1: Color, color2: Color, params?: ColorInterpolationsParameters[I]): (t: number) => Color;
|
|
257
257
|
}
|
|
@@ -5,21 +5,24 @@
|
|
|
5
5
|
* @class FrameRate
|
|
6
6
|
*/
|
|
7
7
|
export default class FrameRate {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
protected _fps: number;
|
|
9
|
+
protected _interval: number;
|
|
10
|
+
protected _time: number;
|
|
11
|
+
protected _elapsedTime: number;
|
|
12
|
+
protected _lastUpdate: number;
|
|
13
13
|
/**
|
|
14
14
|
* @param {number} [fps=60] Frame per second limit
|
|
15
15
|
*/
|
|
16
16
|
constructor(fps?: number);
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Check if elapsed time since last update is higher than current FPS
|
|
19
19
|
*
|
|
20
|
-
* @returns {boolean}
|
|
20
|
+
* @returns {boolean} True if elapsed time since last update is higher than current FPS, false otherwise
|
|
21
21
|
*/
|
|
22
22
|
update(): boolean;
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Frame per second limit
|
|
25
|
+
*/
|
|
24
26
|
set fps(fps: number);
|
|
27
|
+
get fps(): number;
|
|
25
28
|
}
|
|
@@ -18,9 +18,9 @@ export default class FrameRate {
|
|
|
18
18
|
this.fps = fps;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Check if elapsed time since last update is higher than current FPS
|
|
22
22
|
*
|
|
23
|
-
* @returns {boolean}
|
|
23
|
+
* @returns {boolean} True if elapsed time since last update is higher than current FPS, false otherwise
|
|
24
24
|
*/
|
|
25
25
|
update() {
|
|
26
26
|
this._time = now();
|
|
@@ -31,11 +31,14 @@ export default class FrameRate {
|
|
|
31
31
|
this._lastUpdate = this._time - (this._elapsedTime % this._interval);
|
|
32
32
|
return true;
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Frame per second limit
|
|
36
|
+
*/
|
|
37
37
|
set fps(fps) {
|
|
38
38
|
this._fps = fps;
|
|
39
39
|
this._interval = 1000 / fps;
|
|
40
40
|
}
|
|
41
|
+
get fps() {
|
|
42
|
+
return this._fps;
|
|
43
|
+
}
|
|
41
44
|
}
|