mirror of
https://github.com/penpot/penpot.git
synced 2025-07-17 16:37:58 +02:00
✨ Add scale content to render wasm
This commit is contained in:
parent
46b0e4f0e7
commit
bcfa9a82ea
18 changed files with 282 additions and 33 deletions
|
@ -14,6 +14,7 @@ use crate::shapes::{
|
|||
use crate::state::State;
|
||||
use crate::uuid::Uuid;
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn propagate_children(
|
||||
shape: &Shape,
|
||||
shapes: &HashMap<Uuid, &mut Shape>,
|
||||
|
@ -22,6 +23,7 @@ fn propagate_children(
|
|||
transform: Matrix,
|
||||
bounds: &HashMap<Uuid, Bounds>,
|
||||
structure: &HashMap<Uuid, Vec<StructureEntry>>,
|
||||
scale_content: &HashMap<Uuid, f32>,
|
||||
) -> VecDeque<Modifier> {
|
||||
let children_ids = modified_children_ids(shape, structure.get(&shape.id));
|
||||
|
||||
|
@ -36,6 +38,8 @@ fn propagate_children(
|
|||
continue;
|
||||
};
|
||||
|
||||
let ignore_constraints = scale_content.contains_key(child_id);
|
||||
|
||||
let child_bounds = bounds.find(child);
|
||||
|
||||
let constraint_h = match &shape.shape_type {
|
||||
|
@ -73,6 +77,7 @@ fn propagate_children(
|
|||
constraint_h,
|
||||
constraint_v,
|
||||
transform,
|
||||
ignore_constraints,
|
||||
);
|
||||
|
||||
result.push_back(Modifier::transform(*child_id, transform));
|
||||
|
@ -200,6 +205,7 @@ pub fn propagate_modifiers(
|
|||
transform,
|
||||
&bounds,
|
||||
&state.structure,
|
||||
&state.scale_content,
|
||||
);
|
||||
entries.append(&mut children);
|
||||
}
|
||||
|
@ -309,6 +315,12 @@ pub fn propagate_modifiers(
|
|||
continue;
|
||||
};
|
||||
|
||||
let shape = if let Some(scale_content) = state.scale_content.get(id) {
|
||||
&shape.scale_content(*scale_content)
|
||||
} else {
|
||||
shape
|
||||
};
|
||||
|
||||
let Type::Frame(frame_data) = &shape.shape_type else {
|
||||
continue;
|
||||
};
|
||||
|
@ -388,6 +400,7 @@ mod tests {
|
|||
transform,
|
||||
&HashMap::new(),
|
||||
&HashMap::new(),
|
||||
&HashMap::new(),
|
||||
);
|
||||
|
||||
assert_eq!(result.len(), 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue