diff --git a/tests/images/diffs/smooth1.png b/tests/images/diffs/smooth1.png new file mode 100644 index 0000000..9a5edb0 Binary files /dev/null and b/tests/images/diffs/smooth1.png differ diff --git a/tests/images/diffs/smooth2.png b/tests/images/diffs/smooth2.png new file mode 100644 index 0000000..08fc36e Binary files /dev/null and b/tests/images/diffs/smooth2.png differ diff --git a/tests/images/diffs/smooth3.png b/tests/images/diffs/smooth3.png new file mode 100644 index 0000000..59ca693 Binary files /dev/null and b/tests/images/diffs/smooth3.png differ diff --git a/tests/images/diffs/smooth4.png b/tests/images/diffs/smooth4.png new file mode 100644 index 0000000..78aa339 Binary files /dev/null and b/tests/images/diffs/smooth4.png differ diff --git a/tests/images/masters/smooth1.png b/tests/images/masters/smooth1.png new file mode 100644 index 0000000..9271e45 Binary files /dev/null and b/tests/images/masters/smooth1.png differ diff --git a/tests/images/masters/smooth2.png b/tests/images/masters/smooth2.png new file mode 100644 index 0000000..de657ea Binary files /dev/null and b/tests/images/masters/smooth2.png differ diff --git a/tests/images/masters/smooth3.png b/tests/images/masters/smooth3.png new file mode 100644 index 0000000..9366860 Binary files /dev/null and b/tests/images/masters/smooth3.png differ diff --git a/tests/images/masters/smooth4.png b/tests/images/masters/smooth4.png new file mode 100644 index 0000000..71072c8 Binary files /dev/null and b/tests/images/masters/smooth4.png differ diff --git a/tests/images/rendered/smooth1.png b/tests/images/rendered/smooth1.png new file mode 100644 index 0000000..c83aeca Binary files /dev/null and b/tests/images/rendered/smooth1.png differ diff --git a/tests/images/rendered/smooth2.png b/tests/images/rendered/smooth2.png new file mode 100644 index 0000000..56d925a Binary files /dev/null and b/tests/images/rendered/smooth2.png differ diff --git a/tests/images/rendered/smooth3.png b/tests/images/rendered/smooth3.png new file mode 100644 index 0000000..59db7c6 Binary files /dev/null and b/tests/images/rendered/smooth3.png differ diff --git a/tests/images/rendered/smooth4.png b/tests/images/rendered/smooth4.png new file mode 100644 index 0000000..d59f752 Binary files /dev/null and b/tests/images/rendered/smooth4.png differ diff --git a/tests/test_images_draw.nim b/tests/test_images_draw.nim index 4f619a6..1932781 100644 --- a/tests/test_images_draw.nim +++ b/tests/test_images_draw.nim @@ -1,4 +1,4 @@ -import pixie +import pixie, strformat block: let @@ -127,3 +127,49 @@ block: a.draw(b, translate(vec2(250, 250)) * scale(vec2(0.5, 0.5))) a.writeFile("tests/images/scaleHalf.png") + +proc doDiff(rendered: Image, name: string) = + rendered.writeFile(&"tests/images/rendered/{name}.png") + let + master = readImage(&"tests/images/masters/{name}.png") + (diffScore, diffImage) = diff(master, rendered) + echo &"{name} score: {diffScore}" + diffImage.writeFile(&"tests/images/diffs/{name}.png") + +block: + let + image = newImage(100, 100) + path = newPath() + path.rect(0, 0, 99, 99) + image.fillPath(path, rgba(0, 0, 0, 255), translate(vec2(0.5, 0.5))) + doDiff(image, "smooth1") + +block: + let + a = newImage(100, 100) + b = newImage(100, 100) + path = newPath() + path.rect(-25, -25, 50, 50) + path.transform(rotate(45 * PI.float32 / 180)) + b.fillPath(path, rgba(0, 0, 0, 255), translate(vec2(50, 50))) + a.fill(rgba(255, 255, 255, 255)) + a.draw(b, translate(vec2(0, 0.4))) + doDiff(a, "smooth2") + +block: + let + a = newImage(100, 100) + b = newImage(50, 50) + a.fill(rgba(255, 255, 255, 255)) + b.fill(rgba(0, 0, 0, 255)) + a.draw(b, translate(vec2(25.2, 25))) + doDiff(a, "smooth3") + +block: + let + a = newImage(100, 100) + b = newImage(50, 50) + a.fill(rgba(255, 255, 255, 255)) + b.fill(rgba(0, 0, 0, 255)) + a.draw(b, translate(vec2(25.2, 25.6))) + doDiff(a, "smooth4")