Skip to main content

FlattenedPath

Struct FlattenedPath 

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

已经过仿射变换并细分至目标物理像素空间的折线路径集合(可在多个图形元素间复用缓冲)。

Implementations§

Source§

impl FlattenedPath

Source

pub fn new() -> Self

创建空路径缓冲。

Source

pub fn clear(&mut self)

清空顶点与子路径(保留底层容量以便下一图形复用)。

Source

pub fn points(&self) -> &[(f32, f32)]

返回全部物理像素顶点切片。

Source

pub fn subpaths(&self) -> &[SubPath]

返回全部子路径切片。

Source

pub fn is_empty(&self) -> bool

路径是否为空。

Source

pub fn move_to(&mut self, x: f32, y: f32)

开启一条位于屏幕物理坐标 (x, y) 的新子路径。

Source

pub fn line_to(&mut self, x: f32, y: f32)

向当前子路径追加线段终点 (x, y)(自动过滤零长度重复顶点)。

Source

pub fn close(&mut self)

标记当前子路径为闭合。

Source

pub fn quad_to(&mut self, p0: (f32, f32), p1: (f32, f32), p2: (f32, f32))

添加二次贝塞尔曲线(输入已变换至屏幕物理像素坐标),平坦度误差 $\le 0.25\text{px}$。

Source

pub fn cubic_to( &mut self, p0: (f32, f32), p1: (f32, f32), p2: (f32, f32), p3: (f32, f32), )

添加三次贝塞尔曲线(输入已变换至屏幕物理像素坐标),平坦度误差 $\le 0.25\text{px}$。

Source

pub fn arc_to_user( &mut self, xf: Transform2D, x1: f32, y1: f32, rx_in: f32, ry_in: f32, x_axis_rot_deg: f32, large_arc: bool, sweep: bool, x2: f32, y2: f32, )

依据 W3C SVG 1.1 F.6.5/F.6.6 规范展开椭圆弧(在用户空间求中心参数化后按 xf 变换细分)。

Source

pub fn parse_svg_path_d(&mut self, d: &str, xf: Transform2D)

解析完整 SVG Path d 字符串(全部 20 个命令 M/m L/l H/h V/v C/c S/s Q/q T/t A/a Z/z)并写入当前路径。

Source

pub fn add_rect( &mut self, xf: Transform2D, x: f32, y: f32, w: f32, h: f32, rx_in: f32, ry_in: f32, )

展开 <rect x y width height rx ry> 形状。

Source

pub fn add_ellipse( &mut self, xf: Transform2D, cx: f32, cy: f32, rx: f32, ry: f32, )

展开 <circle cx cy r> 或 <ellipse cx cy rx ry> 形状。

Source

pub fn add_line(&mut self, xf: Transform2D, x1: f32, y1: f32, x2: f32, y2: f32)

展开 <line x1 y1 x2 y2>。

Source

pub fn add_points(&mut self, xf: Transform2D, points_str: &str, closed: bool)

展开 <polyline points="..."> 或 <polygon points="...">。

Trait Implementations§

Source§

impl Default for FlattenedPath

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> FluentBuilder for T

Source§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self

当 condition 为 true 时执行闭包修饰自身,否则原样返回。
Source§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self

根据 condition 在两个修饰分支之间二选一。
Source§

fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self

当 option 为 Some(value) 时执行闭包修饰自身,否则原样返回。
Source§

fn when_none<O>( self, option: &Option<O>, then: impl FnOnce(Self) -> Self, ) -> Self

当 option 为 None 时执行闭包修饰自身,否则原样返回。
Source§

fn apply<U>(self, f: impl FnOnce(Self) -> U) -> U

通用管道映射变换(避免与 Iterator::map / Option::map 重名)。
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,