cleaner + perf
This commit is contained in:
parent
9b7fa748d8
commit
33b8a5a839
1 changed files with 16 additions and 24 deletions
|
@ -1430,6 +1430,18 @@ proc parseSomePath(
|
||||||
elif type(path) is seq[seq[Vec2]]:
|
elif type(path) is seq[seq[Vec2]]:
|
||||||
path
|
path
|
||||||
|
|
||||||
|
proc transform(shapes: var seq[seq[Vec2]], transform: Vec2 | Mat3) =
|
||||||
|
when type(transform) is Vec2:
|
||||||
|
if transform != vec2(0, 0):
|
||||||
|
for shape in shapes.mitems:
|
||||||
|
for segment in shape.mitems:
|
||||||
|
segment += transform
|
||||||
|
else:
|
||||||
|
if transform != mat3():
|
||||||
|
for shape in shapes.mitems:
|
||||||
|
for segment in shape.mitems:
|
||||||
|
segment = transform * segment
|
||||||
|
|
||||||
proc fillPath*(
|
proc fillPath*(
|
||||||
image: Image,
|
image: Image,
|
||||||
path: SomePath,
|
path: SomePath,
|
||||||
|
@ -1454,12 +1466,7 @@ proc fillPath*(
|
||||||
else:
|
else:
|
||||||
let pixelScale = 1.0
|
let pixelScale = 1.0
|
||||||
var shapes = parseSomePath(path, pixelScale)
|
var shapes = parseSomePath(path, pixelScale)
|
||||||
for shape in shapes.mitems:
|
shapes.transform(transform)
|
||||||
for segment in shape.mitems:
|
|
||||||
when type(transform) is Vec2:
|
|
||||||
segment += transform
|
|
||||||
else:
|
|
||||||
segment = transform * segment
|
|
||||||
image.fillShapes(shapes, color, windingRule, blendMode)
|
image.fillShapes(shapes, color, windingRule, blendMode)
|
||||||
|
|
||||||
proc fillPath*(
|
proc fillPath*(
|
||||||
|
@ -1482,12 +1489,7 @@ proc fillPath*(
|
||||||
else:
|
else:
|
||||||
let pixelScale = 1.0
|
let pixelScale = 1.0
|
||||||
var shapes = parseSomePath(path, pixelScale)
|
var shapes = parseSomePath(path, pixelScale)
|
||||||
for shape in shapes.mitems:
|
shapes.transform(transform)
|
||||||
for segment in shape.mitems:
|
|
||||||
when type(transform) is Vec2:
|
|
||||||
segment += transform
|
|
||||||
else:
|
|
||||||
segment = transform * segment
|
|
||||||
mask.fillShapes(shapes, windingRule)
|
mask.fillShapes(shapes, windingRule)
|
||||||
|
|
||||||
proc fillPath*(
|
proc fillPath*(
|
||||||
|
@ -1571,12 +1573,7 @@ proc strokePath*(
|
||||||
var strokeShapes = strokeShapes(
|
var strokeShapes = strokeShapes(
|
||||||
parseSomePath(path, pixelScale), strokeWidth, lineCap, lineJoin
|
parseSomePath(path, pixelScale), strokeWidth, lineCap, lineJoin
|
||||||
)
|
)
|
||||||
for shape in strokeShapes.mitems:
|
strokeShapes.transform(transform)
|
||||||
for segment in shape.mitems:
|
|
||||||
when type(transform) is Vec2:
|
|
||||||
segment += transform
|
|
||||||
else:
|
|
||||||
segment = transform * segment
|
|
||||||
image.fillShapes(strokeShapes, color, wrNonZero, blendMode)
|
image.fillShapes(strokeShapes, color, wrNonZero, blendMode)
|
||||||
|
|
||||||
proc strokePath*(
|
proc strokePath*(
|
||||||
|
@ -1608,12 +1605,7 @@ proc strokePath*(
|
||||||
var strokeShapes = strokeShapes(
|
var strokeShapes = strokeShapes(
|
||||||
parseSomePath(path, pixelScale), strokeWidth, lineCap, lineJoin
|
parseSomePath(path, pixelScale), strokeWidth, lineCap, lineJoin
|
||||||
)
|
)
|
||||||
for shape in strokeShapes.mitems:
|
strokeShapes.transform(transform)
|
||||||
for segment in shape.mitems:
|
|
||||||
when type(transform) is Vec2:
|
|
||||||
segment += transform
|
|
||||||
else:
|
|
||||||
segment = transform * segment
|
|
||||||
mask.fillShapes(strokeShapes, wrNonZero)
|
mask.fillShapes(strokeShapes, wrNonZero)
|
||||||
|
|
||||||
when defined(release):
|
when defined(release):
|
||||||
|
|
Loading…
Reference in a new issue