gpt-4.1-mini-2025-04-14· OpenAI
WildChat-4.8M (AI2)
html css js minecraft circle generator width height pos
- User
html css js minecraft circle generator width height pos
- Assistant
html css js minecraft circle generator width height pos
Sure! Here's a simple example of a Minecraft-style pixel art circle generator using HTML, CSS, and JavaScript. This will allow you to specify the width, height, and position of the circle on a grid, and it will render a pixelated (blocky) circle reminiscent of Minecraft blocks.
<!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: Arial, sans-serif;
padding: 20px;
background: #222;
color: #eee;
}
.controls {
margin-bottom: 15px;
}
label {
display: inline-block;
margin-right: 15px;
}
input[type=number] {
width: 60px;
padding: 4px;
margin-left: 5px;
font-size: 1rem;
}
button {
padding: 6px 12px;
font-size: 1rem;
cursor: pointer;
}
#grid {
position: relative;
width: 320px; /* gridWidth * blockSize */
height: 320px; /* gridHeight * blockSize */
background: #3c3f41;
display: grid;
grid-template-columns: repeat(32, 10px);
grid-template-rows: repeat(32, 10px);
gap: 1px;
border: 3px solid #555;
}
.block {
width: 10px;
height: 10px;
background-color: #6b8e23; /* default grass green */
}
.block.empty {
background-color: #3c3f41;
}
.block.circle {
background-color: #937048; /* dirt block color */
box-shadow: inset 0 0 2px #5b3e1a;
}
</style>
</head>
<body>
<h1>Minecraft Pixel Circle Generator</h1>
<div class="controls">
<label>Width:
<input type="number" id="widthInput" min="1" max="32" value="10" />
</label>
<label>Height:
<input type="number" id="heightInput" min="1" max="32" value="10" />
</label>
<label>Position X:
<input type="number" id="posXInput" min="0" max="31" value="11" />
</label>
<label>Position Y:
<input type="number" id="posYInput" min="0" max="31" value="11" />
</label>
<button id="drawBtn">Draw Circle</button>
</div>
<div id="grid"></div>
<script>
// Grid size
const gridWidth = 32;
const gridHeight = 32;
const grid = document.getElementById('grid');
// Initialize grid blocks and add to DOM
const blocks = [];
function createGrid() {
grid.innerHTML = '';
blocks.length = 0;
for(let y = 0; y < gridHeight; y++) {
for(let x = 0; x < gridWidth; x++) {
const block = document.createElement('div');
block.classList.add('block', 'empty');
block.dataset.x = x;
block.dataset.y = y;
grid.appendChild(block);
blocks.push(block);
}
}
}
// Draw circle in pixel blocks
// params: width, height = dimensions of the ellipse
// posX, posY = top-left corner position on the grid
function drawCircle(width, height, posX, posY) {
createGrid();
// Midpoints of ellipse
const rx = width / 2;
const ry = height / 2;
const cx = posX + rx;
const cy = posY + ry;
for(let block of blocks) {
const x = parseInt(block.dataset.x);
const y = parseInt(block.dataset.y);
// Normalize coordinates to ellipse center
const dx = (x + 0.5 - cx) / rx;
const dy = (y + 0.5 - cy) / ry;
const ellipseEq = dx * dx + dy * dy;
// Check if point lies roughly on the perimeter of ellipse (thickness 0.2)
if(ellipseEq <= 1.0 && ellipseEq >= 0.6) {
block.classList.remove('empty');
block.classList.add('circle');
} else {
block.classList.remove('circle');
block.classList.add('empty');
}
}
}
document.getElementById('drawBtn').addEventListener('click', () => {
let width = parseInt(document.getElementById('widthInput').value);
let height = parseInt(document.getElementById('heightInput').value);
let posX = parseInt(document.getElementById('posXInput').value);
let posY = parseInt(document.getElementById('posYInput').value);
// Clamp inputs
width = Math.min(Math.max(width,1), gridWidth);
height = Math.min(Math.max(height,1), gridHeight);
posX = Math.min(Math.max(posX,0), gridWidth - width);
posY = Math.min(Math.max(posY,0), gridHeight - height);
drawCircle(width, height, posX, posY);
});
// Draw initial circle on page load
drawCircle(10, 10, 11, 11);
</script>
</body>
</html>
You can modify width, height, posX, and posY to create various circle shapes made of Minecraft-style pixel blocks.
Feel free to ask if you want additional features!
Not yet included in a published release.