Merge pull request #140 from guzba/master

quick optimization
This commit is contained in:
treeform 2021-02-26 09:04:56 -08:00 committed by GitHub
commit 489e9359ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1482,13 +1482,19 @@ proc fillPath*(
windingRule = wrNonZero, windingRule = wrNonZero,
) = ) =
## Fills a path. ## Fills a path.
var mask = newMask(image.width, image.height) if paint.kind == pkSolid:
var fill = newImage(image.width, image.height) image.fillPath(path, paint.color)
return
let
mask = newMask(image.width, image.height)
fill = newImage(image.width, image.height)
mask.fillPath(parseSomePath(path), windingRule) mask.fillPath(parseSomePath(path), windingRule)
case paint.kind: case paint.kind:
of pkSolid: of pkSolid:
fill.fill(paint.color) discard # Handled above
of pkImage: of pkImage:
fill.draw(paint.image, paint.imageMat) fill.draw(paint.image, paint.imageMat)
of pkImageTiled: of pkImageTiled:
@ -1514,7 +1520,7 @@ proc fillPath*(
paint.gradientStops paint.gradientStops
) )
fill.draw(mask, blendMode = bmMask) fill.draw(mask)
image.draw(fill, blendMode = paint.blendMode) image.draw(fill, blendMode = paint.blendMode)
proc strokePath*( proc strokePath*(