Fill a circle

Get help using Construct 2

Post » Sat Apr 02, 2016 2:04 am

Looking for a quick formula to fill the xy's of a circle.
I can do it with sin cos, but I can't think of a way to do it without having some actions repeated unnecessarily.

Barring that a formula to fill a polygon might work.
Image ImageImage
B
168
S
50
G
164
Posts: 8,239
Reputation: 105,597

Post » Sat Apr 02, 2016 3:47 am

You could use y=sqrt(r^2-(X-a)^2)+b where a,b is the center and r is the radius. That would give the equation for the top half of the circle. Make the sqrt negative to get the bottom half. There's an example of this in some terrain destruction using tilemaps elsewhere on the forum.

Or you could just loop over all the pixels and draw the pixel if this is true:
R^2>=x^2+y^2

Replace X with (X-a) and y with (y-b) if you want to center the circle at a,b instead of 0,0.
B
91
S
31
G
103
Posts: 5,241
Reputation: 67,768

Post » Sat Apr 02, 2016 6:01 am

Ahh that worms using tilemaps example from way back.


Thanks.
Image ImageImage
B
168
S
50
G
164
Posts: 8,239
Reputation: 105,597


Return to How do I....?

Who is online

Users browsing this forum: Allardje, Rudi55, sublimate and 2 guests