toosoon-utils 4.0.6 → 4.1.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 (45) hide show
  1. package/README.md +716 -88
  2. package/lib/constants.d.ts +2 -0
  3. package/lib/constants.js +5 -3
  4. package/lib/extras/_wip/pool.d.ts +56 -0
  5. package/lib/extras/_wip/pool.js +67 -0
  6. package/lib/{classes/color-scale.d.ts → extras/color-scale/ColorScale.d.ts} +1 -1
  7. package/lib/{classes/color-scale.js → extras/color-scale/ColorScale.js} +2 -2
  8. package/lib/extras/curves/ArcCurve.d.ts +19 -0
  9. package/lib/extras/curves/ArcCurve.js +21 -0
  10. package/lib/extras/curves/CatmulRomCurve.d.ts +62 -0
  11. package/lib/extras/curves/CatmulRomCurve.js +75 -0
  12. package/lib/extras/curves/CubicBezierCurve.d.ts +62 -0
  13. package/lib/extras/curves/CubicBezierCurve.js +75 -0
  14. package/lib/extras/curves/Curve.d.ts +95 -0
  15. package/lib/extras/curves/Curve.js +174 -0
  16. package/lib/extras/curves/EllipseCurve.d.ts +63 -0
  17. package/lib/extras/curves/EllipseCurve.js +76 -0
  18. package/lib/extras/curves/LineCurve.d.ts +51 -0
  19. package/lib/extras/curves/LineCurve.js +71 -0
  20. package/lib/extras/curves/Path.d.ts +164 -0
  21. package/lib/extras/curves/Path.js +367 -0
  22. package/lib/extras/curves/PathCurve.d.ts +69 -0
  23. package/lib/extras/curves/PathCurve.js +148 -0
  24. package/lib/extras/curves/PathSVG.d.ts +41 -0
  25. package/lib/extras/curves/PathSVG.js +135 -0
  26. package/lib/extras/curves/PolylineCurve.d.ts +27 -0
  27. package/lib/extras/curves/PolylineCurve.js +39 -0
  28. package/lib/extras/curves/QuadraticBezierCurve.d.ts +52 -0
  29. package/lib/extras/curves/QuadraticBezierCurve.js +63 -0
  30. package/lib/extras/curves/SplineCurve.d.ts +24 -0
  31. package/lib/extras/curves/SplineCurve.js +38 -0
  32. package/lib/extras/curves/index.d.ts +12 -0
  33. package/lib/extras/curves/index.js +12 -0
  34. package/lib/{classes/frame-rate.js → extras/frame-rate/FrameRate.js} +1 -1
  35. package/lib/geometry.d.ts +87 -68
  36. package/lib/geometry.js +144 -140
  37. package/lib/prng.js +2 -1
  38. package/lib/random.d.ts +13 -13
  39. package/lib/random.js +14 -14
  40. package/lib/tsconfig.tsbuildinfo +1 -1
  41. package/lib/types.d.ts +3 -10
  42. package/package.json +4 -3
  43. /package/lib/{classes/_pool.d.ts → extras/_/pool.d.ts} +0 -0
  44. /package/lib/{classes/_pool.js → extras/_/pool.js} +0 -0
  45. /package/lib/{classes/frame-rate.d.ts → extras/frame-rate/FrameRate.d.ts} +0 -0
@@ -0,0 +1,174 @@
1
+ import { distance, isCoincident } from 'src/geometry';
2
+ /**
3
+ * Utility abstract class for manipulating curves
4
+ *
5
+ * @exports
6
+ * @class Curve
7
+ * @abstract
8
+ */
9
+ export default class Curve {
10
+ type = 'Curve';
11
+ /**
12
+ * Amount of divisions when calculating the cumulative segment lengths of a curve
13
+ */
14
+ arcLengthDivisions = 200;
15
+ /**
16
+ * Must be set to `true` if the curve parameters have changed
17
+ */
18
+ needsUpdate = false;
19
+ _cacheArcLengths = [];
20
+ /**
21
+ * Interpolate a point on the curve
22
+ *
23
+ * @param {number} u Normalized position value to interpolate
24
+ * @returns {Point} Interpolated coordinates on the curve
25
+ */
26
+ getPointAt(u) {
27
+ const t = this.getUtoTmapping(u);
28
+ return this.getPoint(t);
29
+ }
30
+ /**
31
+ * Compute the curve shape into an array of points
32
+ *
33
+ * @param {number} [divisions=5] Number of divisions
34
+ * @returns {Point[]}
35
+ */
36
+ getPoints(divisions = 10) {
37
+ const points = [];
38
+ for (let i = 0; i <= divisions; i++) {
39
+ points.push(this.getPoint(i / divisions));
40
+ }
41
+ return points;
42
+ }
43
+ /**
44
+ * Compute the curve shape into an array of equi-spaced points across the entire curve
45
+ *
46
+ * @param {number} [divisions=5] Number of divisions
47
+ * @returns {Point[]}
48
+ */
49
+ getSpacedPoints(divisions = 10) {
50
+ const points = [];
51
+ for (let i = 0; i <= divisions; i++) {
52
+ points.push(this.getPointAt(i / divisions));
53
+ }
54
+ return points;
55
+ }
56
+ /**
57
+ * Compute the total arc length of the curve
58
+ *
59
+ * @returns {number}
60
+ */
61
+ getLength() {
62
+ const lengths = this.getLengths();
63
+ return lengths[lengths.length - 1];
64
+ }
65
+ /**
66
+ * Compute the cumulative segment lengths of the curve
67
+ *
68
+ * @param {number} [divisions=this.arcLengthDivisions] Number of divisions
69
+ * @returns {number[]}
70
+ */
71
+ getLengths(divisions = this.arcLengthDivisions) {
72
+ if (this._cacheArcLengths.length === divisions + 1 && !this.needsUpdate) {
73
+ return this._cacheArcLengths;
74
+ }
75
+ this.needsUpdate = false;
76
+ const lengths = [0];
77
+ let currentPoint;
78
+ let lastPoint = this.getPoint(0);
79
+ let sum = 0;
80
+ for (let i = 1; i <= divisions; i++) {
81
+ currentPoint = this.getPoint(i / divisions);
82
+ sum += distance(...currentPoint, ...lastPoint);
83
+ lengths.push(sum);
84
+ lastPoint = currentPoint;
85
+ }
86
+ this._cacheArcLengths = lengths;
87
+ return lengths;
88
+ }
89
+ /**
90
+ * Update the cached cumulative segment lengths
91
+ */
92
+ updateArcLengths() {
93
+ this.needsUpdate = true;
94
+ this.getLengths();
95
+ }
96
+ /**
97
+ * Re-map a normalized position value into normalized time
98
+ *
99
+ * @param {number} u Normalized position value to interpolate
100
+ * @param {number} [targetArcLength] Distance on the curve
101
+ * @returns {number} Updated interpolation value
102
+ */
103
+ getUtoTmapping(u, targetArcLength) {
104
+ const arcLengths = this.getLengths();
105
+ let i = 0;
106
+ const length = arcLengths.length;
107
+ targetArcLength = targetArcLength ?? u * arcLengths[length - 1];
108
+ let low = 0;
109
+ let high = length - 1;
110
+ let comparison;
111
+ while (low < high) {
112
+ i = Math.floor(low + (high - low) / 2);
113
+ comparison = arcLengths[i] - targetArcLength;
114
+ if (comparison < 0) {
115
+ low = i + 1;
116
+ }
117
+ else if (comparison > 0) {
118
+ high = i - 1;
119
+ }
120
+ else {
121
+ high = i;
122
+ break;
123
+ }
124
+ }
125
+ i = high;
126
+ if (arcLengths[i] === targetArcLength) {
127
+ return i / (length - 1);
128
+ }
129
+ const lengthBefore = arcLengths[i];
130
+ const lengthAfter = arcLengths[i + 1];
131
+ const segmentLength = lengthAfter - lengthBefore;
132
+ const segmentFraction = (targetArcLength - lengthBefore) / segmentLength;
133
+ const t = (i + segmentFraction) / (length - 1);
134
+ return t;
135
+ }
136
+ /**
137
+ * Compute an unit vector tangent for the given normalized time value
138
+ *
139
+ * @param {number} t Normalized time value
140
+ * @returns {[number, number]} Tangent vector
141
+ */
142
+ getTangent(t) {
143
+ const delta = 0.0001;
144
+ let t1 = Math.max(0, t - delta);
145
+ let t2 = Math.min(1, t + delta);
146
+ const p1 = this.getPoint(t1);
147
+ const p2 = this.getPoint(t2);
148
+ let x = p2[0] - p1[0];
149
+ let y = p2[1] - p1[1];
150
+ const length = Math.sqrt(x * x + y * y);
151
+ x /= length;
152
+ y /= length;
153
+ return [x, y];
154
+ }
155
+ /**
156
+ * Compute an unit vector tangent for the given normalized position value
157
+ *
158
+ * @param {number} u Normalized position value
159
+ * @returns {[number, number]} Tangent vector
160
+ */
161
+ getTangentAt(u) {
162
+ const t = this.getUtoTmapping(u);
163
+ return this.getTangent(t);
164
+ }
165
+ /**
166
+ * Static method to check if given points are defining a closed curve
167
+ *
168
+ * @param {Point[]} points Points to check
169
+ * @returns {boolean} True if the curve is closed, false otherwise
170
+ */
171
+ static isClosed(points) {
172
+ return points.length > 1 && !isCoincident(...points[0], ...points[points.length - 1]);
173
+ }
174
+ }
@@ -0,0 +1,63 @@
1
+ import type { Point } from 'src/types';
2
+ import Curve from './Curve';
3
+ /**
4
+ * Utility class for manipulating Ellipse curves
5
+ *
6
+ * @exports
7
+ * @class EllipseCurve
8
+ * @extends Curve
9
+ */
10
+ export default class EllipseCurve extends Curve {
11
+ readonly type: string;
12
+ /**
13
+ * X-axis coordinate of the center of the ellipse
14
+ */
15
+ cx: number;
16
+ /**
17
+ * Y-axis coordinate of the center of the ellipse
18
+ */
19
+ cy: number;
20
+ /**
21
+ * X-radius of the ellipse
22
+ */
23
+ rx: number;
24
+ /**
25
+ * Y-radius of the ellipse
26
+ */
27
+ ry: number;
28
+ /**
29
+ * Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis
30
+ */
31
+ rotation?: number;
32
+ /**
33
+ * Start angle of the arc (in radians)
34
+ */
35
+ startAngle?: number;
36
+ /**
37
+ * End angle of the arc (in radians)
38
+ */
39
+ endAngle?: number;
40
+ /**
41
+ * Flag indicating the direction of the arc
42
+ */
43
+ counterclockwise?: boolean;
44
+ /**
45
+ * @param {number} cx X-axis coordinate of the center of the ellipse
46
+ * @param {number} cy Y-axis coordinate of the center of the ellipse
47
+ * @param {number} rx X-radius of the ellipse
48
+ * @param {number} ry Y-radius of the ellipse
49
+ * @param {number} [rotation] Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis
50
+ * @param {number} [startAngle] Rotation angle of the arc (in radians)
51
+ * @param {number} [endAngle] Rotation angle of the arc (in radians)
52
+ * @param {boolean} [counterclockwise] Flag indicating the direction of the arc
53
+ */
54
+ constructor(cx: number, cy: number, rx: number, ry: number, rotation?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean);
55
+ /**
56
+ * Interpolate a point on the Ellipse curve
57
+ *
58
+ * @abstract
59
+ * @param {number} t Normalized time value to interpolate
60
+ * @returns {Point} Interpolated coordinates on the curve
61
+ */
62
+ getPoint(t: number): Point;
63
+ }
@@ -0,0 +1,76 @@
1
+ import { ellipse } from 'src/geometry';
2
+ import Curve from './Curve';
3
+ /**
4
+ * Utility class for manipulating Ellipse curves
5
+ *
6
+ * @exports
7
+ * @class EllipseCurve
8
+ * @extends Curve
9
+ */
10
+ export default class EllipseCurve extends Curve {
11
+ type = 'EllipseCurve';
12
+ /**
13
+ * X-axis coordinate of the center of the ellipse
14
+ */
15
+ cx;
16
+ /**
17
+ * Y-axis coordinate of the center of the ellipse
18
+ */
19
+ cy;
20
+ /**
21
+ * X-radius of the ellipse
22
+ */
23
+ rx;
24
+ /**
25
+ * Y-radius of the ellipse
26
+ */
27
+ ry;
28
+ /**
29
+ * Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis
30
+ */
31
+ rotation;
32
+ /**
33
+ * Start angle of the arc (in radians)
34
+ */
35
+ startAngle;
36
+ /**
37
+ * End angle of the arc (in radians)
38
+ */
39
+ endAngle;
40
+ /**
41
+ * Flag indicating the direction of the arc
42
+ */
43
+ counterclockwise;
44
+ /**
45
+ * @param {number} cx X-axis coordinate of the center of the ellipse
46
+ * @param {number} cy Y-axis coordinate of the center of the ellipse
47
+ * @param {number} rx X-radius of the ellipse
48
+ * @param {number} ry Y-radius of the ellipse
49
+ * @param {number} [rotation] Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis
50
+ * @param {number} [startAngle] Rotation angle of the arc (in radians)
51
+ * @param {number} [endAngle] Rotation angle of the arc (in radians)
52
+ * @param {boolean} [counterclockwise] Flag indicating the direction of the arc
53
+ */
54
+ constructor(cx, cy, rx, ry, rotation, startAngle, endAngle, counterclockwise) {
55
+ super();
56
+ this.cx = cx;
57
+ this.cy = cy;
58
+ this.rx = rx;
59
+ this.ry = ry;
60
+ this.rotation = rotation;
61
+ this.startAngle = startAngle;
62
+ this.endAngle = endAngle;
63
+ this.counterclockwise = counterclockwise;
64
+ }
65
+ /**
66
+ * Interpolate a point on the Ellipse curve
67
+ *
68
+ * @abstract
69
+ * @param {number} t Normalized time value to interpolate
70
+ * @returns {Point} Interpolated coordinates on the curve
71
+ */
72
+ getPoint(t) {
73
+ const point = ellipse(t, this.cx, this.cy, this.rx, this.ry, this.rotation, this.startAngle, this.endAngle, this.counterclockwise);
74
+ return point;
75
+ }
76
+ }
@@ -0,0 +1,51 @@
1
+ import type { Point } from 'src/types';
2
+ import Curve from './Curve';
3
+ /**
4
+ * Utility class for manipulating lines
5
+ *
6
+ * @exports
7
+ * @class LineCurve
8
+ * @extends Curve
9
+ */
10
+ export default class LineCurve extends Curve {
11
+ readonly type: string;
12
+ /**
13
+ * X-axis coordinate of the start point
14
+ */
15
+ x1: number;
16
+ /**
17
+ * Y-axis coordinate of the start point
18
+ */
19
+ y1: number;
20
+ /**
21
+ * X-axis coordinate of the end point
22
+ */
23
+ x2: number;
24
+ /**
25
+ * Y-axis coordinate of the end point
26
+ */
27
+ y2: number;
28
+ /**
29
+ * @param {number} x1 X-axis coordinate of the start point
30
+ * @param {number} y1 Y-axis coordinate of the start point
31
+ * @param {number} x2 X-axis coordinate of the end point
32
+ * @param {number} y2 Y-axis coordinate of the end point
33
+ */
34
+ constructor(x1: number, y1: number, x2: number, y2: number);
35
+ /**
36
+ * Interpolate a point on the line
37
+ *
38
+ * @param {number} t Normalized time value to interpolate
39
+ * @returns {Point} Interpolated coordinates on the line
40
+ */
41
+ getPoint(t: number): Point;
42
+ getPointAt(u: number): Point;
43
+ /**
44
+ * Compute an unit vector tangent for the given normalized time value
45
+ *
46
+ * @param {number} t Normalized time value
47
+ * @returns {[number, number]} Tangent vector
48
+ */
49
+ getTangent(t?: number): [number, number];
50
+ getTangentAt(u: number): [number, number];
51
+ }
@@ -0,0 +1,71 @@
1
+ import { line } from 'src/geometry';
2
+ import Curve from './Curve';
3
+ /**
4
+ * Utility class for manipulating lines
5
+ *
6
+ * @exports
7
+ * @class LineCurve
8
+ * @extends Curve
9
+ */
10
+ export default class LineCurve extends Curve {
11
+ type = 'LineCurve';
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 end point
22
+ */
23
+ x2;
24
+ /**
25
+ * Y-axis coordinate of the end point
26
+ */
27
+ y2;
28
+ /**
29
+ * @param {number} x1 X-axis coordinate of the start point
30
+ * @param {number} y1 Y-axis coordinate of the start point
31
+ * @param {number} x2 X-axis coordinate of the end point
32
+ * @param {number} y2 Y-axis coordinate of the end point
33
+ */
34
+ constructor(x1, y1, x2, y2) {
35
+ super();
36
+ this.x1 = x1;
37
+ this.y1 = y1;
38
+ this.x2 = x2;
39
+ this.y2 = y2;
40
+ }
41
+ /**
42
+ * Interpolate a point on the line
43
+ *
44
+ * @param {number} t Normalized time value to interpolate
45
+ * @returns {Point} Interpolated coordinates on the line
46
+ */
47
+ getPoint(t) {
48
+ const point = line(t, this.x1, this.y1, this.x2, this.y2);
49
+ return point;
50
+ }
51
+ getPointAt(u) {
52
+ return this.getPoint(u);
53
+ }
54
+ /**
55
+ * Compute an unit vector tangent for the given normalized time value
56
+ *
57
+ * @param {number} t Normalized time value
58
+ * @returns {[number, number]} Tangent vector
59
+ */
60
+ getTangent(t) {
61
+ let x = this.x2 - this.x1;
62
+ let y = this.y2 - this.y1;
63
+ const length = Math.sqrt(x * x + y * y);
64
+ x /= length;
65
+ y /= length;
66
+ return [x, y];
67
+ }
68
+ getTangentAt(u) {
69
+ return this.getTangent(u);
70
+ }
71
+ }
@@ -0,0 +1,164 @@
1
+ import { Point } from 'src/types';
2
+ import PathCurve from './PathCurve';
3
+ /**
4
+ * Utility class for manipulating connected curves
5
+ *
6
+ * It works by providing methods for creating curves similar to the 2D Canvas API
7
+ *
8
+ *
9
+ * @exports
10
+ * @class CurvePath
11
+ * @extends PathCurve
12
+ */
13
+ export default class Path extends PathCurve {
14
+ /**
15
+ * Path current offset
16
+ */
17
+ currentPosition: Point;
18
+ /**
19
+ * Create a path from the given list of points
20
+ *
21
+ * @param {Point[]} points Array of points defining the path
22
+ * @param {Point[]} type Type of curve used for creating the path
23
+ * @return {this}
24
+ */
25
+ setFromPoints(points: Point[], type?: 'lines' | 'polyline' | 'spline'): this;
26
+ /**
27
+ * Move {@link Path#currentPosition} to the coordinates specified by `x` and `y`
28
+ *
29
+ * @param {number} x X-axis coordinate of the point
30
+ * @param {number} y Y-axis coordinate of the point
31
+ * @return {this}
32
+ */
33
+ moveTo(x: number, y: number): this;
34
+ /**
35
+ * Draw a line from the current position to the position specified by `x` and `y`
36
+ * Add an instance of {@link LineCurve} to the path
37
+ *
38
+ * @param {number} x X-axis coordinate of the point
39
+ * @param {number} y Y-axis coordinate of the point
40
+ * @return {this}
41
+ */
42
+ lineTo(x: number, y: number): this;
43
+ /**
44
+ * Draw a Polyline curve from the current position through the given points
45
+ * Add an instance of {@link PolylineCurve} to the path
46
+ *
47
+ * @param {Point[]} points Array of points defining the curve
48
+ * @returns {this}
49
+ */
50
+ polylineTo(points: Point[]): this;
51
+ /**
52
+ * Draw an Arc curve from the current position, tangential to the 2 segments created by both control points
53
+ * Add an instance of {@link ArcCurve} to the path
54
+ *
55
+ * @param {number} x1 X-axis coordinate of the first control point
56
+ * @param {number} y1 Y-axis coordinate of the first control point
57
+ * @param {number} x2 X-axis coordinate of the second control point
58
+ * @param {number} y2 Y-axis coordinate of the second control point
59
+ * @param {number} radius Arc radius (Must be non-negative)
60
+ * @returns {this}
61
+ */
62
+ arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): this;
63
+ /**
64
+ * 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`
65
+ * Add an instance of {@link QuadraticBezierCurve} to the path
66
+ *
67
+ * @param {number} cpx X-axis coordinate of the control point
68
+ * @param {number} cpy Y-axis coordinate of the control point
69
+ * @param {number} x2 X-axis coordinate of the end point
70
+ * @param {number} y2 Y-axis coordinate of the end point
71
+ * @return {this}
72
+ */
73
+ quadraticCurveTo(cpx: number, cpy: number, x2: number, y2: number): this;
74
+ /**
75
+ * 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`)
76
+ * Add an instance of {@link CubicBezierCurve} to the path
77
+ *
78
+ * @param {number} cp1x X-axis coordinate of the first control point
79
+ * @param {number} cp1y Y-axis coordinate of the first control point
80
+ * @param {number} cp2x X-axis coordinate of the second control point
81
+ * @param {number} cp2y Y-axis coordinate of the second control point
82
+ * @param {number} x2 X-axis coordinate of the end point
83
+ * @param {number} y2 Y-axis coordinate of the end point
84
+ * @return {this}
85
+ */
86
+ bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): this;
87
+ /**
88
+ * Draw a Catmul-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`)
89
+ * Add an instance of {@link CatmullRomCurve} to the path
90
+ *
91
+ * @param {number} cp1x X-axis coordinate of the first control point
92
+ * @param {number} cp1y Y-axis coordinate of the first control point
93
+ * @param {number} cp2x X-axis coordinate of the second control point
94
+ * @param {number} cp2y Y-axis coordinate of the second control point
95
+ * @param {number} x2 X-axis coordinate of the end point
96
+ * @param {number} y2 Y-axis coordinate of the end point
97
+ * @return {this}
98
+ */
99
+ catmulRomCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): this;
100
+ /**
101
+ * Draw a Spline curve from the current position through the given points
102
+ * Add an instance of {@link SplineCurve} to the path
103
+ *
104
+ * @param {Point[]} points Array of points defining the curve
105
+ * @return {this}
106
+ */
107
+ splineTo(points: Point[]): this;
108
+ /**
109
+ * Draw an Ellispe curve which is centered at (`cx`, `cy`) position
110
+ * Add an instance of {@link EllipseCurve} to the path
111
+ *
112
+ * @param {number} cx X-axis coordinate of the center of the circle
113
+ * @param {number} cy Y-axis coordinate of the center of the circle
114
+ * @param {number} rx X-radius of the ellipse
115
+ * @param {number} ry Y-radius of the ellipse
116
+ * @param {number} [rotation] Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis
117
+ * @param {number} [startAngle] Start angle of the arc (in radians)
118
+ * @param {number} [endAngle] End angle of the arc (in radians)
119
+ * @param {boolean} [counterclockwise] Flag indicating the direction of the arc
120
+ * @return {this}
121
+ */
122
+ ellipse(cx: number, cy: number, rx: number, ry: number, rotation?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): this;
123
+ /**
124
+ * Draw an Arc curve which is centered at (`cx`, `cy`) position
125
+ * Add an instance of {@link ArcCurve} to the path
126
+ *
127
+ * @param {number} cx X-axis coordinate of the center of the circle
128
+ * @param {number} cy Y-axis coordinate of the center of the circle
129
+ * @param {number} radius Radius of the circle
130
+ * @param {number} [startAngle] Start angle of the arc (in radians)
131
+ * @param {number} [endAngle] End angle of the arc (in radians)
132
+ * @param {boolean} [counterclockwise] Flag indicating the direction of the arc
133
+ * @return {this}
134
+ */
135
+ arc(cx: number, cy: number, radius: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): this;
136
+ /**
137
+ * Draw a rectangular path from the start position specified by `x` and `y` to the end position using `width` and `height`
138
+ * Add an instance of {@link PolylineCurve} to the path
139
+ *
140
+ * @param {number} x X-axis coordinate of the rectangle starting point
141
+ * @param {number} y Y-axis coordinate of the rectangle starting point
142
+ * @param {number} width Rectangle width (Positive values are to the right and negative to the left)
143
+ * @param {number} height Rectangle height (Positive values are down, and negative are up)
144
+ * @return {this}
145
+ */
146
+ rect(x: number, y: number, width: number, height: number): this;
147
+ /**
148
+ * Draw a rounded rectangular path from the start position specified by `x` and `y` to the end position using `width` and `height`
149
+ *
150
+ * @param {number} x X-axis coordinate of the rectangle starting point
151
+ * @param {number} y Y-axis coordinate of the rectangle starting point
152
+ * @param {number} width Rectangle width (Positive values are to the right and negative to the left)
153
+ * @param {number} height Rectangle height (Positive values are down, and negative are up)
154
+ * @param {number|number[]} radius Radius of the circular arc to be used for the corners of the rectangle
155
+ * @return {this}
156
+ */
157
+ roundRect(x: number, y: number, width: number, height: number, radius: number | number[]): this;
158
+ /**
159
+ * Add a line curve to close the curve path
160
+ * Add an instance of {@link LineCurve} to the path
161
+ */
162
+ closePath(): this;
163
+ private _setCurrentPosition;
164
+ }