iam-medvedev / sierpinski-generator

Sierpiński triangle dataset generator.

Home Page:https://iam-medvedev.github.io/sierpinski-generator/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sierpinski-generator

Sierpiński triangle dataset generator.

See interactive svg-generator demo.

Install

yarn add sierpinski-generator

Triangle generator

Usage:

import { createSierpinskiTriangle } from 'sierpinski-generator';

const result = createSierpinskiTriangle({
  size: 1000,
  iterations: 4,
});

// [
//   {
//     box: { width: 62.5, height: 62.5, x: 0, y: 0 },
//     points: [
//       { x: 0, y: 0 },
//       { x: 62.5, y: 0 },
//       { x: 31.25, y: 62.5 },
//     ],
//   },
//   {
//     box: { width: 62.5, height: 62.5, x: 62.5, y: 0 },
//     points: [
//       { x: 62.5, y: 0 },
//       { x: 125, y: 0 },
//       { x: 93.75, y: 62.5 },
//     ],
//   },
//   ...
// ];

Carpet generator

Usage:

import { createSierpinskiCarpet } from 'sierpinski-generator';

const result = createSierpinskiCarpet({
  size: 1000,
  iterations: 4,
});

// [
//   { width: 333.3333333333333, height: 333.3333333333333, x: 0, y: 0 },
//   { width: 333.3333333333333, height: 333.3333333333333, x: 0, y: 333.3333333333333 },
// ];

Local demo

yarn demo

License

sierpinski-generator is WTFPL licensed.

About

Sierpiński triangle dataset generator.

https://iam-medvedev.github.io/sierpinski-generator/

License:Do What The F*ck You Want To Public License


Languages

Language:TypeScript 100.0%