Skip to content

Commit

Permalink
gdk: Add with_* constructors for RGBA
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaDve committed Aug 16, 2023
1 parent f27af90 commit 1bb696e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions gdk4/src/rgba.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,44 @@ impl RGBA {
}
}

/// Creates an owned [`RGBA`] like `self` but with the given red value.
#[inline]
pub const fn with_red(self, red: f32) -> Self {
Self {
inner: ffi::GdkRGBA { red, ..self.inner },
}
}

/// Creates an owned [`RGBA`] like `self` but with the given green value.
#[inline]
pub const fn with_green(self, green: f32) -> Self {
Self {
inner: ffi::GdkRGBA {
green,
..self.inner
},
}
}

/// Creates an owned [`RGBA`] like `self` but with the given blue value.
#[inline]
pub const fn with_blue(self, blue: f32) -> Self {
Self {
inner: ffi::GdkRGBA { blue, ..self.inner },
}
}

/// Creates an owned [`RGBA`] like `self` but with the given alpha value.
#[inline]
pub const fn with_alpha(self, alpha: f32) -> Self {
Self {
inner: ffi::GdkRGBA {
alpha,
..self.inner
},
}
}

// rustdoc-stripper-ignore-next
/// Creates a new builder-pattern struct instance to construct [`RGBA`] objects.
///
Expand Down

0 comments on commit 1bb696e

Please sign in to comment.