-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hiccup-svg): add support for precision attribute
- update convertTree() to allow dynamic floating point precision handling via `__prec` control attrib - update docs - add tests
- Loading branch information
1 parent
0736f0c
commit f81d0d8
Showing
3 changed files
with
123 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,51 @@ | ||
import { hsv } from "@thi.ng/color"; | ||
import { group } from "@thi.ng/testament"; | ||
// import * as assert from "assert"; | ||
// import * as svg from "../src/index.js" | ||
import * as assert from "assert"; | ||
import { convertTree } from "../src/index.js"; | ||
|
||
group("hiccup-svg", {}); | ||
group("hiccup-svg", { | ||
convertTree: () => { | ||
const res = convertTree([ | ||
"g", | ||
{ __prec: 1 }, | ||
[ | ||
"circle", | ||
{ stroke: [1, 0, 0], __prec: 3 }, | ||
[1.2345, -1.2345], | ||
99.9994, | ||
], | ||
[ | ||
"line", | ||
{ stroke: hsv("blue") }, | ||
[1.2345, -1.2345], | ||
[99.999, -99.999], | ||
], | ||
]); | ||
assert.deepStrictEqual(res, [ | ||
"g", | ||
{ | ||
__prec: 1, | ||
}, | ||
[ | ||
"circle", | ||
{ | ||
__prec: 3, | ||
cx: "1.234", | ||
cy: "-1.234", | ||
r: "99.999", | ||
stroke: "#ff0000", | ||
}, | ||
], | ||
[ | ||
"line", | ||
{ | ||
stroke: "hsl(240.000,100.000%,50.000%)", | ||
x1: "1.2", | ||
x2: "100.0", | ||
y1: "-1.2", | ||
y2: "-100.0", | ||
}, | ||
], | ||
]); | ||
}, | ||
}); |