CrImage::Util::Selection
Selection and flood fill operations for image editing.
Provides tools for selecting regions based on color similarity and filling areas with new colors.
Class methods
flood_fill(img : RGBA, x : Int32, y : Int32, fill_color : Color::Color, tolerance : Int32 = 10) : Int32
Performs flood fill starting from a seed point.
Fills all connected pixels that are similar to the seed pixel's color within the specified tolerance.
Parameters:
img: The image to modify (modified in place)x: Starting X coordinatey: Starting Y coordinatefill_color: Color to fill withtolerance: Maximum color difference to consider "similar" (0-255)
Returns: Number of pixels filled
replace_color(img : Image, target_color : Color::Color, replacement_color : Color::Color, tolerance : Int32 = 10) : RGBA
Replaces all pixels of one color with another.
Parameters:
img: Source imagetarget_color: Color to replacereplacement_color: New colortolerance: Maximum color difference (0-255)
Returns: New RGBA image with colors replaced
select_by_color(img : Image, x : Int32, y : Int32, tolerance : Int32 = 10, contiguous : Bool = true) : Gray
Creates a selection mask based on color similarity.
Returns a grayscale image where white (255) indicates selected pixels and black (0) indicates unselected pixels.
Parameters:
img: Source imagex: Seed point X coordinatey: Seed point Y coordinatetolerance: Maximum color difference (0-255)contiguous: If true, only selects connected pixels; if false, selects all similar pixels
Returns: Gray image representing the selection mask