diff --git a/src/pixie/images.nim b/src/pixie/images.nim index 658eb11..d63f347 100644 --- a/src/pixie/images.nim +++ b/src/pixie/images.nim @@ -653,16 +653,22 @@ proc drawUber( p = matInv * vec2(0 + h, 0 + h) dx = matInv * vec2(1 + h, 0 + h) - p dy = matInv * vec2(0 + h, 1 + h) - p - minFilterBy2 = max(dx.length, dy.length) + filterBy2 = max(dx.length, dy.length) b = b - while minFilterBy2 >= 2.0: + while filterBy2 >= 2.0: b = b.minifyBy2() p /= 2 dx /= 2 dy /= 2 - minFilterBy2 /= 2 - matInv = matInv * scale(vec2(0.5, 0.5)) + filterBy2 /= 2 + + while filterBy2 <= 0.5: + b = b.magnifyBy2() + p *= 2 + dx *= 2 + dy *= 2 + filterBy2 *= 2 let smooth = not( dx.length == 1.0 and diff --git a/tests/images/diffs/smooth11.png b/tests/images/diffs/smooth11.png new file mode 100644 index 0000000..c318c4a Binary files /dev/null and b/tests/images/diffs/smooth11.png differ diff --git a/tests/images/diffs/smooth2.png b/tests/images/diffs/smooth2.png index 4bec07b..477dd12 100644 Binary files a/tests/images/diffs/smooth2.png and b/tests/images/diffs/smooth2.png differ diff --git a/tests/images/diffs/smooth8.png b/tests/images/diffs/smooth8.png index 01210bb..a37198b 100644 Binary files a/tests/images/diffs/smooth8.png and b/tests/images/diffs/smooth8.png differ diff --git a/tests/images/diffs/smooth9.png b/tests/images/diffs/smooth9.png index a71c1ea..a37198b 100644 Binary files a/tests/images/diffs/smooth9.png and b/tests/images/diffs/smooth9.png differ diff --git a/tests/images/masters/smooth11.png b/tests/images/masters/smooth11.png new file mode 100644 index 0000000..25faa14 Binary files /dev/null and b/tests/images/masters/smooth11.png differ diff --git a/tests/images/masters/smooth2.png b/tests/images/masters/smooth2.png index de657ea..10f9ec6 100644 Binary files a/tests/images/masters/smooth2.png and b/tests/images/masters/smooth2.png differ diff --git a/tests/images/rendered/smooth11.png b/tests/images/rendered/smooth11.png new file mode 100644 index 0000000..5fc8850 Binary files /dev/null and b/tests/images/rendered/smooth11.png differ diff --git a/tests/images/rendered/smooth2.png b/tests/images/rendered/smooth2.png index 602243d..93e2407 100644 Binary files a/tests/images/rendered/smooth2.png and b/tests/images/rendered/smooth2.png differ diff --git a/tests/images/rendered/smooth8.png b/tests/images/rendered/smooth8.png index 34b248b..127a2f4 100644 Binary files a/tests/images/rendered/smooth8.png and b/tests/images/rendered/smooth8.png differ diff --git a/tests/images/rendered/smooth9.png b/tests/images/rendered/smooth9.png index aaca1a6..d56d4e7 100644 Binary files a/tests/images/rendered/smooth9.png and b/tests/images/rendered/smooth9.png differ diff --git a/tests/test_images_draw.nim b/tests/test_images_draw.nim index 9cdf945..003dddb 100644 --- a/tests/test_images_draw.nim +++ b/tests/test_images_draw.nim @@ -151,7 +151,7 @@ block: b = newImage(50, 50) a.fill(rgba(255, 255, 255, 255)) b.fill(rgbx(0, 0, 0, 255)) - a.draw(b, translate(vec2(14.64, 50.4)) * rotate(45.toRadians)) + a.draw(b, translate(vec2(0, 50)) * rotate(45.toRadians)) doDiff(a, "smooth2") block: @@ -226,3 +226,14 @@ block: let m = translate(vec2(0.5, 0.5)) * scale(vec2(2, 2)) a.draw(b, m) doDiff(a, "smooth10") + +block: + let + a = newImage(100, 100) + b = readImage(&"tests/images/turtle.png") + a.fill(rgba(255, 255, 255, 255)) + let m = translate(vec2(-43.29, -103.87)) * + rotate(-15.toRadians) * + scale(vec2(263.86/40, 263.86/40)) + a.draw(b, m) + doDiff(a, "smooth11")