summaryrefslogtreecommitdiffstats
path: root/examples/progress_indicators/src/easing.rs
diff options
context:
space:
mode:
authorLibravatar Nick Senger <dev@nsenger.com>2023-06-07 15:19:11 -0700
committerLibravatar Nick Senger <dev@nsenger.com>2023-06-07 15:42:13 -0700
commit2ebc92319711e6fa0dda310939257334625b59c9 (patch)
tree3643af813fbb72e4308893cd33d383c7a0c12986 /examples/progress_indicators/src/easing.rs
parentcdfb8b30680de164280b8b90fbc08a1638e597e2 (diff)
downloadiced-2ebc92319711e6fa0dda310939257334625b59c9.tar.gz
iced-2ebc92319711e6fa0dda310939257334625b59c9.tar.bz2
iced-2ebc92319711e6fa0dda310939257334625b59c9.zip
feat: use lyon for easing
Diffstat (limited to 'examples/progress_indicators/src/easing.rs')
-rw-r--r--examples/progress_indicators/src/easing.rs67
1 files changed, 0 insertions, 67 deletions
diff --git a/examples/progress_indicators/src/easing.rs b/examples/progress_indicators/src/easing.rs
deleted file mode 100644
index 10479659..00000000
--- a/examples/progress_indicators/src/easing.rs
+++ /dev/null
@@ -1,67 +0,0 @@
-use flo_curves::bezier::Curve;
-use flo_curves::*;
-use lazy_static::lazy_static;
-
-use std::borrow::Cow;
-
-lazy_static! {
- pub static ref EXAMPLES: [Easing; 3] = [
- Easing::CubicBezier(Curve::from_points(
- Coord2(0.0, 0.0),
- (Coord2(0.05, 0.7), Coord2(0.1, 1.0)),
- Coord2(1.0, 1.0),
- )),
- Easing::CubicBezier(Curve::from_points(
- Coord2(0.0, 0.0),
- (Coord2(0.3, 0.0), Coord2(0.8, 0.15)),
- Coord2(1.0, 1.0),
- )),
- Easing::CubicBezier(Curve::from_points(
- Coord2(0.0, 0.0),
- (Coord2(0.2, 0.0), Coord2(0.0, 1.0)),
- Coord2(1.0, 1.0),
- ))
- ];
- pub static ref STANDARD: Easing = {
- Easing::CubicBezier(Curve::from_points(
- Coord2(0.0, 0.0),
- (Coord2(0.2, 0.0), Coord2(0.0, 1.0)),
- Coord2(1.0, 1.0),
- ))
- };
-}
-
-#[derive(Clone, Debug)]
-pub enum Easing {
- BezierPath(Vec<Curve<Coord2>>),
- CubicBezier(Curve<Coord2>),
-}
-
-impl Easing {
- pub fn y_at_x(&self, x: f32) -> f32 {
- let x = x as f64;
-
- match self {
- Self::BezierPath(curves) => curves
- .iter()
- .find_map(|curve| {
- (curve.start_point().0 <= x && curve.end_point().0 >= x)
- .then(|| curve.point_at_pos(x).1 as f32)
- })
- .unwrap_or_default(),
- Self::CubicBezier(curve) => curve.point_at_pos(x).1 as f32,
- }
- }
-}
-
-impl<'a> From<Easing> for Cow<'a, Easing> {
- fn from(easing: Easing) -> Self {
- Cow::Owned(easing)
- }
-}
-
-impl<'a> From<&'a Easing> for Cow<'a, Easing> {
- fn from(easing: &'a Easing) -> Self {
- Cow::Borrowed(easing)
- }
-}