impl Parse for cairo::Matrix; remove property_bag::transform_or_none()

We can now use the normal property_bag::parse_or_none() insted.
parent 5510e4c3
......@@ -557,7 +557,7 @@ impl NodeTrait for NodeGradient {
// Attributes common to linear and radial gradients
g.common.units = property_bag::parse_or_none (pbag, "gradientUnits", ())?;
g.common.affine = property_bag::transform_or_none (pbag, "gradientTransform")?;
g.common.affine = property_bag::parse_or_none (pbag, "gradientTransform", ())?;
g.common.spread = property_bag::parse_or_none (pbag, "spreadMethod", ())?;
g.common.fallback = property_bag::lookup (pbag, "xlink:href");
......
......@@ -205,7 +205,7 @@ impl NodeTrait for NodePattern {
p.preserve_aspect_ratio = property_bag::parse_or_none (pbag, "preserveAspectRatio", ())?;
p.affine = property_bag::transform_or_none (pbag, "patternTransform")?;
p.affine = property_bag::parse_or_none (pbag, "patternTransform", ())?;
p.fallback = property_bag::lookup (pbag, "xlink:href");
......
......@@ -97,13 +97,3 @@ pub fn parse_or_value<T> (pbag: *const RsvgPropertyBag, key: &'static str, data:
Err (e) => Err (e)
}
}
pub fn transform_or_none (pbag: *const RsvgPropertyBag, key: &'static str) -> Result <Option<cairo::Matrix>, NodeError> {
if let Some (s) = lookup (pbag, key) {
parse_transform (&s)
.map (|v| Some (v))
.map_err (|e| NodeError::attribute_error (key, e))
} else {
Ok (None)
}
}
......@@ -3,6 +3,7 @@ use ::glib::translate::*;
use ::glib_sys;
use ::libc;
#[cfg(test)]
use std::f64::consts::*;
use cairo::MatrixTrait;
......@@ -11,6 +12,16 @@ use parse_transform::*;
use error::*;
use parsers::ParseError;
use parsers::Parse;
impl Parse for cairo::Matrix {
type Data = ();
type Err = AttributeError;
fn parse (s: &str, _: ()) -> Result<cairo::Matrix, AttributeError> {
parse_transform (s)
}
}
pub fn parse_transform (s: &str) -> Result <cairo::Matrix, AttributeError> {
let r = parse_TransformList (s);
......@@ -27,6 +38,7 @@ pub fn parse_transform (s: &str) -> Result <cairo::Matrix, AttributeError> {
}
}
#[cfg(test)]
fn make_rotation_matrix (angle_degrees: f64, tx: f64, ty: f64) -> cairo::Matrix {
let angle = angle_degrees * PI / 180.0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment