Skip to main content

Path

Struct Path 

Source
pub struct Path {
    pub cmds: Vec<PathCmd>,
    pub even_odd: bool,
}
Expand description

Um caminho: uma ou mais figuras, abertas ou fechadas.

Fields§

§cmds: Vec<PathCmd>§even_odd: bool

Regra de preenchimento “par-ímpar” (fill-rule="evenodd" do SVG); o padrão é “não zero”.

Implementations§

Source§

impl Path

Source

pub fn new() -> Self

Source

pub fn is_empty(&self) -> bool

Source

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

Source

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

Source

pub fn quad_to(&mut self, cx: f32, cy: f32, x: f32, y: f32) -> &mut Self

Source

pub fn cubic_to( &mut self, c1x: f32, c1y: f32, c2x: f32, c2y: f32, x: f32, y: f32, ) -> &mut Self

Source

pub fn close(&mut self) -> &mut Self

Source

pub fn corners(r: RectF, c: Bounds) -> Path

O contorno de r com um raio por canto, na ordem do CSS em c: left = cima-esquerda, top = cima-direita, right = baixo-direita, bottom = baixo-esquerda (o radius: [8, 8, 0, 0] do JSON). Raio negativo curva o canto para fora do retângulo, em direção ao lado de cima ou de baixo (a aba que se funde no painel, como as do navegador): o desenho passa do retângulo nesse tanto.

Source

pub fn arc( &mut self, center: PointF, rx: f32, ry: f32, start: f32, sweep: f32, ) -> &mut Self

Arco de elipse em volta de center, de start a start + sweep (graus; 0 aponta para a direita e o ângulo cresce no sentido horário, como na tela). Liga com uma reta ao ponto atual (ou começa uma figura, se o caminho estiver vazio).

Source

pub fn rect(&mut self, r: RectF, radius: f32) -> &mut Self

Retângulo (de cantos arredondados com radius > 0).

Source

pub fn ellipse(&mut self, r: RectF) -> &mut Self

Elipse inscrita no retângulo.

Source

pub fn polygon(&mut self, points: &[PointF], closed: bool) -> &mut Self

Polígono (ou linha quebrada, se closed for falso).

Source

pub fn current(&self) -> Option<PointF>

Último ponto do caminho.

Source

pub fn from_svg(d: &str) -> Option<Path>

Lê o atributo d do SVG (M L H V C S Q T A Z, maiúsculas e minúsculas). None se estiver mal formado.

Source

pub fn transformed(&self, scale: f32, offset: PointF) -> Path

O mesmo caminho escalado e deslocado (p * scale + offset).

Source

pub fn append(&mut self, other: &Path) -> &mut Self

Acrescenta as figuras de outro caminho.

Source

pub fn map_points(&self, f: impl Fn(PointF) -> PointF) -> Path

O mesmo caminho com cada ponto passado por f (uma transformação qualquer).

Source

pub fn bounds(&self) -> RectF

Retângulo que contém todos os pontos (inclusive os de controle).

Source

pub fn flatten(&self, segments: usize) -> Vec<(Vec<PointF>, bool)>

As figuras como linhas quebradas (curvas divididas em segments retas cada): (pontos, fechada). Usado por canvases sem curvas e para testes de clique.

Source

pub fn to_svg(&self) -> String

O caminho como o atributo d do SVG (coordenadas absolutas, até 2 casas).

Source

pub fn contains(&self, p: PointF) -> bool

O ponto está dentro da área preenchida (regra não zero, a do fill_path)? As figuras abertas contam como fechadas, como no preenchimento.

Source

pub fn distance_to(&self, p: PointF) -> f32

Distância de um ponto até o caminho (como linha), para clicar em cabos e traços.

Trait Implementations§

Source§

impl Clone for Path

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Path

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Path

Source§

fn default() -> Self

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

impl PartialEq for Path

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Path

Auto Trait Implementations§

§

impl Forget for Path

§

impl Freeze for Path

§

impl Move for Path

§

impl RefUnwindSafe for Path

§

impl Send for Path

§

impl Sync for Path

§

impl Unpin for Path

§

impl UnsafeUnpin for Path

§

impl UnwindSafe for Path

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.