toosoon-utils 4.1.4 → 4.1.6

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.
@@ -0,0 +1,75 @@
1
+ import { catmullRom } from '../../geometry';
2
+ import Curve from './Curve';
3
+ /**
4
+ * Utility class for manipulating Catmull-Rom curves
5
+ *
6
+ * @exports
7
+ * @class CatmullRomCurve
8
+ * @extends Curve
9
+ */
10
+ export default class CatmullRomCurve extends Curve {
11
+ type = 'CatmullRomCurve';
12
+ /**
13
+ * X-axis coordinate of the start point
14
+ */
15
+ x1;
16
+ /**
17
+ * Y-axis coordinate of the start point
18
+ */
19
+ y1;
20
+ /**
21
+ * X-axis coordinate of the first control point
22
+ */
23
+ cp1x;
24
+ /**
25
+ * Y-axis coordinate of the first control point
26
+ */
27
+ cp1y;
28
+ /**
29
+ * X-axis coordinate of the second control point
30
+ */
31
+ cp2x;
32
+ /**
33
+ * Y-axis coordinate of the second control point
34
+ */
35
+ cp2y;
36
+ /**
37
+ * X-axis coordinate of the end point
38
+ */
39
+ x2;
40
+ /**
41
+ * Y-axis coordinate of the end point
42
+ */
43
+ y2;
44
+ /**
45
+ * @param {number} x1 X-axis coordinate of the start point
46
+ * @param {number} y1 Y-axis coordinate of the start point
47
+ * @param {number} cp1x X-axis coordinate of the first control point
48
+ * @param {number} cp1y Y-axis coordinate of the first control point
49
+ * @param {number} cp2x X-axis coordinate of the second control point
50
+ * @param {number} cp2y Y-axis coordinate of the second control point
51
+ * @param {number} x2 X-axis coordinate of the end point
52
+ * @param {number} y2 Y-axis coordinate of the end point
53
+ */
54
+ constructor(x1, y1, cp1x, cp1y, cp2x, cp2y, x2, y2) {
55
+ super();
56
+ this.x1 = x1;
57
+ this.y1 = y1;
58
+ this.cp1x = cp1x;
59
+ this.cp1y = cp1y;
60
+ this.cp2x = cp2x;
61
+ this.cp2y = cp2y;
62
+ this.x2 = x2;
63
+ this.y2 = y2;
64
+ }
65
+ /**
66
+ * Interpolate a point on the Catmull-Rom curve
67
+ *
68
+ * @param {number} t Normalized time value to interpolate
69
+ * @returns {Point} Interpolated coordinates on the curve
70
+ */
71
+ getPoint(t) {
72
+ const point = catmullRom(t, this.x1, this.y1, this.cp1x, this.cp1y, this.cp2x, this.cp2y, this.x2, this.y2);
73
+ return point;
74
+ }
75
+ }
@@ -7,6 +7,7 @@ import type { Point } from '../../types';
7
7
  * @abstract
8
8
  */
9
9
  export default abstract class Curve {
10
+ readonly isCurve = true;
10
11
  readonly type: string;
11
12
  /**
12
13
  * Amount of divisions when calculating the cumulative segment lengths of a curve
@@ -7,6 +7,7 @@ import { distance, isCoincident } from '../../geometry';
7
7
  * @abstract
8
8
  */
9
9
  export default class Curve {
10
+ isCurve = true;
10
11
  type = 'Curve';
11
12
  /**
12
13
  * Amount of divisions when calculating the cumulative segment lengths of a curve
@@ -1,7 +1,7 @@
1
1
  import type { Point } from '../../types';
2
2
  import Curve from './Curve';
3
3
  /**
4
- * Utility class for manipulating Ellipse curves
4
+ * Utility class for manipulating ellipses
5
5
  *
6
6
  * @exports
7
7
  * @class EllipseCurve
@@ -28,19 +28,19 @@ export default class EllipseCurve extends Curve {
28
28
  /**
29
29
  * Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis
30
30
  */
31
- rotation?: number;
31
+ rotation: number;
32
32
  /**
33
33
  * Start angle of the arc (in radians)
34
34
  */
35
- startAngle?: number;
35
+ startAngle: number;
36
36
  /**
37
37
  * End angle of the arc (in radians)
38
38
  */
39
- endAngle?: number;
39
+ endAngle: number;
40
40
  /**
41
41
  * Flag indicating the direction of the arc
42
42
  */
43
- counterclockwise?: boolean;
43
+ counterclockwise: boolean;
44
44
  /**
45
45
  * @param {number} cx X-axis coordinate of the center of the ellipse
46
46
  * @param {number} cy Y-axis coordinate of the center of the ellipse
@@ -1,7 +1,8 @@
1
+ import { TWO_PI } from '../../constants';
1
2
  import { ellipse } from '../../geometry';
2
3
  import Curve from './Curve';
3
4
  /**
4
- * Utility class for manipulating Ellipse curves
5
+ * Utility class for manipulating ellipses
5
6
  *
6
7
  * @exports
7
8
  * @class EllipseCurve
@@ -57,10 +58,10 @@ export default class EllipseCurve extends Curve {
57
58
  this.cy = cy;
58
59
  this.rx = rx;
59
60
  this.ry = ry;
60
- this.rotation = rotation;
61
- this.startAngle = startAngle;
62
- this.endAngle = endAngle;
63
- this.counterclockwise = counterclockwise;
61
+ this.rotation = rotation ?? 0;
62
+ this.startAngle = startAngle ?? 0;
63
+ this.endAngle = endAngle ?? TWO_PI;
64
+ this.counterclockwise = counterclockwise ?? false;
64
65
  }
65
66
  /**
66
67
  * Interpolate a point on the Ellipse curve
@@ -1,7 +1,7 @@
1
1
  import type { Point } from '../../types';
2
2
  import Curve from './Curve';
3
3
  /**
4
- * Utility class for manipulating Polyline curves
4
+ * Utility class for manipulating polylines
5
5
  *
6
6
  * @exports
7
7
  * @class PolylineCurve
@@ -1,7 +1,7 @@
1
1
  import { line } from '../../geometry';
2
2
  import Curve from './Curve';
3
3
  /**
4
- * Utility class for manipulating Polyline curves
4
+ * Utility class for manipulating polylines
5
5
  *
6
6
  * @exports
7
7
  * @class PolylineCurve
@@ -1,7 +1,7 @@
1
1
  import type { Point } from '../../types';
2
2
  import Curve from './Curve';
3
3
  /**
4
- * Utility class for manipulating Spline curves
4
+ * Utility class for manipulating splines
5
5
  *
6
6
  * @exports
7
7
  * @class SplineCurve
@@ -1,7 +1,7 @@
1
1
  import { catmullRom } from '../../geometry';
2
2
  import Curve from './Curve';
3
3
  /**
4
- * Utility class for manipulating Spline curves
4
+ * Utility class for manipulating splines
5
5
  *
6
6
  * @exports
7
7
  * @class SplineCurve
@@ -3,10 +3,7 @@ export { default as LineCurve } from './LineCurve';
3
3
  export { default as PolylineCurve } from './PolylineCurve';
4
4
  export { default as QuadraticBezierCurve } from './QuadraticBezierCurve';
5
5
  export { default as CubicBezierCurve } from './CubicBezierCurve';
6
- export { default as CatmulRomCurve } from './CatmulRomCurve';
6
+ export { default as CatmullRomCurve } from './CatmullRomCurve';
7
7
  export { default as SplineCurve } from './SplineCurve';
8
8
  export { default as EllipseCurve } from './EllipseCurve';
9
9
  export { default as ArcCurve } from './ArcCurve';
10
- export { default as PathCurve } from './PathCurve';
11
- export { default as Path } from './Path';
12
- export { default as PathSVG } from './PathSVG';
@@ -3,10 +3,7 @@ export { default as LineCurve } from './LineCurve';
3
3
  export { default as PolylineCurve } from './PolylineCurve';
4
4
  export { default as QuadraticBezierCurve } from './QuadraticBezierCurve';
5
5
  export { default as CubicBezierCurve } from './CubicBezierCurve';
6
- export { default as CatmulRomCurve } from './CatmulRomCurve';
6
+ export { default as CatmullRomCurve } from './CatmullRomCurve';
7
7
  export { default as SplineCurve } from './SplineCurve';
8
8
  export { default as EllipseCurve } from './EllipseCurve';
9
9
  export { default as ArcCurve } from './ArcCurve';
10
- export { default as PathCurve } from './PathCurve';
11
- export { default as Path } from './Path';
12
- export { default as PathSVG } from './PathSVG';
@@ -0,0 +1,65 @@
1
+ import type { Point } from '../../types';
2
+ import Curve from '../curves/Curve';
3
+ /**
4
+ * Utility class for manipulating connected curves
5
+ *
6
+ * @exports
7
+ * @class Path
8
+ * @extends Curve
9
+ */
10
+ export default class Path extends Curve {
11
+ readonly isPath = true;
12
+ readonly type: string;
13
+ /**
14
+ * Array of curves composing the path
15
+ */
16
+ curves: Curve[];
17
+ /**
18
+ * Array of points composing the path
19
+ */
20
+ points: Point[];
21
+ autoClose: boolean;
22
+ /**
23
+ * Add a curve to this curve path
24
+ *
25
+ * @param {Curve} curve Curve to add
26
+ */
27
+ add(curve: Curve): void;
28
+ /**
29
+ * Interpolate a point on the curve path
30
+ *
31
+ * @param {number} t Normalized time value to interpolate
32
+ * @returns {Point|null} Interpolated coordinates on the curve
33
+ */
34
+ getPoint(t: number): Point;
35
+ /**
36
+ * Compute the curve shape into an array of points
37
+ *
38
+ * @param {number} [divisions=40] Number of divisions
39
+ * @returns {Point[]}
40
+ */
41
+ getPoints(divisions?: number): Point[];
42
+ /**
43
+ * Compute the curve shape into an array of equi-spaced points across the entire curve path
44
+ *
45
+ * @param {number} [divisions=40] Number of divisions
46
+ * @returns {Point[]}
47
+ */
48
+ getSpacedPoints(divisions?: number): Point[];
49
+ /**
50
+ * Compute the total arc length of the curve path
51
+ *
52
+ * @returns {number}
53
+ */
54
+ getLength(): number;
55
+ /**
56
+ * Compute the cumulative curve lengths of the curve path
57
+ *
58
+ * @returns {number[]}
59
+ */
60
+ getCurveLengths(): number[];
61
+ /**
62
+ * Update the cached cumulative segment lengths
63
+ */
64
+ updateArcLengths(): void;
65
+ }
@@ -0,0 +1,137 @@
1
+ import { isCoincident } from '../../geometry';
2
+ import Curve from '../curves/Curve';
3
+ /**
4
+ * Utility class for manipulating connected curves
5
+ *
6
+ * @exports
7
+ * @class Path
8
+ * @extends Curve
9
+ */
10
+ export default class Path extends Curve {
11
+ isPath = true;
12
+ type = 'Path';
13
+ /**
14
+ * Array of curves composing the path
15
+ */
16
+ curves = [];
17
+ /**
18
+ * Array of points composing the path
19
+ */
20
+ points = [];
21
+ autoClose = false;
22
+ /**
23
+ * Add a curve to this curve path
24
+ *
25
+ * @param {Curve} curve Curve to add
26
+ */
27
+ add(curve) {
28
+ this.curves.push(curve);
29
+ }
30
+ /**
31
+ * Interpolate a point on the curve path
32
+ *
33
+ * @param {number} t Normalized time value to interpolate
34
+ * @returns {Point|null} Interpolated coordinates on the curve
35
+ */
36
+ getPoint(t) {
37
+ const d = t * this.getLength();
38
+ const curveLengths = this.getCurveLengths();
39
+ let i = 0;
40
+ while (i < curveLengths.length) {
41
+ if (curveLengths[i] >= d) {
42
+ const delta = curveLengths[i] - d;
43
+ const curve = this.curves[i];
44
+ const segmentLength = curve.getLength();
45
+ const u = segmentLength === 0 ? 0 : 1 - delta / segmentLength;
46
+ return curve.getPointAt(u);
47
+ }
48
+ i++;
49
+ }
50
+ console.warn(`PathCurve.getPoint()`, `No point found in curve.`, this);
51
+ return [0, 0];
52
+ }
53
+ /**
54
+ * Compute the curve shape into an array of points
55
+ *
56
+ * @param {number} [divisions=40] Number of divisions
57
+ * @returns {Point[]}
58
+ */
59
+ getPoints(divisions = 40) {
60
+ const curves = this.curves;
61
+ const points = [];
62
+ let lastPoint = null;
63
+ for (let i = 0; i < curves.length; i++) {
64
+ const curve = curves[i];
65
+ const resolution = curve.type === 'EllipseCurve'
66
+ ? divisions * 2
67
+ : curve.type === 'LineCurve'
68
+ ? 1
69
+ : curve.type === 'SplineCurve'
70
+ ? divisions * curve.points.length
71
+ : divisions;
72
+ const points = curve.getPoints(resolution);
73
+ for (let j = 0; j < points.length; j++) {
74
+ const point = points[j];
75
+ if (lastPoint && isCoincident(...lastPoint, ...point))
76
+ continue;
77
+ points.push(point);
78
+ lastPoint = point;
79
+ }
80
+ }
81
+ if (this.autoClose && !Curve.isClosed(points)) {
82
+ points.push(points[0]);
83
+ }
84
+ return points;
85
+ }
86
+ /**
87
+ * Compute the curve shape into an array of equi-spaced points across the entire curve path
88
+ *
89
+ * @param {number} [divisions=40] Number of divisions
90
+ * @returns {Point[]}
91
+ */
92
+ getSpacedPoints(divisions = 40) {
93
+ const points = [];
94
+ for (let i = 0; i <= divisions; i++) {
95
+ points.push(this.getPoint(i / divisions));
96
+ }
97
+ if (this.autoClose && !Curve.isClosed(points)) {
98
+ points.push(points[0]);
99
+ }
100
+ return points;
101
+ }
102
+ /**
103
+ * Compute the total arc length of the curve path
104
+ *
105
+ * @returns {number}
106
+ */
107
+ getLength() {
108
+ const lengths = this.getCurveLengths();
109
+ return lengths[lengths.length - 1];
110
+ }
111
+ /**
112
+ * Compute the cumulative curve lengths of the curve path
113
+ *
114
+ * @returns {number[]}
115
+ */
116
+ getCurveLengths() {
117
+ if (this._cacheArcLengths.length === this.curves.length) {
118
+ return this._cacheArcLengths;
119
+ }
120
+ const lengths = [];
121
+ let sums = 0;
122
+ for (let i = 0, l = this.curves.length; i < l; i++) {
123
+ sums += this.curves[i].getLength();
124
+ lengths.push(sums);
125
+ }
126
+ this._cacheArcLengths = lengths;
127
+ return lengths;
128
+ }
129
+ /**
130
+ * Update the cached cumulative segment lengths
131
+ */
132
+ updateArcLengths() {
133
+ this.needsUpdate = true;
134
+ this._cacheArcLengths = [];
135
+ this.getCurveLengths();
136
+ }
137
+ }
@@ -0,0 +1,227 @@
1
+ import type { Point } from '../../types';
2
+ import Path from './Path';
3
+ /**
4
+ * Utility class for manipulating connected curves providing methods similar to the 2D Canvas API
5
+ *
6
+ * @exports
7
+ * @class PathContext
8
+ * @extends Path
9
+ */
10
+ export default class PathContext extends Path implements CanvasRenderingContext2D {
11
+ /**
12
+ * Path current offset
13
+ */
14
+ currentPosition: Point;
15
+ /**
16
+ * Create a path from the given list of points
17
+ *
18
+ * @param {Point[]} points Array of points defining the path
19
+ * @param {Point[]} type Type of curve used for creating the path
20
+ * @return {this}
21
+ */
22
+ setFromPoints(points: Point[], type?: 'lines' | 'polyline' | 'spline'): this;
23
+ /**
24
+ * Begin the path
25
+ * Reset `currentPosition`
26
+ */
27
+ beginPath(): void;
28
+ /**
29
+ * Draw a line from the ending position to the beginning position of the path
30
+ * Add an instance of {@link LineCurve} to the path
31
+ */
32
+ closePath(): this;
33
+ /**
34
+ * Move {@link Path#currentPosition} to the coordinates specified by `x` and `y`
35
+ *
36
+ * @param {number} x X-axis coordinate of the point
37
+ * @param {number} y Y-axis coordinate of the point
38
+ * @return {this}
39
+ */
40
+ moveTo(x: number, y: number): this;
41
+ /**
42
+ * Draw a line from the current position to the position specified by `x` and `y`
43
+ * Add an instance of {@link LineCurve} to the path
44
+ *
45
+ * @param {number} x X-axis coordinate of the point
46
+ * @param {number} y Y-axis coordinate of the point
47
+ * @return {this}
48
+ */
49
+ lineTo(x: number, y: number): this;
50
+ /**
51
+ * Draw a Polyline curve from the current position through the given points
52
+ * Add an instance of {@link PolylineCurve} to the path
53
+ *
54
+ * @param {Point[]} points Array of points defining the curve
55
+ * @returns {this}
56
+ */
57
+ polylineTo(points: Point[]): this;
58
+ /**
59
+ * Draw an Arc curve from the current position, tangential to the 2 segments created by both control points
60
+ * Add an instance of {@link ArcCurve} to the path
61
+ *
62
+ * @param {number} x1 X-axis coordinate of the first control point
63
+ * @param {number} y1 Y-axis coordinate of the first control point
64
+ * @param {number} x2 X-axis coordinate of the second control point
65
+ * @param {number} y2 Y-axis coordinate of the second control point
66
+ * @param {number} radius Arc radius (Must be non-negative)
67
+ * @returns {this}
68
+ */
69
+ arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): this;
70
+ /**
71
+ * Draw a Quadratic Bézier curve from the current position to the end point specified by `x` and `y`, using the control point specified by `cpx` and `cpy`
72
+ * Add an instance of {@link QuadraticBezierCurve} to the path
73
+ *
74
+ * @param {number} cpx X-axis coordinate of the control point
75
+ * @param {number} cpy Y-axis coordinate of the control point
76
+ * @param {number} x2 X-axis coordinate of the end point
77
+ * @param {number} y2 Y-axis coordinate of the end point
78
+ * @return {this}
79
+ */
80
+ quadraticCurveTo(cpx: number, cpy: number, x2: number, y2: number): this;
81
+ /**
82
+ * Draw a Cubic Bézier curve from the current position to the end point specified by `x` and `y`, using the control point specified by (`cp1x`, `cp1y`) and (`cp2x`, `cp2y`)
83
+ * Add an instance of {@link CubicBezierCurve} to the path
84
+ *
85
+ * @param {number} cp1x X-axis coordinate of the first control point
86
+ * @param {number} cp1y Y-axis coordinate of the first control point
87
+ * @param {number} cp2x X-axis coordinate of the second control point
88
+ * @param {number} cp2y Y-axis coordinate of the second control point
89
+ * @param {number} x2 X-axis coordinate of the end point
90
+ * @param {number} y2 Y-axis coordinate of the end point
91
+ * @return {this}
92
+ */
93
+ bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): this;
94
+ /**
95
+ * Draw a Catmull-Rom curve from the current position to the end point specified by `x` and `y`, using the control points specified by (`cp1x`, `cp1y`) and (`cp2x`, `cp2y`)
96
+ * Add an instance of {@link CatmullRomCurve} to the path
97
+ *
98
+ * @param {number} cp1x X-axis coordinate of the first control point
99
+ * @param {number} cp1y Y-axis coordinate of the first control point
100
+ * @param {number} cp2x X-axis coordinate of the second control point
101
+ * @param {number} cp2y Y-axis coordinate of the second control point
102
+ * @param {number} x2 X-axis coordinate of the end point
103
+ * @param {number} y2 Y-axis coordinate of the end point
104
+ * @return {this}
105
+ */
106
+ catmullRomCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): this;
107
+ /**
108
+ * Draw a Spline curve from the current position through the given points
109
+ * Add an instance of {@link SplineCurve} to the path
110
+ *
111
+ * @param {Point[]} points Array of points defining the curve
112
+ * @return {this}
113
+ */
114
+ splineTo(points: Point[]): this;
115
+ /**
116
+ * Draw an Ellispe curve which is centered at (`cx`, `cy`) position
117
+ * Add an instance of {@link EllipseCurve} to the path
118
+ *
119
+ * @param {number} cx X-axis coordinate of the center of the circle
120
+ * @param {number} cy Y-axis coordinate of the center of the circle
121
+ * @param {number} rx X-radius of the ellipse
122
+ * @param {number} ry Y-radius of the ellipse
123
+ * @param {number} [rotation] Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis
124
+ * @param {number} [startAngle] Start angle of the arc (in radians)
125
+ * @param {number} [endAngle] End angle of the arc (in radians)
126
+ * @param {boolean} [counterclockwise] Flag indicating the direction of the arc
127
+ * @return {this}
128
+ */
129
+ ellipse(cx: number, cy: number, rx: number, ry: number, rotation?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): this;
130
+ /**
131
+ * Draw an Arc curve which is centered at (`cx`, `cy`) position
132
+ * Add an instance of {@link ArcCurve} to the path
133
+ *
134
+ * @param {number} cx X-axis coordinate of the center of the circle
135
+ * @param {number} cy Y-axis coordinate of the center of the circle
136
+ * @param {number} radius Radius of the circle
137
+ * @param {number} [startAngle] Start angle of the arc (in radians)
138
+ * @param {number} [endAngle] End angle of the arc (in radians)
139
+ * @param {boolean} [counterclockwise] Flag indicating the direction of the arc
140
+ * @return {this}
141
+ */
142
+ arc(cx: number, cy: number, radius: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): this;
143
+ /**
144
+ * Draw a rectangular path from the start position specified by `x` and `y` to the end position using `width` and `height`
145
+ * Add an instance of {@link PolylineCurve} to the path
146
+ *
147
+ * @param {number} x X-axis coordinate of the rectangle starting point
148
+ * @param {number} y Y-axis coordinate of the rectangle starting point
149
+ * @param {number} width Rectangle width (Positive values are to the right and negative to the left)
150
+ * @param {number} height Rectangle height (Positive values are down, and negative are up)
151
+ * @return {this}
152
+ */
153
+ rect(x: number, y: number, width: number, height: number): this;
154
+ /**
155
+ * Draw a rounded rectangular path from the start position specified by `x` and `y` to the end position using `width` and `height`
156
+ *
157
+ * @param {number} x X-axis coordinate of the rectangle starting point
158
+ * @param {number} y Y-axis coordinate of the rectangle starting point
159
+ * @param {number} width Rectangle width (Positive values are to the right and negative to the left)
160
+ * @param {number} height Rectangle height (Positive values are down, and negative are up)
161
+ * @param {number|number[]} radius Radius of the circular arc to be used for the corners of the rectangle
162
+ * @return {this}
163
+ */
164
+ roundRect(x: number, y: number, width: number, height: number, radius: number | number[]): this;
165
+ protected _setCurrentPosition(x: number, y: number): void;
166
+ canvas: CanvasRenderingContext2D['canvas'];
167
+ fillStyle: CanvasRenderingContext2D['fillStyle'];
168
+ strokeStyle: CanvasRenderingContext2D['strokeStyle'];
169
+ lineWidth: CanvasRenderingContext2D['lineWidth'];
170
+ lineCap: CanvasRenderingContext2D['lineCap'];
171
+ lineJoin: CanvasRenderingContext2D['lineJoin'];
172
+ lineDashOffset: CanvasRenderingContext2D['lineDashOffset'];
173
+ fillText: CanvasRenderingContext2D['fillText'];
174
+ strokeText: CanvasRenderingContext2D['strokeText'];
175
+ fill: CanvasRenderingContext2D['fill'];
176
+ stroke: CanvasRenderingContext2D['stroke'];
177
+ clearRect: CanvasRenderingContext2D['clearRect'];
178
+ fillRect: CanvasRenderingContext2D['fillRect'];
179
+ strokeRect: CanvasRenderingContext2D['strokeRect'];
180
+ drawImage: CanvasRenderingContext2D['drawImage'];
181
+ clip: CanvasRenderingContext2D['clip'];
182
+ createLinearGradient: CanvasRenderingContext2D['createLinearGradient'];
183
+ createRadialGradient: CanvasRenderingContext2D['createRadialGradient'];
184
+ createConicGradient: CanvasRenderingContext2D['createConicGradient'];
185
+ createPattern: CanvasRenderingContext2D['createPattern'];
186
+ createImageData: CanvasRenderingContext2D['createImageData'];
187
+ getImageData: CanvasRenderingContext2D['getImageData'];
188
+ putImageData: CanvasRenderingContext2D['putImageData'];
189
+ imageSmoothingEnabled: CanvasRenderingContext2D['imageSmoothingEnabled'];
190
+ imageSmoothingQuality: CanvasRenderingContext2D['imageSmoothingQuality'];
191
+ font: CanvasRenderingContext2D['font'];
192
+ fontKerning: CanvasRenderingContext2D['fontKerning'];
193
+ fontStretch: CanvasRenderingContext2D['fontStretch'];
194
+ fontVariantCaps: CanvasRenderingContext2D['fontVariantCaps'];
195
+ letterSpacing: CanvasRenderingContext2D['letterSpacing'];
196
+ textAlign: CanvasRenderingContext2D['textAlign'];
197
+ textBaseline: CanvasRenderingContext2D['textBaseline'];
198
+ textRendering: CanvasRenderingContext2D['textRendering'];
199
+ wordSpacing: CanvasRenderingContext2D['wordSpacing'];
200
+ direction: CanvasRenderingContext2D['direction'];
201
+ measureText: CanvasRenderingContext2D['measureText'];
202
+ filter: CanvasRenderingContext2D['filter'];
203
+ globalAlpha: CanvasRenderingContext2D['globalAlpha'];
204
+ globalCompositeOperation: CanvasRenderingContext2D['globalCompositeOperation'];
205
+ miterLimit: CanvasRenderingContext2D['miterLimit'];
206
+ save: CanvasRenderingContext2D['save'];
207
+ restore: CanvasRenderingContext2D['restore'];
208
+ reset: CanvasRenderingContext2D['reset'];
209
+ transform: CanvasRenderingContext2D['transform'];
210
+ translate: CanvasRenderingContext2D['translate'];
211
+ rotate: CanvasRenderingContext2D['rotate'];
212
+ scale: CanvasRenderingContext2D['scale'];
213
+ getTransform: CanvasRenderingContext2D['getTransform'];
214
+ setTransform: CanvasRenderingContext2D['setTransform'];
215
+ resetTransform: CanvasRenderingContext2D['resetTransform'];
216
+ getLineDash: CanvasRenderingContext2D['getLineDash'];
217
+ setLineDash: CanvasRenderingContext2D['setLineDash'];
218
+ shadowBlur: CanvasRenderingContext2D['shadowBlur'];
219
+ shadowColor: CanvasRenderingContext2D['shadowColor'];
220
+ shadowOffsetX: CanvasRenderingContext2D['shadowOffsetX'];
221
+ shadowOffsetY: CanvasRenderingContext2D['shadowOffsetY'];
222
+ drawFocusIfNeeded: CanvasRenderingContext2D['drawFocusIfNeeded'];
223
+ isPointInPath: CanvasRenderingContext2D['isPointInPath'];
224
+ isPointInStroke: CanvasRenderingContext2D['isPointInStroke'];
225
+ getContextAttributes: CanvasRenderingContext2D['getContextAttributes'];
226
+ isContextLost: () => false;
227
+ }