merge into test_paths.nim

This commit is contained in:
Ryan Oldenburg 2021-02-23 02:11:34 -06:00
parent cda6dabf60
commit aa19910380
3 changed files with 15 additions and 12 deletions

View file

@ -1256,7 +1256,9 @@ proc strokeShapes(
if strokeShape.len > 0:
result.add(strokeShape)
proc parseSomePath(path: SomePath, pixelScale:float32 = 1.0): seq[seq[Vec2]] {.inline.} =
proc parseSomePath(
path: SomePath, pixelScale: float32 = 1.0
): seq[seq[Vec2]] {.inline.} =
when type(path) is string:
parsePath(path).commandsToShapes(pixelScale)
elif type(path) is Path:

View file

@ -202,3 +202,15 @@ block:
path.arcTo(x, y, x + w, y, r)
mask.fillPath(path)
writeFile("tests/images/paths/pathRoundRectMask.png", mask.encodePng())
block:
let image = newImage(200, 200)
image.fill(rgba(255, 255, 255, 255))
var p = parsePath("M1 0.5C1 0.776142 0.776142 1 0.5 1C0.223858 1 0 0.776142 0 0.5C0 0.223858 0.223858 0 0.5 0C0.776142 0 1 0.223858 1 0.5Z")
image.fillPath(p, rgba(255, 0, 0, 255), scale(vec2(200, 200)))
image.strokePath(p, rgba(0, 255, 0, 255), scale(vec2(200, 200)),
strokeWidth = 0.01)
image.writeFile("tests/images/paths/pixelScale.png")

View file

@ -1,11 +0,0 @@
import pixie
let image = newImage(200, 200)
image.fill(rgba(255, 255, 255, 255))
var p = parsePath("M1 0.5C1 0.776142 0.776142 1 0.5 1C0.223858 1 0 0.776142 0 0.5C0 0.223858 0.223858 0 0.5 0C0.776142 0 1 0.223858 1 0.5Z")
image.fillPath(p, rgba(255, 0, 0, 255), scale(vec2(200, 200)))
image.strokePath(p, rgba(0, 255, 0, 255), scale(vec2(200, 200)), strokeWidth=0.01)
image.writeFile("tests/images/paths/pixelScale.png")