summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-08-04 03:36:05 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-08-04 03:36:05 +0200
commited959023e96f9e5fca66b0bc6b3b3b2e13bdc359 (patch)
tree6725179c38604734f07b7930bf8a7d4ea9c7e429 /examples
parent4f5de3bbe910a36163daa52af85d21461eff2f96 (diff)
downloadiced-ed959023e96f9e5fca66b0bc6b3b3b2e13bdc359.tar.gz
iced-ed959023e96f9e5fca66b0bc6b3b3b2e13bdc359.tar.bz2
iced-ed959023e96f9e5fca66b0bc6b3b3b2e13bdc359.zip
Remove unnecessary `with_save` calls in `solar_system` example
Diffstat (limited to 'examples')
-rw-r--r--examples/solar_system/src/main.rs46
1 files changed, 21 insertions, 25 deletions
diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs
index 1d420959..1f4e642b 100644
--- a/examples/solar_system/src/main.rs
+++ b/examples/solar_system/src/main.rs
@@ -185,31 +185,27 @@ impl<Message> canvas::Program<Message> for State {
let rotation = (2.0 * PI / 60.0) * elapsed.as_secs() as f32
+ (2.0 * PI / 60_000.0) * elapsed.subsec_millis() as f32;
- frame.with_save(|frame| {
- frame.rotate(rotation);
- frame.translate(Vector::new(Self::ORBIT_RADIUS, 0.0));
-
- frame.draw_image(
- &self.earth,
- Rectangle::with_radius(Self::EARTH_RADIUS),
- image::FilterMethod::Linear,
- rotation * 10.0,
- 1.0,
- );
-
- frame.with_save(|frame| {
- frame.rotate(rotation * 10.0);
- frame.translate(Vector::new(0.0, Self::MOON_DISTANCE));
-
- frame.draw_image(
- &self.moon,
- Rectangle::with_radius(Self::MOON_RADIUS),
- image::FilterMethod::Linear,
- 0,
- 1.0,
- );
- });
- });
+ frame.rotate(rotation);
+ frame.translate(Vector::new(Self::ORBIT_RADIUS, 0.0));
+
+ frame.draw_image(
+ &self.earth,
+ Rectangle::with_radius(Self::EARTH_RADIUS),
+ image::FilterMethod::Linear,
+ rotation * 10.0,
+ 1.0,
+ );
+
+ frame.rotate(rotation * 10.0);
+ frame.translate(Vector::new(0.0, Self::MOON_DISTANCE));
+
+ frame.draw_image(
+ &self.moon,
+ Rectangle::with_radius(Self::MOON_RADIUS),
+ image::FilterMethod::Linear,
+ 0,
+ 1.0,
+ );
});
vec![background, system]