Sure! I can help you build a simple Minecraft pixel circle generator using HTML, CSS, and JavaScript. This generator will allow you to specify the center coordinates (x, z), zoom level, start and end degrees (for partial circles), and a color. It will draw the circle's pixels as colored blocks on a grid. There will also be a debug option to show coordinate labels.
Additionally, the URL hash ("#/") will update to encode the parameters, so you can share the link to recreate the same circle.
Features:
Input fields: color, start degree, end degree, center x, center z, zoom, move offsets (for panning)
Button for toggling debug (show coordinates)
Canvas rendering of the circle in Minecraft pixel style (square pixels)
URL hash encoding of current parameters for sharing
Circle drawn using Bresenham or Midpoint circle algorithm with start/end angular clip
Here's the full code:
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Minecraft Pixel Circle Generator</title>
<style>
body {
font-family: monospace, monospace;
background: #222;
color: #eee;
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
padding: 10px;
}
#controls {
margin-bottom: 10px;
display: grid;
grid-template-columns: repeat(auto-fill,minmax(150px,1fr));
gap: 8px;
width: 100%;
max-width: 800px;
}
label {
display: block;
font-size: 0.9em;
margin-bottom: 4px;
}
input[type=text], input[type=number] {
width: 100%;
padding: 6px 8px;
font-size: 1em;
border-radius: 4px;
border: none;
}
input[type=color] {
width: 100%;
height: 32px;
border: none;
padding: 0;
cursor: pointer;
}
button {
padding: 8px 14px;
font-size: 1em;
border-radius: 4px;
border: none;
cursor: pointer;
background: #555;
color: #eee;
white-space: nowrap;
}
button:hover {
background: #888;
}
#canvas-container {
position: relative;
background: #111;
border: 2px solid #555;
}
canvas {
display: block;
background: #111;
}
#shareLink {
margin-top: 10px;
width: 100%;
max-width: 800px;
padding: 6px 8px;
font-size: 0.9em;
background: #333;
border-radius: 4px;
border: none;
color: #eee;
user-select: all;
cursor: pointer;
text-align: center;
}
small {
font-size: 0.8em;
color: #888;
}
</style>
</head>
<body>
<h1>Minecraft Pixel Circle Generator</h1>
<div id="controls">
<div>
<label for="color">Color</label>
<input type="color" id="color" value="#00ff00" />
</div>
<div>
<label for="startDeg">Start Degree (0-360)</label>
<input type="number" id="startDeg" value="0" min="0" max="360" />
</div>
<div>
<label for="endDeg">End Degree (0-360)</label>
<input type="number" id="endDeg" value="360" min="0" max="360" />
</div>
<div>
<label for="centerX">Center X</label>
<input type="number" id="centerX" value="0" />
</div>
<div>
<label for="centerZ">Center Z</label>
<input type="number" id="centerZ" value="0" />
</div>
<div>
<label for="zoom">Zoom (pixel size)</label>
<input type="number" id="zoom" value="10" min="1" max="50" />
</div>
<div>
<label for="moveX">Move X (pan)</label>
<input type="number" id="moveX" value="0" />
</div>
<div>
<label for="moveZ">Move Z (pan)</label>
<input type="number" id="moveZ" value="0" />
</div>
<div style="display:flex; align-items:center; padding-top: 24px;">
<button id="debugBtn">Toggle Debug</button>
</div>
</div>
<div id="canvas-container">
<canvas id="canvas" width="600" height="600"></canvas>
</div>
<input type="text" id="shareLink" readonly title="Click to select and copy shareable URL" />
<script>
(() => {
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const colorInput = document.getElementById('color');
const startDegInput = document.getElementById('startDeg');
const endDegInput = document.getElementById('endDeg');
const centerXInput = document.getElementById('centerX');
const centerZInput = document.getElementById('centerZ');
const zoomInput = document.getElementById('zoom');
const moveXInput = document.getElementById('moveX');
const moveZInput = document.getElementById('moveZ');
const debugBtn = document.getElementById('debugBtn');
const shareLinkInput = document.getElementById('shareLink');
let debug = false;
function degreesToRadians(d) {
return d * Math.PI / 180;
}
// Normalize degrees in [0, 360)
function normalizeDeg(d) {
d = d % 360;
if (d < 0) d += 360;
return d;
}
// Check if angle is between start and end angle (both normalized 0-360), clockwise
function angleBetween(angle, start, end) {
angle = normalizeDeg(angle);
start = normalizeDeg(start);
end = normalizeDeg(end);
if (start <= end) {
return angle >= start && angle <= end;
} else {
// wrapped around 360
return angle >= start || angle <= end;
}
}
// Draw a pixel at (x,z) on canvas with zoom scale, considering pan offsets and center
function drawPixel(x, z, centerX, centerZ, zoom, moveX, moveZ, color) {
// Screen coordinates: find relative position from center, applying move (pan)
// The canvas center corresponds to (centerX + moveX, centerZ + moveZ)
const screenX = (x - centerX - moveX) * zoom + canvas.width/2;
const screenZ = (z - centerZ - moveZ) * zoom + canvas.height/2;
// Draw rectangle representing pixel (Minecraft block)
ctx.fillStyle = color;
ctx.fillRect(screenX, screenZ, zoom, zoom);
if (debug) {
// Draw borders + coordinates
ctx.strokeStyle = '#888';
ctx.lineWidth = 1;
ctx.strokeRect(screenX, screenZ, zoom, zoom);
ctx.fillStyle = '#ccc';
ctx.font = `${zoom*0.4}px monospace`;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText(`${x},${z}`, screenX + zoom/2, screenZ + zoom/2);
}
}
// Midpoint circle algorithm adapted for JavaScript and to test angle filtering
function drawCircle(centerX, centerZ, radius, startDeg, endDeg, zoom, moveX, moveZ, color) {
// Clear canvas
ctx.clearRect(0, 0, canvas.width, canvas.height);
if (radius < 0.5) return; // radius too small
// For each x from -r to r, calculate z range from circle equation and draw pixels between start and end angles
// Or use midpoint circle - we’ll plot 8 symmetric points per step
let x = radius;
let z = 0;
let err = 1 - x;
function plotEight(xOffset, zOffset) {
// Points to plot (xOffset,zOffset) are relative to center (centerX, centerZ)
// Calculate angles for each point - angle from center to point in degrees (0 deg points to +X axis)
// We want to include pixels only if their angle is between startDeg and endDeg
// 8 symmetrical points:
// 1 ( x, z)
plotIfAngle(centerX + xOffset, centerZ + zOffset);
// 2 ( z, x)
plotIfAngle(centerX + zOffset, centerZ + xOffset);
// 3 (-z, x)
plotIfAngle(centerX - zOffset, centerZ + xOffset);
// 4 (-x, z)
plotIfAngle(centerX - xOffset, centerZ + zOffset);
// 5 (-x, -z)
plotIfAngle(centerX - xOffset, centerZ - zOffset);
// 6 (-z, -x)
plotIfAngle(centerX - zOffset, centerZ - xOffset);
// 7 ( z, -x)
plotIfAngle(centerX + zOffset, centerZ - xOffset);
// 8 ( x, -z)
plotIfAngle(centerX + xOffset, centerZ - zOffset);
}
function plotIfAngle(px, pz) {
const dx = px - centerX;
const dz = pz - centerZ;
let angle = Math.atan2(dz, dx) * 180 / Math.PI;
if (angle < 0) angle += 360;
if (angleBetween(angle, startDeg, endDeg)) {
drawPixel(px, pz, centerX, centerZ, zoom, moveX, moveZ, color);
}
}
while (x >= z) {
plotEight(x, z);
z++;
if (err < 0) {
err += 2 * z + 1;
} else {
x--;
err += 2 * (z - x + 1);
}
}
}
// Parse URL hash and update inputs, returns false if no valid params in hash
function parseHash() {
// format: #/color/startDeg/endDeg/centerX/centerZ/zoom/moveX/moveZ/debug
const h = window.location.hash.slice(2).split('/');
if (h.length >= 8) {
try {
colorInput.value = h[0] || '#00ff00';
startDegInput.value = Number(h[1]) || 0;
endDegInput.value = Number(h[2]) || 360;
centerXInput.value = Number(h[3]) || 0;
centerZInput.value = Number(h[4]) || 0;
zoomInput.value = Number(h[5]) || 10;
moveXInput.value = Number(h[6]) || 0;
moveZInput.value = Number(h[7]) || 0;
debug = h[8] === '1';
debugBtn.textContent = debug ? 'Debug ON' : 'Toggle Debug';
return true;
} catch {
return false;
}
}
return false;
}
// Write current state to hash and update share link input
function updateHashAndShare() {
const params = [
colorInput.value,
normalizeDeg(Number(startDegInput.value)),
normalizeDeg(Number(endDegInput.value)),
Number(centerXInput.value),
Number(centerZInput.value),
Number(zoomInput.value),
Number(moveXInput.value),
Number(moveZInput.value),
debug ? 1 : 0
];
const hash = params.map(p => encodeURIComponent(p)).join('/');
window.location.hash = '#/' + hash;
let shareURL = window.location.origin + window.location.pathname + window.location.hash;
shareLinkInput.value = shareURL;
}
// Main update function
function update() {
// Clamp inputs
let color = colorInput.value;
let startDeg = normalizeDeg(Number(startDegInput.value));
let endDeg = normalizeDeg(Number(endDegInput.value));
let centerX = Math.round(Number(centerXInput.value));
let centerZ = Math.round(Number(centerZInput.value));
let zoom = Math.max(1, Math.min(50, Math.round(Number(zoomInput.value))));
let moveX = Math.round(Number(moveXInput.value));
let moveZ = Math.round(Number(moveZInput.value));
debugBtn.textContent = debug ? 'Debug ON' : 'Toggle Debug';
startDegInput.value = startDeg;
endDegInput.value = endDeg;
centerXInput.value = centerX;
centerZInput.value = centerZ;
zoomInput.value = zoom;
moveXInput.value = moveX;
moveZInput.value = moveZ;
// Calculate radius based on zoom and canvas size, limiting radius to fit on canvas
// Radius in Minecraft blocks/pixels = half smallest dimension / zoom - some padding
const maxRadiusX = Math.floor(((canvas.width / zoom) / 2) - Math.abs(moveX));
const maxRadiusZ = Math.floor(((canvas.height / zoom) / 2) - Math.abs(moveZ));
const radius = Math.min(maxRadiusX, maxRadiusZ);
drawCircle(centerX, centerZ, radius, startDeg, endDeg, zoom, moveX, moveZ, color);
updateHashAndShare();
}
// Add event listeners
const inputs = [colorInput, startDegInput, endDegInput, centerXInput, centerZInput, zoomInput, moveXInput, moveZInput];
inputs.forEach(inp => inp.addEventListener('input', () => setTimeout(update, 0)));
debugBtn.addEventListener('click', () => {
debug = !debug;
update();
});
shareLinkInput.addEventListener('click', () => {
shareLinkInput.select();
try {
navigator.clipboard.writeText(shareLinkInput.value);
alert('Link copied to clipboard!');
} catch {
// fallback
}
});
window.addEventListener('hashchange', () => {
if (parseHash()) {
update();
}
});
// Initialize from hash or default
if (!parseHash()) {
update();
} else {
update();
}
})();
</script>
</body>
</html>
How to Use
Adjust the Color picker to select the color of your Minecraft pixels.
Enter Start Degree and End Degree to draw full or partial circles. 0 degrees corresponds to the positive X axis, increasing counter-clockwise.
Set Center X and Center Z to the Minecraft block coordinates for the circle center.
Adjust Zoom to change the pixel block size on screen.
Use Move X and Move Z to pan around the canvas.
Click Toggle Debug to show each pixel's coordinates on the blocks.
The URL updates automatically to encode current parameters — copy the link in the bottom box and share it. Clicking the box copies it to the clipboard.
Notes
The circle radius is automatically calculated to fit inside the canvas with given zoom and pan.
The generator uses the midpoint circle algorithm and filters pixels by angle range.
This is a visualization only and helps plan Minecraft builds by showing pixel-perfect circles at block scale.
Please try the HTML file saved locally or run it on any static file server or code playground. Let me know if you want me to add other features!