You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was messing around and found that calling graphics::Rectangle::draw or graphics::Ellipse::draw panics when the Ellipse has resolution >= 171u32 or the Rectangle has rounded corners with resolution >= 43u32.
The panic message is: thread 'main' panicked at 'index out of bounds: the len is 1023 but the index is 1023', /Users/[my account]/.cargo/registry/src/github.com-1ecc6299db9ec823/piston2d-graphics-0.40.0/./src/triangulation.rs:498:9
The same thing happens for Ellipse, if you replace the line let shape... with
let shape = graphics::Ellipse{border:Some(graphics::ellipse::Border{color:[1.,0.,0.,1.],radius:1.}),color:[0.,1.,1.,1.],// If this is 170 or lower, it works fine. 171 or higher, it reliably panics.resolution:171,};
I have no idea what could be causing this, or why those specific numbers. I couldn't find anything in the docs suggesting that resolution has a maximum to avoid panics, and this seems a little worrying since different shapes seem to have different upper limits? It was causing problems for me since I had code trying to determine at runtime the best resolution to use, and it would panic under certain conditions because of this issue.
Hi all,
I was messing around and found that calling
graphics::Rectangle::draw
orgraphics::Ellipse::draw
panics when theEllipse
hasresolution >= 171u32
or theRectangle
has rounded corners withresolution >= 43u32
.The panic message is:
thread 'main' panicked at 'index out of bounds: the len is 1023 but the index is 1023', /Users/[my account]/.cargo/registry/src/github.com-1ecc6299db9ec823/piston2d-graphics-0.40.0/./src/triangulation.rs:498:9
Reproducible example:
The same thing happens for
Ellipse
, if you replace the linelet shape...
withI have no idea what could be causing this, or why those specific numbers. I couldn't find anything in the docs suggesting that resolution has a maximum to avoid panics, and this seems a little worrying since different shapes seem to have different upper limits? It was causing problems for me since I had code trying to determine at runtime the best resolution to use, and it would panic under certain conditions because of this issue.
My dependencies are:
I'm running macOS Big Sur on a 13.3-inch macbook, with Intel HD Graphics 6000 1536 MB.
I hope this is helpful. If you're already aware of the issue, is there a range of resolution values I should stick to to avoid panics in general?
The text was updated successfully, but these errors were encountered: