make comments disappear when pasting over them, but not when placing single tiles

This commit is contained in:
Crispy 2025-03-29 01:10:02 +01:00
parent ae42cd10a4
commit 6b8b2e6e6e
3 changed files with 78 additions and 40 deletions

View file

@ -23,6 +23,35 @@ pub struct ResizeDeltas {
pub y_neg: usize,
}
impl ResizeDeltas {
pub fn new(
margin: usize,
(width, height): (usize, usize),
pos: Pos,
(new_width, new_height): (usize, usize),
) -> Self {
let margin = margin as PosInt;
let width = width as PosInt;
let height = height as PosInt;
let new_width = new_width as PosInt;
let new_height = new_height as PosInt;
Self {
x_pos: if (pos.x + margin + new_width) > width {
pos.x + margin + new_width - width
} else {
0
} as usize,
x_neg: if pos.x < margin { margin - pos.x } else { 0 } as usize,
y_pos: if (pos.y + margin + new_height) > height {
pos.y + margin + new_height - height
} else {
0
} as usize,
y_neg: if pos.y < margin { margin - pos.y } else { 0 } as usize,
}
}
}
impl Grid {
pub fn parse(source: &str) -> Self {
let mut rows = Vec::new();
@ -185,6 +214,10 @@ impl Grid {
self.height
}
pub fn size(&self) -> (usize, usize) {
(self.width, self.height)
}
pub fn get_marbles(&self) -> Vec<Pos> {
let mut out = Vec::new();
for y in 0..self.height {