mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Animate basic shapes
This commit is contained in:
parent
56f5fc41fa
commit
c4e33d9dca
8 changed files with 456 additions and 48 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue