mirror of
https://github.com/penpot/penpot.git
synced 2025-05-29 01:36:12 +02:00
♻️ Refactor image fills
This commit is contained in:
parent
7105e49ac2
commit
58c4e53ee4
4 changed files with 44 additions and 28 deletions
|
@ -60,10 +60,20 @@ impl Gradient {
|
|||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct ImageFill {
|
||||
pub id: Uuid,
|
||||
pub alpha: u8,
|
||||
pub height: f32,
|
||||
pub width: f32,
|
||||
id: Uuid,
|
||||
opacity: u8,
|
||||
height: i32,
|
||||
width: i32,
|
||||
}
|
||||
|
||||
impl ImageFill {
|
||||
pub fn size(&self) -> (i32, i32) {
|
||||
(self.width, self.height)
|
||||
}
|
||||
|
||||
pub fn id(&self) -> Uuid {
|
||||
self.id
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
|
@ -84,10 +94,10 @@ impl Fill {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn new_image_fill(id: Uuid, alpha: u8, height: f32, width: f32) -> Self {
|
||||
pub fn new_image_fill(id: Uuid, opacity: u8, (width, height): (i32, i32)) -> Self {
|
||||
Self::Image(ImageFill {
|
||||
id,
|
||||
alpha,
|
||||
opacity,
|
||||
height,
|
||||
width,
|
||||
})
|
||||
|
@ -116,7 +126,7 @@ impl Fill {
|
|||
p.set_style(skia::PaintStyle::Fill);
|
||||
p.set_anti_alias(true);
|
||||
p.set_blend_mode(skia::BlendMode::SrcOver);
|
||||
p.set_alpha(image_fill.alpha);
|
||||
p.set_alpha(image_fill.opacity);
|
||||
p
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue