Merge pull request #206 from guzba/master
fix path parse bug for m 1 2 3 4 5 6...
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
|
@ -136,6 +136,11 @@ proc parsePath*(path: string): Path =
|
|||
"Invalid path, wrong number of parameters"
|
||||
)
|
||||
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(
|
||||
kind: kind,
|
||||
numbers: numbers[batch * paramCount ..< (batch + 1) * paramCount]
|
||||
|
@ -1523,7 +1528,11 @@ proc fillPath*(
|
|||
mask = newMask(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:
|
||||
of pkSolid:
|
||||
|
@ -1595,7 +1604,7 @@ proc strokePath*(
|
|||
fill = newImage(image.width, image.height)
|
||||
|
||||
mask.strokePath(
|
||||
parseSomePath(path),
|
||||
parseSomePath(path, transform.pixelScale()),
|
||||
transform,
|
||||
strokeWidth,
|
||||
lineCap,
|
||||
|
|
24
tests/benchmark_image_loop.nim
Normal file
|
@ -0,0 +1,24 @@
|
|||
import benchy, pixie
|
||||
|
||||
let image = newImage(2560, 1440)
|
||||
image.fill(rgba(50, 100, 150, 200))
|
||||
|
||||
timeIt "x then y":
|
||||
var sum: uint64
|
||||
for x in 0 ..< image.width:
|
||||
for y in 0 ..< image.height:
|
||||
let pixel = image.getRgbaUnsafe(x, y)
|
||||
sum += pixel.r + pixel.g + pixel.b + pixel.a
|
||||
if sum == 0:
|
||||
echo "0"
|
||||
keep sum
|
||||
|
||||
timeIt "y then x":
|
||||
var sum: uint64
|
||||
for y in 0 ..< image.height:
|
||||
for x in 0 ..< image.width:
|
||||
let pixel = image.getRgbaUnsafe(x, y)
|
||||
sum += pixel.r + pixel.g + pixel.b + pixel.a
|
||||
if sum == 0:
|
||||
echo "0"
|
||||
keep sum
|
Before Width: | Height: | Size: 357 KiB After Width: | Height: | Size: 357 KiB |
Before Width: | Height: | Size: 631 KiB After Width: | Height: | Size: 636 KiB |
Before Width: | Height: | Size: 1.4 MiB After Width: | Height: | Size: 1.4 MiB |
|
@ -5,7 +5,14 @@ block:
|
|||
m 1 2 3 4 5 6
|
||||
"""
|
||||
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:
|
||||
let pathStr = """
|
||||
|
|