Pixel Data JS - v0.28.0
    Preparing search index...

    Function floodFillSelection

    • Performs a color-based flood fill selection PixelData. This utility identifies pixels starting from a specific coordinate that fall within a color tolerance. It can operate in "contiguous" mode (classic bucket fill) or "non-contiguous" mode (selects all matching pixels in the buffer).

      Parameters

      • target: PixelData

        The source image data to process.

      • startX: number

        The starting horizontal coordinate.

      • startY: number

        The starting vertical coordinate.

      • contiguous: boolean = true

        If true, only connected pixels are selected. If false, all pixels within tolerance are selected regardless of position.

      • tolerance: number = 0

        The maximum allowed difference in color distance (0-255) for a pixel to be included.

      • Optionalbounds: Rect

        Optional bounding box to restrict the search area.

      • Optionalout: FloodFillResult

        output object

      Returns FloodFillResult | null

      A FloodFillResult containing the mask and bounds of the selection, or null if the starting coordinates are out of bounds.

      const result = floodFillImageDataSelection(
      ctx.getImageData(0, 0, 100, 100),
      50,
      50,
      {
      tolerance: 20,
      contiguous: true
      }
      );