<!DOCTYPE html>
<html lang="vi">
<meta charset="utf-8">
<title>Rìu chéo 32×32</title>
<style>
  body { padding:24px; font-family:system-ui; }
  canvas {
    display:block; width:256px; height:256px;
    image-rendering:pixelated;
    background:conic-gradient(#ddd 25%,#fff 0 50%,#ddd 0 75%,#fff 0)
      0 0 / 32px 32px;
  }
  a { display:inline-block; margin-top:16px; }
</style>

<canvas id="art" width="32" height="32"></canvas>
<a id="download" download="riu-cheo-32x32.png">Tải PNG</a>

<script>
const canvas = document.getElementById("art");
const ctx = canvas.getContext("2d");
const palette = {
  "#": "#192632", // Viền
  H: "#edf9ff", L: "#abcbd6", S: "#5c7c91", // Thép
  a: "#e7ad62", b: "#ae6b37", c: "#693b27"  // Gỗ
};

function pixel(x, y, color, flip = false) {
  ctx.fillStyle = palette[color];
  ctx.fillRect(flip ? 31 - x : x, y, 1, 1);
}

// Hai cán rìu nằm chéo, có viền và bóng.
for (const flip of [false, true]) {
  for (let t = 7; t <= 25; t++) {
    for (let dx = -2; dx <= 2; dx++) {
      for (let dy = -2; dy <= 2; dy++) {
        if (Math.abs(dx) + Math.abs(dy) <= 2) {
          pixel(t + dx, t + 1 + dy, "#", flip);
        }
      }
    }
  }

  for (let t = 7; t <= 25; t++) {
    const [light, mid, dark] =
      t < 11 ? ["H", "L", "S"] : ["a", "b", "c"];
    pixel(t - 1, t + 1, light, flip);
    pixel(t,     t,     light, flip);
    pixel(t,     t + 1, mid,   flip);
    pixel(t + 1, t + 1, dark,  flip);
    pixel(t,     t + 2, dark,  flip);
  }
}

// Lưỡi rìu: mỗi ký tự tương ứng đúng một pixel.
const blade = [
  "...##.......",
  "..#HH#..##..",
  ".#HHHL##SS#.",
  "#HHHHLLLSSS#",
  "#HHHLLLLSSS#",
  "#HHLLLLSSS#.",
  "#HLLLLSSS#..",
  "#LLLLSSS#...",
  ".#LLLSS#....",
  "..#LSS#.....",
  "...###......"
];

for (const flip of [false, true]) {
  blade.forEach((row, y) => {
    [...row].forEach((color, x) => {
      if (color !== ".") pixel(x + 1, y + 2, color, flip);
    });
  });
}

// PNG giữ nguyên kích thước 32×32 và nền trong suốt.
document.getElementById("download").href =
  canvas.toDataURL("image/png");
</script>
</html>
