@@ -79,6 +79,84 @@ impl RGBA {
79
79
}
80
80
}
81
81
82
+ // rustdoc-stripper-ignore-next
83
+ /// Creates an owned [`RGBA`] like `self` but with the given red value.
84
+ ///
85
+ /// # Example
86
+ ///
87
+ /// ```
88
+ /// # use gdk4::RGBA;
89
+ ///
90
+ /// let rgba = RGBA::new(1.0, 1.0, 1.0, 1.0);
91
+ /// assert_eq!(rgba.with_red(0.5), RGBA::new(0.5, 1.0, 1.0, 1.0));
92
+ /// ```
93
+ #[ inline]
94
+ pub const fn with_red ( self , red : f32 ) -> Self {
95
+ Self {
96
+ inner : ffi:: GdkRGBA { red, ..self . inner } ,
97
+ }
98
+ }
99
+
100
+ // rustdoc-stripper-ignore-next
101
+ /// Creates an owned [`RGBA`] like `self` but with the given green value.
102
+ ///
103
+ /// # Example
104
+ ///
105
+ /// ```
106
+ /// # use gdk4::RGBA;
107
+ ///
108
+ /// let rgba = RGBA::new(1.0, 1.0, 1.0, 1.0);
109
+ /// assert_eq!(rgba.with_green(0.5), RGBA::new(1.0, 0.5, 1.0, 1.0));
110
+ /// ```
111
+ #[ inline]
112
+ pub const fn with_green ( self , green : f32 ) -> Self {
113
+ Self {
114
+ inner : ffi:: GdkRGBA {
115
+ green,
116
+ ..self . inner
117
+ } ,
118
+ }
119
+ }
120
+
121
+ // rustdoc-stripper-ignore-next
122
+ /// Creates an owned [`RGBA`] like `self` but with the given blue value.
123
+ ///
124
+ /// # Example
125
+ ///
126
+ /// ```
127
+ /// # use gdk4::RGBA;
128
+ ///
129
+ /// let rgba = RGBA::new(1.0, 1.0, 1.0, 1.0);
130
+ /// assert_eq!(rgba.with_blue(0.5), RGBA::new(1.0, 1.0, 0.5, 1.0));
131
+ /// ```
132
+ #[ inline]
133
+ pub const fn with_blue ( self , blue : f32 ) -> Self {
134
+ Self {
135
+ inner : ffi:: GdkRGBA { blue, ..self . inner } ,
136
+ }
137
+ }
138
+
139
+ // rustdoc-stripper-ignore-next
140
+ /// Creates an owned [`RGBA`] like `self` but with the given alpha value.
141
+ ///
142
+ /// # Example
143
+ ///
144
+ /// ```
145
+ /// # use gdk4::RGBA;
146
+ ///
147
+ /// let rgba = RGBA::new(1.0, 1.0, 1.0, 1.0);
148
+ /// assert_eq!(rgba.with_alpha(0.5), RGBA::new(1.0, 1.0, 1.0, 0.5));
149
+ /// ```
150
+ #[ inline]
151
+ pub const fn with_alpha ( self , alpha : f32 ) -> Self {
152
+ Self {
153
+ inner : ffi:: GdkRGBA {
154
+ alpha,
155
+ ..self . inner
156
+ } ,
157
+ }
158
+ }
159
+
82
160
// rustdoc-stripper-ignore-next
83
161
/// Creates a new builder-pattern struct instance to construct [`RGBA`] objects.
84
162
///
0 commit comments