mirror of
https://github.com/servo/servo.git
synced 2025-08-11 00:15:32 +01:00
Rewrite interpolate() in terms of a more general add_weighted() function
Generalizing the procedure like this will allow us to re-use it for addition of most types.
This commit is contained in:
parent
8366b4d4f9
commit
2f07b29296
7 changed files with 261 additions and 200 deletions
|
@ -1073,10 +1073,12 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
}
|
||||
|
||||
impl Animatable for T {
|
||||
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
|
||||
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64)
|
||||
-> Result<Self, ()> {
|
||||
match (*self, *other) {
|
||||
(T::Number(ref number), T::Number(ref other)) =>
|
||||
Ok(T::Number(try!(number.interpolate(other, time)))),
|
||||
Ok(T::Number(try!(number.add_weighted(other,
|
||||
self_portion, other_portion)))),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue