npm

Bring the best of OSS JavaScript development to your projects with npm Orgs - private packages & team management tools.Learn more »

block-fractal

1.0.0 • Public • Published

BlockFractal

Generates a blocky fractal-like shape, like a tile-based randomized koch curve

See the demo

Installation

npm install block-fractal

Usage

Create a block fractal:

const BlockFractal = require('block-fractal');
 
const path = BlockFractal.makeBlockFractal({
    iterations: 7
});

Convert the path into a set of raster lines (makes cell tests faster):

const mask = path.rasterize();

Test if a tile is in the shape:

const inside = mask.get(x, y);

...

Details

BlockFractal starts with a "seed" shape, which by default is a 2x2 square:

Example 1

The shape is doubled, and then each edge is either left in place or moved to one side or the other:

Example 10

The result is a new, bigger shape, similar to the previous shape but with a more varied border:

Example 13

That process is then repeated as many times as requested.

For more information, see the Algorithm Overview

install

npm i block-fractal

Downloadsweekly downloads

0

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability