Animate basic shapes

This commit is contained in:
Anthony Ramine 2017-08-10 10:54:56 +02:00
parent 56f5fc41fa
commit c4e33d9dca
8 changed files with 456 additions and 48 deletions

View file

@ -6,6 +6,7 @@
use cssparser::Parser;
use parser::{Parse, ParserContext};
use properties::animated_properties::Animatable;
use std::fmt;
use style_traits::{ToCss, ParseError};
@ -51,6 +52,24 @@ impl<T> Rect<T>
}
}
impl<L> Animatable for Rect<L>
where
L: Animatable,
{
fn add_weighted(
&self,
other: &Self,
self_portion: f64,
other_portion: f64,
) -> Result<Self, ()> {
let first = self.0.add_weighted(&other.0, self_portion, other_portion)?;
let second = self.1.add_weighted(&other.1, self_portion, other_portion)?;
let third = self.2.add_weighted(&other.2, self_portion, other_portion)?;
let fourth = self.3.add_weighted(&other.3, self_portion, other_portion)?;
Ok(Rect(first, second, third, fourth))
}
}
impl<T> From<T> for Rect<T>
where T: Clone
{