toosoon-utils 4.1.8 → 4.2.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.
Files changed (62) hide show
  1. package/README.md +97 -885
  2. package/lib/constants.d.ts +0 -1
  3. package/lib/constants.js +3 -1
  4. package/lib/extras/color-scale/ColorScale.d.ts +2 -2
  5. package/lib/extras/color-scale/ColorScale.js +2 -2
  6. package/lib/extras/curves/CatmullRomCurve.d.ts +20 -5
  7. package/lib/extras/curves/CatmullRomCurve.js +23 -5
  8. package/lib/extras/curves/CatmullRomCurve3.d.ts +101 -0
  9. package/lib/extras/curves/CatmullRomCurve3.js +122 -0
  10. package/lib/extras/curves/CubicBezierCurve.d.ts +20 -5
  11. package/lib/extras/curves/CubicBezierCurve.js +23 -5
  12. package/lib/extras/curves/CubicBezierCurve3.d.ts +101 -0
  13. package/lib/extras/curves/CubicBezierCurve3.js +122 -0
  14. package/lib/extras/curves/Curve.d.ts +23 -24
  15. package/lib/extras/curves/Curve.js +19 -26
  16. package/lib/extras/curves/EllipseCurve.d.ts +21 -5
  17. package/lib/extras/curves/EllipseCurve.js +55 -6
  18. package/lib/extras/curves/LineCurve.d.ts +34 -10
  19. package/lib/extras/curves/LineCurve.js +35 -13
  20. package/lib/extras/curves/LineCurve3.d.ts +87 -0
  21. package/lib/extras/curves/LineCurve3.js +108 -0
  22. package/lib/extras/curves/PolylineCurve.d.ts +9 -8
  23. package/lib/extras/curves/PolylineCurve.js +6 -6
  24. package/lib/extras/curves/PolylineCurve3.d.ts +28 -0
  25. package/lib/extras/curves/PolylineCurve3.js +39 -0
  26. package/lib/extras/curves/QuadraticBezierCurve.d.ts +19 -5
  27. package/lib/extras/curves/QuadraticBezierCurve.js +22 -5
  28. package/lib/extras/curves/QuadraticBezierCurve3.d.ts +84 -0
  29. package/lib/extras/curves/QuadraticBezierCurve3.js +102 -0
  30. package/lib/extras/curves/SplineCurve.d.ts +12 -8
  31. package/lib/extras/curves/SplineCurve.js +9 -6
  32. package/lib/extras/curves/SplineCurve3.d.ts +28 -0
  33. package/lib/extras/curves/SplineCurve3.js +41 -0
  34. package/lib/extras/curves/index.d.ts +6 -0
  35. package/lib/extras/curves/index.js +6 -0
  36. package/lib/extras/geometry/Matrix2.d.ts +1 -0
  37. package/lib/extras/geometry/Matrix2.js +230 -0
  38. package/lib/extras/geometry/Matrix4.d.ts +1 -0
  39. package/lib/extras/geometry/Matrix4.js +632 -0
  40. package/lib/extras/geometry/Vector.d.ts +42 -0
  41. package/lib/extras/geometry/Vector.js +1 -0
  42. package/lib/extras/geometry/Vector2.d.ts +480 -0
  43. package/lib/extras/geometry/Vector2.js +709 -0
  44. package/lib/extras/geometry/Vector3.d.ts +486 -0
  45. package/lib/extras/geometry/Vector3.js +765 -0
  46. package/lib/extras/geometry/index.d.ts +3 -0
  47. package/lib/extras/geometry/index.js +2 -0
  48. package/lib/extras/paths/Path.d.ts +24 -18
  49. package/lib/extras/paths/Path.js +48 -35
  50. package/lib/extras/paths/PathContext.d.ts +97 -67
  51. package/lib/extras/paths/PathContext.js +326 -183
  52. package/lib/extras/paths/PathSVG.d.ts +43 -31
  53. package/lib/extras/paths/PathSVG.js +68 -50
  54. package/lib/geometry.d.ts +0 -135
  55. package/lib/geometry.js +1 -219
  56. package/lib/maths.d.ts +54 -22
  57. package/lib/maths.js +77 -27
  58. package/lib/random.d.ts +12 -16
  59. package/lib/random.js +19 -27
  60. package/lib/tsconfig.tsbuildinfo +1 -1
  61. package/lib/types.d.ts +43 -1
  62. package/package.json +2 -1
@@ -0,0 +1,3 @@
1
+ export { type Vector } from './Vector';
2
+ export { default as Vector2 } from './Vector2';
3
+ export { default as Vector3 } from './Vector3';
@@ -0,0 +1,2 @@
1
+ export { default as Vector2 } from './Vector2';
2
+ export { default as Vector3 } from './Vector3';
@@ -1,5 +1,5 @@
1
- import type { Point } from '../../types';
2
- import Curve from '../curves/Curve';
1
+ import { Curve } from '../curves';
2
+ import { type Vector, Vector2, Vector3 } from '../geometry';
3
3
  /**
4
4
  * Utility class for manipulating connected curves
5
5
  *
@@ -7,53 +7,59 @@ import Curve from '../curves/Curve';
7
7
  * @class Path
8
8
  * @extends Curve
9
9
  */
10
- export default class Path extends Curve {
10
+ export default class Path<V extends Vector = Vector2 | Vector3, S extends Curve<V> = Curve<V>> extends Curve<V> {
11
11
  readonly isPath = true;
12
12
  readonly type: string;
13
13
  /**
14
- * Array of curves composing the path
14
+ * Array of curves composing this path
15
15
  */
16
- curves: Curve[];
16
+ subpaths: S[];
17
17
  /**
18
- * Array of points composing the path
18
+ * Array of points composing this path
19
+ */
20
+ points: V[];
21
+ /**
22
+ * Define if a last point should be automatically added to close this path
19
23
  */
20
- points: Point[];
21
24
  autoClose: boolean;
25
+ constructor({ autoClose }?: {
26
+ autoClose?: boolean;
27
+ });
22
28
  /**
23
- * Add a curve to this curve path
29
+ * Add a curve to this path
24
30
  *
25
31
  * @param {Curve} curve Curve to add
26
32
  */
27
- add(curve: Curve): void;
33
+ add(curve: S): void;
28
34
  /**
29
- * Interpolate a point on the curve path
35
+ * Interpolate a point on this path
30
36
  *
31
37
  * @param {number} t Normalized time value to interpolate
32
- * @returns {Point|null} Interpolated coordinates on the curve
38
+ * @returns {Vector} Interpolated coordinates on the curve
33
39
  */
34
- getPoint(t: number): Point;
40
+ getPoint(t: number): V;
35
41
  /**
36
42
  * Compute the curve shape into an array of points
37
43
  *
38
44
  * @param {number} [divisions=40] Number of divisions
39
- * @returns {Point[]}
45
+ * @returns {Vector[]}
40
46
  */
41
- getPoints(divisions?: number): Point[];
47
+ getPoints(divisions?: number): V[];
42
48
  /**
43
49
  * Compute the curve shape into an array of equi-spaced points across the entire curve path
44
50
  *
45
51
  * @param {number} [divisions=40] Number of divisions
46
- * @returns {Point[]}
52
+ * @returns {Vector[]}
47
53
  */
48
- getSpacedPoints(divisions?: number): Point[];
54
+ getSpacedPoints(divisions?: number): V[];
49
55
  /**
50
- * Compute the total arc length of the curve path
56
+ * Compute the total arc length of this path
51
57
  *
52
58
  * @returns {number}
53
59
  */
54
60
  getLength(): number;
55
61
  /**
56
- * Compute the cumulative curve lengths of the curve path
62
+ * Compute the cumulative curve lengths of this path
57
63
  *
58
64
  * @returns {number[]}
59
65
  */
@@ -1,5 +1,4 @@
1
- import { isCoincident } from '../../geometry';
2
- import Curve from '../curves/Curve';
1
+ import { Curve, LineCurve, LineCurve3, PolylineCurve, PolylineCurve3, SplineCurve, SplineCurve3, EllipseCurve } from '../curves';
3
2
  /**
4
3
  * Utility class for manipulating connected curves
5
4
  *
@@ -11,27 +10,34 @@ export default class Path extends Curve {
11
10
  isPath = true;
12
11
  type = 'Path';
13
12
  /**
14
- * Array of curves composing the path
13
+ * Array of curves composing this path
15
14
  */
16
- curves = [];
15
+ subpaths = [];
17
16
  /**
18
- * Array of points composing the path
17
+ * Array of points composing this path
19
18
  */
20
19
  points = [];
21
- autoClose = false;
22
20
  /**
23
- * Add a curve to this curve path
21
+ * Define if a last point should be automatically added to close this path
22
+ */
23
+ autoClose;
24
+ constructor({ autoClose = false } = {}) {
25
+ super();
26
+ this.autoClose = autoClose;
27
+ }
28
+ /**
29
+ * Add a curve to this path
24
30
  *
25
31
  * @param {Curve} curve Curve to add
26
32
  */
27
33
  add(curve) {
28
- this.curves.push(curve);
34
+ this.subpaths.push(curve);
29
35
  }
30
36
  /**
31
- * Interpolate a point on the curve path
37
+ * Interpolate a point on this path
32
38
  *
33
39
  * @param {number} t Normalized time value to interpolate
34
- * @returns {Point|null} Interpolated coordinates on the curve
40
+ * @returns {Vector} Interpolated coordinates on the curve
35
41
  */
36
42
  getPoint(t) {
37
43
  const d = t * this.getLength();
@@ -40,7 +46,7 @@ export default class Path extends Curve {
40
46
  while (i < curveLengths.length) {
41
47
  if (curveLengths[i] >= d) {
42
48
  const delta = curveLengths[i] - d;
43
- const curve = this.curves[i];
49
+ const curve = this.subpaths[i];
44
50
  const segmentLength = curve.getLength();
45
51
  const u = segmentLength === 0 ? 0 : 1 - delta / segmentLength;
46
52
  return curve.getPointAt(u);
@@ -48,37 +54,43 @@ export default class Path extends Curve {
48
54
  i++;
49
55
  }
50
56
  console.warn(`Path.getPoint()`, `No point found in curve.`, this);
51
- return [0, 0];
57
+ return this.subpaths[0].getPoint(0);
52
58
  }
53
59
  /**
54
60
  * Compute the curve shape into an array of points
55
61
  *
56
62
  * @param {number} [divisions=40] Number of divisions
57
- * @returns {Point[]}
63
+ * @returns {Vector[]}
58
64
  */
59
65
  getPoints(divisions = 40) {
60
- const curves = this.curves;
61
66
  const points = [];
62
67
  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))
68
+ for (let i = 0; i < this.subpaths.length; i++) {
69
+ const curve = this.subpaths[i];
70
+ let resolution = divisions;
71
+ if (curve instanceof LineCurve || curve instanceof LineCurve3) {
72
+ resolution = 1;
73
+ }
74
+ else if (curve instanceof PolylineCurve || curve instanceof PolylineCurve3) {
75
+ resolution = curve.points.length;
76
+ }
77
+ else if (curve instanceof SplineCurve || curve instanceof SplineCurve3) {
78
+ resolution *= curve.points.length;
79
+ }
80
+ else if (curve instanceof EllipseCurve) {
81
+ resolution *= 2;
82
+ }
83
+ const pts = this.subpaths[i].getPoints(resolution);
84
+ for (let j = 0; j < pts.length; j++) {
85
+ const point = pts[j];
86
+ if (point?.equals(lastPoint))
76
87
  continue;
77
88
  points.push(point);
78
89
  lastPoint = point;
79
90
  }
80
91
  }
81
- if (this.autoClose && !Curve.isClosed(points)) {
92
+ const isClosed = points.length > 1 && points[0].equals(points[points.length - 1]);
93
+ if (this.autoClose && !isClosed) {
82
94
  points.push(points[0]);
83
95
  }
84
96
  return points;
@@ -87,20 +99,21 @@ export default class Path extends Curve {
87
99
  * Compute the curve shape into an array of equi-spaced points across the entire curve path
88
100
  *
89
101
  * @param {number} [divisions=40] Number of divisions
90
- * @returns {Point[]}
102
+ * @returns {Vector[]}
91
103
  */
92
104
  getSpacedPoints(divisions = 40) {
93
105
  const points = [];
94
106
  for (let i = 0; i <= divisions; i++) {
95
107
  points.push(this.getPoint(i / divisions));
96
108
  }
97
- if (this.autoClose && !Curve.isClosed(points)) {
109
+ const isClosed = points.length > 1 && points[0].equals(points[points.length - 1]);
110
+ if (this.autoClose && !isClosed) {
98
111
  points.push(points[0]);
99
112
  }
100
113
  return points;
101
114
  }
102
115
  /**
103
- * Compute the total arc length of the curve path
116
+ * Compute the total arc length of this path
104
117
  *
105
118
  * @returns {number}
106
119
  */
@@ -109,18 +122,18 @@ export default class Path extends Curve {
109
122
  return lengths[lengths.length - 1];
110
123
  }
111
124
  /**
112
- * Compute the cumulative curve lengths of the curve path
125
+ * Compute the cumulative curve lengths of this path
113
126
  *
114
127
  * @returns {number[]}
115
128
  */
116
129
  getCurveLengths() {
117
- if (this._cacheArcLengths.length === this.curves.length) {
130
+ if (this._cacheArcLengths.length === this.subpaths.length) {
118
131
  return this._cacheArcLengths;
119
132
  }
120
133
  const lengths = [];
121
134
  let sums = 0;
122
- for (let i = 0, l = this.curves.length; i < l; i++) {
123
- sums += this.curves[i].getLength();
135
+ for (let i = 0, j = this.subpaths.length; i < j; i++) {
136
+ sums += this.subpaths[i].getLength();
124
137
  lengths.push(sums);
125
138
  }
126
139
  this._cacheArcLengths = lengths;
@@ -1,4 +1,5 @@
1
- import type { Point } from '../../types';
1
+ import type { Point2 } from '../../types';
2
+ import { Vector2 } from '../geometry';
2
3
  import Path from './Path';
3
4
  /**
4
5
  * Utility class for manipulating connected curves providing methods similar to the 2D Canvas API
@@ -6,28 +7,36 @@ import Path from './Path';
6
7
  * @exports
7
8
  * @class PathContext
8
9
  * @extends Path
10
+ * @implements CanvasRenderingContext2D
9
11
  */
10
- export default class PathContext extends Path implements CanvasRenderingContext2D {
12
+ export default class PathContext extends Path<Vector2> implements CanvasRenderingContext2D {
11
13
  /**
12
- * Path current offset
14
+ * Path current position
13
15
  */
14
- currentPosition: Point;
16
+ currentPosition: Vector2;
15
17
  /**
16
- * Create a path from the given list of points
18
+ * Path current transformation matrix
19
+ */
20
+ currentTransform: DOMMatrix;
21
+ private _transformStack;
22
+ /**
23
+ * Create a path from a given list of points
17
24
  *
18
- * @param {Point[]} points Array of points defining the path
19
- * @param {Point[]} type Type of curve used for creating the path
25
+ * @param {Point2[]} points Array of points defining the path
20
26
  * @return {this}
21
27
  */
22
- setFromPoints(points: Point[], type?: 'lines' | 'polyline' | 'spline'): this;
28
+ setFromPoints(points: Point2[]): this;
23
29
  /**
24
- * Begin the path
25
- * Reset `currentPosition`
30
+ * Begin this path
31
+ *
32
+ * @return {this}
26
33
  */
27
- beginPath(): void;
34
+ beginPath(): this;
28
35
  /**
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
36
+ * Draw a line from the ending position to the beginning position of this path
37
+ * Add an instance of {@link LineCurve} to this path
38
+ *
39
+ * @return {this}
31
40
  */
32
41
  closePath(): this;
33
42
  /**
@@ -40,7 +49,7 @@ export default class PathContext extends Path implements CanvasRenderingContext2
40
49
  moveTo(x: number, y: number): this;
41
50
  /**
42
51
  * 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
52
+ * Add an instance of {@link LineCurve} to this path
44
53
  *
45
54
  * @param {number} x X-axis coordinate of the point
46
55
  * @param {number} y Y-axis coordinate of the point
@@ -48,28 +57,16 @@ export default class PathContext extends Path implements CanvasRenderingContext2
48
57
  */
49
58
  lineTo(x: number, y: number): this;
50
59
  /**
51
- * Draw a Polyline curve from the current position through the given points
52
- * Add an instance of {@link PolylineCurve} to the path
60
+ * Draw a Polyline curve from the current position through given points
61
+ * Add an instance of {@link PolylineCurve} to this path
53
62
  *
54
- * @param {Point[]} points Array of points defining the curve
63
+ * @param {Point2[]} points Array of points defining the curve
55
64
  * @returns {this}
56
65
  */
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;
66
+ polylineTo(points: Point2[]): this;
70
67
  /**
71
68
  * 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
69
+ * Add an instance of {@link QuadraticBezierCurve} to this path
73
70
  *
74
71
  * @param {number} cpx X-axis coordinate of the control point
75
72
  * @param {number} cpy Y-axis coordinate of the control point
@@ -80,7 +77,7 @@ export default class PathContext extends Path implements CanvasRenderingContext2
80
77
  quadraticCurveTo(cpx: number, cpy: number, x2: number, y2: number): this;
81
78
  /**
82
79
  * 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
80
+ * Add an instance of {@link CubicBezierCurve} to this path
84
81
  *
85
82
  * @param {number} cp1x X-axis coordinate of the first control point
86
83
  * @param {number} cp1y Y-axis coordinate of the first control point
@@ -93,7 +90,7 @@ export default class PathContext extends Path implements CanvasRenderingContext2
93
90
  bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): this;
94
91
  /**
95
92
  * 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
93
+ * Add an instance of {@link CatmullRomCurve} to this path
97
94
  *
98
95
  * @param {number} cp1x X-axis coordinate of the first control point
99
96
  * @param {number} cp1y Y-axis coordinate of the first control point
@@ -105,44 +102,56 @@ export default class PathContext extends Path implements CanvasRenderingContext2
105
102
  */
106
103
  catmullRomCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): this;
107
104
  /**
108
- * Draw a Spline curve from the current position through the given points
109
- * Add an instance of {@link SplineCurve} to the path
105
+ * Draw a Spline curve from the current position through given points
106
+ * Add an instance of {@link SplineCurve} to this path
110
107
  *
111
- * @param {Point[]} points Array of points defining the curve
108
+ * @param {Point2[]} points Array of points defining the curve
112
109
  * @return {this}
113
110
  */
114
- splineTo(points: Point[]): this;
111
+ splineTo(points: Point2[]): this;
115
112
  /**
116
113
  * Draw an Ellispe curve which is centered at (`cx`, `cy`) position
117
- * Add an instance of {@link EllipseCurve} to the path
114
+ * Add an instance of {@link EllipseCurve} to this path
118
115
  *
119
116
  * @param {number} cx X-axis coordinate of the center of the circle
120
117
  * @param {number} cy Y-axis coordinate of the center of the circle
121
118
  * @param {number} rx X-radius of the ellipse
122
119
  * @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)
120
+ * @param {number} rotation Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis
121
+ * @param {number} startAngle Start angle of the arc (in radians)
122
+ * @param {number} endAngle End angle of the arc (in radians)
126
123
  * @param {boolean} [counterclockwise] Flag indicating the direction of the arc
127
124
  * @return {this}
128
125
  */
129
- ellipse(cx: number, cy: number, rx: number, ry: number, rotation?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): this;
126
+ ellipse(cx: number, cy: number, rx: number, ry: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): this;
130
127
  /**
131
128
  * Draw an Arc curve which is centered at (`cx`, `cy`) position
132
- * Add an instance of {@link ArcCurve} to the path
129
+ * Add an instance of {@link ArcCurve} to this path
133
130
  *
134
131
  * @param {number} cx X-axis coordinate of the center of the circle
135
132
  * @param {number} cy Y-axis coordinate of the center of the circle
136
133
  * @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)
134
+ * @param {number} startAngle Start angle of the arc (in radians)
135
+ * @param {number} endAngle End angle of the arc (in radians)
139
136
  * @param {boolean} [counterclockwise] Flag indicating the direction of the arc
140
137
  * @return {this}
141
138
  */
142
- arc(cx: number, cy: number, radius: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): this;
139
+ arc(cx: number, cy: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): this;
140
+ /**
141
+ * Draw an Arc curve from the current position, tangential to the 2 segments created by both control points
142
+ * Add an instance of {@link ArcCurve} to this path
143
+ *
144
+ * @param {number} x1 X-axis coordinate of the first control point
145
+ * @param {number} y1 Y-axis coordinate of the first control point
146
+ * @param {number} x2 X-axis coordinate of the second control point
147
+ * @param {number} y2 Y-axis coordinate of the second control point
148
+ * @param {number} radius Arc radius (Must be non-negative)
149
+ * @returns {this}
150
+ */
151
+ arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): this;
143
152
  /**
144
153
  * 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
154
+ * Add an instance of {@link PolylineCurve} to this path
146
155
  *
147
156
  * @param {number} x X-axis coordinate of the rectangle starting point
148
157
  * @param {number} y Y-axis coordinate of the rectangle starting point
@@ -153,6 +162,7 @@ export default class PathContext extends Path implements CanvasRenderingContext2
153
162
  rect(x: number, y: number, width: number, height: number): this;
154
163
  /**
155
164
  * Draw a rounded rectangular path from the start position specified by `x` and `y` to the end position using `width` and `height`
165
+ * Add an instance of {@link Path} to this path
156
166
  *
157
167
  * @param {number} x X-axis coordinate of the rectangle starting point
158
168
  * @param {number} y Y-axis coordinate of the rectangle starting point
@@ -162,7 +172,37 @@ export default class PathContext extends Path implements CanvasRenderingContext2
162
172
  * @return {this}
163
173
  */
164
174
  roundRect(x: number, y: number, width: number, height: number, radius: number | number[]): this;
165
- protected _setCurrentPosition(x: number, y: number): void;
175
+ protected _hasCurrentPosition(): boolean;
176
+ protected _setCurrentPosition(x: number, y: number): this;
177
+ setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
178
+ setTransform(matrix: DOMMatrix): void;
179
+ getTransform(): DOMMatrix;
180
+ resetTransform(): void;
181
+ transform(a: number, b: number, c: number, d: number, e: number, f: number): void;
182
+ translate(x: number, y: number): void;
183
+ rotate(angle: number): void;
184
+ scale(x: number, y: number): void;
185
+ save(): void;
186
+ restore(): void;
187
+ reset(): void;
188
+ protected _transformPoint(point: Point2, matrix?: DOMMatrix): Point2;
189
+ protected _transformPoints(points: Point2[], matrix?: DOMMatrix): Point2[];
190
+ protected _transformVector(vector: Point2, matrix?: DOMMatrix): Point2;
191
+ protected _transformEllipse(cx: number, cy: number, rx: number, ry: number, rotation: number, matrix?: DOMMatrix): [number, number, number, number, number];
192
+ protected _inversePoint(point: Point2): Point2;
193
+ protected get _translateX(): number;
194
+ protected get _translateY(): number;
195
+ protected get _scaleX(): number;
196
+ protected get _scaleY(): number;
197
+ protected get _rotation(): number;
198
+ protected get _skewX(): number;
199
+ protected get _skewY(): number;
200
+ protected get _isTranslated(): boolean;
201
+ protected get _isScaled(): boolean;
202
+ protected get _isRotated(): boolean;
203
+ protected get _isSkewed(): boolean;
204
+ protected get _isUniform(): boolean;
205
+ protected get _isIdentity(): boolean;
166
206
  canvas: CanvasRenderingContext2D['canvas'];
167
207
  fillStyle: CanvasRenderingContext2D['fillStyle'];
168
208
  strokeStyle: CanvasRenderingContext2D['strokeStyle'];
@@ -170,8 +210,11 @@ export default class PathContext extends Path implements CanvasRenderingContext2
170
210
  lineCap: CanvasRenderingContext2D['lineCap'];
171
211
  lineJoin: CanvasRenderingContext2D['lineJoin'];
172
212
  lineDashOffset: CanvasRenderingContext2D['lineDashOffset'];
213
+ setLineDash: CanvasRenderingContext2D['setLineDash'];
214
+ getLineDash: CanvasRenderingContext2D['getLineDash'];
173
215
  fillText: CanvasRenderingContext2D['fillText'];
174
216
  strokeText: CanvasRenderingContext2D['strokeText'];
217
+ miterLimit: CanvasRenderingContext2D['miterLimit'];
175
218
  fill: CanvasRenderingContext2D['fill'];
176
219
  stroke: CanvasRenderingContext2D['stroke'];
177
220
  clearRect: CanvasRenderingContext2D['clearRect'];
@@ -179,6 +222,9 @@ export default class PathContext extends Path implements CanvasRenderingContext2
179
222
  strokeRect: CanvasRenderingContext2D['strokeRect'];
180
223
  drawImage: CanvasRenderingContext2D['drawImage'];
181
224
  clip: CanvasRenderingContext2D['clip'];
225
+ filter: CanvasRenderingContext2D['filter'];
226
+ globalAlpha: CanvasRenderingContext2D['globalAlpha'];
227
+ globalCompositeOperation: CanvasRenderingContext2D['globalCompositeOperation'];
182
228
  createLinearGradient: CanvasRenderingContext2D['createLinearGradient'];
183
229
  createRadialGradient: CanvasRenderingContext2D['createRadialGradient'];
184
230
  createConicGradient: CanvasRenderingContext2D['createConicGradient'];
@@ -199,29 +245,13 @@ export default class PathContext extends Path implements CanvasRenderingContext2
199
245
  wordSpacing: CanvasRenderingContext2D['wordSpacing'];
200
246
  direction: CanvasRenderingContext2D['direction'];
201
247
  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
248
  shadowColor: CanvasRenderingContext2D['shadowColor'];
249
+ shadowBlur: CanvasRenderingContext2D['shadowBlur'];
220
250
  shadowOffsetX: CanvasRenderingContext2D['shadowOffsetX'];
221
251
  shadowOffsetY: CanvasRenderingContext2D['shadowOffsetY'];
222
252
  drawFocusIfNeeded: CanvasRenderingContext2D['drawFocusIfNeeded'];
223
253
  isPointInPath: CanvasRenderingContext2D['isPointInPath'];
224
254
  isPointInStroke: CanvasRenderingContext2D['isPointInStroke'];
225
- getContextAttributes: CanvasRenderingContext2D['getContextAttributes'];
226
- isContextLost: () => false;
255
+ getContextAttributes(): CanvasRenderingContext2DSettings;
256
+ isContextLost(): boolean;
227
257
  }