diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-09 16:30:29 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-09 16:30:29 -0700 |
| commit | 167e31655b63aa4d4548532cf0410cea9fd145ca (patch) | |
| tree | 2b9b3d3832404979fecfa3972464c37613d43db2 /src/sim/overlay.rs | |
| parent | 2eff3a26da27f68355ee2316f956e1bdfb6f1b68 (diff) | |
drawing
Diffstat (limited to 'src/sim/overlay.rs')
| -rw-r--r-- | src/sim/overlay.rs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/sim/overlay.rs b/src/sim/overlay.rs new file mode 100644 index 0000000..36a810b --- /dev/null +++ b/src/sim/overlay.rs @@ -0,0 +1,50 @@ +use crate::{Config, Input, sim::board::Board}; + +pub fn create_compute_combined_overlay_offset( + board: &Board, + config: &Config, + input: &Input, +) -> impl Fn(i32, i32) -> (u8, u8, u8, u8) { + |x: i32, y: i32| { + // could allow negative offsets too + let mut offset: (u8, u8, u8, u8) = (0x00, 0x00, 0x00, 0x00); + + // bounds + // left + let xl = -((board.size_x / 2 + 1) as i32); + // right + let xu = (board.size_x / 2 + 1) as i32; + // bottom + let yl = -((board.size_y / 2 + 1) as i32); + // top + let yu = (board.size_y / 2 + 1) as i32; + + if ((x == xl || x == xu) && (y <= yu && y >= yl)) + || (y == yl || y == yu) && (x <= xu && x >= xl) + { + offset.0 = offset.0.saturating_add(0xFF); + offset.1 = offset.1.saturating_add(0xFF); + offset.2 = offset.2.saturating_add(0xFF); + } + + // grid + if x % 30 == 0 || y % 30 == 0 { + offset.0 = offset.0.saturating_add(0x10); + offset.1 = offset.1.saturating_add(0x10); + offset.2 = offset.2.saturating_add(0x10); + } + + // brush/selection + if (((x - input.last_mouse_pos_on_board.0).pow(2) + + (y - input.last_mouse_pos_on_board.1).pow(2)) as f32) + .sqrt() + < config.brush_size as f32 + { + offset.0 = offset.0.saturating_add(0xAA); + offset.1 = offset.1.saturating_add(0x00); + offset.2 = offset.2.saturating_add(0xAA); + } + + return offset; + } +} |
