Spaces:
Running
Running
File size: 11,167 Bytes
ffdd33c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | <!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>
|