💄 Format rust code

This commit is contained in:
Belén Albeza 2024-11-21 17:23:49 +01:00
parent f7ff3129ed
commit 6fd6074934
8 changed files with 85 additions and 91 deletions

View file

@ -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
}
}