/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
/// The computed value of `inset()`. pubtype InsetRect = generic::GenericInsetRect<LengthPercentage, NonNegativeLengthPercentage>;
/// A computed circle. pubtype Circle = generic::Circle<Position, NonNegativeLengthPercentage>;
/// A computed ellipse. pubtype Ellipse = generic::Ellipse<Position, NonNegativeLengthPercentage>;
/// The computed value of `ShapeRadius`. pubtype ShapeRadius = generic::GenericShapeRadius<NonNegativeLengthPercentage>;
/// The computed value of `shape()`. pubtype Shape = generic::Shape<Angle, LengthPercentage>;
/// The computed value of `ShapeCommand`. pubtype ShapeCommand = generic::GenericShapeCommand<Angle, LengthPercentage>;
/// The computed value of `PathOrShapeFunction`. pubtype PathOrShapeFunction = generic::GenericPathOrShapeFunction<Angle, LengthPercentage>;
/// The computed value of `CoordinatePair`. pubtype CoordinatePair = generic::CoordinatePair<LengthPercentage>;
/// Animate from `Shape` to `Path`, and vice versa.
macro_rules! animate_shape {
(
$from:ident,
$to:ident,
$procedure:ident,
$from_as_shape:tt,
$to_as_shape:tt
) => {{ // Check fill-rule. if $from.fill != $to.fill { return Err(());
}
// Check the list of commands. (This is a specialized lists::by_computed_value::animate().) let from_cmds = $from.commands(); let to_cmds = $to.commands(); if from_cmds.len() != to_cmds.len() { return Err(());
} let commands = from_cmds
.iter()
.zip(to_cmds.iter())
.map(|(from_cmd, to_cmd)| {
$from_as_shape(from_cmd).animate(&$to_as_shape(to_cmd), $procedure)
})
.collect::<Result<Vec<ShapeCommand>, ()>>()?;
impl Animate for PathOrShapeFunction { #[inline] fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> { // Per spec, commands are "the same" if they use the same command keyword, and use the same // <by-to> keyword. For curve and smooth, they also must have the same number of control // points. Therefore, we don't have to do normalization here. (Note that we do // normalization if we animate from path() to path(). See svg_path.rs for more details.) // // https://drafts.csswg.org/css-shapes-2/#interpolating-shape match (self, other) {
(Self::Path(ref from), Self::Path(ref to)) => {
from.animate(to, procedure).map(Self::Path)
},
(Self::Shape(ref from), Self::Shape(ref to)) => {
from.animate(to, procedure).map(Self::Shape)
},
(Self::Shape(ref from), Self::Path(ref to)) => { // Animate from shape() to path(). We convert each PathCommand into ShapeCommand, // and return shape().
animate_shape!(
from,
to,
procedure,
(|shape_cmd| shape_cmd),
(|path_cmd| ShapeCommand::from(path_cmd))
)
.map(Self::Shape)
},
(Self::Path(ref from), Self::Shape(ref to)) => { // Animate from path() to shape(). We convert each PathCommand into ShapeCommand, // and return shape().
animate_shape!(
from,
to,
procedure,
(|path_cmd| ShapeCommand::from(path_cmd)),
(|shape_cmd| shape_cmd)
)
.map(Self::Shape)
},
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.