[doc] Magic wand: a visible pixel matches by colour, so a stroke's soft edge goes with it
This commit is contained in:
@@ -309,12 +309,16 @@ pub fn pencil(
|
||||
dirty
|
||||
}
|
||||
|
||||
/// Whether a pixel belongs with the seed: transparent with transparent (by alpha), visible with visible by colour
|
||||
/// alone, so a stroke's soft, half-transparent edge goes with the stroke.
|
||||
fn close(a: &[u8], b: [u8; 4], tol: u8) -> bool {
|
||||
// Fully transparent pixels match each other whatever their colour channels say.
|
||||
if a[3] == 0 && b[3] == 0 {
|
||||
return true;
|
||||
if b[3] == 0 {
|
||||
return a[3] <= tol;
|
||||
}
|
||||
(0..4).all(|i| (a[i] as i16 - b[i] as i16).unsigned_abs() <= tol as u16)
|
||||
if a[3] == 0 {
|
||||
return false;
|
||||
}
|
||||
(0..3).all(|i| (a[i] as i16 - b[i] as i16).unsigned_abs() <= tol as u16)
|
||||
}
|
||||
|
||||
/// The region around (x, y) whose pixels are within `tol` of its colour (4-connected).
|
||||
|
||||
Reference in New Issue
Block a user