Skip to content

Commit

Permalink
feat: add triangle head to hello_world example
Browse files Browse the repository at this point in the history
  • Loading branch information
nixon-voxell committed Aug 8, 2024
1 parent 1a9ffc7 commit f065de6
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@ fn setup(mut commands: Commands) {
}

fn render_shapes(mut commands: Commands) {
let mut triangle_path = kurbo::BezPath::new();
triangle_path.move_to(kurbo::Point::new(0.0, -10.0));
triangle_path.line_to(kurbo::Point::new(0.0, 10.0));
triangle_path.line_to(kurbo::Point::new(20.0, 0.0));
triangle_path.close_path();

let triangle = VelloBezPath::new().with_path(triangle_path);

// Line
let line = (
VelloLine::new(DVec2::new(100.0, 100.0), DVec2::new(0.0, -100.0)),
Fill::new().with_color(Color::WHITE),
Stroke::new(5.0).with_color(Color::WHITE),
Transform::from_xyz(-300.0, 0.0, 0.0),
HeadBundle::new(VelloRect::new(20.0, 20.0)),
HeadBundle::new(triangle.clone()),
);

// Rectangle
Expand All @@ -32,7 +40,7 @@ fn render_shapes(mut commands: Commands) {
Fill::new().with_color(css::ORANGE.into()),
Stroke::new(5.0).with_color(css::RED.into()),
Transform::from_xyz(-100.0, 0.0, 0.0),
HeadBundle::new(VelloRect::new(20.0, 20.0)),
HeadBundle::new(triangle.clone()),
);

// Circle
Expand All @@ -41,12 +49,7 @@ fn render_shapes(mut commands: Commands) {
Fill::new().with_color(css::YELLOW_GREEN.into()),
Stroke::new(5.0).with_color(css::DARK_GREEN.into()),
Transform::from_xyz(100.0, 0.0, 0.0),
HeadBundle::new(VelloRect::new(20.0, 20.0)),
// HeadBundle {
// vector: HeadVector(VelloRect::new(20.0, 20.0)),
// head: Head::default().with_offset(DVec2::new(0.0, -50.0)),
// transform: HeadTransform::default(),
// },
HeadBundle::new(triangle.clone()),
);

let mut bez_path = kurbo::BezPath::new();
Expand All @@ -57,7 +60,7 @@ fn render_shapes(mut commands: Commands) {
let bezier_path = (
VelloBezPath::new().with_path(bez_path),
Stroke::new(4.0).with_color(css::YELLOW.into()),
HeadBundle::new(VelloRect::new(20.0, 20.0)),
HeadBundle::new(triangle),
);

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

0 comments on commit f065de6

Please sign in to comment.