@stroke-stabilizer/core 0.2.16 → 0.3.1
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 +108 -2
- package/dist/StabilizedPointer.d.ts +1 -1
- package/dist/filters/DouglasPeuckerFilter.d.ts +37 -0
- package/dist/filters/DouglasPeuckerFilter.d.ts.map +1 -0
- package/dist/filters/EmaFilter.d.ts.map +1 -1
- package/dist/filters/KalmanFilter.d.ts.map +1 -1
- package/dist/filters/LinearPredictionFilter.d.ts.map +1 -1
- package/dist/filters/MovingAverageFilter.d.ts.map +1 -1
- package/dist/filters/OneEuroFilter.d.ts.map +1 -1
- package/dist/filters/StringFilter.d.ts.map +1 -1
- package/dist/filters/index.d.ts +2 -0
- package/dist/filters/index.d.ts.map +1 -1
- package/dist/index.cjs +578 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +578 -14
- package/dist/index.js.map +1 -1
- package/dist/prediction.d.ts +102 -0
- package/dist/prediction.d.ts.map +1 -0
- package/dist/spline.d.ts +53 -0
- package/dist/spline.d.ts.map +1 -0
- package/dist/svg.d.ts +79 -0
- package/dist/svg.d.ts.map +1 -0
- package/dist/types.d.ts +7 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/svg.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Point } from './types';
|
|
2
|
+
export interface ToSVGPathOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Number of decimal places for coordinates
|
|
5
|
+
* @default 2
|
|
6
|
+
*/
|
|
7
|
+
precision?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Use relative commands (lowercase) instead of absolute (uppercase)
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
|
+
relative?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Close the path with 'Z' command
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
closePath?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Convert an array of points to an SVG path string
|
|
21
|
+
*
|
|
22
|
+
* Generates a polyline path (M for move, L for lines).
|
|
23
|
+
* For smoother curves, consider using `toSVGPathSmooth` which uses
|
|
24
|
+
* quadratic Bezier curves.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const points = stabilizer.finish()
|
|
29
|
+
* const pathData = toSVGPath(points)
|
|
30
|
+
* // "M 10 20 L 15 25 L 20 30"
|
|
31
|
+
*
|
|
32
|
+
* // Use in SVG
|
|
33
|
+
* svg.innerHTML = `<path d="${pathData}" stroke="black" fill="none"/>`
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function toSVGPath(points: Point[], options?: ToSVGPathOptions): string;
|
|
37
|
+
export interface ToSVGPathSmoothOptions extends ToSVGPathOptions {
|
|
38
|
+
/**
|
|
39
|
+
* Smoothing tension (0-1). Higher values create tighter curves.
|
|
40
|
+
* @default 0.5
|
|
41
|
+
*/
|
|
42
|
+
tension?: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Convert an array of points to a smooth SVG path using quadratic Bezier curves
|
|
46
|
+
*
|
|
47
|
+
* Creates smoother curves by calculating control points between segments.
|
|
48
|
+
* Better for artistic strokes compared to simple polylines.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const points = stabilizer.finish()
|
|
53
|
+
* const pathData = toSVGPathSmooth(points, { tension: 0.3 })
|
|
54
|
+
* // "M 10 20 Q 12.5 22.5 15 25 Q 17.5 27.5 20 30"
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function toSVGPathSmooth(points: Point[], options?: ToSVGPathSmoothOptions): string;
|
|
58
|
+
export interface ToSVGPathCubicOptions extends ToSVGPathOptions {
|
|
59
|
+
/**
|
|
60
|
+
* Smoothing factor for control points (0-1)
|
|
61
|
+
* @default 0.25
|
|
62
|
+
*/
|
|
63
|
+
smoothing?: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Convert an array of points to a smooth SVG path using cubic Bezier curves
|
|
67
|
+
*
|
|
68
|
+
* Uses Catmull-Rom to Bezier conversion for smoother curves than quadratic.
|
|
69
|
+
* Best quality for artistic strokes.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const points = stabilizer.finish()
|
|
74
|
+
* const pathData = toSVGPathCubic(points)
|
|
75
|
+
* // "M 10 20 C 12 21 14 24 15 25 C 16 26 18 29 20 30"
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function toSVGPathCubic(points: Point[], options?: ToSVGPathCubicOptions): string;
|
|
79
|
+
//# sourceMappingURL=svg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,KAAK,EAAE,EACf,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAyCR;AAED,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC9D;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,KAAK,EAAE,EACf,OAAO,GAAE,sBAA2B,GACnC,MAAM,CA0ER;AAED,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,KAAK,EAAE,EACf,OAAO,GAAE,qBAA0B,GAClC,MAAM,CA+DR"}
|
package/dist/types.d.ts
CHANGED
|
@@ -6,10 +6,16 @@ export interface Point {
|
|
|
6
6
|
y: number;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* Pointer input point with timestamp
|
|
9
|
+
* Pointer input point with timestamp and optional pen data
|
|
10
10
|
*/
|
|
11
11
|
export interface PointerPoint extends Point {
|
|
12
|
+
/** Pen pressure (0-1) */
|
|
12
13
|
pressure?: number;
|
|
14
|
+
/** Pen tilt angle on X axis in degrees (-90 to 90) */
|
|
15
|
+
tiltX?: number;
|
|
16
|
+
/** Pen tilt angle on Y axis in degrees (-90 to 90) */
|
|
17
|
+
tiltY?: number;
|
|
18
|
+
/** Event timestamp in milliseconds */
|
|
13
19
|
timestamp: number;
|
|
14
20
|
}
|
|
15
21
|
/**
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,KAAK;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,GAAG,IAAI,CAAA;IACjD,KAAK,IAAI,IAAI,CAAA;CACd;AAED;;GAEG;AACH,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