gamercade-io / gamercade_console

A Neo-Retro Fantasy Console. Make WASM-powered, networked multiplayer games.
https://gamercade.io
Apache License 2.0
168 stars 10 forks source link

"Draw Circle" function doesn't correctly handle out of bounds pixels. #4

Closed RobDavenport closed 1 year ago

RobDavenport commented 2 years ago

When trying to call draw_circle and parameters in which include pixel coordinates outside of the screen, nothing is draw.

We should draw the circle's pixels on screen, regardless of location, assuming it actually has pixels inside of the screen.

RobDavenport commented 2 years ago

now that draw_circle_filled exists I wonder if this issue also exists for it.

Cardosaum commented 2 years ago

@RobDavenport, Yup, it does.

I think that solving the problem pointed out in #3 might solve this one here as well (this will be my next PR probably). I'll take a closer look at the code base, as I'm not that familiar with it yet.

RobDavenport commented 2 years ago

@Cardosaum , actually, draw horizontal and vertical already handle bounds checks. So in the cases where a draw_line is called with a perfectly vertical or horizontal one it works.

You can test this by doing a moving pixel where you move the end point (like a character) and put it at various points off screen.

I think the issue with draw circle is the radius is incorrect being clamped, so when a circle is drawn near the edge, it shrinks the radius.