Skip to main content

gsk4/auto/
repeating_linear_gradient_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::{ColorStop, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// A render node for a repeating linear gradient.
10    #[doc(alias = "GskRepeatingLinearGradientNode")]
11    pub struct RepeatingLinearGradientNode(Shared<ffi::GskRepeatingLinearGradientNode>);
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 RepeatingLinearGradientNode {
20    fn static_type() -> glib::Type {
21        unsafe { from_glib(ffi::gsk_repeating_linear_gradient_node_get_type()) }
22    }
23}
24
25impl RepeatingLinearGradientNode {
26    /// Creates a [`RenderNode`][crate::RenderNode] that will create a repeating linear gradient
27    /// from the given points and color stops, and render that into the area
28    /// given by @bounds.
29    /// ## `bounds`
30    /// the rectangle to render the linear gradient into
31    /// ## `start`
32    /// the point at which the linear gradient will begin
33    /// ## `end`
34    /// the point at which the linear gradient will finish
35    /// ## `color_stops`
36    /// = 1.
37    ///
38    /// # Returns
39    ///
40    /// A new [`RenderNode`][crate::RenderNode]
41    #[doc(alias = "gsk_repeating_linear_gradient_node_new")]
42    pub fn new(
43        bounds: &graphene::Rect,
44        start: &graphene::Point,
45        end: &graphene::Point,
46        color_stops: &[ColorStop],
47    ) -> RepeatingLinearGradientNode {
48        assert_initialized_main_thread!();
49        let n_color_stops = color_stops.len() as _;
50        unsafe {
51            from_glib_full(ffi::gsk_repeating_linear_gradient_node_new(
52                bounds.to_glib_none().0,
53                start.to_glib_none().0,
54                end.to_glib_none().0,
55                color_stops.to_glib_none().0,
56                n_color_stops,
57            ))
58        }
59    }
60}