UNPKG

@prachwal/mandelbrot-generator

Version:

Professional Mandelbrot fractal generator with TypeScript support, interactive web interface, and multiple output formats

135 lines 4.08 kB
#!/usr/bin/env node /** * @fileoverview Command-line interface and Node.js entry point for Mandelbrot fractal generator * @module index * @version 1.0.0 * @author Prachwal * @since 1.0.0 * * This module provides a complete command-line interface for generating Mandelbrot fractals * as SVG files. It supports various output formats, interesting point navigation, * and batch generation capabilities for Node.js environments. * * @example * ```bash * # Generate default fractal * npx mandelbrot-generator * * # Generate with custom parameters * npx mandelbrot-generator --width 1920 --height 1080 --iterations 256 * * # Generate interesting locations * npx mandelbrot-generator --preset elephant --output elephant.svg * ``` * * @example * ```typescript * // Use programmatically * import { generateMandelbrotSVG, main } from './index.js'; * * // Generate SVG string * const svg = generateMandelbrotSVG({ * width: 800, * height: 600, * maxIterations: 100, * colorPalette: 'fire' * }); * * // Run CLI with custom args * await main(['--preset', 'seahorse', '--output', 'test.svg']); * ``` */ import type { MandelbrotConfig } from './types.js'; /** * Saves a Mandelbrot fractal as an SVG file to the output directory * * This function generates the fractal and writes it directly to a file in the * project's output folder. It automatically creates the output directory if needed. * * @param config - Complete fractal generation configuration * @param filename - Name of the output file (will be converted to .svg) * @returns Absolute path to the saved SVG file * * @example * ```typescript * import { saveImageAsSVG, defaultConfig } from '@prachwal/mandelbrot-generator'; * * const filePath = saveImageAsSVG({ * ...defaultConfig, * width: 1200, * height: 800, * maxIterations: 256 * }, 'my-fractal.svg'); * * console.log(`Fractal saved to: ${filePath}`); * ``` * * @see {@link generateMandelbrotSVG} for generating SVG content without saving * @since 1.0.0 */ export declare function saveImageAsSVG(config: MandelbrotConfig, filename: string): string; /** * Generates SVG content for a Mandelbrot fractal * * This function creates a complete SVG document as a string, containing * the visual representation of the Mandelbrot set. The SVG can be saved * to a file, embedded in HTML, or processed further. * * @param config - Complete fractal generation configuration * @returns Complete SVG document as a string * * @example * ```typescript * import { generateMandelbrotSVG, interestingPoints } from '@prachwal/mandelbrot-generator'; * * // Generate classic view * const svg = generateMandelbrotSVG({ * width: 800, * height: 600, * maxIterations: 100, * escapeRadius: 2, * zoom: 1, * centerX: -0.5, * centerY: 0, * colorPalette: 'rainbow' * }); * * // Use with predefined locations * const elephantSvg = generateMandelbrotSVG({ * width: 1200, * height: 800, * maxIterations: 256, * escapeRadius: 2, * colorPalette: 'fire', * ...interestingPoints.elephant * }); * * // Save to file or use directly * document.getElementById('fractal').innerHTML = svg; * ``` * * @performance * - Uses 2x2 pixel rectangles for better SVG performance * - Skips black pixels (points in the Mandelbrot set) to reduce file size * - Progress reporting every 10% during generation * * @see {@link saveImageAsSVG} for direct file saving * @see {@link generateMandelbrotData} for raw pixel data generation * @since 1.0.0 */ export declare function generateMandelbrotSVG(config: MandelbrotConfig): string; /** * Main function */ declare function main(): Promise<void>; export * from './types.js'; export * from './mandelbrot.js'; export * from './colors.js'; export * from './config.js'; export * from './core/fractal-engine.js'; export * from './core/base-fractal.js'; export * from './algorithms/mandelbrot.js'; export * from './algorithms/julia.js'; export * from './algorithms/burning-ship.js'; export { main }; //# sourceMappingURL=index.d.ts.map