# Fill a circle

Get help using Construct 2

### » 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.
B
178
S
50
G
206
Posts: 8,686
Reputation: 127,715

### » 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
100
S
38
G
134
Posts: 5,556
Reputation: 85,325

### » Sat Apr 02, 2016 6:01 am

Ahh that worms using tilemaps example from way back.

Thanks.
B
178
S
50
G
206
Posts: 8,686
Reputation: 127,715