sierpinski-triangle-cli

1.4.0 • Public • Published

sierpinski-triangle-cli

Print the Sierpinski Triangle to the console!

What sierpinski-triangle-cli prints to the console

npm version bundle size downloads license

Why the console? Because it's the cool way.

See All Fractals in the fractals-cli project.

Usage

Via npx:

$ npx sierpinski-triangle-cli <n>
$ npx sierpinski-triangle-cli <n> [size] [options]

where n >= 0 and size >= n (if provided).

Via Global Install

$ npm install --global sierpinski-triangle-cli
$ sierpinski-triangle-cli <n>
$ sierpinski-triangle-cli <n> [size] [options]

where n >= 0 and size >= n (if provided).

Via Import

$ npm install sierpinski-triangle-cli

then:

const sierpinski = require('sierpinski-triangle-cli');
console.log(sierpinski.create(<n>));
console.log(sierpinski.create(<n>, { 
    size: <number>, 
    inverse: <boolean>, 
    rotate: <flip|standard>, 
    character: <character> 
}));

The config params are optional.

Options

Recursive Step

$ sierpinski-triangle-cli <n>

The first param <n> is the recursive step. <n> should be an integer greater than or equal to 0.

Examples:

$ sierpinski-triangle-cli 4

What sierpinski-triangle-cli prints to the console

$ sierpinski-triangle-cli 5

What sierpinski-triangle-cli prints to the console

Size

$ sierpinski-triangle-cli <n> [size]

The optional [size] param allows the Sierpinski Triangle to be drawn at larger sizes. [size] should be an integer greater than or equal to <n>. Including size will draw a Sierpinski Triangle of <n> recursive steps the size of a triangle with [size] recursive steps.

Example:

$ sierpinski-triangle-cli 2 5

What sierpinski-triangle-cli prints to the console

Inverse

$ sierpinski-triangle-cli <n> --inverse

The optional --inverse param (or shorthand -i) will draw the inverse Sierpinski Triangle.

Example:

$ sierpinski-triangle-cli 3 5 --inverse

What sierpinski-triangle-cli prints to the console

Rotation

$ sierpinski-triangle-cli <n> --rotate=<flip|standard>

The optional --rotate param rotates the Sierpinski Triangle. Supported values:

  • flip: Rotate 180 degrees
  • standard: No rotation (default)

Example:

$ sierpinski-triangle-cli 5 --rotate=flip

What sierpinski-triangle-cli prints to the console

Custom Characters

$ sierpinski-triangle-cli <n> --character=<character>

The optional --character=<character> param will draw triangles using the provided character. (Please provide only 1 character)

Example:

$ sierpinski-triangle-cli 4 5 --character=*

What sierpinski-triangle-cli prints to the console

Related

Main Project

Fractal Shapes

Fractal Patterns

Space Filling Curves

License

Dependents (1)

Package Sidebar

Install

npm i sierpinski-triangle-cli

Weekly Downloads

2

Version

1.4.0

License

MIT

Unpacked Size

17.4 kB

Total Files

5

Last publish

Collaborators

  • spirometaxas