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

@cbnsndwch/fractal-cli

v0.3.0

Published

CLI tool for generating fractal SVGs

Readme

@cbnsndwch/fractal-cli

Command-line interface for generating fractal SVG patterns.

Installation

# Install globally
npm install -g @cbnsndwch/fractal-cli

# Or use with npx (no installation required)
npx @cbnsndwch/fractal-cli

Usage

Interactive Mode

Launch the interactive prompt to be guided through fractal generation:

fractal-svg

The interactive mode will:

  1. Prompt you to select a fractal type
  2. Ask for customization parameters
  3. Generate the SVG and save it to the output directory

Command Line Mode

Generate fractals directly with command-line arguments:

fractal-svg <type> [type-specific-args] [options]

Fractal Types

Koch Curve

fractal-svg koch [options]

Options:

  • --sides <n> - Number of sides (3 = snowflake, 4 = square, etc.) [default: 3]
  • --inward - Make bumps point inward [default: false]

Examples:

# Classic Koch snowflake
fractal-svg koch --sides 3 --iter 4 --fill "#3b82f6"

# Hexagonal Koch with gradient
fractal-svg koch --sides 6 --iter 3 --gradient "#22c55e,#3b82f6"

# Square Koch with inward bumps
fractal-svg koch --sides 4 --inward --stroke black --strokeWidth 2

Dragon Curve

fractal-svg dragon [options]

Example:

fractal-svg dragon --iter 12 --stroke "#ff6b6b" --strokeWidth 1.5

Hilbert Curve

fractal-svg hilbert [options]

Example:

fractal-svg hilbert --iter 6 --stroke "#3b82f6" --strokeWidth 1

Lévy C Curve

fractal-svg levy [options]

Example:

fractal-svg levy --iter 14 --stroke "#22c55e" --strokeWidth 0.5

Sierpinski Arrowhead

fractal-svg sierpinski [options]

Example:

fractal-svg sierpinski --iter 10 --stroke "#f59e0b"

Peano Curve

fractal-svg peano [options]

Example:

fractal-svg peano --iter 4 --stroke "#8b5cf6"

Gosper Curve

fractal-svg gosper [options]

Example:

fractal-svg gosper --iter 4 --stroke "#ec4899"

Carpet Fractal

fractal-svg carpet <dimension> [options]

Arguments:

  • <dimension> - Fractal dimension (0, 2]. Classic Sierpinski is ~1.8928 (required)

Options:

  • --kMin <n> - Minimum subdivision factor [default: 2]
  • --kMax <n> - Maximum subdivision factor [default: 9]
  • --maxRects <n> - Max rectangles before stopping [default: 40000]

Examples:

# Classic Sierpinski carpet
fractal-svg carpet 1.8928 --iter 4

# Low-dimension carpet with gradient
fractal-svg carpet 0.63 --gradient "#f59e0b,#ef4444" --size 256

Mandelbrot Set

fractal-svg mandelbrot [options]

Options:

  • --resolution <n> - Grid resolution for contour tracing [default: 256]
  • --centerX <n> - Center X in complex plane [default: -0.5]
  • --centerY <n> - Center Y in complex plane [default: 0]
  • --zoom <n> - View width in complex plane [default: 3]
  • --maxIter <n> - Max escape iterations [default: 100]
  • --threshold <n> - Contour threshold level [default: 2]

Examples:

# Default Mandelbrot
fractal-svg mandelbrot --gradient "#22c55e,#06b6d4,#3b82f6"

# Zoomed into an interesting region
fractal-svg mandelbrot --centerX -0.75 --zoom 0.5 --resolution 512

Julia Set

fractal-svg julia [options]

Options:

  • --juliaReal <n> - Real part of c constant [default: -0.7]
  • --juliaImag <n> - Imaginary part of c constant [default: 0.27015]
  • --resolution <n> - Grid resolution [default: 256]
  • --centerX <n> - Center X in complex plane [default: 0]
  • --centerY <n> - Center Y in complex plane [default: 0]
  • --zoom <n> - View width [default: 3.5]

Famous Julia constants:

# Dendrite pattern
fractal-svg julia --juliaReal -0.7 --juliaImag 0.27015

# Spiral arms
fractal-svg julia --juliaReal -0.8 --juliaImag 0.156

# Rabbit-like
fractal-svg julia --juliaReal -0.4 --juliaImag 0.6

# Sea horse valley
fractal-svg julia --juliaReal 0.285 --juliaImag 0.01

Common Options

These options work with all fractal types:

| Option | Description | Default | | --------------------- | ---------------------------------- | ------------- | | --out <file> | Output SVG filename | <type>.svg | | --size <px> | Canvas size in pixels (min: 64) | 512 | | --iter <n> | Iteration depth | type-specific | | --bg <color> | Background color | transparent | | --circleBg <color> | Circular background behind fractal | none | | --fill <color> | Fill color | type-specific | | --gradient <colors> | Comma-separated gradient stops | none | | --gradientAngle <n> | Gradient angle in degrees | 135 | | --stroke <color> | Stroke color | type-specific | | --strokeWidth <n> | Stroke width | type-specific | | --margin <px> | Margin around the fractal | 10 |

Advanced Examples

Multi-color Gradient

fractal-svg koch --sides 5 --iter 4 \
  --gradient "#ff6b6b,#4ecdc4,#45b7d1" \
  --gradientAngle 90 \
  --size 1024

Logo with Circular Background

fractal-svg dragon --iter 12 \
  --circleBg "#1e1e1e" \
  --stroke "#ffffff" \
  --strokeWidth 2 \
  --bg transparent \
  --out logo.svg

Custom Output Location

fractal-svg koch --sides 6 --iter 4 --out logos/my-logo.svg

Output

Generated SVG files are saved to the output/ directory by default. You can specify a custom path with the --out option.

output/
├── koch.svg
├── dragon.svg
├── carpet.svg
└── logos/
    └── my-logo.svg

Iteration Limits

Each fractal type has recommended iteration limits to prevent memory exhaustion:

| Fractal | Default | Maximum | Complexity | | ---------- | ------- | ------- | ----------------- | | carpet | 4 | 8 | N^iter rectangles | | koch | 4 | 7 | 4^iter segments | | mandelbrot | 4 | 10 | resolution-based | | julia | 4 | 10 | resolution-based | | dragon | 12 | 18 | 2^iter segments | | hilbert | 6 | 9 | 4^iter segments | | levy | 14 | 18 | 2^iter segments | | sierpinski | 10 | 14 | 3^iter segments | | peano | 4 | 6 | 9^iter segments | | gosper | 4 | 6 | 7^iter segments |

Development

# Install dependencies
pnpm install

# Run in development mode
pnpm dev

# Build for production
pnpm build

# Type check
pnpm types

Related Packages

License

MIT © cbnsndwch