Skip to main content

OpBuilder

Struct OpBuilder 

Source
pub struct OpBuilder { /* private fields */ }
Expand description

路径操作构建器,用于批量执行路径布尔运算。 Path operation builder, optimized for unioning/combining many paths.

底层为 pk::SkOpBuilder,与 Skia PathKit 行为一致。 Backed by pk::SkOpBuilder, matching Skia PathKit behavior.

用法:多次 add 后调用 resolve 得到最终结果。 Usage: call add multiple times, then resolve to get the final result.

Implementations§

Source§

impl OpBuilder

Source

pub fn new() -> Self

创建空构建器。Creates an empty builder.

Source

pub fn add(&mut self, path: Path, op: PathOp) -> &mut Self

添加路径及对应操作(消费 Path,C++ 侧会拷贝几何)。 Adds a path with its boolean operation (consumes Path; native side copies geometry).

第一次 add 时相当于 (空路径 OP path),后续每次为 (当前结果 OP path)。 First add: (empty OP path). Each subsequent: (current_result OP path).

Source

pub fn add_ref(&mut self, path: &Path, op: PathOp) -> &mut Self

按引用添加路径(C++ 侧拷贝几何,Rust 侧不消费 Path)。 Adds path by reference (native side copies geometry).

复用同一路径时比 add(path.clone(), op) 更简洁。 Convenient when reusing the same path.

Source

pub fn resolve(&mut self) -> Option<Path>

计算并返回所有路径运算的结果。Resolves all operations and returns the result.

调用后构建器会清空,可继续复用。 Builder is reset after resolve; can be reused.

Trait Implementations§

Source§

impl Default for OpBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.