How to Draw a Circle in Minecraft Blocks: the Math Behind a Pixel Circle Generator
A circle in Minecraft is a grid problem: every block is either placed or not. We build PixelCircles , a browser tool that draws Minecraft circles, spheres and domes block by block, and this post walks through the four decisions that shape every circle it draws. The code excerpts are simplified from the site's source; every number below came from running it. 1. Which cells are inside? Take a…
Minecraft circles are built by deciding which cells are inside the circle's boundaries. A function called insideEllipse determines if a cell's center lies within the ellipse, calculated using w and h values. The code places the circle on a d × d grid and asks if the center of each cell is inside the circle. Adding 0.5 to the cell's coordinates moves from the cell's corner to its center, and 1e-9 prevents floating-point noise from dropping cells on the edge.
Odd and even widths create different circle shapes. Odd widths have a single center block, whereas even widths have a 2 × 2 center, leading to no single middle block. For thin outlines, only the four side neighbors are checked to see if they are empty. For thick outlines, diagonal neighbors are also considered. The outline function checks if a cell should be included in the outline based on its neighbors and the chosen mode.
For large circles, testing each cell individually is slow. Instead, we start at the middle column of each row and walk outwards until the next cell falls outside the circle. This approach is efficient and suitable for creating large circles in Minecraft.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.