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

cyberheroic-maps1

v2.4.4

Published

Procedural generation 2D map with biomes

Readme

Cyber Heroic Maps

Procedural generation 2D map with biomes

.

Install

npm i cyberheroic-maps

.

Generator

Create world generator

const generator = new WorldGenerator<T>(params)
  • params {
    • width - Map width
    • height - Map height
  • }

.

Layers

Add layer to generator

const layer: WorldLayer = generator.addLayer(params?)
  • params {
    • frequencyChange - Frequency of biomes change
      • Default: 0.3, Min: 0.0, Max: 1.0
    • borderSmoothness - Smoothness of biomes borders
      • Default: 0.5, Min: 0.0, Max: 1.0
    • heightRedistribution - Redistribution of biomes height
      • Default: 1.0, Min: 0.5, Max: 1.5
    • heightAveraging - Averaging of biomes height
      • Default: true
    • falloff - Scale of falloff area
      • Default: 0.0
  • }

Get generator layers

const layers: WorldLayers[] = generator.getLayers()

Clear all generator layers

generator.clearLayers()

.

Biomes

Add biome to layer

for (const { params, data } of ...) {
  const biome: WorldBiome = layer.addBiome(params, data)
}
  • params {
    • lowerBound - Lower biome bound
      • Default: 0.0
    • upperBound - Upper biome bound
      • Default: 1.0
  • }
  • data - Data of biome

Get layer biomes

const biomes: WorldBiome[] = layer.getBiomes()

Clear all layer biomes

layer.clearBiomes()

.

Generation

Generate world

const world: World = generator.generate(params?)
  • params {
    • seed - Generation seed
      • Default: Autogenerate
    • seedSize - Size of seed array
      • Default: 512
  • }

.

World

Get matrix of biomes data

const matrix: T[][] = world.getMatrix()

Each all positions

world.each(callback)
  • callback(
    • position - Position at matrix
    • data - Biome data
  • )

Get biome data at position

const data: T = world.getAt(position)
  • position {
    • x - X position at matrix
    • y - Y position at matrix
  • }

Replace biome data at position

world.replaceAt(position, data)
  • position {
    • x - X position at matrix
    • y - Y position at matrix
  • }
  • data - New data of biome

Get current world generation seed

const seed: number[] = world.seed

Get world width

const width: number = world.width

Get world height

const height: number = world.height

.

Example

const TILE_SIZE = 2;
const BIOMES = [
  { // WATER
    params: { lowerBound: 0.0, upperBound: 0.2 },
    data: { color: 'blue' },
  },
  { // GRASS
    params: { lowerBound: 0.2, upperBound: 0.7 },
    data: { color: 'green' },
  },
  { // MOUNTS
    params: { lowerBound: 0.7 },
    data: { color: 'gray' },
  },
];

const generator = new WorldGenerator({
  width: 100,
  height: 100,
});

const layer = generator.addLayer();

for (const { params, data } of BIOMES) {
  layer.addBiome(params, data);
}

const world = generator.generate();

world.each((position, biome) => {
  const tileX = position.x * TILE_SIZE;
  const tileY = position.y * TILE_SIZE;

  ctx.fillStyle = biome.color;
  ctx.fillRect(tileX, tileY, TILE_SIZE, TILE_SIZE);
});