@thi.ng/geom-sdf 1.0.84 → 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/README.md CHANGED
@@ -7,9 +7,11 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 215 standalone projects, maintained as part
11
- > of the [@thi.ng/umbrella](https://codeberg.org/thi.ng/umbrella/) ecosystem
12
- > and anti-framework.
10
+
11
+ > This is one of 215 standalone projects. LLM-free, human-made and
12
+ > cared for software, maintained as part of the
13
+ > [@thi.ng/umbrella](https://codeberg.org/thi.ng/umbrella/) ecosystem and
14
+ > anti-framework.
13
15
  >
14
16
  > 🚀 Please help me to work full-time on these projects by [sponsoring
15
17
  > me](https://codeberg.org/thi.ng/umbrella/src/branch/develop/CONTRIBUTING.md#donations).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/geom-sdf",
3
- "version": "1.0.84",
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.22",
44
- "@thi.ng/checks": "^3.9.2",
45
- "@thi.ng/defmulti": "^3.0.99",
46
- "@thi.ng/errors": "^2.6.11",
47
- "@thi.ng/geom": "^8.3.30",
48
- "@thi.ng/geom-isoline": "^2.1.225",
49
- "@thi.ng/geom-poly-utils": "^3.1.25",
50
- "@thi.ng/geom-resample": "^3.0.88",
51
- "@thi.ng/math": "^5.15.11",
52
- "@thi.ng/transducers": "^9.6.36",
53
- "@thi.ng/vectors": "^8.6.32"
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": "17d2d1a6542704f55f2daa37550a4213b4a32cd8"
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
  };