diff --git a/src/pixie/paths.nim b/src/pixie/paths.nim index 479c98d..415fc0f 100644 --- a/src/pixie/paths.nim +++ b/src/pixie/paths.nim @@ -693,6 +693,8 @@ proc commandsToShapes( next = halfway halfway = compute(at, ctrl1, ctrl2, to, t + step / 4) step /= 2 + if step == 0: + raise newException(PixieError, "Unable to discretize arc") else: shape.addSegment(prev, next) t += step @@ -724,8 +726,10 @@ proc commandsToShapes( if error > errorMarginSq: next = halfway halfway = compute(at, ctrl, to, t + step / 4) - step /= 2 halfStepping = true + step /= 2 + if step == 0: + raise newException(PixieError, "Unable to discretize arc") else: shape.addSegment(prev, next) t += step @@ -853,6 +857,8 @@ proc commandsToShapes( step = min(step / 2, 1 - t) # Assume next steps hould be the same size else: step = step / 4 # We know a half-step is too big + if step == 0: + raise newException(PixieError, "Unable to discretize arc") else: shape.addSegment(prev, next) prev = next diff --git a/tests/test_paths.nim b/tests/test_paths.nim index 482d29d..27bbc67 100644 --- a/tests/test_paths.nim +++ b/tests/test_paths.nim @@ -699,3 +699,25 @@ block: let mask = newMask(100, 100) mask.fillPath(path) mask.writeFile(&"tests/paths/polygon{i}.png") + +block: + let image = newImage(200, 200) + image.fill(rgba(255, 255, 255, 255)) + + let + pathStr =""" + L -16370.0 -18156.0 + A 4100 4100 0 1 0 -19670 -14134 + Z + """ + + let path = parsePath(pathStr) + + let paint = newPaint(SolidPaint) + paint.color = color(255, 255, 255, 255) + + doAssertRaises PixieError: + image.strokePath( + path, + paint + )