Sure! Below is a simple Minecraft pixel-style circle generator using HTML, CSS, and JavaScript. It allows you to:
The generator creates circles using "pixels" as small div squares, arranged in a grid. It only draws the pixels that fall within the specified segment of the circle.
html Copy code
<!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; padding: 0;
display: flex; flex-direction: column; height: 100vh;
}
header {
padding: 0.5em 1em;
background: #111;
box-shadow: inset 0 -1px 4px rgba(0,0,0,0.5);
}
main {
flex: 1;
display: flex;
overflow: hidden;
}
#controls {
background: #111;
padding: 1em;
width: 280px;
box-sizing: border-box;
display: flex;
flex-direction: column;
gap: 0.7em;
}
#controls label {
display: flex;
flex-direction: column;
font-size: 0.9em;
}
#controls input[type="number"],
#controls input[type="color"] {
font-family: monospace;
font-size: 1em;
padding: 0.3em;
border-radius: 4px;
border: 1px solid #555;
background: #222;
color: #eee;
}
#controls input[type="checkbox"] {
width: 18px;
height: 18px;
margin-top: 0.3em;
}
#canvas-container {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
background: #333;
overflow: auto;
}
#circle {
position: relative;
background: #111;
box-sizing: content-box;
}
.pixel {
position: absolute;
width: 1em;
height: 1em;
box-sizing: border-box;
}
.pixel.debug {
border: 1px solid rgba(255, 255, 255, 0.1);
}
footer {
padding: 0.5em 1em;
background: #111;
font-size: 0.8em;
text-align: center;
color: #888;
user-select: none;
}
a {
color: #88aaff;
}
</style>
</head>
<body>
<header>
<h1>Minecraft Pixel Circle Generator</h1>
</header>
<main>
<section id="controls" aria-label="Controls">
<label>
Color:
<input type="color" id="color" value="#ffcc00" />
</label>
<label>
Start Angle (deg):
<input type="number" id="startdeg" min="0" max="360" step="1" value="0" />
</label>
<label>
End Angle (deg):
<input type="number" id="enddeg" min="0" max="360" step="1" value="360" />
</label>
<label>
Debug Grid:
<input type="checkbox" id="debug" />
</label>
<label>
Center X:
<input type="number" id="cx" value="0" step="1" />
</label>
<label>
Center Z:
<input type="number" id="cz" value="0" step="1" />
</label>
<label>
Zoom (pixel size):
<input type="number" id="zoom" min="1" max="32" value="8" />
</label>
<button id="sharebtn" type="button">Copy Share URL</button>
</section>
<section id="canvas-container" aria-label="Pixel circle display">
<div id="circle" aria-live="polite" aria-atomic="true"></div>
</section>
</main>
<footer>
© 2024 Minecraft Pixel Circle Generator —
Share link with parameters in the URL hash
</footer>
<script>
(() => {
const circle = document.getElementById('circle');
const colorInput = document.getElementById('color');
const startdegInput = document.getElementById('startdeg');
const enddegInput = document.getElementById('enddeg');
const debugInput = document.getElementById('debug');
const cxInput = document.getElementById('cx');
const czInput = document.getElementById('cz');
const zoomInput = document.getElementById('zoom');
const shareBtn = document.getElementById('sharebtn');
// You can change this to control circle radius in "block/pixels"
// We assume radius 16 blocks (pixels), adjustable here:
const RADIUS = 16;
// Parse params from URL hash
function parseHash() {
if (!location.hash) return;
const hash = location.hash.slice(1);
// decode & split key=value pairs
const params = new URLSearchParams(hash.replace(/&/g, '&'));
const color = params.get('color');
if (color) colorInput.value = color;
const start = params.get('start');
if (start !== null) startdegInput.value = +start;
const end = params.get('end');
if (end !== null) enddegInput.value = +end;
const debug = params.get('debug');
if (debug !== null) debugInput.checked = debug === "1";
const cx = params.get('x');
if (cx !== null) cxInput.value = +cx;
const cz = params.get('z');
if (cz !== null) czInput.value = +cz;
const zoom = params.get('zoom');
if (zoom !== null) zoomInput.value = +zoom;
}
// Save params to hash
function updateHash() {
const params = new URLSearchParams({
color: colorInput.value,
start: startdegInput.value,
end: enddegInput.value,
debug: debugInput.checked ? "1" : "0",
x: cxInput.value,
z: czInput.value,
zoom: zoomInput.value
});
const newHash = params.toString();
if (location.hash.slice(1) !== newHash)
history.replaceState(null, "", `#${newHash}`);
}
// Degree to radians
const deg2rad = deg => deg * Math.PI / 180;
function drawCircle() {
circle.innerHTML = '';
const color = colorInput.value;
const startDeg = Number(startdegInput.value);
let endDeg = Number(enddegInput.value);
const debug = debugInput.checked;
const zoom = Number(zoomInput.value);
// Normalize angles so endDeg > startDeg (for angle comparisons)
let startAngle = deg2rad(startDeg % 360);
let endAngle = deg2rad(endDeg % 360);
if (endDeg <= startDeg) endDeg += 360;
startAngle = deg2rad(startDeg);
endAngle = deg2rad(endDeg);
const diameter = RADIUS * 2 + 1;
circle.style.width = diameter * zoom + "px";
circle.style.height = diameter * zoom + "px";
// center pixel coords in container
const center = RADIUS;
// We'll draw a filled circle pixel by pixel
// For Minecraft style we fill pixels whose center is within radius from circle center
// and whose angle is between startAngle and endAngle
for (let px = 0; px < diameter; px++) {
for (let pz = 0; pz < diameter; pz++) {
// Coordinates relative to center pixel
const dx = px - center;
const dz = pz - center;
const dist = Math.sqrt(dx * dx + dz * dz);
// pixel center angle (atan2 y,z: z is vertical, x is horizontal in 2D plane)
// We consider +x right, +z down (typical for grids)
let angle = Math.atan2(dz, dx);
if (angle < 0) angle += 2 * Math.PI;
// check if pixel is inside radius with 0.5 fudge factor to fill pixel properly
if (dist <= RADIUS + 0.5) {
// Check if angle is within segment startAngle <= angle <= endAngle (angle wraps)
let angleDeg = angle * 180 / Math.PI;
let s = startDeg % 360;
let e = endDeg % 360;
if (e <= s) e += 360;
let a = angleDeg;
if (a < s) a += 360;
if (a >= s && a <= e) {
const pixel = document.createElement('div');
pixel.className = 'pixel' + (debug ? ' debug' : '');
pixel.style.backgroundColor = color;
pixel.style.width = zoom + 'px';
pixel.style.height = zoom + 'px';
pixel.style.left = px * zoom + 'px';
pixel.style.top = pz * zoom + 'px';
circle.appendChild(pixel);
} else if (debug) {
// Show debug grid for empty pixels in segment? (optional)
const pixel = document.createElement('div');
pixel.className = 'pixel debug';
pixel.style.backgroundColor = 'transparent';
pixel.style.width = zoom + 'px';
pixel.style.height = zoom + 'px';
pixel.style.left = px * zoom + 'px';
pixel.style.top = pz * zoom + 'px';
circle.appendChild(pixel);
}
} else if (debug) {
// Outside radius grid pixel for debug
const pixel = document.createElement('div');
pixel.className = 'pixel debug';
pixel.style.backgroundColor = 'transparent';
pixel.style.width = zoom + 'px';
pixel.style.height = zoom + 'px';
pixel.style.left = px * zoom + 'px';
pixel.style.top = pz * zoom + 'px';
circle.appendChild(pixel);
}
}
}
}
function update() {
updateHash();
drawCircle();
}
// Attach event listeners
[
colorInput,
startdegInput,
enddegInput,
debugInput,
cxInput,
czInput,
zoomInput
].forEach(el => el.addEventListener('input', update));
shareBtn.addEventListener('click', () => {
navigator.clipboard.writeText(location.href).then(() => {
shareBtn.textContent = "Copied!";
setTimeout(() => {
shareBtn.textContent = "Copy Share URL";
}, 1500);
}).catch(() => {
alert("Failed to copy to clipboard");
});
});
// Initialize from hash or defaults
parseHash();
update();
})();
</script>
</body>
</html>
Open this HTML file locally or on a server to try it out.
Let me know if you'd want the coordinates printout as well or other Minecraft-specific outputs!