gsk4/auto/
repeating_radial_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 radial gradient.
10    #[doc(alias = "GskRepeatingRadialGradientNode")]
11    pub struct RepeatingRadialGradientNode(Shared<ffi::GskRepeatingRadialGradientNode>);
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 RepeatingRadialGradientNode {
20    fn static_type() -> glib::Type {
21        unsafe { from_glib(ffi::gsk_repeating_radial_gradient_node_get_type()) }
22    }
23}
24
25impl RepeatingRadialGradientNode {
26    /// Creates a [`RenderNode`][crate::RenderNode] that draws a repeating radial gradient.
27    ///
28    /// The radial gradient starts around @center. The size of the gradient
29    /// is dictated by @hradius in horizontal orientation and by @vradius
30    /// in vertical orientation.
31    /// ## `bounds`
32    /// the bounds of the node
33    /// ## `center`
34    /// the center of the gradient
35    /// ## `hradius`
36    /// the horizontal radius
37    /// ## `vradius`
38    /// the vertical radius
39    /// ## `start`
40    /// a percentage >= 0 that defines the start of the gradient around @center
41    /// ## `end`
42    /// a percentage >= 0 that defines the end of the gradient around @center
43    /// ## `color_stops`
44    /// a pointer to an array of
45    ///   [`ColorStop`][crate::ColorStop] defining the gradient. The offsets of all color stops
46    ///   must be increasing. The first stop's offset must be >= 0 and the last
47    ///   stop's offset must be <= 1.
48    ///
49    /// # Returns
50    ///
51    /// A new [`RenderNode`][crate::RenderNode]
52    #[doc(alias = "gsk_repeating_radial_gradient_node_new")]
53    pub fn new(
54        bounds: &graphene::Rect,
55        center: &graphene::Point,
56        hradius: f32,
57        vradius: f32,
58        start: f32,
59        end: f32,
60        color_stops: &[ColorStop],
61    ) -> RepeatingRadialGradientNode {
62        assert_initialized_main_thread!();
63        let n_color_stops = color_stops.len() as _;
64        unsafe {
65            from_glib_full(ffi::gsk_repeating_radial_gradient_node_new(
66                bounds.to_glib_none().0,
67                center.to_glib_none().0,
68                hradius,
69                vradius,
70                start,
71                end,
72                color_stops.to_glib_none().0,
73                n_color_stops,
74            ))
75        }
76    }
77}