-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the
prop!
macro for all style properties (#128)
- Loading branch information
Showing
17 changed files
with
715 additions
and
992 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,40 @@ | ||
use std::{any::Any, rc::Rc}; | ||
|
||
use peniko::Color; | ||
|
||
#[derive(Debug, Clone)] | ||
pub enum AnimValue { | ||
Float(f64), | ||
Color(Color), | ||
Prop(Rc<dyn Any>), | ||
} | ||
|
||
impl AnimValue { | ||
pub fn get_f32(self) -> f32 { | ||
match self { | ||
AnimValue::Float(v) => v as f32, | ||
AnimValue::Color(_) => panic!(), | ||
} | ||
self.get_f64() as f32 | ||
} | ||
|
||
pub fn get_f64(self) -> f64 { | ||
match self { | ||
AnimValue::Float(v) => v, | ||
AnimValue::Color(_) => panic!(), | ||
AnimValue::Prop(prop) => *prop.downcast_ref::<f64>().unwrap(), | ||
} | ||
} | ||
|
||
pub fn get_color(self) -> Color { | ||
match self { | ||
AnimValue::Color(c) => c, | ||
AnimValue::Float(_) => panic!(), | ||
AnimValue::Prop(prop) => *prop.downcast_ref::<Color>().unwrap(), | ||
} | ||
} | ||
|
||
pub fn get_any(self) -> Rc<dyn Any> { | ||
match self { | ||
AnimValue::Color(_) => panic!(), | ||
AnimValue::Float(_) => panic!(), | ||
AnimValue::Prop(prop) => prop.clone(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.