@flighthq/motionpath 0.5.0-next.1944.cd6b6e7 → 0.5.1-edge.1047.858b9b6
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 +2 -2
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +1 -0
- package/dist/contract.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/motionPath.d.ts +4 -1
- package/dist/motionPath.d.ts.map +1 -1
- package/dist/motionPath.js +26 -16
- package/dist/motionPath.js.map +1 -1
- package/package.json +5 -4
- package/src/motionPath.test.ts +51 -20
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/motionpath`. The `@f
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/motionpath@0.5.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/motionpath@0.5.1-edge.1047.858b9b6](https://github.com/flighthq/flight/tree/858b9b601de814f6b6940cbb1ffff0916b903268/packages/motionpath)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/858b9b601de814f6b6940cbb1ffff0916b903268/LICENSE.md)
|
package/dist/contract.d.ts
CHANGED
package/dist/contract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/contract.js
CHANGED
package/dist/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createMotionPath, getMotionPathHeading, getMotionPathPosition, getMotionPathProgress, setMotionPathDistance, setMotionPathProgress, updateMotionPath, } from './contract';
|
|
1
|
+
export { createMotionPath, getMotionPathHeading, getMotionPathPosition, getMotionPathProgress, isMotionPathAtEnd, setMotionPathDistance, setMotionPathProgress, setMotionPathDirection, updateMotionPath, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { createMotionPath, getMotionPathHeading, getMotionPathPosition, getMotionPathProgress, setMotionPathDistance, setMotionPathProgress, updateMotionPath, } from './contract';
|
|
1
|
+
export { createMotionPath, getMotionPathHeading, getMotionPathPosition, getMotionPathProgress, isMotionPathAtEnd, setMotionPathDistance, setMotionPathProgress, setMotionPathDirection, updateMotionPath, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
package/dist/motionPath.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type { MotionPath, MotionPathLoopMode, Path, Vector2Like } from '@flighthq/types/contract';
|
|
1
|
+
import type { EntityConstruction, MotionPath, MotionPathLoopMode, Path, Vector2Like } from '@flighthq/types/contract';
|
|
2
2
|
export declare function createMotionPath(path: Path, speed?: number, loopMode?: MotionPathLoopMode, tolerance?: number): MotionPath;
|
|
3
3
|
export declare function getMotionPathHeading(mp: Readonly<MotionPath>): number;
|
|
4
4
|
export declare function getMotionPathPosition(mp: Readonly<MotionPath>, pointOut: Vector2Like, tangentOut: Vector2Like): boolean;
|
|
5
5
|
export declare function getMotionPathProgress(mp: Readonly<MotionPath>): number;
|
|
6
|
+
export declare function initializeMotionPath(out: EntityConstruction<MotionPath>, path: Path, speed?: number, loopMode?: MotionPathLoopMode, tolerance?: number): void;
|
|
7
|
+
export declare function isMotionPathAtEnd(mp: Readonly<MotionPath>): boolean;
|
|
8
|
+
export declare function setMotionPathDirection(mp: MotionPath, direction: 1 | -1): void;
|
|
6
9
|
export declare function setMotionPathDistance(mp: MotionPath, distance: number): void;
|
|
7
10
|
export declare function setMotionPathProgress(mp: MotionPath, t: number): void;
|
|
8
11
|
export declare function updateMotionPath(mp: MotionPath, deltaTime: number): void;
|
package/dist/motionPath.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motionPath.d.ts","sourceRoot":"","sources":["../src/motionPath.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"motionPath.d.ts","sourceRoot":"","sources":["../src/motionPath.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,kBAAkB,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEtH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,IAAI,EACV,KAAK,SAAI,EACT,QAAQ,GAAE,kBAA4B,EACtC,SAAS,CAAC,EAAE,MAAM,GACjB,UAAU,CAIZ;AAMD,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,CAGrE;AAMD,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC,EACxB,QAAQ,EAAE,WAAW,EACrB,UAAU,EAAE,WAAW,GACtB,OAAO,CAET;AAID,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,CAEtE;AASD,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,kBAAkB,CAAC,UAAU,CAAC,EACnC,IAAI,EAAE,IAAI,EACV,KAAK,SAAI,EACT,QAAQ,GAAE,kBAA4B,EACtC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI,CAON;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,OAAO,CAEnE;AAED,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAE9E;AAID,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAM5E;AAID,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAKrE;AAMD,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAQxE"}
|
package/dist/motionPath.js
CHANGED
|
@@ -1,21 +1,10 @@
|
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
1
2
|
import { createVector2 } from '@flighthq/geometry/contract';
|
|
2
3
|
import { getPathLength, getPathPositionAtDistance, getPathTangentAtDistance } from '@flighthq/path/contract';
|
|
3
|
-
// Allocate a `MotionPath` marker at the start of `path` (`distance` 0, `direction` forward).
|
|
4
|
-
// `speed` is the traversal rate in path units per second (a magnitude; default 0 = stationary),
|
|
5
|
-
// `loopMode` the end behavior (default `clamp`). The path's total arc length is measured once here
|
|
6
|
-
// with `getPathLength(path, tolerance)` and cached in `length`; per-frame updates reuse it rather
|
|
7
|
-
// than re-measuring. `tolerance` is the curve-flattening tolerance forwarded to the arc-length
|
|
8
|
-
// measurement. This is the only allocating function; `updateMotionPath` and the seek helpers write
|
|
9
|
-
// into an existing marker.
|
|
10
4
|
export function createMotionPath(path, speed = 0, loopMode = 'clamp', tolerance) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
length: getPathLength(path, tolerance),
|
|
15
|
-
loopMode,
|
|
16
|
-
path,
|
|
17
|
-
speed,
|
|
18
|
-
};
|
|
5
|
+
const out = allocateEntity();
|
|
6
|
+
initializeMotionPath(out, path, speed, loopMode, tolerance);
|
|
7
|
+
return finishEntity(out);
|
|
19
8
|
}
|
|
20
9
|
// Return the marker's heading angle in radians — `atan2(tangentY, tangentX)` of the path tangent at
|
|
21
10
|
// the current `distance` — for orienting an object along the curve. Samples the tangent into a
|
|
@@ -25,7 +14,6 @@ export function getMotionPathHeading(mp) {
|
|
|
25
14
|
getPathTangentAtDistance(mp.path, mp.distance, scratchTangent);
|
|
26
15
|
return Math.atan2(scratchTangent.y, scratchTangent.x);
|
|
27
16
|
}
|
|
28
|
-
const scratchTangent = createVector2();
|
|
29
17
|
// Sample the marker's current world position and unit tangent, writing them into `pointOut` and
|
|
30
18
|
// `tangentOut`. Returns `true` on success, `false` for an empty/degenerate path (in which case the
|
|
31
19
|
// outputs are left unchanged). Delegates to `@flighthq/path`'s `getPathPositionAtDistance` at the
|
|
@@ -38,6 +26,27 @@ export function getMotionPathPosition(mp, pointOut, tangentOut) {
|
|
|
38
26
|
export function getMotionPathProgress(mp) {
|
|
39
27
|
return mp.length > 0 ? mp.distance / mp.length : 0;
|
|
40
28
|
}
|
|
29
|
+
// Allocate a `MotionPath` marker at the start of `path` (`distance` 0, `direction` forward).
|
|
30
|
+
// `speed` is the traversal rate in path units per second (a magnitude; default 0 = stationary),
|
|
31
|
+
// `loopMode` the end behavior (default `clamp`). The path's total arc length is measured once here
|
|
32
|
+
// with `getPathLength(path, tolerance)` and cached in `length`; per-frame updates reuse it rather
|
|
33
|
+
// than re-measuring. `tolerance` is the curve-flattening tolerance forwarded to the arc-length
|
|
34
|
+
// measurement. This is the only allocating function; `updateMotionPath` and the seek helpers write
|
|
35
|
+
// into an existing marker.
|
|
36
|
+
export function initializeMotionPath(out, path, speed = 0, loopMode = 'clamp', tolerance) {
|
|
37
|
+
out.direction = 1;
|
|
38
|
+
out.distance = 0;
|
|
39
|
+
out.length = getPathLength(path, tolerance);
|
|
40
|
+
out.loopMode = loopMode;
|
|
41
|
+
out.path = path;
|
|
42
|
+
out.speed = speed;
|
|
43
|
+
}
|
|
44
|
+
export function isMotionPathAtEnd(mp) {
|
|
45
|
+
return mp.direction > 0 ? mp.distance >= mp.length : mp.distance <= 0;
|
|
46
|
+
}
|
|
47
|
+
export function setMotionPathDirection(mp, direction) {
|
|
48
|
+
mp.direction = direction;
|
|
49
|
+
}
|
|
41
50
|
// Seek the marker to an absolute arc-length `distance`, clamping to the valid `[0, length]` range.
|
|
42
51
|
// Does not change `direction` or `speed`.
|
|
43
52
|
export function setMotionPathDistance(mp, distance) {
|
|
@@ -118,4 +127,5 @@ function applyMotionPathLoopMode(mp, move, length) {
|
|
|
118
127
|
clamped = length;
|
|
119
128
|
mp.distance = clamped;
|
|
120
129
|
}
|
|
130
|
+
const scratchTangent = createVector2();
|
|
121
131
|
//# sourceMappingURL=motionPath.js.map
|
package/dist/motionPath.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motionPath.js","sourceRoot":"","sources":["../src/motionPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAG7G,
|
|
1
|
+
{"version":3,"file":"motionPath.js","sourceRoot":"","sources":["../src/motionPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAG7G,MAAM,UAAU,gBAAgB,CAC9B,IAAU,EACV,KAAK,GAAG,CAAC,EACT,WAA+B,OAAO,EACtC,SAAkB;IAElB,MAAM,GAAG,GAAG,cAAc,EAAc,CAAC;IACzC,oBAAoB,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,Q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AAE,CAAC;YACvB,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC;YACvB,EAAE,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,EAAE,CAAC,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;YAChC,EAAE,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;QACpB,CAAC;QACD,OAAO;IACT,CAAC;IAED,QAAQ;IACR,IAAI,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAC;IAC1C,IAAI,OAAO,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC,CAAC;SACxB,IAAI,OAAO,GAAG,MAAM;QAAE,OAAO,GAAG,MAAM,CAAC;IAC5C,EAAE,CAAC,QAAQ,GAAG,OAAO,CAAC;AACxB,CAAC;AAED,MAAM,cAAc,GAAG,aAAa,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/motionpath",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1-edge.1047.858b9b6",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,9 +38,10 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/
|
|
42
|
-
"@flighthq/
|
|
43
|
-
"@flighthq/
|
|
41
|
+
"@flighthq/entity": "0.5.1-edge.1047.858b9b6",
|
|
42
|
+
"@flighthq/geometry": "0.5.1-edge.1047.858b9b6",
|
|
43
|
+
"@flighthq/path": "0.5.1-edge.1047.858b9b6",
|
|
44
|
+
"@flighthq/types": "0.5.1-edge.1047.858b9b6"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"typescript": "^5.3.0"
|
package/src/motionPath.test.ts
CHANGED
|
@@ -7,8 +7,11 @@ import {
|
|
|
7
7
|
getMotionPathHeading,
|
|
8
8
|
getMotionPathPosition,
|
|
9
9
|
getMotionPathProgress,
|
|
10
|
+
isMotionPathAtEnd,
|
|
11
|
+
initializeMotionPath,
|
|
10
12
|
setMotionPathDistance,
|
|
11
13
|
setMotionPathProgress,
|
|
14
|
+
setMotionPathDirection,
|
|
12
15
|
updateMotionPath,
|
|
13
16
|
} from './motionPath';
|
|
14
17
|
|
|
@@ -93,6 +96,35 @@ describe('getMotionPathProgress', () => {
|
|
|
93
96
|
});
|
|
94
97
|
});
|
|
95
98
|
|
|
99
|
+
describe('initializeMotionPath', () => {
|
|
100
|
+
it('is the construction initializer of createMotionPath', () => {
|
|
101
|
+
expect(typeof initializeMotionPath).toBe('function');
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe('isMotionPathAtEnd', () => {
|
|
106
|
+
it('reports the terminal edge in the current direction', () => {
|
|
107
|
+
const mp = createMotionPath(line());
|
|
108
|
+
expect(isMotionPathAtEnd(mp)).toBe(false);
|
|
109
|
+
setMotionPathDistance(mp, 100);
|
|
110
|
+
expect(isMotionPathAtEnd(mp)).toBe(true);
|
|
111
|
+
setMotionPathDirection(mp, -1);
|
|
112
|
+
expect(isMotionPathAtEnd(mp)).toBe(false);
|
|
113
|
+
setMotionPathDistance(mp, 0);
|
|
114
|
+
expect(isMotionPathAtEnd(mp)).toBe(true);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('setMotionPathDirection', () => {
|
|
119
|
+
it('changes traversal direction without changing distance', () => {
|
|
120
|
+
const mp = createMotionPath(line());
|
|
121
|
+
setMotionPathDistance(mp, 25);
|
|
122
|
+
setMotionPathDirection(mp, -1);
|
|
123
|
+
expect(mp.direction).toBe(-1);
|
|
124
|
+
expect(mp.distance).toBe(25);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
96
128
|
// A straight horizontal line from (0,0) to (100,0): arc length 100.
|
|
97
129
|
describe('setMotionPathDistance', () => {
|
|
98
130
|
it('seeks to an absolute arc-length distance', () => {
|
|
@@ -135,6 +167,25 @@ describe('setMotionPathProgress', () => {
|
|
|
135
167
|
});
|
|
136
168
|
});
|
|
137
169
|
|
|
170
|
+
// A straight horizontal line from (0,0) to (100,0): arc length 100.
|
|
171
|
+
function line(): Path {
|
|
172
|
+
const path = createPath();
|
|
173
|
+
appendPathMoveTo(path, 0, 0);
|
|
174
|
+
appendPathLineTo(path, 100, 0);
|
|
175
|
+
return path;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function corner(): Path {
|
|
179
|
+
const path = createPath();
|
|
180
|
+
appendPathMoveTo(path, 0, 0);
|
|
181
|
+
appendPathLineTo(path, 100, 0);
|
|
182
|
+
appendPathLineTo(path, 100, 100);
|
|
183
|
+
return path;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function empty(): Path {
|
|
187
|
+
return createPath();
|
|
188
|
+
}
|
|
138
189
|
// A straight horizontal line from (0,0) to (100,0): arc length 100.
|
|
139
190
|
describe('updateMotionPath', () => {
|
|
140
191
|
it('advances distance by speed * deltaTime', () => {
|
|
@@ -220,23 +271,3 @@ describe('updateMotionPath', () => {
|
|
|
220
271
|
expect(mp.distance).toBe(0);
|
|
221
272
|
});
|
|
222
273
|
});
|
|
223
|
-
|
|
224
|
-
// A straight horizontal line from (0,0) to (100,0): arc length 100.
|
|
225
|
-
function line(): Path {
|
|
226
|
-
const path = createPath();
|
|
227
|
-
appendPathMoveTo(path, 0, 0);
|
|
228
|
-
appendPathLineTo(path, 100, 0);
|
|
229
|
-
return path;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function corner(): Path {
|
|
233
|
-
const path = createPath();
|
|
234
|
-
appendPathMoveTo(path, 0, 0);
|
|
235
|
-
appendPathLineTo(path, 100, 0);
|
|
236
|
-
appendPathLineTo(path, 100, 100);
|
|
237
|
-
return path;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function empty(): Path {
|
|
241
|
-
return createPath();
|
|
242
|
-
}
|