The magnifyBy2 fix.

This commit is contained in:
treeform 2021-10-04 11:41:09 -07:00
parent 88cd22e22b
commit d29b4e1c45
12 changed files with 22 additions and 5 deletions

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 775 B

After

Width:  |  Height:  |  Size: 574 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 763 B

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 785 B

After

Width:  |  Height:  |  Size: 814 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -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")