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
|
|
@ -1,5 +1,5 @@
|
|||
//! Build and draw curves.
|
||||
use iced_core::{Point, Vector};
|
||||
use iced_core::{Point, Radians, Vector};
|
||||
|
||||
/// A segment of a differentiable curve.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
@ -8,10 +8,10 @@ pub struct Arc {
|
|||
pub center: Point,
|
||||
/// The radius of the arc.
|
||||
pub radius: f32,
|
||||
/// The start of the segment's angle in radians, clockwise rotation from positive x-axis.
|
||||
pub start_angle: f32,
|
||||
/// The end of the segment's angle in radians, clockwise rotation from positive x-axis.
|
||||
pub end_angle: f32,
|
||||
/// The start of the segment's angle, clockwise rotation from positive x-axis.
|
||||
pub start_angle: Radians,
|
||||
/// The end of the segment's angle, clockwise rotation from positive x-axis.
|
||||
pub end_angle: Radians,
|
||||
}
|
||||
|
||||
/// An elliptical [`Arc`].
|
||||
|
|
@ -22,11 +22,11 @@ pub struct Elliptical {
|
|||
/// The radii of the arc's ellipse. The horizontal and vertical half-dimensions of the ellipse will match the x and y values of the radii vector.
|
||||
pub radii: Vector,
|
||||
/// The clockwise rotation of the arc's ellipse.
|
||||
pub rotation: f32,
|
||||
/// The start of the segment's angle in radians, clockwise rotation from positive x-axis.
|
||||
pub start_angle: f32,
|
||||
/// The end of the segment's angle in radians, clockwise rotation from positive x-axis.
|
||||
pub end_angle: f32,
|
||||
pub rotation: Radians,
|
||||
/// The start of the segment's angle, clockwise rotation from positive x-axis.
|
||||
pub start_angle: Radians,
|
||||
/// The end of the segment's angle, clockwise rotation from positive x-axis.
|
||||
pub end_angle: Radians,
|
||||
}
|
||||
|
||||
impl From<Arc> for Elliptical {
|
||||
|
|
@ -34,7 +34,7 @@ impl From<Arc> for Elliptical {
|
|||
Elliptical {
|
||||
center: arc.center,
|
||||
radii: Vector::new(arc.radius, arc.radius),
|
||||
rotation: 0.0,
|
||||
rotation: Radians(0.0),
|
||||
start_angle: arc.start_angle,
|
||||
end_angle: arc.end_angle,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::geometry::path::{arc, Arc, Path};
|
||||
|
||||
use iced_core::{Point, Size};
|
||||
use iced_core::{Point, Radians, Size};
|
||||
|
||||
use lyon_path::builder::{self, SvgPathBuilder};
|
||||
use lyon_path::geom;
|
||||
|
|
@ -106,9 +106,11 @@ impl Builder {
|
|||
let arc = geom::Arc {
|
||||
center: math::Point::new(arc.center.x, arc.center.y),
|
||||
radii: math::Vector::new(arc.radii.x, arc.radii.y),
|
||||
x_rotation: math::Angle::radians(arc.rotation),
|
||||
start_angle: math::Angle::radians(arc.start_angle),
|
||||
sweep_angle: math::Angle::radians(arc.end_angle - arc.start_angle),
|
||||
x_rotation: math::Angle::radians(arc.rotation.0),
|
||||
start_angle: math::Angle::radians(arc.start_angle.0),
|
||||
sweep_angle: math::Angle::radians(
|
||||
(arc.end_angle - arc.start_angle).0,
|
||||
),
|
||||
};
|
||||
|
||||
let _ = self.raw.move_to(arc.sample(0.0));
|
||||
|
|
@ -165,8 +167,8 @@ impl Builder {
|
|||
self.arc(Arc {
|
||||
center,
|
||||
radius,
|
||||
start_angle: 0.0,
|
||||
end_angle: 2.0 * std::f32::consts::PI,
|
||||
start_angle: Radians(0.0),
|
||||
end_angle: Radians(2.0 * std::f32::consts::PI),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue