Skip to content

Commit

Permalink
Fmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
tychedelia committed Jul 19, 2024
1 parent add91b3 commit 1fe7236
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
7 changes: 1 addition & 6 deletions examples/draw/draw_texture_sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ fn view(app: &App, model: &Model) {
// sampler behaves when sampling beyond the bounds of the texture in each of the different
// address modes. By default, the bounds of the texture coordinates are 0.0 to 1.0. We will
// triple the size.
let area = geom::Rect::from_x_y_w_h(
0.5,
0.5,
app.time().sin() * 10.0,
app.time().sin() * 10.0,
);
let area = geom::Rect::from_x_y_w_h(0.5, 0.5, app.time().sin() * 10.0, app.time().sin() * 10.0);
let window_rect = app.main_window().rect();

draw.rect()
Expand Down
3 changes: 1 addition & 2 deletions examples/draw/draw_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ fn view(app: &App) {

// Return a new rotated draw instance.
// This will rotate both the rect and text around the origin.
let rotate = (app.time() * 0.5).sin()
* (app.time() * 0.25 + f * PI * 2.0).cos();
let rotate = (app.time() * 0.5).sin() * (app.time() * 0.25 + f * PI * 2.0).cos();
let draw = draw.rotate(rotate);

let hue = app.time() + f * 2.0 * PI;
Expand Down
14 changes: 9 additions & 5 deletions nannou/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,15 +569,19 @@ impl<'w> App<'w> {

#[cfg(feature = "egui")]
/// Get the egui context for the provided window.
pub fn egui_for_window(&self, window: Entity) -> Mut<EguiContext> {
self.world_mut()
.get_mut::<EguiContext>(window)
.expect("No egui context")
pub fn egui_for_window(&self, window: Entity) -> RefMut<EguiContext> {
let world = self.world_mut();
RefMut::map(world, |world| {
world
.get_mut::<EguiContext>(window)
.expect("No egui context")
.into_inner()
})
}

#[cfg(feature = "egui")]
/// Get the egui context for the currently focused window.
pub fn egui(&self) -> Mut<EguiContext> {
pub fn egui(&self) -> RefMut<EguiContext> {
self.egui_for_window(self.window_id())
}

Expand Down
4 changes: 1 addition & 3 deletions nannou/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,7 @@ impl<'a, 'w> Window<'a, 'w> {

/// Saves a screenshot of the window to the given path.
pub fn save_screenshot<P: AsRef<Path>>(&mut self, path: P) {
let mut world = self
.app
.world_mut();
let mut world = self.app.world_mut();
let mut screenshot_manager = world
.get_resource_mut::<ScreenshotManager>()
.expect("ScreenshotManager resource not found");
Expand Down

0 comments on commit 1fe7236

Please sign in to comment.