mirror of
https://github.com/penpot/penpot.git
synced 2025-05-13 07:06:38 +02:00
🎉 Render wasm ellipses support
This commit is contained in:
parent
33e70a4108
commit
307329cf2e
6 changed files with 67 additions and 7 deletions
|
@ -1,10 +1,9 @@
|
|||
use crate::math;
|
||||
use crate::shapes::Kind;
|
||||
use skia_safe as skia;
|
||||
|
||||
pub type Image = skia::Image;
|
||||
|
||||
use crate::shapes::Kind;
|
||||
|
||||
pub fn draw_image_in_container(
|
||||
canvas: &skia::Canvas,
|
||||
image: &Image,
|
||||
|
@ -18,6 +17,7 @@ pub fn draw_image_in_container(
|
|||
|
||||
let container = match kind {
|
||||
Kind::Rect(r) => r.to_owned(),
|
||||
Kind::Circle(r) => r.to_owned(),
|
||||
Kind::Path(p) => p.to_skia_path().bounds().to_owned(),
|
||||
};
|
||||
|
||||
|
@ -53,6 +53,11 @@ pub fn draw_image_in_container(
|
|||
Kind::Rect(_) => {
|
||||
canvas.clip_rect(container, skia::ClipOp::Intersect, true);
|
||||
}
|
||||
Kind::Circle(_) => {
|
||||
let mut oval_path = skia::Path::new();
|
||||
oval_path.add_oval(container, None);
|
||||
canvas.clip_path(&oval_path, skia::ClipOp::Intersect, true);
|
||||
}
|
||||
Kind::Path(p) => {
|
||||
canvas.clip_path(&p.to_skia_path(), skia::ClipOp::Intersect, true);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue