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
172
S
50
G
189
Posts: 8,513
Reputation: 118,745

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
94
S
33
G
124
Posts: 5,455
Reputation: 79,473

Post » Sat Apr 02, 2016 6:01 am

Ahh that worms using tilemaps example from way back.


Thanks.
Image ImageImage
B
172
S
50
G
189
Posts: 8,513
Reputation: 118,745


Return to How do I....?

Who is online

Users browsing this forum: Bootfit, Google [Bot], Yahoo [Bot] and 8 guests