add check for arc step of 0

This commit is contained in:
Ryan Oldenburg 2022-03-22 15:48:39 -05:00
parent c887910285
commit dd85e5f9b0
2 changed files with 29 additions and 1 deletions

View file

@ -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

View file

@ -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
)