fix path parse bug for m 1 2 3 4 5 6...

This commit is contained in:
Ryan Oldenburg 2021-05-24 19:24:56 -05:00
parent a8531980d9
commit 2afcbaa621
6 changed files with 19 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View file

@ -136,6 +136,11 @@ proc parsePath*(path: string): Path =
"Invalid path, wrong number of parameters" "Invalid path, wrong number of parameters"
) )
for batch in 0 ..< numbers.len div paramCount: for batch in 0 ..< numbers.len div paramCount:
if batch > 0:
if kind == Move:
kind = Line
elif kind == RMove:
kind = RLine
result.commands.add(PathCommand( result.commands.add(PathCommand(
kind: kind, kind: kind,
numbers: numbers[batch * paramCount ..< (batch + 1) * paramCount] numbers: numbers[batch * paramCount ..< (batch + 1) * paramCount]
@ -1523,7 +1528,11 @@ proc fillPath*(
mask = newMask(image.width, image.height) mask = newMask(image.width, image.height)
fill = newImage(image.width, image.height) fill = newImage(image.width, image.height)
mask.fillPath(parseSomePath(path), transform, windingRule) mask.fillPath(
parseSomePath(path, transform.pixelScale()),
transform,
windingRule
)
case paint.kind: case paint.kind:
of pkSolid: of pkSolid:
@ -1595,7 +1604,7 @@ proc strokePath*(
fill = newImage(image.width, image.height) fill = newImage(image.width, image.height)
mask.strokePath( mask.strokePath(
parseSomePath(path), parseSomePath(path, transform.pixelScale()),
transform, transform,
strokeWidth, strokeWidth,
lineCap, lineCap,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 357 KiB

After

Width:  |  Height:  |  Size: 357 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 631 KiB

After

Width:  |  Height:  |  Size: 636 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View file

@ -5,7 +5,14 @@ block:
m 1 2 3 4 5 6 m 1 2 3 4 5 6
""" """
let path = parsePath(pathStr) let path = parsePath(pathStr)
doAssert $path == "m1 2 m3 4 m5 6" doAssert $path == "m1 2 l3 4 l5 6"
block:
let pathStr = """
l 1 2 3 4 5 6
"""
let path = parsePath(pathStr)
doAssert $path == "l1 2 l3 4 l5 6"
block: block:
let pathStr = """ let pathStr = """