[librsvg/attribute-parsers-737: 17/26] ColorMatrix::saturate_matrix() - extract function
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/attribute-parsers-737: 17/26] ColorMatrix::saturate_matrix() - extract function
- Date: Fri, 21 Oct 2022 01:06:08 +0000 (UTC)
commit 0fea4c7f078d0d516f003c8094bb2fdf577f8d80
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Oct 20 17:13:22 2022 -0500
ColorMatrix::saturate_matrix() - extract function
src/filters/color_matrix.rs | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/src/filters/color_matrix.rs b/src/filters/color_matrix.rs
index b31cb9334..763972c8f 100644
--- a/src/filters/color_matrix.rs
+++ b/src/filters/color_matrix.rs
@@ -96,14 +96,7 @@ impl SetAttributes for FeColorMatrix {
}
OperationType::Saturate => {
let s: f64 = attr.parse(value)?;
-
- Matrix5::new(
- 0.213 + 0.787 * s, 0.715 - 0.715 * s, 0.072 - 0.072 * s, 0.0, 0.0,
- 0.213 - 0.213 * s, 0.715 + 0.285 * s, 0.072 - 0.072 * s, 0.0, 0.0,
- 0.213 - 0.213 * s, 0.715 - 0.715 * s, 0.072 + 0.928 * s, 0.0, 0.0,
- 0.0, 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 0.0, 1.0,
- )
+ ColorMatrix::saturate_matrix(s)
}
OperationType::HueRotate => {
let degrees: f64 = attr.parse(value)?;
@@ -225,6 +218,18 @@ impl ColorMatrix {
0.0, 0.0, 0.0, 0.0, 1.0,
)
}
+
+ // https://drafts.fxtf.org/filter-effects/#element-attrdef-fecolormatrix-values
+ #[rustfmt::skip]
+ fn saturate_matrix(s: f64) -> Matrix5<f64> {
+ Matrix5::new(
+ 0.213 + 0.787 * s, 0.715 - 0.715 * s, 0.072 - 0.072 * s, 0.0, 0.0,
+ 0.213 - 0.213 * s, 0.715 + 0.285 * s, 0.072 - 0.072 * s, 0.0, 0.0,
+ 0.213 - 0.213 * s, 0.715 - 0.715 * s, 0.072 + 0.928 * s, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 1.0,
+ )
+ }
}
impl FilterEffect for FeColorMatrix {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]