@thi.ng/geom 4.0.2 → 4.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 +9 -1
- package/README.md +2 -2
- package/as-svg.d.ts +16 -4
- package/as-svg.js +23 -4
- package/package.json +30 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2022-12-
|
|
3
|
+
- **Last updated**: 2022-12-22T21:47:07Z
|
|
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,14 @@ 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
|
+
## [4.1.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom@4.1.0) (2022-12-22)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add SVG default attribs & setter ([3cb07a6](https://github.com/thi-ng/umbrella/commit/3cb07a6))
|
|
17
|
+
- set defaults to no fill & black stroke
|
|
18
|
+
- add setSvgDefaultAttribs()
|
|
19
|
+
|
|
12
20
|
# [4.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/geom@4.0.0) (2022-12-10)
|
|
13
21
|
|
|
14
22
|
#### 🛑 Breaking changes
|
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ For the Clojure version, please visit: [thi.ng/geom-clj](https://thi.ng/geom-clj
|
|
|
27
27
|
|
|
28
28
|
## About
|
|
29
29
|
|
|
30
|
-
Functional, polymorphic API for 2D geometry types & SVG generation
|
|
30
|
+
Functional, polymorphic API for 2D geometry types & SVG generation.
|
|
31
31
|
|
|
32
32
|
This project is a partially ported from the [Clojure version of the same
|
|
33
33
|
name](http://thi.ng/geom-clj). All polymorphic operations built on
|
|
@@ -186,7 +186,7 @@ For Node.js REPL:
|
|
|
186
186
|
const geom = await import("@thi.ng/geom");
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
-
Package sizes (brotli'd, pre-treeshake): ESM:
|
|
189
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 12.03 KB
|
|
190
190
|
|
|
191
191
|
## Dependencies
|
|
192
192
|
|
package/as-svg.d.ts
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import type { Attribs, IShape } from "@thi.ng/geom-api";
|
|
2
|
+
/**
|
|
3
|
+
* Sets the SVG root element attribs used by default by {@link svgDoc}.
|
|
4
|
+
*
|
|
5
|
+
* @param attribs
|
|
6
|
+
*/
|
|
7
|
+
export declare const setSvgDefaultAttribs: (attribs: Attribs) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Serializes given hiccup tree to an actual SVG source string.
|
|
10
|
+
*
|
|
11
|
+
* @param args
|
|
12
|
+
*/
|
|
2
13
|
export declare const asSvg: (...args: any[]) => string;
|
|
3
14
|
/**
|
|
4
|
-
* Creates a hiccup SVG doc element for given {@link IShape}s and attribs
|
|
5
|
-
* the attribs do not include a `viewBox`, it
|
|
6
|
-
* Furthermore (and only for the case a viewbox
|
|
7
|
-
* attrib can be provided to include a
|
|
15
|
+
* Creates a hiccup SVG doc element for given {@link IShape}s and attribs
|
|
16
|
+
* (merged with default attribs). If the attribs do not include a `viewBox`, it
|
|
17
|
+
* will be computed automatically. Furthermore (and only for the case a viewbox
|
|
18
|
+
* needs to be computed), a `bleed` attrib can be provided to include a
|
|
19
|
+
* bleed/margin for the viewbox.
|
|
8
20
|
*
|
|
9
21
|
* @remarks
|
|
10
22
|
* Use {@link asSvg} to serialize the resulting doc to an SVG string.
|
package/as-svg.js
CHANGED
|
@@ -5,12 +5,30 @@ import { svg } from "@thi.ng/hiccup-svg/svg";
|
|
|
5
5
|
import { serialize } from "@thi.ng/hiccup/serialize";
|
|
6
6
|
import { bounds } from "./bounds.js";
|
|
7
7
|
import { __collBounds } from "./internal/bounds.js";
|
|
8
|
+
/**
|
|
9
|
+
* Can be overridden via {@link setSvgDefaultAttribs}.
|
|
10
|
+
*/
|
|
11
|
+
let DEFAULT_ATTRIBS = { fill: "none", stroke: "#000" };
|
|
12
|
+
/**
|
|
13
|
+
* Sets the SVG root element attribs used by default by {@link svgDoc}.
|
|
14
|
+
*
|
|
15
|
+
* @param attribs
|
|
16
|
+
*/
|
|
17
|
+
export const setSvgDefaultAttribs = (attribs) => {
|
|
18
|
+
DEFAULT_ATTRIBS = attribs;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Serializes given hiccup tree to an actual SVG source string.
|
|
22
|
+
*
|
|
23
|
+
* @param args
|
|
24
|
+
*/
|
|
8
25
|
export const asSvg = (...args) => args.map((x) => serialize(convertTree(x))).join("");
|
|
9
26
|
/**
|
|
10
|
-
* Creates a hiccup SVG doc element for given {@link IShape}s and attribs
|
|
11
|
-
* the attribs do not include a `viewBox`, it
|
|
12
|
-
* Furthermore (and only for the case a viewbox
|
|
13
|
-
* attrib can be provided to include a
|
|
27
|
+
* Creates a hiccup SVG doc element for given {@link IShape}s and attribs
|
|
28
|
+
* (merged with default attribs). If the attribs do not include a `viewBox`, it
|
|
29
|
+
* will be computed automatically. Furthermore (and only for the case a viewbox
|
|
30
|
+
* needs to be computed), a `bleed` attrib can be provided to include a
|
|
31
|
+
* bleed/margin for the viewbox.
|
|
14
32
|
*
|
|
15
33
|
* @remarks
|
|
16
34
|
* Use {@link asSvg} to serialize the resulting doc to an SVG string.
|
|
@@ -19,6 +37,7 @@ export const asSvg = (...args) => args.map((x) => serialize(convertTree(x))).joi
|
|
|
19
37
|
* @param xs
|
|
20
38
|
*/
|
|
21
39
|
export const svgDoc = (attribs, ...xs) => {
|
|
40
|
+
attribs = { ...DEFAULT_ATTRIBS, ...attribs };
|
|
22
41
|
if (xs.length > 0) {
|
|
23
42
|
if (!attribs.viewBox) {
|
|
24
43
|
const cbounds = __collBounds(xs, bounds);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/geom",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "Functional, polymorphic API for 2D geometry types & SVG generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -35,37 +35,37 @@
|
|
|
35
35
|
"tool:bpatch": "tools:node-esm tools/bpatch.ts"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@thi.ng/api": "^8.6.
|
|
39
|
-
"@thi.ng/arrays": "^2.
|
|
40
|
-
"@thi.ng/associative": "^6.2.
|
|
41
|
-
"@thi.ng/checks": "^3.3.
|
|
42
|
-
"@thi.ng/defmulti": "^2.1.
|
|
43
|
-
"@thi.ng/equiv": "^2.1.
|
|
44
|
-
"@thi.ng/errors": "^2.2.
|
|
45
|
-
"@thi.ng/geom-api": "^3.3.
|
|
46
|
-
"@thi.ng/geom-arc": "^2.1.
|
|
47
|
-
"@thi.ng/geom-clip-line": "^2.2.
|
|
48
|
-
"@thi.ng/geom-clip-poly": "^2.1.
|
|
49
|
-
"@thi.ng/geom-closest-point": "^2.1.
|
|
50
|
-
"@thi.ng/geom-hull": "^2.1.
|
|
51
|
-
"@thi.ng/geom-isec": "^2.1.
|
|
52
|
-
"@thi.ng/geom-poly-utils": "^2.3.
|
|
53
|
-
"@thi.ng/geom-resample": "^2.1.
|
|
54
|
-
"@thi.ng/geom-splines": "^2.2.
|
|
55
|
-
"@thi.ng/geom-subdiv-curve": "^2.1.
|
|
56
|
-
"@thi.ng/geom-tessellate": "^2.1.
|
|
57
|
-
"@thi.ng/hiccup": "^4.2.
|
|
58
|
-
"@thi.ng/hiccup-svg": "^4.3.
|
|
59
|
-
"@thi.ng/math": "^5.3.
|
|
60
|
-
"@thi.ng/matrices": "^2.1.
|
|
61
|
-
"@thi.ng/random": "^3.3.
|
|
62
|
-
"@thi.ng/strings": "^3.3.
|
|
63
|
-
"@thi.ng/transducers": "^8.3.
|
|
64
|
-
"@thi.ng/vectors": "^7.5.
|
|
38
|
+
"@thi.ng/api": "^8.6.2",
|
|
39
|
+
"@thi.ng/arrays": "^2.5.0",
|
|
40
|
+
"@thi.ng/associative": "^6.2.22",
|
|
41
|
+
"@thi.ng/checks": "^3.3.6",
|
|
42
|
+
"@thi.ng/defmulti": "^2.1.26",
|
|
43
|
+
"@thi.ng/equiv": "^2.1.16",
|
|
44
|
+
"@thi.ng/errors": "^2.2.7",
|
|
45
|
+
"@thi.ng/geom-api": "^3.3.24",
|
|
46
|
+
"@thi.ng/geom-arc": "^2.1.42",
|
|
47
|
+
"@thi.ng/geom-clip-line": "^2.2.4",
|
|
48
|
+
"@thi.ng/geom-clip-poly": "^2.1.41",
|
|
49
|
+
"@thi.ng/geom-closest-point": "^2.1.38",
|
|
50
|
+
"@thi.ng/geom-hull": "^2.1.38",
|
|
51
|
+
"@thi.ng/geom-isec": "^2.1.41",
|
|
52
|
+
"@thi.ng/geom-poly-utils": "^2.3.25",
|
|
53
|
+
"@thi.ng/geom-resample": "^2.1.42",
|
|
54
|
+
"@thi.ng/geom-splines": "^2.2.16",
|
|
55
|
+
"@thi.ng/geom-subdiv-curve": "^2.1.41",
|
|
56
|
+
"@thi.ng/geom-tessellate": "^2.1.41",
|
|
57
|
+
"@thi.ng/hiccup": "^4.2.28",
|
|
58
|
+
"@thi.ng/hiccup-svg": "^4.3.27",
|
|
59
|
+
"@thi.ng/math": "^5.3.18",
|
|
60
|
+
"@thi.ng/matrices": "^2.1.39",
|
|
61
|
+
"@thi.ng/random": "^3.3.20",
|
|
62
|
+
"@thi.ng/strings": "^3.3.22",
|
|
63
|
+
"@thi.ng/transducers": "^8.3.29",
|
|
64
|
+
"@thi.ng/vectors": "^7.5.30"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@microsoft/api-extractor": "^7.33.7",
|
|
68
|
-
"@thi.ng/testament": "^0.3.
|
|
68
|
+
"@thi.ng/testament": "^0.3.8",
|
|
69
69
|
"rimraf": "^3.0.2",
|
|
70
70
|
"tools": "^0.0.1",
|
|
71
71
|
"typedoc": "^0.23.22",
|
|
@@ -383,5 +383,5 @@
|
|
|
383
383
|
"thi.ng": {
|
|
384
384
|
"year": 2013
|
|
385
385
|
},
|
|
386
|
-
"gitHead": "
|
|
386
|
+
"gitHead": "28bb74c67217a352d673b6efdab234921d4a370e\n"
|
|
387
387
|
}
|