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

    Function rgbToHex

    • Converts RGB color values to hexadecimal color string format

      This utility function transforms individual red, green, and blue components into a standard web-compatible hex color string for use in CSS, HTML, or other systems that expect hex color notation.

      Parameters

      • r: number

        Red component value (0-255)

      • g: number

        Green component value (0-255)

      • b: number

        Blue component value (0-255)

      Returns string

      Hexadecimal color string in format "#RRGGBB"

      import { rgbToHex } from './colors.js';

      // Convert primary colors
      const red = rgbToHex(255, 0, 0); // "#ff0000"
      const green = rgbToHex(0, 255, 0); // "#00ff00"
      const blue = rgbToHex(0, 0, 255); // "#0000ff"

      // Convert custom colors
      const purple = rgbToHex(128, 0, 128); // "#800080"
      const orange = rgbToHex(255, 165, 0); // "#ffa500"

      // Use in web contexts
      element.style.backgroundColor = rgbToHex(200, 150, 100);

      Uses bit shifting for efficient hex conversion

      O(1) - constant time operation

      getColorHex for direct fractal iteration to hex conversion

      1.0.0