Skip to main content

gsk4/auto/
component_transfer.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9    /// Specifies a transfer function for a color component to be applied
10    /// while rendering.
11    ///
12    /// The available functions include linear, piecewise-linear,
13    /// gamma and step functions.
14    ///
15    /// Note that the transfer function is applied to un-premultiplied
16    /// values, and all results are clamped to the [0, 1] range.
17    #[derive(Debug, PartialOrd, Ord, Hash)]
18    pub struct ComponentTransfer(Boxed<ffi::GskComponentTransfer>);
19
20    match fn {
21        copy => |ptr| ffi::gsk_component_transfer_copy(ptr),
22        free => |ptr| ffi::gsk_component_transfer_free(ptr),
23        type_ => || ffi::gsk_component_transfer_get_type(),
24    }
25}
26
27impl ComponentTransfer {
28    /// /figure
29    /// ## `values`
30    /// Values
31    ///
32    /// # Returns
33    ///
34    /// a new [`ComponentTransfer`][crate::ComponentTransfer]
35    #[doc(alias = "gsk_component_transfer_new_discrete")]
36    pub fn new_discrete(values: &[f32]) -> ComponentTransfer {
37        assert_initialized_main_thread!();
38        let n = values.len() as _;
39        unsafe {
40            from_glib_full(ffi::gsk_component_transfer_new_discrete(
41                n,
42                values.to_glib_none().0,
43            ))
44        }
45    }
46
47    /// /figure
48    /// ## `amp`
49    /// Amplitude
50    /// ## `exp`
51    /// Exponent
52    /// ## `ofs`
53    /// Offset
54    ///
55    /// # Returns
56    ///
57    /// a new [`ComponentTransfer`][crate::ComponentTransfer]
58    #[doc(alias = "gsk_component_transfer_new_gamma")]
59    pub fn new_gamma(amp: f32, exp: f32, ofs: f32) -> ComponentTransfer {
60        assert_initialized_main_thread!();
61        unsafe { from_glib_full(ffi::gsk_component_transfer_new_gamma(amp, exp, ofs)) }
62    }
63
64    /// /figure
65    ///
66    /// # Returns
67    ///
68    /// a new [`ComponentTransfer`][crate::ComponentTransfer]
69    #[doc(alias = "gsk_component_transfer_new_identity")]
70    pub fn new_identity() -> ComponentTransfer {
71        assert_initialized_main_thread!();
72        unsafe { from_glib_full(ffi::gsk_component_transfer_new_identity()) }
73    }
74
75    /// /figure
76    /// ## `n`
77    /// Number of levels
78    ///
79    /// # Returns
80    ///
81    /// a new [`ComponentTransfer`][crate::ComponentTransfer]
82    #[doc(alias = "gsk_component_transfer_new_levels")]
83    pub fn new_levels(n: f32) -> ComponentTransfer {
84        assert_initialized_main_thread!();
85        unsafe { from_glib_full(ffi::gsk_component_transfer_new_levels(n)) }
86    }
87
88    /// /figure
89    /// ## `m`
90    /// Slope
91    /// ## `b`
92    /// Offset
93    ///
94    /// # Returns
95    ///
96    /// a new [`ComponentTransfer`][crate::ComponentTransfer]
97    #[doc(alias = "gsk_component_transfer_new_linear")]
98    pub fn new_linear(m: f32, b: f32) -> ComponentTransfer {
99        assert_initialized_main_thread!();
100        unsafe { from_glib_full(ffi::gsk_component_transfer_new_linear(m, b)) }
101    }
102
103    /// /figure
104    /// ## `values`
105    /// Values
106    ///
107    /// # Returns
108    ///
109    /// a new [`ComponentTransfer`][crate::ComponentTransfer]
110    #[doc(alias = "gsk_component_transfer_new_table")]
111    pub fn new_table(values: &[f32]) -> ComponentTransfer {
112        assert_initialized_main_thread!();
113        let n = values.len() as _;
114        unsafe {
115            from_glib_full(ffi::gsk_component_transfer_new_table(
116                n,
117                values.to_glib_none().0,
118            ))
119        }
120    }
121
122    #[doc(alias = "gsk_component_transfer_equal")]
123    fn equal(&self, other: &ComponentTransfer) -> bool {
124        assert_initialized_main_thread!();
125        unsafe {
126            from_glib(ffi::gsk_component_transfer_equal(
127                ToGlibPtr::<*const ffi::GskComponentTransfer>::to_glib_none(self).0
128                    as glib::ffi::gconstpointer,
129                ToGlibPtr::<*const ffi::GskComponentTransfer>::to_glib_none(other).0
130                    as glib::ffi::gconstpointer,
131            ))
132        }
133    }
134}
135
136impl PartialEq for ComponentTransfer {
137    #[inline]
138    fn eq(&self, other: &Self) -> bool {
139        self.equal(other)
140    }
141}
142
143impl Eq for ComponentTransfer {}