hex-world
    Preparing search index...

    Function drawMapImage

    • Draws a flat top-down view of the map into an existing 2D context and returns the world ↔ pixel transform it used.

      This is the synchronous core of renderMapImage. Prefer it for a live minimap: it draws straight into a visible canvas with no Blob encode, no object URL, and no image decode, so it can be re-run on every edit.

      The context is assumed to be at least transform.width × transform.height pixels; size it with getMapImageTransform first, or read the returned transform after the first draw.

      Parameters

      Returns MapImageTransform

      const t = getMapImageTransform(map, layout, { scale: 2 });
      canvas.width = t.width; canvas.height = t.height;
      drawMapImage(canvas.getContext('2d')!, map, layout, terrainDefinitions, {
      scale: 2, elevationShading: 0.05, rivers: true, roads: true,
      });