treeform / pixie

Full-featured 2d graphics library for Nim.
MIT License
743 stars 28 forks source link

ctx.StrokePolygon consumes all memory until killed by OS #390

Closed kwhitefoot closed 2 years ago

kwhitefoot commented 2 years ago

I've found a bug related to #388 (I think). This time lineDash is not zero.

import pixie

let image = newImage(200, 200)
image.fill(rgba(255, 255, 255, 255))

let ctx = newContext(image)

ctx.setLineDash(@[2.0.float32])
ctx.strokePolygon(vec2(0.0, 0.0), 0.0, 0)

This has exactly the same behaviour as in #388: consumes memory until killed by the OS. I've looked at the code for context.StrokePolygon and paths.strokePolygon and I can't see why it happens. The code looks right to me; with sides == 0 nothing should be added to the path.

guzba commented 2 years ago

This ctx.strokePolygon(vec2(0.0, 0.0), 0.0, 0) produces a degenerate / invalid path (a polygon with 0 sides does not exist). I'll add a check + exception for this.

guzba commented 2 years ago

Added the check in tagged release 4.0.2