@thi.ng/geom-sdf 0.1.0 → 0.1.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/CHANGELOG.md +7 -1
- package/README.md +6 -4
- package/as-sdf.js +6 -2
- package/dist.d.ts +1 -1
- package/dist.js +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2022-06-
|
|
3
|
+
- **Last updated**: 2022-06-20T18:04:57Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [0.1.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-sdf@0.1.1) (2022-06-20)
|
|
13
|
+
|
|
14
|
+
#### 🩹 Bug fixes
|
|
15
|
+
|
|
16
|
+
- fix rect size handling ([cc72bab](https://github.com/thi-ng/umbrella/commit/cc72bab))
|
|
17
|
+
|
|
12
18
|
## [0.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom-sdf@0.1.0) (2022-06-20)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ node --experimental-repl-await
|
|
|
50
50
|
> const geomSdf = await import("@thi.ng/geom-sdf");
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
Package sizes (gzipped, pre-treeshake): ESM: 2.
|
|
53
|
+
Package sizes (gzipped, pre-treeshake): ESM: 2.63 KB
|
|
54
54
|
|
|
55
55
|
## Dependencies
|
|
56
56
|
|
|
@@ -130,9 +130,11 @@ writeFileSync(
|
|
|
130
130
|
|
|
131
131
|
Results:
|
|
132
132
|
|
|
133
|
-
|
|
|
134
|
-
|
|
135
|
-
| 
|
|
133
|
+
| `circle()` | `rect()` |
|
|
134
|
+
|------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
|
|
135
|
+
|  |  |
|
|
136
|
+
| `circle()` (smooth) | `rect()` (smooth) |
|
|
137
|
+
|  |  |
|
|
136
138
|
|
|
137
139
|
## Authors
|
|
138
140
|
|
package/as-sdf.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { DEFAULT, defmulti } from "@thi.ng/defmulti/defmulti";
|
|
2
2
|
import { unsupported } from "@thi.ng/errors/unsupported";
|
|
3
3
|
import { __dispatch } from "@thi.ng/geom/internal/dispatch";
|
|
4
|
-
import {
|
|
4
|
+
import { add2 } from "@thi.ng/vectors/add";
|
|
5
|
+
import { mulN2 } from "@thi.ng/vectors/muln";
|
|
5
6
|
import { difference, intersection, smoothDifference, smoothIntersection, smoothUnion, union, } from "./ops.js";
|
|
6
7
|
import { box2, circle2, DEFAULT_ATTRIBS, ellipse2, line2, points2, polygon2, polyline2, quadratic2, withSDFAttribs, } from "./shapes.js";
|
|
7
8
|
/**
|
|
@@ -68,7 +69,10 @@ export const asSDF = defmulti(__dispatch, {
|
|
|
68
69
|
poly: ($) => polygon2($.points, __sdfAttribs($.attribs)),
|
|
69
70
|
polyline: ($) => polyline2($.points, __sdfAttribs($.attribs)),
|
|
70
71
|
quadratic: ({ points: [a, b, c], attribs }) => quadratic2(a, b, c, __sdfAttribs(attribs)),
|
|
71
|
-
rect: ({ pos, size, attribs }) =>
|
|
72
|
+
rect: ({ pos, size, attribs }) => {
|
|
73
|
+
const s = mulN2([], size, 0.5);
|
|
74
|
+
return box2(add2([], s, pos), s, __sdfAttribs(attribs));
|
|
75
|
+
},
|
|
72
76
|
});
|
|
73
77
|
/** @internal */
|
|
74
78
|
const __sdfAttribs = (attribs) => attribs ? attribs.__sdf : null;
|
package/dist.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReadonlyVec } from "@thi.ng/vectors/api";
|
|
2
2
|
export declare const distCircle2: (p: ReadonlyVec, radius: number) => number;
|
|
3
|
-
export declare const distBox2: (p: ReadonlyVec,
|
|
3
|
+
export declare const distBox2: (p: ReadonlyVec, halfSize: ReadonlyVec) => number;
|
|
4
4
|
export declare const distPolygon2: (pts: ReadonlyVec[], p: ReadonlyVec) => number;
|
|
5
5
|
export declare const distSegment2: (a: ReadonlyVec, b: ReadonlyVec, p: ReadonlyVec) => number;
|
|
6
6
|
export declare const distPolyline2: (pts: ReadonlyVec[], p: ReadonlyVec) => number;
|
package/dist.js
CHANGED
|
@@ -18,8 +18,8 @@ import { some3 } from "@thi.ng/vectors/some";
|
|
|
18
18
|
import { sub2 } from "@thi.ng/vectors/sub";
|
|
19
19
|
const mag2 = (v) => Math.sqrt(magSq2(v));
|
|
20
20
|
export const distCircle2 = (p, radius) => mag2(p) - radius;
|
|
21
|
-
export const distBox2 = (p,
|
|
22
|
-
const d = sub2(null, abs2([], p),
|
|
21
|
+
export const distBox2 = (p, halfSize) => {
|
|
22
|
+
const d = sub2(null, abs2([], p), halfSize);
|
|
23
23
|
return Math.min(Math.max(d[0], d[1]), 0) + mag2(max2(null, d, ZERO2));
|
|
24
24
|
};
|
|
25
25
|
export const distPolygon2 = (pts, p) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/geom-sdf",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
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",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"status": "alpha",
|
|
111
111
|
"year": 2022
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "1486ab1a34372b2d07ed29b521ef6c97b275f9a7\n"
|
|
114
114
|
}
|