♻️ Move rendering a single shape to the shape itself

This commit is contained in:
Belén Albeza 2024-12-10 15:29:49 +01:00
parent 001aa3f319
commit 967bc75a1c
5 changed files with 121 additions and 72 deletions

View file

@ -0,0 +1,28 @@
use skia_safe as skia;
#[derive(Debug, PartialEq, Clone, Copy)]
pub struct BlendMode(skia::BlendMode);
impl Default for BlendMode {
fn default() -> Self {
BlendMode(skia::BlendMode::SrcOver)
}
}
impl From<i32> for BlendMode {
fn from(value: i32) -> Self {
if value <= skia::BlendMode::Luminosity as i32 {
unsafe { Self(std::mem::transmute(value)) }
} else {
Self::default()
}
}
}
impl Into<skia::BlendMode> for BlendMode {
fn into(self) -> skia::BlendMode {
match self {
Self(skia_blend) => skia_blend,
}
}
}