npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vanduo-oss/hex-grid

v1.0.0

Published

Standalone VdHexGrid package for canvas-based hex grids

Downloads

81

Readme

@vanduo-oss/hex-grid

Standalone VdHexGrid package for canvas-based hex grids.

Install

pnpm add @vanduo-oss/hex-grid

Usage

import { VdHexGrid } from '@vanduo-oss/hex-grid';

const grid = new VdHexGrid({
  element: document.getElementById('hex-demo-container'),
  canvas: document.getElementById('hex-demo'),
  size: 30,
  width: 15,
  height: 10,
  rotation: 0
});

Optional Utility Import

import { hexToPixel, pixelToHex, hexDistance } from '@vanduo-oss/hex-grid/hex-math';

API

Constructor

new VdHexGrid({ element, canvas, size, width, height, rotation })

| Option | Type | Default | Description | |--------|------|---------|-------------| | element | HTMLElement | required | Container element | | canvas | HTMLCanvasElement | auto-created | Canvas element | | size | number | 30 | Hex radius in pixels | | width | number | 10 | Grid width in hexes | | height | number | 10 | Grid height in hexes | | rotation | number | 0 | Grid rotation in radians |

Methods

  • on(event, callback) — Subscribe to events (select, zoom, pan)
  • setSize(size) — Change hex radius
  • setDimensions(width, height) — Change grid dimensions
  • setRotation(rotation) — Rotate the grid
  • reset() — Reset to defaults
  • resetView() — Reset pan and zoom
  • zoomIn() / zoomOut() — Adjust zoom
  • fillRandom() — Fill hexes with random colors
  • getHex(q, r) — Get a hex by coordinates
  • getAllHexes() — Get all hexes
  • setHexFill(q, r, color) — Set hex fill color
  • setHexTerrain(q, r, terrainType) — Set hex terrain
  • getHexTerrain(q, r) — Get hex terrain
  • generateRandomTerrain() — Randomize all terrains
  • getValidMoves(q, r, movementPoints) — Get reachable hexes
  • getPath(startQ, startR, endQ, endR) — BFS pathfinding
  • hexDistance(q1, r1, q2, r2) — Distance between hexes
  • setHexData(q, r, data) / getHexData(q, r) / clearHexData(q, r) — Custom data
  • exportTerrainData() / importTerrainData(data) — Serialization
  • setCustomRender(callback) / clearCustomRender() — Per-hex rendering hooks

Terrain Types

GRASSLAND, PLAINS, DESERT, TUNDRA, SNOW, MOUNTAIN, OCEAN, COAST

Hex Math Utilities

import {
  hexToPixel, pixelToHex, axialRound, rotatePoint, unrotatePoint,
  getHexCorners, getAdjacentHexes, hexDistance, isPassable,
  getMovementCost, getTerrainYields, getTerrainColor,
  TerrainType, TERRAIN_COLORS, DEFAULT_TERRAIN_COLOR,
  TERRAIN_YIELDS, TERRAIN_MOVEMENT_COSTS
} from '@vanduo-oss/hex-grid/hex-math';

License

MIT