20 lines
1.0 KiB
HTML
20 lines
1.0 KiB
HTML
<!DOCTYPE html><html><body>
|
|
<script type="module">
|
|
import { makeAtlas, BLOCKS, HOTBAR, tileIndexOf, faceTile } from '../js/blocks.js'
|
|
const canvas = makeAtlas()
|
|
const g = canvas.getContext('2d')
|
|
const report = { size: canvas.width, tiles: [], blank: 0 }
|
|
for (const name of ['grass_top', 'dirt', 'stone', 'sand', 'water', 'planks', 'leaves', 'brick', 'glass', 'snow', 'gravel', 'bedrock', 'log_side', 'log_top']) {
|
|
const ti = tileIndexOf(name)
|
|
const d = g.getImageData((ti % 4) * 16, Math.floor(ti / 4) * 16, 16, 16).data
|
|
let r = 0, gg = 0, b = 0, a = 0, n = 0
|
|
for (let i = 0; i < d.length; i += 4) { r += d[i]; gg += d[i + 1]; b += d[i + 2]; a += d[i + 3]; n++ }
|
|
const px = [Math.round(r / n), Math.round(gg / n), Math.round(b / n), Math.round(a / n)]
|
|
if (px[0] + px[1] + px[2] === 0) report.blank++
|
|
report.tiles.push({ name, ti, px })
|
|
}
|
|
report.hotbar = HOTBAR.map((id) => ({ id, name: BLOCKS[id].name, tile: faceTile(id, 0) }))
|
|
document.title = JSON.stringify(report)
|
|
window.__atlas = report
|
|
</script></body></html>
|