Skip to main content

StrokeRec

Struct StrokeRec 

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

描边参数,描述如何将路径转为描边轮廓。 Stroke parameters - describes how to expand a path to a stroke outline.

用于 apply_to_path 将路径转换为描边后的填充路径。 Used with apply_to_path to convert a path to a stroked fill equivalent.

Implementations§

Source§

impl StrokeRec

Source

pub fn new_fill() -> Self

创建填充样式(无描边)。Creates fill style (no stroke).

Source

pub fn new_hairline() -> Self

创建极细线样式。Creates hairline style (1-pixel stroke).

Source

pub fn new_stroke(width: f32, stroke_and_fill: bool) -> Self

创建描边样式。Creates stroke style with given width.

Source

pub fn set_fill(&mut self)

设置为填充样式。Sets to fill style.

Source

pub fn set_hairline(&mut self)

设置为极细线。Sets to hairline style.

Source

pub fn set_stroke_style(&mut self, width: f32, stroke_and_fill: bool)

设置描边宽度。Sets stroke width (width=0 may switch to fill/hairline).

Source

pub fn set_cap(&mut self, cap: StrokeCap)

设置线端样式。Sets line cap (Butt, Round, Square).

Source

pub fn set_join(&mut self, join: StrokeJoin)

设置转角连接样式。Sets line join (Miter, Round, Bevel).

Source

pub fn set_stroke_params( &mut self, cap: StrokeCap, join: StrokeJoin, miter_limit: f32, )

设置描边端点与转角参数。Sets cap, join, and miter limit.

Source

pub fn cap(&self) -> StrokeCap

线端样式。Returns line cap.

Source

pub fn join(&self) -> StrokeJoin

转角连接样式。Returns line join.

Source

pub fn miter_limit(&self) -> f32

Miter 限制(尖角最长延伸比)。Returns miter limit.

Source

pub fn style(&self) -> StrokeStyle

当前样式。Returns current style (hairline/fill/stroke).

Source

pub fn width(&self) -> f32

描边宽度。Returns stroke width.

Source

pub fn inflation_radius(&self) -> f32

膨胀半径(用于边界计算)。Inflation radius for bounds.

Source

pub fn apply_to_path(&self, path: &Path) -> Option<Path>

将描边参数应用到路径,返回描边后的填充路径。 Applies stroke to path, returning the stroked outline as a fill path.

若样式为 fill/hairline 则返回 None。 Returns None if style is fill or hairline (no expansion).

Trait Implementations§

Source§

impl Default for StrokeRec

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.