2021-02-14 18:27:32 +00:00
|
|
|
import pixie, pixie/fileformats/svg, strformat
|
2020-12-04 16:17:03 +00:00
|
|
|
|
2020-12-20 00:01:14 +00:00
|
|
|
const files = [
|
2020-12-20 03:59:43 +00:00
|
|
|
"line01",
|
|
|
|
"polyline01",
|
|
|
|
"polygon01",
|
|
|
|
"rect01",
|
|
|
|
"rect02",
|
|
|
|
"circle01",
|
2020-12-20 18:17:55 +00:00
|
|
|
"ellipse01",
|
2020-12-20 00:01:14 +00:00
|
|
|
"triangle01",
|
2020-12-20 02:47:05 +00:00
|
|
|
"quad01",
|
2021-04-27 00:50:00 +00:00
|
|
|
"Ghostscript_Tiger",
|
2021-05-24 02:17:30 +00:00
|
|
|
"scale",
|
2021-05-24 03:29:59 +00:00
|
|
|
"miterlimit",
|
2021-12-03 21:24:06 +00:00
|
|
|
"dashes",
|
|
|
|
"dragon2"
|
2020-12-20 00:01:14 +00:00
|
|
|
]
|
2020-12-04 20:09:08 +00:00
|
|
|
|
2021-06-29 02:50:09 +00:00
|
|
|
proc doDiff(rendered: Image, name: string) =
|
2021-10-03 22:17:04 +00:00
|
|
|
rendered.writeFile(&"tests/fileformats/svg/rendered/{name}.png")
|
2020-12-20 00:01:14 +00:00
|
|
|
let
|
2021-10-03 22:17:04 +00:00
|
|
|
master = readImage(&"tests/fileformats/svg/masters/{name}.png")
|
2021-06-29 02:50:09 +00:00
|
|
|
(diffScore, diffImage) = diff(master, rendered)
|
|
|
|
echo &"{name} score: {diffScore}"
|
2021-10-03 22:17:04 +00:00
|
|
|
diffImage.writeFile(&"tests/fileformats/svg/diffs/{name}.png")
|
2020-12-20 00:01:14 +00:00
|
|
|
|
2021-06-29 02:50:09 +00:00
|
|
|
for file in files:
|
2022-05-22 01:05:13 +00:00
|
|
|
doDiff(readImage(&"tests/fileformats/svg/{file}.svg"), file)
|
2021-11-26 05:38:57 +00:00
|
|
|
|
2022-05-22 01:05:13 +00:00
|
|
|
block:
|
2022-05-30 02:22:19 +00:00
|
|
|
let svg = parseSvg(
|
|
|
|
readFile("tests/fileformats/svg/accessibility-outline.svg"),
|
|
|
|
512, 512
|
|
|
|
)
|
2022-05-22 01:05:13 +00:00
|
|
|
doDiff(newImage(svg), "accessibility-outline")
|