@OPEN-KAPPA/COLORS
    Preparing search index...

    Class GeneratorAbstract

    Color sequence generators.

    Index

    Methods

    • Generates a Cubehelix color scale function. Returns a function that takes t (0-1) and returns an Rgb color.

      Parameters

      • start: number = 300

        Start hue in degrees (0-360)

      • rotations: number = -1.5

        Number of rotations (e.g., 1.5)

      • hue: number = 1

        Saturation factor (0 = grayscale, 1 = default, >1 = super saturated)

      • gamma: number = 1

        Gamma correction (1 = linear, <1 brighter, >1 darker)

      Returns (t: number) => Rgb

      The cubehelix function.

    • Generates a set of visually distinct colors. Ideal for charts, data visualization, and categorization. Uses OKLCH to ensure uniform perceptual brightness.

      Parameters

      Returns Oklch[]

      The array of generated colors.

    • Generates a list of colors forming a gradient.

      Type Parameters

      Parameters

      • steps: number

        The number of colors to generate.

      • c1: C

        The first color.

      • c2: C

        The second color.

      • mixer: Mixer<C>

        The mixing method.

      Returns C[]

      The generated colors.

    • Creates a discrete scale (quantization). Unlike scale() which interpolates smoothly between colors, quantize() splits the domain into segments based on the number of colors passed and their weights.

      Ideally suited for ColorBrewer palettes where distinct categories are preferred over gradients.

      Type Parameters

      Parameters

      • colors: C[]

        The array of colors to use as buckets.

      • Optionaldomain: number[]

        The array of weights.

      Returns (t: number) => C

      A function that maps t (0-1) to one of the colors.

      const palette = Brewer.sequential.blues; // Array of 9 blues
      const getBucket = Generator.quantize(palette);

      getBucket(0.05) // Returns bucket 0 (Lightest blue)
      getBucket(0.15) // Returns bucket 1
      // ...
    • Create a weighted scale of colors, passing through the given colors. If no weights are passed, all colors will have the same weight in range 0-1.

      Type Parameters

      Parameters

      • colors: C[]

        The colors to use.

      • mixer: Mixer<C>

        The mixer function.

      • Optionaldomain: number[]

        The array of weights.

      Returns (point: number) => C

      If the number of colors is less then 2, or the passed domain is invalid.

    • Compute a spline interpolation between a set of colors. Uses Catmull-Rom spline on each channel, correctly handling Hue wrapping if present.

      Type Parameters

      Parameters

      • colors: C[]

        The list of colors (at least 1).

      Returns (t: number) => C

      The interpolation method.