pixie/tests/test_svg.nim
2021-06-28 21:50:09 -05:00

29 lines
664 B
Nim

import pixie, pixie/fileformats/svg, strformat
const files = [
"line01",
"polyline01",
"polygon01",
"rect01",
"rect02",
"circle01",
"ellipse01",
"triangle01",
"quad01",
"Ghostscript_Tiger",
"scale",
"miterlimit",
"dashes"
]
proc doDiff(rendered: Image, name: string) =
rendered.writeFile(&"tests/images/svg/rendered/{name}.png")
let
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")
for file in files:
doDiff(decodeSvg(readFile(&"tests/images/svg/{file}.svg")), file)