mirror of
https://github.com/penpot/penpot.git
synced 2025-05-29 01:06:13 +02:00
🎉 Avoid rendering too small shapes
This commit is contained in:
parent
d1d30e7eb5
commit
a80f114d66
2 changed files with 9 additions and 1 deletions
|
@ -586,7 +586,7 @@ impl RenderState {
|
||||||
if !self.render_in_progress {
|
if !self.render_in_progress {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
let scale = self.get_scale();
|
||||||
let mut should_stop = false;
|
let mut should_stop = false;
|
||||||
while !should_stop {
|
while !should_stop {
|
||||||
if let Some(current_tile) = self.current_tile {
|
if let Some(current_tile) = self.current_tile {
|
||||||
|
@ -663,6 +663,7 @@ impl RenderState {
|
||||||
}
|
}
|
||||||
if !transformed_element.extrect().intersects(self.render_area)
|
if !transformed_element.extrect().intersects(self.render_area)
|
||||||
|| transformed_element.hidden()
|
|| transformed_element.hidden()
|
||||||
|
|| transformed_element.visually_insignificant(scale)
|
||||||
{
|
{
|
||||||
debug::render_debug_shape(self, &transformed_element, false);
|
debug::render_debug_shape(self, &transformed_element, false);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -42,6 +42,8 @@ pub use transform::*;
|
||||||
use crate::math;
|
use crate::math;
|
||||||
use crate::math::{Bounds, Matrix, Point};
|
use crate::math::{Bounds, Matrix, Point};
|
||||||
|
|
||||||
|
const MIN_VISIBLE_SIZE: f32 = 2.0;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum Type {
|
pub enum Type {
|
||||||
Frame(Frame),
|
Frame(Frame),
|
||||||
|
@ -505,6 +507,11 @@ impl Shape {
|
||||||
self.hidden
|
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
|
// TODO: Maybe store this inside the shape
|
||||||
pub fn bounds(&self) -> Bounds {
|
pub fn bounds(&self) -> Bounds {
|
||||||
let mut bounds = Bounds::new(
|
let mut bounds = Bounds::new(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue