mirror of
https://github.com/penpot/penpot.git
synced 2025-06-13 07:11:40 +02:00
✨ Add constraints calculation on WASM (#5894)
* ✨ Add constraints calculation on WASM * ✨ Fix after review
This commit is contained in:
parent
f5c913d26e
commit
6cb1aa24cd
15 changed files with 746 additions and 76 deletions
|
@ -49,7 +49,7 @@ pub fn render_debug_shape(render_state: &mut RenderState, element: &Shape, inter
|
|||
});
|
||||
paint.set_stroke_width(1.);
|
||||
|
||||
let mut scaled_rect = element.bounds();
|
||||
let mut scaled_rect = element.selrect();
|
||||
let x = 100. + scaled_rect.x() * 0.2;
|
||||
let y = 100. + scaled_rect.y() * 0.2;
|
||||
let width = scaled_rect.width() * 0.2;
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
use crate::{
|
||||
math,
|
||||
shapes::{Fill, ImageFill, Kind, Shape},
|
||||
};
|
||||
use skia_safe::{self as skia, RRect};
|
||||
use crate::shapes::{Fill, ImageFill, Kind, Shape};
|
||||
use skia_safe::{self as skia, RRect, Rect};
|
||||
|
||||
use super::RenderState;
|
||||
|
||||
|
@ -46,7 +43,7 @@ fn draw_image_fill_in_container(
|
|||
let scaled_width = width * scale;
|
||||
let scaled_height = height * scale;
|
||||
|
||||
let dest_rect = math::Rect::from_xywh(
|
||||
let dest_rect = Rect::from_xywh(
|
||||
container.left - (scaled_width - container_width) / 2.0,
|
||||
container.top - (scaled_height - container_height) / 2.0,
|
||||
scaled_width,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::math::{self, Rect};
|
||||
use crate::shapes::{Corners, Fill, ImageFill, Kind, Path, Shape, Stroke, StrokeCap, StrokeKind};
|
||||
use skia::Rect;
|
||||
use skia_safe::{self as skia, RRect};
|
||||
|
||||
use super::RenderState;
|
||||
|
@ -297,7 +297,7 @@ fn draw_triangle_cap(
|
|||
canvas.draw_path(&path, paint);
|
||||
}
|
||||
|
||||
fn calculate_scaled_rect(size: (i32, i32), container: &math::Rect, delta: f32) -> math::Rect {
|
||||
fn calculate_scaled_rect(size: (i32, i32), container: &Rect, delta: f32) -> Rect {
|
||||
let (width, height) = (size.0 as f32, size.1 as f32);
|
||||
let image_aspect_ratio = width / height;
|
||||
|
||||
|
@ -315,7 +315,7 @@ fn calculate_scaled_rect(size: (i32, i32), container: &math::Rect, delta: f32) -
|
|||
let scaled_width = width * scale;
|
||||
let scaled_height = height * scale;
|
||||
|
||||
math::Rect::from_xywh(
|
||||
Rect::from_xywh(
|
||||
container.left - delta - (scaled_width - container_width) / 2.0,
|
||||
container.top - delta - (scaled_height - container_height) / 2.0,
|
||||
scaled_width + (2. * delta) + (scaled_width - container_width),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue