pixie/tests/test_svg.nim

29 lines
664 B
Nim
Raw Normal View History

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",
"dashes"
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) =
rendered.writeFile(&"tests/images/svg/rendered/{name}.png")
2020-12-20 00:01:14 +00:00
let
2021-06-29 02:50:09 +00:00
master = readImage(&"tests/images/svg/masters/{name}.png")
(diffScore, diffImage) = diff(master, rendered)
echo &"{name} score: {diffScore}"
diffImage.writeFile(&"tests/images/svg/diffs/{name}.png")
2020-12-20 00:01:14 +00:00
2021-06-29 02:50:09 +00:00
for file in files:
doDiff(decodeSvg(readFile(&"tests/images/svg/{file}.svg")), file)