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

    Class ExtractionAbstract

    Module for extracting color palettes from raw image data.

    Index

    Methods

    • Extracts a semantic theme (Vibrant, Muted, Dark, Light) from the image. Uses Median Cut to find candidates and then scores them based on saturation and luminance targets.

      Parameters

      • data:
            | Uint8ClampedArray<ArrayBufferLike>
            | Uint8Array<ArrayBufferLike>
            | ArrayLike<number>

        The raw pixel data (RGBA).

      • options: FullPartial<GetVibtantThemeOpts> = {}

        Extraction options (count defaults to 64 for better accuracy).

      Returns VibrantTheme

      A theme object containing the 6 standard variations.

    • Extract a color palette from an array of pixel data (RGBA). This implements K-Means Clustering (Lloyd standard / Naive K-Means).

      Parameters

      • data:
            | Uint8ClampedArray<ArrayBufferLike>
            | Uint8Array<ArrayBufferLike>
            | ArrayLike<number>

        The raw pixel data (e.g. from Canvas getImageData().data). Must be in RGBA format (4 bytes per pixel, 0 - 255 for all channels including alpha).

      • options: FullPartial<ExtractionOptions> = {}

        Configuration options.

      Returns Rgb[]

      An array of Rgb colors representing the palette. *

      const ctx = canvas.getContext('2d')
      const imgData = ctx.getImageData(0, 0, width, height)
      const palette = Extraction.fromImageData(imgData.data, {
      count: 5,
      sortBy: 'vibrance'
      })
    • Extract a color palette using the Median Cut algorithm. Fast, deterministic, and good for preserving color diversity.

      Parameters

      • data:
            | Uint8ClampedArray<ArrayBufferLike>
            | Uint8Array<ArrayBufferLike>
            | ArrayLike<number>

        The raw pixel data (e.g. from Canvas getImageData().data). Must be in RGBA format (4 bytes per pixel, 0 - 255 for all channels including alpha).

      • options: FullPartial<Omit<ExtractionOptions, "distance" | "maxIterations">> = {}

        Only count, sampleFactor, and sortBy are used.

      Returns Rgb[]