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
170
S
50
G
179
Posts: 8,378
Reputation: 113,425

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
113
Posts: 5,354
Reputation: 73,269

Post » Sat Apr 02, 2016 6:01 am

Ahh that worms using tilemaps example from way back.


Thanks.
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, kainrazial and 7 guests