Skip to main content

magick_rust/types/
geometry_info.rs

1/*
2 * Copyright 2024 5ohue
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16use crate::bindings;
17
18/// A set of up to five numeric parameters (rho, sigma, xi, psi, chi) used by
19/// ImageMagick geometry and kernel operations.
20#[derive(Debug, Copy, Clone, PartialEq)]
21pub struct GeometryInfo(bindings::GeometryInfo);
22
23impl GeometryInfo {
24    /// Create a new [`GeometryInfo`] with all parameters set to zero.
25    pub fn new() -> GeometryInfo {
26        let inner = bindings::GeometryInfo {
27            rho: 0.0,
28            sigma: 0.0,
29            xi: 0.0,
30            psi: 0.0,
31            chi: 0.0,
32        };
33
34        Self(inner)
35    }
36
37    /// Set the `rho` parameter.
38    pub fn set_rho(&mut self, rho: f64) {
39        self.0.rho = rho;
40    }
41    /// Set the `sigma` parameter.
42    pub fn set_sigma(&mut self, sigma: f64) {
43        self.0.sigma = sigma;
44    }
45    /// Set the `xi` parameter.
46    pub fn set_xi(&mut self, xi: f64) {
47        self.0.xi = xi;
48    }
49    /// Set the `psi` parameter.
50    pub fn set_psi(&mut self, psi: f64) {
51        self.0.psi = psi;
52    }
53    /// Set the `chi` parameter.
54    pub fn set_chi(&mut self, chi: f64) {
55        self.0.chi = chi;
56    }
57
58    pub(crate) fn inner(&self) -> &bindings::GeometryInfo {
59        &self.0
60    }
61}
62
63impl Default for GeometryInfo {
64    fn default() -> Self {
65        Self::new()
66    }
67}