JSFiddle - React, Tailwind, and code Playground

by torresomar

HTML

<canvas id='test' height="256" width="256"></canvas>

CSS

#test {
  border: 1px solid #c1c1c1;
}

JavaScript

const geometry = [
  [-64, 4160],
  [-64, 3735],
  [105, 3783],
  [649, 3628],
  [994, 3406],
  [1399, 2925],
  [1519, 2496],
  [1537, 2232],
  [1326, 2136],
  [1151, 2058],
  [1046, 1887],
  [1099, 1713],
  [1405, 1668],
  [1704, 1558],
  [1913, 1716],
  [1828, 1919],
  [1659, 2056],
  [2390, 2126],
  [2446, 2258],
  [2247, 2443],
  [2854, 2463],
  [3115, 2303],
  [3482, 2229],
  [3777, 2268],
  [4027, 2194],
  [4160, 2279],
  [4160, 4160],
  [-64, 4160]
];
const ctx = document.getElementById('test').getContext('2d');
ctx.strokeStyle = '#c1c1c1';
ctx.fillStyle = '#e65e5e';
ctx.beginPath();
geometry.forEach((point, index) => {
  const pad = 0;
  const extent = 4096; // Extent declared in our options object for geojson-vt
  const x = point[0] / extent * 256;
  const y = point[1] / extent * 256;
  if (index) {
    ctx.lineTo(x + pad, y + pad);
  } else {
    ctx.moveTo(x + pad, y + pad);
  }
});
ctx.fill('evenodd');
ctx.stroke();