Draw

Trait Draw 

Source
pub trait Draw {
    // Required method
    fn add_path<T: IntoBezPathTolerance>(&mut self, path: T) -> &mut Self;

    // Provided methods
    fn cubic_bezier(
        &mut self,
        x1: impl Into<f64>,
        y1: impl Into<f64>,
        x2: impl Into<f64>,
        y2: impl Into<f64>,
        x3: impl Into<f64>,
        y3: impl Into<f64>,
        x4: impl Into<f64>,
        y4: impl Into<f64>,
    ) -> &mut Self { ... }
    fn quadratic_bezier(
        &mut self,
        x1: impl Into<f64>,
        y1: impl Into<f64>,
        x2: impl Into<f64>,
        y2: impl Into<f64>,
        x3: impl Into<f64>,
        y3: impl Into<f64>,
    ) -> &mut Self { ... }
    fn arc(
        &mut self,
        x: impl Into<f64>,
        y: impl Into<f64>,
        rx: impl Into<f64>,
        ry: impl Into<f64>,
        start: f64,
        sweep: f64,
        x_rot: f64,
    ) -> &mut Self { ... }
    fn circle(
        &mut self,
        x: impl Into<f64>,
        y: impl Into<f64>,
        r: impl Into<f64>,
    ) -> &mut Self { ... }
    fn ellipse(
        &mut self,
        x: impl Into<f64>,
        y: impl Into<f64>,
        rx: impl Into<f64>,
        ry: impl Into<f64>,
        x_rot: impl Into<f64>,
    ) -> &mut Self { ... }
    fn line(
        &mut self,
        x1: impl Into<f64>,
        y1: impl Into<f64>,
        x2: impl Into<f64>,
        y2: impl Into<f64>,
    ) -> &mut Self { ... }
    fn polyline(
        &mut self,
        points: impl IntoIterator<Item = impl Into<Point>>,
        close: bool,
    ) -> &mut Self { ... }
    fn rect(
        &mut self,
        x: impl Into<f64>,
        y: impl Into<f64>,
        w: impl Into<f64>,
        h: impl Into<f64>,
    ) -> &mut Self { ... }
    fn rounded_rect(
        &mut self,
        x: impl Into<f64>,
        y: impl Into<f64>,
        w: impl Into<f64>,
        h: impl Into<f64>,
        tl: impl Into<f64>,
        tr: impl Into<f64>,
        br: impl Into<f64>,
        bl: impl Into<f64>,
    ) -> &mut Self { ... }
    fn catmull_rom(
        &mut self,
        points: impl IntoIterator<Item = impl Into<Point>>,
        tension: f64,
    ) -> &mut Self { ... }
    fn svg_path(&mut self, path: &str) -> Result<&mut Self, SvgParseError> { ... }
}

Required Methods§

Source

fn add_path<T: IntoBezPathTolerance>(&mut self, path: T) -> &mut Self

Provided Methods§

Source

fn cubic_bezier( &mut self, x1: impl Into<f64>, y1: impl Into<f64>, x2: impl Into<f64>, y2: impl Into<f64>, x3: impl Into<f64>, y3: impl Into<f64>, x4: impl Into<f64>, y4: impl Into<f64>, ) -> &mut Self

Draw a cubic Bézier curve from (x1, y1) to (x4, y4) with control points at (x2, y2) and (x3, y3).

Source

fn quadratic_bezier( &mut self, x1: impl Into<f64>, y1: impl Into<f64>, x2: impl Into<f64>, y2: impl Into<f64>, x3: impl Into<f64>, y3: impl Into<f64>, ) -> &mut Self

Draw a quadratic Bézier curve from (x1, y1) to (x3, y3) with control point at (x2, y2).

Source

fn arc( &mut self, x: impl Into<f64>, y: impl Into<f64>, rx: impl Into<f64>, ry: impl Into<f64>, start: f64, sweep: f64, x_rot: f64, ) -> &mut Self

Draw an elliptical arc centered on (x, y) with radii rx and ry. The arc starts at start and sweeps sweep radians. x_rot is the rotation of the ellipse in radians.

Source

fn circle( &mut self, x: impl Into<f64>, y: impl Into<f64>, r: impl Into<f64>, ) -> &mut Self

Draw a circle centered on (x, y) with radius r.

Source

fn ellipse( &mut self, x: impl Into<f64>, y: impl Into<f64>, rx: impl Into<f64>, ry: impl Into<f64>, x_rot: impl Into<f64>, ) -> &mut Self

Draw an ellipse centered on (x, y) with radii rx and ry. x_rot is the rotation of the ellipse in radians.

Source

fn line( &mut self, x1: impl Into<f64>, y1: impl Into<f64>, x2: impl Into<f64>, y2: impl Into<f64>, ) -> &mut Self

Draw a line from (x1, y1) to (x2, y2).

Source

fn polyline( &mut self, points: impl IntoIterator<Item = impl Into<Point>>, close: bool, ) -> &mut Self

Draw a polyline from a sequence of points, optionally closing it.

Source

fn rect( &mut self, x: impl Into<f64>, y: impl Into<f64>, w: impl Into<f64>, h: impl Into<f64>, ) -> &mut Self

Draw a rectangle centered on (x, y) with width w and height h.

Source

fn rounded_rect( &mut self, x: impl Into<f64>, y: impl Into<f64>, w: impl Into<f64>, h: impl Into<f64>, tl: impl Into<f64>, tr: impl Into<f64>, br: impl Into<f64>, bl: impl Into<f64>, ) -> &mut Self

Draw a rounded rectangle centered on (x, y) with width w and height h. The corners are rounded with radii tl, tr, br, bl.

Source

fn catmull_rom( &mut self, points: impl IntoIterator<Item = impl Into<Point>>, tension: f64, ) -> &mut Self

Draw a Catmull-Rom spline from a sequence of points and a tension parameter.

See crate::CatmullRom for more information.

Source

fn svg_path(&mut self, path: &str) -> Result<&mut Self, SvgParseError>

Draw from an SVG path representation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Draw for Layer

Implementing this trait allows drawing directly into a layer.

Each Draw method will append a new path with default metadata to the layer.

§Example

use vsvg::{Draw, DocumentTrait};

let mut doc = vsvg::Document::default();
let layer = doc.get_mut(0);
layer.circle(5.0, 5.0, 10.0);