gsk4/auto/
color_matrix_node.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, RenderNode};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// A render node controlling the color matrix of its single child node.
10    #[doc(alias = "GskColorMatrixNode")]
11    pub struct ColorMatrixNode(Shared<ffi::GskColorMatrixNode>);
12
13    match fn {
14        ref => |ptr| ffi::gsk_render_node_ref(ptr as *mut ffi::GskRenderNode),
15        unref => |ptr| ffi::gsk_render_node_unref(ptr as *mut ffi::GskRenderNode),
16    }
17}
18
19impl StaticType for ColorMatrixNode {
20    fn static_type() -> glib::Type {
21        unsafe { from_glib(ffi::gsk_color_matrix_node_get_type()) }
22    }
23}
24
25impl ColorMatrixNode {
26    /// Creates a [`RenderNode`][crate::RenderNode] that will drawn the @child with
27    /// @color_matrix.
28    ///
29    /// In particular, the node will transform colors by applying
30    ///
31    ///     pixel = transpose(color_matrix) * pixel + color_offset
32    ///
33    /// for every pixel. The transformation operates on unpremultiplied
34    /// colors, with color components ordered R, G, B, A.
35    /// ## `child`
36    /// The node to draw
37    /// ## `color_matrix`
38    /// The matrix to apply
39    /// ## `color_offset`
40    /// Values to add to the color
41    ///
42    /// # Returns
43    ///
44    /// A new [`RenderNode`][crate::RenderNode]
45    #[doc(alias = "gsk_color_matrix_node_new")]
46    pub fn new(
47        child: impl AsRef<RenderNode>,
48        color_matrix: &graphene::Matrix,
49        color_offset: &graphene::Vec4,
50    ) -> ColorMatrixNode {
51        skip_assert_initialized!();
52        unsafe {
53            from_glib_full(ffi::gsk_color_matrix_node_new(
54                child.as_ref().to_glib_none().0,
55                color_matrix.to_glib_none().0,
56                color_offset.to_glib_none().0,
57            ))
58        }
59    }
60
61    /// Gets the child node that is getting its colors modified by the given @self.
62    ///
63    /// # Returns
64    ///
65    /// The child that is getting its colors modified
66    #[doc(alias = "gsk_color_matrix_node_get_child")]
67    #[doc(alias = "get_child")]
68    pub fn child(&self) -> RenderNode {
69        unsafe { from_glib_none(ffi::gsk_color_matrix_node_get_child(self.to_glib_none().0)) }
70    }
71
72    /// Retrieves the color matrix used by the @self.
73    ///
74    /// # Returns
75    ///
76    /// a 4x4 color matrix
77    #[doc(alias = "gsk_color_matrix_node_get_color_matrix")]
78    #[doc(alias = "get_color_matrix")]
79    pub fn color_matrix(&self) -> graphene::Matrix {
80        unsafe {
81            from_glib_none(ffi::gsk_color_matrix_node_get_color_matrix(
82                self.to_glib_none().0,
83            ))
84        }
85    }
86
87    /// Retrieves the color offset used by the @self.
88    ///
89    /// # Returns
90    ///
91    /// a color vector
92    #[doc(alias = "gsk_color_matrix_node_get_color_offset")]
93    #[doc(alias = "get_color_offset")]
94    pub fn color_offset(&self) -> graphene::Vec4 {
95        unsafe {
96            from_glib_none(ffi::gsk_color_matrix_node_get_color_offset(
97                self.to_glib_none().0,
98            ))
99        }
100    }
101}