🎉 Avoid rendering too small shapes

This commit is contained in:
Alejandro Alonso 2025-03-24 11:49:38 +01:00
parent d1d30e7eb5
commit a80f114d66
2 changed files with 9 additions and 1 deletions

View file

@ -42,6 +42,8 @@ pub use transform::*;
use crate::math;
use crate::math::{Bounds, Matrix, Point};
const MIN_VISIBLE_SIZE: f32 = 2.0;
#[derive(Debug, Clone, PartialEq)]
pub enum Type {
Frame(Frame),
@ -505,6 +507,11 @@ impl Shape {
self.hidden
}
pub fn visually_insignificant(&self, scale: f32) -> bool {
self.selrect.width() * scale < MIN_VISIBLE_SIZE
|| self.selrect.height() * scale < MIN_VISIBLE_SIZE
}
// TODO: Maybe store this inside the shape
pub fn bounds(&self) -> Bounds {
let mut bounds = Bounds::new(