mirror of
https://github.com/penpot/penpot.git
synced 2025-05-19 00:36:11 +02:00
💄 Format rust code
This commit is contained in:
parent
f7ff3129ed
commit
6fd6074934
8 changed files with 85 additions and 91 deletions
|
@ -1,55 +1,49 @@
|
|||
use skia_safe as skia;
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub(crate) struct Viewbox
|
||||
{
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
pub width: f32,
|
||||
pub height: f32,
|
||||
pub zoom: f32,
|
||||
pub area: skia::Rect,
|
||||
pub(crate) struct Viewbox {
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
pub width: f32,
|
||||
pub height: f32,
|
||||
pub zoom: f32,
|
||||
pub area: skia::Rect,
|
||||
}
|
||||
|
||||
impl Viewbox {
|
||||
pub fn set_all(&mut self, zoom: f32, x: f32, y: f32) -> &Self {
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
self.zoom = zoom;
|
||||
self.area.set_xywh(
|
||||
-self.x,
|
||||
-self.y,
|
||||
self.width / self.zoom,
|
||||
self.height / self.zoom
|
||||
);
|
||||
self
|
||||
}
|
||||
pub fn set_all(&mut self, zoom: f32, x: f32, y: f32) -> &Self {
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
self.zoom = zoom;
|
||||
self.area.set_xywh(
|
||||
-self.x,
|
||||
-self.y,
|
||||
self.width / self.zoom,
|
||||
self.height / self.zoom,
|
||||
);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_zoom(&mut self, zoom: f32) -> &Self {
|
||||
self.zoom = zoom;
|
||||
self.area.set_wh(
|
||||
self.width / self.zoom,
|
||||
self.height / self.zoom
|
||||
);
|
||||
self
|
||||
}
|
||||
pub fn set_zoom(&mut self, zoom: f32) -> &Self {
|
||||
self.zoom = zoom;
|
||||
self.area
|
||||
.set_wh(self.width / self.zoom, self.height / self.zoom);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_xy(&mut self, x: f32, y: f32) -> &Self {
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
self.area.left = -x;
|
||||
self.area.top = -y;
|
||||
self
|
||||
}
|
||||
pub fn set_xy(&mut self, x: f32, y: f32) -> &Self {
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
self.area.left = -x;
|
||||
self.area.top = -y;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn set_wh(&mut self, width: f32, height: f32) -> &Self {
|
||||
self.width = width;
|
||||
self.height = height;
|
||||
self.area.set_wh(
|
||||
self.width / self.zoom,
|
||||
self.height / self.zoom
|
||||
);
|
||||
self
|
||||
}
|
||||
pub fn set_wh(&mut self, width: f32, height: f32) -> &Self {
|
||||
self.width = width;
|
||||
self.height = height;
|
||||
self.area
|
||||
.set_wh(self.width / self.zoom, self.height / self.zoom);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue