treeform / pixie

Full-featured 2d graphics library for Nim.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ctx.StrokePolygon consumes all memory until killed by OS

kwhitefoot opened this issue · comments

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.

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.

Added the check in tagged release 4.0.2