Skip to content

Commit c8a6d8e

Browse files
committed
Allow clip paths to nest in the canvas API.
Closes #372.
1 parent 4c8699a commit c8a6d8e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

canvas/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,11 @@ impl CanvasRenderingContext2D {
358358

359359
let mut clip_path = ClipPath::new(outline);
360360
clip_path.set_fill_rule(fill_rule);
361-
let clip_path_id = self.canvas.scene.push_clip_path(clip_path);
361+
if let Some(existing_clip_path) = self.current_state.clip_path.take() {
362+
clip_path.set_clip_path(Some(existing_clip_path));
363+
}
362364

365+
let clip_path_id = self.canvas.scene.push_clip_path(clip_path);
363366
self.current_state.clip_path = Some(clip_path_id);
364367
}
365368

0 commit comments

Comments
 (0)