aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorcc <cc@localhost>2025-08-20 22:14:13 -0700
committercc <cc@localhost>2025-08-20 22:19:01 -0700
commit15df0fec1e368599487e1faeaf8ecebd87980781 (patch)
tree94c9aba0cf1ba340e77b0c773e6869035ad9c8aa /src/lib.rs
Initial commit
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..e47bca8
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,33 @@
+mod large_label_format;
+mod label_format;
+pub mod binfile;
+
+pub use large_label_format::LargeLabelFormat;
+pub use label_format::LabelFormat;
+
+pub(crate) fn flood(source: &LargeLabelFormat, destination: &mut Vec<u16>,
+ x: usize, y: usize,
+ from_color: u32, to_color: u16) {
+ let width = source.width;
+ let destination_color = destination[x + y * width];
+ if destination_color != 0 {
+ 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);
+ }
+}