LoginLogin

Fast Filled Circle

Root / Submissions / [.]

SimeonCreated:
Version:1.0Size:1.6
A fast function to draw a filled circle without any graphical artifacts.

Instructions:

This is slightly faster performance than drawing repetitive circles from 1 to the radius. It uses the overlapping rectangles method which has the smallest rectangle count.

It's actually twice as fast to just do:
DEF CIRCLE X,Y,R,COL
 GCIRCLE X,Y,R,8
 GPAINT X,Y,COL,8
 GCIRCLE X,Y,R,COL
END
This works by drawing a circle in a color that won't be used anywhere else (8, which is red=0 green=0 blue=8 alpha=0, so it's just transparent)m then using GFILL with that color as the border color. Then you just have to re-draw the outer circle with the color you want. Note: You'll need to add some checks to make sure it doesn't fail when the circle is partially/fully offscreen It would be even faster to just use sprites for the circles, since the shape never changes, which would work in most situations.

Replying to:12Me21
It's actually twice as fast to just do:
DEF CIRCLE X,Y,R,COL
 GCIRCLE X,Y,R,8
 GPAINT X,Y,COL,8
 GCIRCLE X,Y,R,COL
END
This works by drawing a circle in a color that won't be used anywhere else (8, which is red=0 green=0 blue=8 alpha=0, so it's just transparent)m then using GFILL with that color as the border color. Then you just have to re-draw the outer circle with the color you want. Note: You'll need to add some checks to make sure it doesn't fail when the circle is partially/fully offscreen It would be even faster to just use sprites for the circles, since the shape never changes, which would work in most situations.
That's brilliant!!

To anybody reading this, go to https://smilebasicsource.com/page?pid=1051