Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
juliapaci committed Jun 24, 2024
1 parent eed2db4 commit e1d8c73
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fn render_shapes(mut commands: Commands) {
// Line
let line = (
VelloLine::new(DVec2::new(0.0, 100.0), DVec2::new(0.0, -100.0)),
Head::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),
);
Expand Down
6 changes: 5 additions & 1 deletion src/head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ pub struct Head {
pub rotation_offset: f32,
}

#[derive(Resource)]
// impl Head {
// pub fn new()
// }

#[derive(Resource, Default)]
pub struct Shapes {
pub scenes: std::collections::HashMap<ShapeId, &'static mut vello::Scene>,
}
Expand Down
24 changes: 14 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ pub struct VelloGraphicsPlugin;

impl Plugin for VelloGraphicsPlugin {
fn build(&self, app: &mut App) {
app.add_plugins(VelloPlugin).add_systems(
Update,
(
build_vector::<VelloRect>(),
build_vector::<VelloCircle>(),
build_vector::<VelloLine>(),
build_vector::<VelloBezPath>(),
),
);
app.add_plugins(VelloPlugin)
.init_resource::<Shapes>()
.add_systems(
Update,
(
build_vector::<VelloRect>(),
build_vector::<VelloCircle>(),
build_vector::<VelloLine>(),
build_vector::<VelloBezPath>(),
),
);
}
}

Expand Down Expand Up @@ -88,8 +90,10 @@ fn append_heads<HeadEquipt: VelloVector + VectorBorder + Component>(
(&HeadEquipt, &Head, &mut VelloScene),
(Without<Stroke>, Or<(Changed<HeadEquipt>, Changed<Fill>)>),
>,
shapes: Res<Shapes>,
shapes: Option<Res<Shapes>>,
) {
let Some(shapes) = shapes else { return };

for (vector, head, mut scene) in q_vectors.iter_mut() {
let translation = vector.border_translation(head.time);
let translation = kurbo::Vec2::new(translation.x, translation.y);
Expand Down
2 changes: 1 addition & 1 deletion src/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ impl VectorBorder for VelloLine {
}

fn border_tangent(&self, _time: f64) -> f64 {
(self.p1.y - self.p0.y) / (self.p1.x - self.p0.x)
((self.p1.y - self.p0.y) / (self.p1.x - self.p0.x)).atan()
}
}

0 comments on commit e1d8c73

Please sign in to comment.