@prachwal/mandelbrot-generator - v1.0.0
    Preparing search index...

    Function getColorHex

    • 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.

      Parameters

      • iterations: number

        Number of iterations before the point escaped

      • maxIterations: number

        Maximum iterations used in fractal calculation

      • paletteType: PaletteType = 'rainbow'

        Name of the color palette to use (default: 'rainbow')

      Returns string

      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')
      );

      O(1) - constant time operation

      1.0.0