Use Radians in arc and ellipse types
This commit is contained in:
parent
8ed3490280
commit
c077e107f2
5 changed files with 74 additions and 26 deletions
|
|
@ -8,6 +8,7 @@ use iced::mouse;
|
|||
use iced::time::Instant;
|
||||
use iced::widget::canvas;
|
||||
use iced::window::{self, RedrawRequest};
|
||||
use iced::Radians;
|
||||
use iced::{
|
||||
Background, Color, Element, Event, Length, Rectangle, Renderer, Size,
|
||||
Vector,
|
||||
|
|
@ -18,8 +19,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 +140,7 @@ 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,
|
||||
((WRAP_ANGLE.0 / (2.0 * PI)) * u32::MAX as f32) 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 = iced::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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue