Skip to content

Commit

Permalink
chore: `hello_world' example, add default trace value for bezier path
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincexodus committed Jun 10, 2024
1 parent 539b2b3 commit a9fe4c5
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
67 changes: 67 additions & 0 deletions examples/hello_world.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
use bevy::{math::DVec2, prelude::*};
use bevy_vello_graphics::prelude::*;

fn main() {
App::new()
// Bevy plugins
.add_plugins(DefaultPlugins)
// Custom Plugins
.add_plugins(VelloGraphicsPlugin)
.add_systems(Startup, (setup, render_shapes))
.run();
}

fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
}

fn render_shapes(mut commands: Commands) {
// Line
let line = (
VelloLine::new(DVec2::new(0.0, 100.0), DVec2::new(0.0, -100.0)),
Stroke::new(5.0).with_color(Color::WHITE),
Transform::from_xyz(-300.0, 0.0, 0.0),
);

// Rectangle
let rect = (
VelloRect::new(100.0, 200.0),
Fill::new().with_color(Color::ORANGE),
Stroke::new(5.0).with_color(Color::RED),
Transform::from_xyz(-100.0, 0.0, 0.0),
);

// Circle
let circle = (
VelloCircle::new(50.0),
Fill::new().with_color(Color::YELLOW_GREEN),
Stroke::new(5.0).with_color(Color::DARK_GREEN),
Transform::from_xyz(100.0, 0.0, 0.0),
);

let mut bez_path = kurbo::BezPath::new();
bez_path.move_to((300.0, 100.0));
bez_path.curve_to((200.0, 50.0), (400.0, -50.0), (300.0, -100.0));

// Beizer Path
let beizer_path = (
VelloBezPath::new().with_path(bez_path),
Stroke::new(4.0).with_color(Color::YELLOW),
);

commands
.spawn(VelloSceneBundle::default())
.insert(line);

commands
.spawn(VelloSceneBundle::default())
.insert(rect);

commands
.spawn(VelloSceneBundle::default())
.insert(circle);

commands
.spawn(VelloSceneBundle::default())
.insert(beizer_path);
}
2 changes: 1 addition & 1 deletion src/bezpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct VelloBezPath {

impl VelloBezPath {
pub fn new() -> Self {
Self::default()
Self::default().with_trace(1.0)
}

pub fn with_path(mut self, path: kurbo::BezPath) -> Self {
Expand Down

0 comments on commit a9fe4c5

Please sign in to comment.