@thi.ng/geom-sdf 1.0.86 → 1.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.
- package/package.json +13 -13
- package/shapes.d.ts +14 -0
- package/shapes.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/geom-sdf",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "2D Signed Distance Field creation from @thi.ng/geom shapes, conversions, sampling, combinators",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -40,17 +40,17 @@
|
|
|
40
40
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@thi.ng/api": "^8.12.
|
|
44
|
-
"@thi.ng/checks": "^3.9.
|
|
45
|
-
"@thi.ng/defmulti": "^3.0.
|
|
46
|
-
"@thi.ng/errors": "^2.6.
|
|
47
|
-
"@thi.ng/geom": "^8.3.
|
|
48
|
-
"@thi.ng/geom-isoline": "^2.1.
|
|
49
|
-
"@thi.ng/geom-poly-utils": "^3.1.
|
|
50
|
-
"@thi.ng/geom-resample": "^3.0.
|
|
51
|
-
"@thi.ng/math": "^5.15.
|
|
52
|
-
"@thi.ng/transducers": "^9.6.
|
|
53
|
-
"@thi.ng/vectors": "^8.6.
|
|
43
|
+
"@thi.ng/api": "^8.12.25",
|
|
44
|
+
"@thi.ng/checks": "^3.9.5",
|
|
45
|
+
"@thi.ng/defmulti": "^3.0.102",
|
|
46
|
+
"@thi.ng/errors": "^2.6.14",
|
|
47
|
+
"@thi.ng/geom": "^8.3.33",
|
|
48
|
+
"@thi.ng/geom-isoline": "^2.1.228",
|
|
49
|
+
"@thi.ng/geom-poly-utils": "^3.1.28",
|
|
50
|
+
"@thi.ng/geom-resample": "^3.0.91",
|
|
51
|
+
"@thi.ng/math": "^5.15.14",
|
|
52
|
+
"@thi.ng/transducers": "^9.6.39",
|
|
53
|
+
"@thi.ng/vectors": "^8.6.35"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"esbuild": "^0.28.0",
|
|
@@ -131,5 +131,5 @@
|
|
|
131
131
|
"tag": "sdf",
|
|
132
132
|
"year": 2022
|
|
133
133
|
},
|
|
134
|
-
"gitHead": "
|
|
134
|
+
"gitHead": "65b041e97110e16c01cf968949b72a0873f14445"
|
|
135
135
|
}
|
package/shapes.d.ts
CHANGED
|
@@ -15,7 +15,21 @@ export declare const circle2: (center: ReadonlyVec, radius: number, attribs?: Pa
|
|
|
15
15
|
export declare const ellipse2: (center: ReadonlyVec, radii: ReadonlyVec, attribs?: Partial<SDFAttribs>) => SDFn;
|
|
16
16
|
export declare const line2: (a: ReadonlyVec, b: ReadonlyVec, attribs?: Partial<SDFAttribs>) => SDFn;
|
|
17
17
|
export declare const points2: (pts: ReadonlyVec[], attribs?: Partial<SDFAttribs>) => SDFn;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new polygon SDF function for given vertices. Automatically dedupes
|
|
20
|
+
* vertices and removes colinear ones.
|
|
21
|
+
*
|
|
22
|
+
* @param pts
|
|
23
|
+
* @param attribs
|
|
24
|
+
*/
|
|
18
25
|
export declare const polygon2: (pts: ReadonlyVec[], attribs?: Partial<SDFAttribs>) => SDFn;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new polyline SDF function for given vertices. Automatically dedupes
|
|
28
|
+
* vertices and removes colinear ones.
|
|
29
|
+
*
|
|
30
|
+
* @param pts
|
|
31
|
+
* @param attribs
|
|
32
|
+
*/
|
|
19
33
|
export declare const polyline2: (pts: ReadonlyVec[], attribs?: Partial<SDFAttribs>) => SDFn;
|
|
20
34
|
/**
|
|
21
35
|
* SDF for a single quadratic bezier segment. Similar to {@link line2}, by
|
package/shapes.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { simplify } from "@thi.ng/geom-resample/simplify";
|
|
1
2
|
import { distSq2 } from "@thi.ng/vectors";
|
|
2
3
|
import { sub2 } from "@thi.ng/vectors/sub";
|
|
3
4
|
import { withBoundingCircle } from "./bounds.js";
|
|
@@ -46,10 +47,12 @@ const points2 = (pts, attribs = {}) => {
|
|
|
46
47
|
return attribs.bounds ? withBoundingCircle(sdf, pts) : sdf;
|
|
47
48
|
};
|
|
48
49
|
const polygon2 = (pts, attribs = {}) => {
|
|
50
|
+
pts = simplify(pts, 1e-6, true);
|
|
49
51
|
const sdf = withSDFAttribs((p) => distPolygon2(p, pts), attribs);
|
|
50
52
|
return attribs.bounds ? withBoundingCircle(sdf, pts) : sdf;
|
|
51
53
|
};
|
|
52
54
|
const polyline2 = (pts, attribs = {}) => {
|
|
55
|
+
pts = simplify(pts, 1e-6, false);
|
|
53
56
|
const sdf = withSDFAttribs((p) => distPolyline2(p, pts), attribs);
|
|
54
57
|
return attribs.bounds ? withBoundingCircle(sdf, pts) : sdf;
|
|
55
58
|
};
|