Skip to content

Commit

Permalink
Replace time().elapsed_seconds() with elapsed_seconds().
Browse files Browse the repository at this point in the history
  • Loading branch information
tychedelia committed Jun 6, 2024
1 parent 4df9200 commit 8c0f0da
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/draw/draw_blend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn view(app: &App) {
// let mut draw = draw.color_blend(desc.clone());

// Draw RGB circles.
let t = app.time().elapsed_seconds();
let t = app.elapsed_seconds();
let n_circles = 3;
let radius = w.right().min(w.top()) * 0.5 / n_circles as f32;
let animate_radius = -((t.sin() * 0.5 + 0.5) * radius * 0.5);
Expand Down
2 changes: 1 addition & 1 deletion examples/draw/draw_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
fn view(app: &App) {
// Begin drawing
let win = app.window_rect();
let t = app.time().elapsed_seconds();
let t = app.sed_seconds();
let draw = app.draw();

// Clear the background to black.
Expand Down
2 changes: 1 addition & 1 deletion examples/draw/draw_textured_mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn view(app: &App, model: &Model) {

// Scale the points up to half the window size.
let cube_side = win_rect.w().min(win_rect.h()) * 0.5;
let t = app.time().elapsed_seconds();
let t = app.elapsed_seconds();
draw.scale(cube_side)
.mesh()
.points_textured(model.texture.clone(), points)
Expand Down
2 changes: 1 addition & 1 deletion examples/draw/draw_textured_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn view(app: &App, model: &Model) {
.stroke()
.weight(0.9 / freq)
.points_textured(model.texture.clone(), points)
.rotate(app.time().elapsed_seconds() * 0.25);
.rotate(app.elapsed_seconds() * 0.25);

// Draw to the frame!

Expand Down
2 changes: 1 addition & 1 deletion examples/draw/draw_textured_polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ fn view(app: &App, model: &Model) {
draw.scale(ellipse_side)
.polygon()
.points_textured(model.texture.clone(), points)
.rotate(app.time().elapsed_seconds() * 0.25);
.rotate(app.elapsed_seconds() * 0.25);
}
2 changes: 1 addition & 1 deletion generative_design/type/p_3_2_1_01.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn view(app: &App, model: &Model) {
draw.ellipse()
.x_y(p.x, p.y)
.radius(map_range(
(i as f32 * 0.05 + app.time().elapsed_seconds() * 4.3).sin(),
(i as f32 * 0.05 + app.elapsed_seconds() * 4.3).sin(),
-1.0,
1.0,
3.0,
Expand Down
5 changes: 5 additions & 0 deletions nannou/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,11 @@ impl<'w> App<'w> {
time.clone()
}

pub fn elapsed_seconds(&self) -> f32 {
let time = self.world().get_resource::<Time>().unwrap();
time.elapsed_seconds()
}

// Create a new `App`.
fn new(world: &'w mut World) -> Self {
let world = world.as_unsafe_world_cell();
Expand Down

0 comments on commit 8c0f0da

Please sign in to comment.