[librsvg: 4/7] TransformProperty::to_transform - use an exhaustive match
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 4/7] TransformProperty::to_transform - use an exhaustive match
- Date: Wed, 1 Sep 2021 00:59:51 +0000 (UTC)
commit 1fb52754d1f0a66c02c0e23c3a9e0ed212397fd4
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Aug 31 18:51:34 2021 -0500
TransformProperty::to_transform - use an exhaustive match
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/582>
src/transform.rs | 48 ++++++++++++++++++++++++++----------------------
1 file changed, 26 insertions(+), 22 deletions(-)
---
diff --git a/src/transform.rs b/src/transform.rs
index e7c493c5..634b8d1a 100644
--- a/src/transform.rs
+++ b/src/transform.rs
@@ -45,30 +45,34 @@ impl TransformProperty {
// Multiply by each of the transform functions in transform property from left to right
// TODO: implement - Translate by the negated computed X and Y values of transform-origin
- let mut final_transform = Transform::identity();
-
- if let TransformProperty::List(l) = self {
- for f in l.iter() {
- let transform_matrix = match f {
- TransformFunction::Matrix(trans_matrix) => *trans_matrix,
- TransformFunction::Translate(h, v) => {
- Transform::new_translate(h.length, v.length)
- }
- TransformFunction::TranslateX(h) => Transform::new_translate(h.length, 0.0),
- TransformFunction::TranslateY(v) => Transform::new_translate(0.0, v.length),
- TransformFunction::Scale(x, y) => Transform::new_scale(*x, *y),
- TransformFunction::ScaleX(x) => Transform::new_scale(*x, 1.0),
- TransformFunction::ScaleY(y) => Transform::new_scale(1.0, *y),
- TransformFunction::Rotate(a) => Transform::new_rotate(*a),
- TransformFunction::Skew(ax, ay) => Transform::new_skew(*ax, *ay),
- TransformFunction::SkewX(ax) => Transform::new_skew(*ax, Angle::new(0.0)),
- TransformFunction::SkewY(ay) => Transform::new_skew(Angle::new(0.0), *ay),
- };
- final_transform = transform_matrix.post_transform(&final_transform);
+ match self {
+ TransformProperty::None => Transform::identity(),
+
+ TransformProperty::List(l) => {
+ let mut final_transform = Transform::identity();
+
+ for f in l.iter() {
+ use TransformFunction::*;
+
+ let transform_matrix = match f {
+ Matrix(trans_matrix) => *trans_matrix,
+ Translate(h, v) => Transform::new_translate(h.length, v.length),
+ TranslateX(h) => Transform::new_translate(h.length, 0.0),
+ TranslateY(v) => Transform::new_translate(0.0, v.length),
+ Scale(x, y) => Transform::new_scale(*x, *y),
+ ScaleX(x) => Transform::new_scale(*x, 1.0),
+ ScaleY(y) => Transform::new_scale(1.0, *y),
+ Rotate(a) => Transform::new_rotate(*a),
+ Skew(ax, ay) => Transform::new_skew(*ax, *ay),
+ SkewX(ax) => Transform::new_skew(*ax, Angle::new(0.0)),
+ SkewY(ay) => Transform::new_skew(Angle::new(0.0), *ay),
+ };
+ final_transform = transform_matrix.post_transform(&final_transform);
+ }
+
+ final_transform
}
}
-
- final_transform
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]