<!doctype html>
<html lang="vi">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Cung pixel art 32×32</title>
<style>
  * { box-sizing: border-box; }
  body { margin:0; min-height:100vh; padding:24px; display:grid;
    place-items:center; background:#151a25; color:#f5eedb;
    font:16px/1.5 system-ui,sans-serif; }
  main { text-align:center; max-width:100%; }
  h1 { font-size:24px; margin:0 0 8px; }
  p { color:#b9c1cf; margin:0 0 20px; }
  .preview { width:min(320px,80vw); aspect-ratio:1; margin:0 auto 24px;
    border:1px solid #3b4354; border-radius:12px; overflow:hidden;
    background-color:#252d3a;
    background-image:conic-gradient(#303a49 25%,transparent 0 50%,#303a49 0 75%,transparent 0);
    background-size:40px 40px; }
  canvas { width:100%; height:100%; image-rendering:pixelated; display:block; }
  button { font:inherit; font-weight:650; color:#152c30; background:#7ed8bd;
    border:0; padding:12px 24px; border-radius:8px; cursor:pointer; }
  button:hover { background:#a0ead3; }
  button:focus-visible { outline:3px solid #ffe3a0; outline-offset:4px; }
  small { display:block; margin-top:12px; color:#b9c1cf; }
</style>
<main>
  <h1>Cung pixel art</h1>
  <p>32 × 32 pixel · PNG nền trong suốt</p>
  <div class="preview"><canvas id="bow" width="32" height="32"
    role="img" aria-label="Cây cung gỗ với dây cung và mũi tên"></canvas></div>
  <button id="download" type="button">Tải PNG 32×32</button>
  <small>Ảnh xem trước phóng to 10 lần.</small>
</main>
<script>
// Sửa bảng màu hoặc các ô trong pixels để thay đổi hình.
const palette = ["transparent", "#222537", "#ffe3a0", "#edba58", "#b77a36", "#73432c", "#bb713b", "#efb665", "#e8dfb9", "#60b5a4", "#14434d", "#edf6e7", "#b6d4db", "#287579", "#738d9f"];
const pixels = [
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 1, 0, 0, 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 0, 0, 1, 5, 7, 6, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 1, 0, 0, 1, 5, 7, 6, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 1, 0, 1, 5, 6, 7, 6, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 5, 7, 7, 6, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 5, 6, 7, 6, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 1, 5, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
];
const canvas = document.getElementById('bow');
const ctx = canvas.getContext('2d');
ctx.imageSmoothingEnabled = false;
pixels.forEach((row, y) => row.forEach((color, x) => {
  if (!color) return;
  ctx.fillStyle = palette[color];
  ctx.fillRect(x, y, 1, 1);
}));
document.getElementById('download').addEventListener('click', () => {
  const link = document.createElement('a');
  link.download = 'cung_32x32.png';
  link.href = canvas.toDataURL('image/png');
  link.click();
});
</script>
</html>
