tibia-style-void-arena / inspect.html
magus75's picture
Upload folder using huggingface_hub
ffdd33c verified
Raw History Blame Contribute Delete
11.2 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Asset & Coordinate Inspector</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #1e1e24;
color: #e0e0e0;
padding: 20px;
}
h1 {
color: #ff9800;
}
.container {
display: flex;
flex-direction: column;
gap: 20px;
}
.panel {
background: #2a2a35;
border: 1px solid #3a3a4c;
border-radius: 8px;
padding: 15px;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 15px;
margin-top: 15px;
}
.card {
background: #333344;
border-radius: 6px;
padding: 10px;
display: flex;
flex-direction: column;
align-items: center;
}
.card img {
max-width: 100%;
max-height: 180px;
object-fit: contain;
border: 1px solid #444;
background: #000;
margin-bottom: 5px;
}
.info {
font-size: 13px;
text-align: center;
}
canvas {
border: 1px solid #ff9800;
background: #000;
max-width: 100%;
}
pre {
background: #000;
color: #a7f3d0;
padding: 10px;
border-radius: 4px;
overflow-x: auto;
font-family: monospace;
}
</style>
</head>
<body>
<h1>Asset & Coordinate Inspector</h1>
<p>Open this page at <strong>http://localhost:5173/inspect.html</strong> to see pixel coordinates and images.</p>
<div class="container">
<!-- PANEL 1.5: INSPECTOR DE GRELHA DO ESPANTALHO -->
<div class="panel">
<h2>Inspector de Grelha - Espantalho (/assets/scarecrow.png)</h2>
<div>
<label>Largura do Frame: <input type="number" id="sc-w" value="64" style="width:60px;"></label>
<label>Altura do Frame: <input type="number" id="sc-h" value="95" style="width:60px;"></label>
<label>Colunas: <input type="number" id="sc-cols" value="16" style="width:60px;"></label>
<label>Linhas: <input type="number" id="sc-rows" value="6" style="width:60px;"></label>
</div>
<div style="margin-top: 10px; overflow-x: auto;">
<canvas id="scarecrow-canvas" width="1024" height="569"></canvas>
</div>
</div>
<!-- PANEL 1: SCANNER DE COORDENADAS DO COWBOY -->
<div class="panel">
<h2>Scan de Coordenadas do Cowboy (em media7.jpg)</h2>
<canvas id="scan-canvas" width="1024" height="569"></canvas>
<h3>Resultados do Escaneamento:</h3>
<pre id="scan-log">Carregando imagem e escaneando pixels...</pre>
</div>
<!-- PANEL 2: SLICES DA ARENA -->
<div class="panel">
<h2>Recortes (Slices) Gerados para a Arena</h2>
<p>Esses pedaços foram recortados de <code>tileset.png</code> com base em estimativas de coordenadas:</p>
<div class="grid" id="slices-grid"></div>
</div>
<!-- PANEL 2.5: SLICES DO ESPANTALHO -->
<div class="panel">
<h2>Slices Gerados do Espantalho</h2>
<p>Slices recortados de <code>scarecrow.png</code> com tamanho 64x95:</p>
<div class="grid" id="scarecrow-slices-grid"></div>
</div>
<!-- PANEL 3: TODAS AS IMAGENS -->
<div class="panel">
<h2>Galeria de Mídias Completa</h2>
<div class="grid" id="gallery-grid"></div>
</div>
</div>
<script>
// 1. Escaneamento de Coordenadas
const scanCanvas = document.getElementById('scan-canvas');
const scanCtx = scanCanvas.getContext('2d');
const scanLog = document.getElementById('scan-log');
const img7 = new Image();
img7.src = '/media7.jpg';
img7.onload = () => {
scanCtx.drawImage(img7, 0, 0);
const imgData = scanCtx.getImageData(0, 0, 1024, 569);
const data = imgData.data;
const width = imgData.width;
const height = imgData.height;
const detectedBars = [];
for (let y = 0; y < height; y++) {
let greenRun = 0;
let startX = 0;
for (let x = 0; x < width; x++) {
const idx = (y * width + x) * 4;
const r = data[idx];
const g = data[idx + 1];
const b = data[idx + 2];
const isGreen = (g > 110 && r < 100 && b < 100);
if (isGreen) {
if (greenRun === 0) startX = x;
greenRun++;
} else {
if (greenRun >= 15 && greenRun <= 40) {
detectedBars.push({ x: startX, y: y, width: greenRun });
}
greenRun = 0;
}
}
if (greenRun >= 15 && greenRun <= 40) {
detectedBars.push({ x: startX, y: y, width: greenRun });
}
}
const uniqueBars = [];
detectedBars.forEach(bar => {
const close = uniqueBars.find(ub => Math.abs(ub.x - bar.x) < 5 && Math.abs(ub.y - bar.y) < 5);
if (!close) {
uniqueBars.push(bar);
}
});
let logText = `Barras de HP detectadas (Total: ${uniqueBars.length}):\n`;
uniqueBars.forEach((bar, idx) => {
const charX = Math.round(bar.x + bar.width / 2 - 20);
const charY = bar.y + 5;
const charW = 40;
const charH = 65;
logText += `Barra #${idx+1}: localizado em X=${bar.x}, Y=${bar.y} (Largura: ${bar.width}px)\n`;
logText += ` -> Bounding Box estimado do Personagem:\n`;
logText += ` sx: ${charX}, sy: ${charY}, sw: ${charW}, sh: ${charH}\n`;
scanCtx.strokeStyle = '#ef4444';
scanCtx.lineWidth = 2;
scanCtx.strokeRect(charX, charY, charW, charH);
scanCtx.fillStyle = '#00ff00';
scanCtx.font = 'bold 12px Arial';
scanCtx.fillText(`Personagem #${idx+1} (sx: ${charX}, sy: ${charY})`, charX - 10, charY - 8);
});
scanLog.textContent = logText;
};
// 2. Renderização dos Slices
const slices = [
{ file: 'slice_tent1.png', desc: 'Tent 1 (x:0, y:0, w:150, h:150)' },
{ file: 'slice_tent2.png', desc: 'Tent 2 (x:150, y:0, w:100, h:100)' },
{ file: 'slice_tent3.png', desc: 'Tent 3 (x:250, y:0, w:130, h:130)' },
{ file: 'slice_tent4.png', desc: 'Tent 4 (x:380, y:0, w:100, h:100)' },
{ file: 'slice_wagon.png', desc: 'Wagon (x:500, y:140, w:120, h:120)' },
{ file: 'slice_campfire.png', desc: 'Campfire (x:0, y:280, w:120, h:100)' },
{ file: 'slice_trough.png', desc: 'Water Trough (x:512, y:0, w:120, h:80)' },
{ file: 'slice_crates.png', desc: 'Crates & Barrels (x:0, y:140, w:150, h:100)' }
];
const slicesGrid = document.getElementById('slices-grid');
slices.forEach(slice => {
const card = document.createElement('div');
card.className = 'card';
const img = document.createElement('img');
img.src = '/' + slice.file;
const info = document.createElement('div');
info.className = 'info';
info.innerHTML = `<strong>${slice.file}</strong><br>${slice.desc}`;
card.appendChild(img);
card.appendChild(info);
slicesGrid.appendChild(card);
});
// 2.5. Renderização dos Slices do Espantalho
const scSlicesGrid = document.getElementById('scarecrow-slices-grid');
for (let r = 0; r < 5; r++) {
for (let c = 0; c < 16; c++) {
const fileName = `sc_r${r}_c${c}.png`;
const card = document.createElement('div');
card.className = 'card';
const img = document.createElement('img');
img.src = '/assets/' + fileName;
const info = document.createElement('div');
info.className = 'info';
info.innerHTML = `<strong>${fileName}</strong><br>Linha ${r}, Coluna ${c}`;
card.appendChild(img);
card.appendChild(info);
scSlicesGrid.appendChild(card);
}
}
// 3. Galeria de Mídias
const mediaFiles = [
{ name: 'media1.png', desc: 'Reference image from Step 3 (Mage Request)' },
{ name: 'media2.png', desc: 'Spritesheet from Step 5 (Mage Walk)' },
{ name: 'media3.png', desc: 'Spritesheet from Step 6 (Mage Actions)' },
{ name: 'media4.jpg', desc: 'JPEG from Step 8' },
{ name: 'media5.jpg', desc: 'JPEG from Step 9' },
{ name: 'media6.jpg', desc: 'JPEG from Step 9' },
{ name: 'media7.jpg', desc: 'Arena Print from Step 10' },
{ name: 'media8.png', desc: 'Tileset Print from Step 10' }
];
const galleryGrid = document.getElementById('gallery-grid');
mediaFiles.forEach(file => {
const card = document.createElement('div');
card.className = 'card';
const img = document.createElement('img');
img.src = '/' + file.name;
img.onload = () => {
const dimensions = `${img.naturalWidth}x${img.naturalHeight}px`;
info.innerHTML = `<strong>${file.name}</strong><br>${dimensions}<br>${file.desc}`;
};
img.onerror = () => {
info.innerHTML = `<strong>${file.name}</strong><br><span style="color:red">Failed to load</span><br>${file.desc}`;
};
const info = document.createElement('div');
info.className = 'info';
info.innerHTML = `<strong>${file.name}</strong><br>Loading...<br>${file.desc}`;
card.appendChild(img);
card.appendChild(info);
galleryGrid.appendChild(card);
});
// Código do Espantalho
const scCanvas = document.getElementById('scarecrow-canvas');
const scCtx = scCanvas.getContext('2d');
const scWInput = document.getElementById('sc-w');
const scHInput = document.getElementById('sc-h');
const scColsInput = document.getElementById('sc-cols');
const scRowsInput = document.getElementById('sc-rows');
const scImg = new Image();
scImg.src = '/assets/scarecrow.png';
scImg.onload = () => {
drawScarecrowGrid();
};
function drawScarecrowGrid() {
if (!scImg.complete) return;
scCtx.clearRect(0, 0, scCanvas.width, scCanvas.height);
scCtx.drawImage(scImg, 0, 0);
const fw = parseInt(scWInput.value) || 64;
const fh = parseInt(scHInput.value) || 95;
const cols = parseInt(scColsInput.value) || 16;
const rows = parseInt(scRowsInput.value) || 6;
scCtx.strokeStyle = 'rgba(255, 235, 59, 0.7)'; // Amarelo semitransparente
scCtx.lineWidth = 1;
// Desenha linhas verticais
for (let c = 0; c <= cols; c++) {
const x = c * fw;
scCtx.beginPath();
scCtx.moveTo(x, 0);
scCtx.lineTo(x, scCanvas.height);
scCtx.stroke();
}
// Desenha linhas horizontais
for (let r = 0; r <= rows; r++) {
const y = r * fh;
scCtx.beginPath();
scCtx.moveTo(0, y);
scCtx.lineTo(scCanvas.width, y);
scCtx.stroke();
}
// Adiciona rótulos para cada célula
scCtx.fillStyle = '#ffeb3b';
scCtx.font = '9px monospace';
for (let r = 0; r < rows; r++) {
for (let c = 0; c < cols; c++) {
const x = c * fw;
const y = r * fh;
scCtx.fillText(`[${r},${c}]`, x + 2, y + 10);
}
}
}
[scWInput, scHInput, scColsInput, scRowsInput].forEach(input => {
input.addEventListener('input', drawScarecrowGrid);
});
</script>
</body>
</html>