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::{ffi, ColorStop};
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    /// a pointer to an array of
37    /// [`ColorStop`][crate::ColorStop] defining the gradient. The offsets of all color stops
38    ///   must be increasing. The first stop's offset must be >= 0 and the last
39    ///   stop's offset must be <= 1.
40    ///
41    /// # Returns
42    ///
43    /// A new [`RenderNode`][crate::RenderNode]
44    #[doc(alias = "gsk_repeating_linear_gradient_node_new")]
45    pub fn new(
46        bounds: &graphene::Rect,
47        start: &graphene::Point,
48        end: &graphene::Point,
49        color_stops: &[ColorStop],
50    ) -> RepeatingLinearGradientNode {
51        assert_initialized_main_thread!();
52        let n_color_stops = color_stops.len() as _;
53        unsafe {
54            from_glib_full(ffi::gsk_repeating_linear_gradient_node_new(
55                bounds.to_glib_none().0,
56                start.to_glib_none().0,
57                end.to_glib_none().0,
58                color_stops.to_glib_none().0,
59                n_color_stops,
60            ))
61        }
62    }
63}