updated exmaples, bugfix

This commit is contained in:
Ryan Oldenburg 2021-02-08 22:50:39 -06:00
parent ad11eac936
commit 8231583429
6 changed files with 13 additions and 28 deletions

View file

@ -25,8 +25,8 @@ var p: Path
p.polygon(100, 100, 70, sides=6)
p.closePath()
let mask = newImage(200, 200)
mask.fillPath(p, rgba(255, 255, 255, 255))
let mask = newMask(200, 200)
mask.fillPath(p)
blur.blur(20)
blur.draw(mask, blendMode = bmMask)
@ -47,12 +47,7 @@ let
r = 25.0
var path: Path
path.moveTo(x+r, y)
path.arcTo(x+w, y, x+w, y+h, r)
path.arcTo(x+w, y+h, x, y+h, r)
path.arcTo(x, y+h, x, y, r)
path.arcTo(x, y, x+w, y, r)
path.closePath()
path.roundedRect(vec2(x, y), vec2(w, h), r, r, r, r)
image.fillPath(path, rgba(255, 0, 0, 255))
```
@ -62,11 +57,7 @@ image.fillPath(path, rgba(255, 0, 0, 255))
[examples/square.nim](examples/square.nim)
```nim
var p: Path
p.moveTo(50, 50)
p.lineTo(50, 150)
p.lineTo(150, 150)
p.lineTo(150, 50)
p.closePath()
p.rect(50, 50, 100, 100)
image.fillPath(p, rgba(255, 0, 0, 255))
```

View file

@ -11,8 +11,8 @@ var p: Path
p.polygon(100, 100, 70, sides=6)
p.closePath()
let mask = newImage(200, 200)
mask.fillPath(p, rgba(255, 255, 255, 255))
let mask = newMask(200, 200)
mask.fillPath(p)
blur.blur(20)
blur.draw(mask, blendMode = bmMask)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 88 KiB

View file

@ -1,4 +1,4 @@
import pixie, chroma
import pixie, chroma, vmath
let image = newImage(200, 200)
image.fill(rgba(255, 255, 255, 255))
@ -11,12 +11,7 @@ let
r = 25.0
var path: Path
path.moveTo(x+r, y)
path.arcTo(x+w, y, x+w, y+h, r)
path.arcTo(x+w, y+h, x, y+h, r)
path.arcTo(x, y+h, x, y, r)
path.arcTo(x, y, x+w, y, r)
path.closePath()
path.roundedRect(vec2(x, y), vec2(w, h), r, r, r, r)
image.fillPath(path, rgba(255, 0, 0, 255))

View file

@ -4,11 +4,7 @@ var image = newImage(200, 200)
image.fill(rgba(255, 255, 255, 255))
var p: Path
p.moveTo(50, 50)
p.lineTo(50, 150)
p.lineTo(150, 150)
p.lineTo(150, 50)
p.closePath()
p.rect(50, 50, 100, 100)
image.fillPath(p, rgba(255, 0, 0, 255))

View file

@ -418,10 +418,13 @@ proc drawCorrect(
p = matInv * vec2(0 + h, 0 + h)
dx = matInv * vec2(1 + h, 0 + h) - p
dy = matInv * vec2(0 + h, 1 + h) - p
while max(dx.length, dy.length) > 2:
minFilterBy2 = max(dx.length, dy.length)
while minFilterBy2 > 2:
b = b.minifyBy2()
dx /= 2
dy /= 2
minFilterBy2 /= 2
matInv = matInv * scale(vec2(0.5, 0.5))
for y in 0 ..< a.height: