[librsvg/attribute-parsers-737: 15/26] feColorMatrix: Update coefficients for luminanceToAlpha per the Filter Effects Module Level 1 spec
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/attribute-parsers-737: 15/26] feColorMatrix: Update coefficients for luminanceToAlpha per the Filter Effects Module Level 1 spec
- Date: Fri, 21 Oct 2022 01:06:08 +0000 (UTC)
commit 90c07e62092038e0e8a8b4c7f35131870fdcfe90
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Oct 20 16:59:53 2022 -0500
feColorMatrix: Update coefficients for luminanceToAlpha per the Filter Effects Module Level 1 spec
Old values from SVG 1.1: https://www.w3.org/TR/SVG11/filters.html#feColorMatrixElement
New values: https://drafts.fxtf.org/filter-effects/#element-attrdef-fecolormatrix-values
src/filters/color_matrix.rs | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/src/filters/color_matrix.rs b/src/filters/color_matrix.rs
index 8b4f469b9..9376cec4a 100644
--- a/src/filters/color_matrix.rs
+++ b/src/filters/color_matrix.rs
@@ -79,15 +79,7 @@ impl SetAttributes for FeColorMatrix {
// Now read the matrix correspondingly.
// LuminanceToAlpha doesn't accept any matrix.
if operation_type == OperationType::LuminanceToAlpha {
- self.params.matrix = {
- Matrix5::new(
- 0.0, 0.0, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0, 0.0,
- 0.2125, 0.7154, 0.0721, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0, 1.0,
- )
- };
+ self.params.matrix = ColorMatrix::luminance_to_alpha_matrix();
} else {
for (attr, value) in attrs
.iter()
@@ -214,6 +206,18 @@ impl ColorMatrix {
matrix[(4, 4)] = 1.0;
matrix
}
+
+ // https://drafts.fxtf.org/filter-effects/#element-attrdef-fecolormatrix-values
+ #[rustfmt::skip]
+ fn luminance_to_alpha_matrix() -> Matrix5<f64> {
+ Matrix5::new(
+ 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.2126, 0.7152, 0.0722, 0.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]