extern crate avl_tree; mod label_format; pub mod binfile; pub mod analysis; pub use crate::label_format::{LabelFormat,LabelU16}; pub(crate) fn flood(source: &LabelFormat, destination: &mut Vec, x: usize, y: usize, from_color: T, to_color: R) { let width = source.width; let destination_color = destination[x + y * width]; if !destination_color.is_zero() { return; } let source_color = source.buffer[x + y * width]; if source_color != from_color { return; } destination[x + y * width] = to_color; if x > 0 { flood(source, destination, x-1, y, from_color, to_color); } if (x+1) < width { flood(source, destination, x+1, y, from_color, to_color); } if y > 0 { flood(source, destination, x, y-1, from_color, to_color); } if (y+1) < source.height { flood(source, destination, x, y+1, from_color, to_color); } } pub(crate) mod color { pub(crate) fn reset_color() { print!("\x1b[0m"); } // Set background color from a number pub(crate) fn set_color(color: usize) { if color == 0 { reset_color(); return; } let paint_color = color-1; let paint_color = paint_color % 13; if paint_color < 7 { print!("\x1b[{}m", 40 + (paint_color+1)); } else { print!("\x1b[{}m", 100 + (paint_color+1-7)); } } }