summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-01-31 19:42:38 +0100
committerLibravatar GitHub <noreply@github.com>2024-01-31 19:42:38 +0100
commit66c8a804c6b665718a2cc80222ba8b906b543014 (patch)
tree5034f46b591dee2bc73b16d09a4711f23a69a236 /examples
parent8ed3490280a4dd8a1d4e3cd421b1785725f65865 (diff)
parentb1932989b0146c1957ba5bc8a4b8fc1bbf037975 (diff)
downloadiced-66c8a804c6b665718a2cc80222ba8b906b543014.tar.gz
iced-66c8a804c6b665718a2cc80222ba8b906b543014.tar.bz2
iced-66c8a804c6b665718a2cc80222ba8b906b543014.zip
Merge pull request #2029 from ua-kxie/arc-and-ellipse-radians-type
use radians type in arc and ellipse
Diffstat (limited to 'examples')
-rw-r--r--examples/loading_spinners/src/circular.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/examples/loading_spinners/src/circular.rs b/examples/loading_spinners/src/circular.rs
index 8598b20a..12670ed1 100644
--- a/examples/loading_spinners/src/circular.rs
+++ b/examples/loading_spinners/src/circular.rs
@@ -9,8 +9,8 @@ use iced::time::Instant;
use iced::widget::canvas;
use iced::window::{self, RedrawRequest};
use iced::{
- Background, Color, Element, Event, Length, Rectangle, Renderer, Size,
- Vector,
+ Background, Color, Element, Event, Length, Radians, Rectangle, Renderer,
+ Size, Vector,
};
use super::easing::{self, Easing};
@@ -18,8 +18,8 @@ use super::easing::{self, Easing};
use std::f32::consts::PI;
use std::time::Duration;
-const MIN_RADIANS: f32 = PI / 8.0;
-const WRAP_RADIANS: f32 = 2.0 * PI - PI / 4.0;
+const MIN_ANGLE: Radians = Radians(PI / 8.0);
+const WRAP_ANGLE: Radians = Radians(2.0 * PI - PI / 4.0);
const BASE_ROTATION_SPEED: u32 = u32::MAX / 80;
#[allow(missing_debug_implementations)]
@@ -139,7 +139,8 @@ impl Animation {
progress: 0.0,
rotation: rotation.wrapping_add(
BASE_ROTATION_SPEED.wrapping_add(
- ((WRAP_RADIANS / (2.0 * PI)) * u32::MAX as f32) as u32,
+ (f64::from(WRAP_ANGLE / (2.0 * Radians::PI)) * f64::MAX)
+ as u32,
),
),
last: now,
@@ -318,7 +319,7 @@ where
let mut builder = canvas::path::Builder::new();
- let start = state.animation.rotation() * 2.0 * PI;
+ let start = Radians(state.animation.rotation() * 2.0 * PI);
match state.animation {
Animation::Expanding { progress, .. } => {
@@ -327,8 +328,8 @@ where
radius: track_radius,
start_angle: start,
end_angle: start
- + MIN_RADIANS
- + WRAP_RADIANS * (self.easing.y_at_x(progress)),
+ + MIN_ANGLE
+ + WRAP_ANGLE * (self.easing.y_at_x(progress)),
});
}
Animation::Contracting { progress, .. } => {
@@ -336,8 +337,8 @@ where
center: frame.center(),
radius: track_radius,
start_angle: start
- + WRAP_RADIANS * (self.easing.y_at_x(progress)),
- end_angle: start + MIN_RADIANS + WRAP_RADIANS,
+ + WRAP_ANGLE * (self.easing.y_at_x(progress)),
+ end_angle: start + MIN_ANGLE + WRAP_ANGLE,
});
}
}