Trait bevy_canvas::Geometry[][src]

pub trait Geometry {
    fn generate_path(&self) -> Path;
}

Determines how a struct can be transformed into a Lyon Path.

Usage

use bevy::math::Vec2;
use bevy_canvas::{Geometry, Path, PathBuilder};

// First, we need to define our struct :3
struct UwuMouth;

impl Geometry for UwuMouth {
    fn generate_path(&self) -> Path {
        // we need a custom path
        let mut b = PathBuilder::new();

        // svg magic starts here...

        // left lip ·ω·
        b.cubic_bezier_to(
            Vec2::new(-25.0, -60.0),
            Vec2::new(-75.0, -60.0),
            Vec2::new(-100.0, 10.0),
        );

        // return to monke lol
        b.move_to(Vec2::ZERO);

        // right lip ·ω·
        b.cubic_bezier_to(
            Vec2::new(25.0, -60.0),
            Vec2::new(75.0, -60.0),
            Vec2::new(100.0, 10.0),
        ); // <-- why that sad face...

        // ...drawing is fun! uwu
        b.build()
    }
}

Required methods

Loading content...

Implementors

Loading content...