From 542c8e84fd99d0ef1b22e4680bd89c170bae3ae7 Mon Sep 17 00:00:00 2001 From: treeform Date: Thu, 17 Mar 2022 07:32:47 -0700 Subject: [PATCH] Fix #394 - zero width mask fill. --- src/pixie/paths.nim | 3 +++ tests/test_paths.nim | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/pixie/paths.nim b/src/pixie/paths.nim index 9bc124f..deb3d4d 100644 --- a/src/pixie/paths.nim +++ b/src/pixie/paths.nim @@ -1679,6 +1679,9 @@ proc fillShapes( pathHeight = min(mask.height, (bounds.y + bounds.h).int) partitioning = partitionSegments(segments, startY, pathHeight) + if pathWidth == 0: + return + var coverages = newSeq[uint8](pathWidth) hits = newSeq[(float32, int16)](partitioning.maxEntryCount) diff --git a/tests/test_paths.nim b/tests/test_paths.nim index fe09072..626fb7e 100644 --- a/tests/test_paths.nim +++ b/tests/test_paths.nim @@ -675,3 +675,18 @@ block: doAssertRaises PixieError: ctx.strokePolygon(vec2(0.0, 0.0), 0.0, 0) + +block: + # Test zero width image fill. + let + image = newImage(100, 100) + pathStr = "M0 0 L0 1 L0 0 Z" + color = rgba(255, 0, 0, 255) + image.fillPath(pathStr, color) + +block: + # Test zero width mask fill. + let + mask = newMask(100, 100) + pathStr = "M0 0 L0 1 L0 0 Z" + mask.fillPath(pathStr)