Number of iterations before the point escaped
Maximum iterations used in fractal calculation
Name of the color palette to use (default: 'rainbow')
Hexadecimal color string in format "#RRGGBB"
import { getColorHex } from './colors.js';
// Get hex colors for fractal points
const setColor = getColorHex(1000, 1000, 'fire'); // "#000000" (black)
const escapeColor = getColorHex(50, 200, 'ocean'); // "#1e3f5c" (blue)
// Use directly in web contexts
canvas.style.backgroundColor = getColorHex(75, 100, 'sunset');
// Generate CSS color arrays
const cssColors = Array.from({length: 10}, (_, i) =>
getColorHex(i * 10, 100, 'rainbow')
);
Maps iteration count directly to hexadecimal color string
Convenience function that combines getColor() and rgbToHex() for direct conversion from Mandelbrot iteration results to web-compatible hex colors. Ideal for web applications, CSS generation, and HTML canvas operations.