summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@gnome.org>2022-10-21 19:27:30 -0500
committerFederico Mena Quintero <federico@gnome.org>2022-11-04 08:44:28 -0600
commitc7da83f9f338d0ae42f54b4d62e153c2758e4c7e (patch)
tree4fb3f4cff51420d99a4fd871e2fe1856f311ae92
parent4eb9ff171392e4efc7ad905ec902bf71c0f0000f (diff)
downloadlibrsvg-c7da83f9f338d0ae42f54b4d62e153c2758e4c7e.tar.gz
filters/lighting.rs: use set_attribute() for specular_constant
Same in principle as the last commit. Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/763>
-rw-r--r--src/filters/lighting.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/filters/lighting.rs b/src/filters/lighting.rs
index 060b36e2..e4197812 100644
--- a/src/filters/lighting.rs
+++ b/src/filters/lighting.rs
@@ -69,7 +69,7 @@ pub struct SpecularLightingParams {
in1: Input,
surface_scale: f64,
kernel_unit_length: Option<(f64, f64)>,
- specular_constant: f64,
+ specular_constant: NonNegative,
specular_exponent: f64,
}
@@ -79,7 +79,7 @@ impl Default for SpecularLightingParams {
in1: Default::default(),
surface_scale: 1.0,
kernel_unit_length: None,
- specular_constant: 1.0,
+ specular_constant: NonNegative(1.0),
specular_exponent: 1.0,
}
}
@@ -437,8 +437,11 @@ impl SetAttributes for FeSpecularLighting {
}
}
expanded_name!("", "specularConstant") => {
- let NonNegative(c) = attr.parse(value)?;
- self.params.specular_constant = c;
+ set_attribute(
+ &mut self.params.specular_constant,
+ attr.parse(value),
+ session,
+ );
}
expanded_name!("", "specularExponent") => {
set_attribute(
@@ -478,9 +481,9 @@ impl SpecularLighting {
};
if approx_eq!(f64, self.params.specular_exponent, 1.0) {
- self.params.specular_constant * n_dot_h
+ self.params.specular_constant.0 * n_dot_h
} else {
- self.params.specular_constant * n_dot_h.powf(self.params.specular_exponent)
+ self.params.specular_constant.0 * n_dot_h.powf(self.params.specular_exponent)
}
}
}