path_kit/path_fill_type.rs
1//! 路径填充规则。Path fill rule (winding / even-odd / inverse).
2//!
3//! 枚举变体与 `pk::SkPathFillType` 一致,由 cxx 桥接共享;本模块 re-export 并扩展便捷方法。
4//! Variants match `pk::SkPathFillType` (cxx shared type); re-exported here with helpers.
5
6pub use crate::bridge::ffi::PathFillType;
7
8impl PathFillType {
9 /// 是否为奇偶类规则(`EvenOdd` / `InverseEvenOdd`)。
10 /// True for even-odd style fill rules.
11 pub fn is_even_odd(self) -> bool {
12 matches!(self, Self::EvenOdd | Self::InverseEvenOdd)
13 }
14
15 /// 是否为「反色」填充(填充几何外部)。
16 /// True for inverse fill (paint outside the geometry).
17 pub fn is_inverse(self) -> bool {
18 matches!(self, Self::InverseWinding | Self::InverseEvenOdd)
19 }
20
21 /// 去掉 inverse 位,得到 `Winding` 或 `EvenOdd`。
22 /// Strips the inverse bit, yielding `Winding` or `EvenOdd`.
23 pub fn to_non_inverse(self) -> Self {
24 match self {
25 Self::Winding | Self::InverseWinding => Self::Winding,
26 Self::EvenOdd | Self::InverseEvenOdd => Self::EvenOdd,
27 _ => Self::Winding,
28 }
29 }
30}