diff options
| author | HydroH <ixlesis@gmail.com> | 2024-07-22 22:24:29 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-22 14:24:29 +0000 |
| commit | 1d74c8e8bfe47723f62eb0dbb3852c07a43be5fd (patch) | |
| tree | 8db52750dd488ed3611a5328cd1407f302897c76 /crates/typst-render/src | |
| parent | 684efa2e0eadcf5b5d7d216ab8f5f5b1c68a35a6 (diff) | |
Add `non-zero` and `even-odd` fill rules to `path` and `polygon` (#4580)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates/typst-render/src')
| -rw-r--r-- | crates/typst-render/src/shape.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crates/typst-render/src/shape.rs b/crates/typst-render/src/shape.rs index 360c2a4f..f31262ef 100644 --- a/crates/typst-render/src/shape.rs +++ b/crates/typst-render/src/shape.rs @@ -1,7 +1,8 @@ use tiny_skia as sk; use typst::layout::{Abs, Axes, Point, Ratio, Size}; use typst::visualize::{ - DashPattern, FixedStroke, Geometry, LineCap, LineJoin, Path, PathItem, Shape, + DashPattern, FillRule, FixedStroke, Geometry, LineCap, LineJoin, Path, PathItem, + Shape, }; use crate::{paint, AbsExt, State}; @@ -51,7 +52,10 @@ pub fn render_shape(canvas: &mut sk::Pixmap, state: State, shape: &Shape) -> Opt paint.anti_alias = false; } - let rule = sk::FillRule::default(); + let rule = match shape.fill_rule { + FillRule::NonZero => sk::FillRule::Winding, + FillRule::EvenOdd => sk::FillRule::EvenOdd, + }; canvas.fill_path(&path, &paint, rule, ts, state.mask); } |
