Skip to content

Commit 7ca3b0d

Browse files
cyrganinot-fl3
authored andcommitted
remove some inaccurate details in color documentation
1 parent 2c60f75 commit 7ca3b0d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/color.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@ pub use colors::*;
66
#[repr(C)]
77
#[derive(Clone, Copy, Debug, Default, PartialEq)]
88
pub struct Color {
9-
/// Red channel value from 0.0 to 1.0
9+
/// Red channel value from 0.0 to 1.0.
1010
pub r: f32,
11-
/// Green channel value from 0.0 to 1.0
11+
/// Green channel value from 0.0 to 1.0.
1212
pub g: f32,
13-
/// Blue channel value from 0.0 to 1.0
13+
/// Blue channel value from 0.0 to 1.0.
1414
pub b: f32,
15-
/// Alpha channel value from 0.0 to 1.0
15+
/// Alpha channel value from 0.0 to 1.0.
1616
pub a: f32,
1717
}
1818

19-
/// Build a color from 4 components of 0..255 values
20-
/// This is a temporary solution and going to be replaced with const fn,
21-
/// waiting for [this issue](https://github.com/rust-lang/rust/issues/57241) to be resolved.
19+
/// Build a color from 4 components of 0..255 values.
20+
/// This was a temporary solution because [Color::from_rgba] was not a const fn due to
21+
/// [this issue](https://github.com/rust-lang/rust/issues/57241) waiting to be resolved.
22+
/// It is not needed anymore.
2223
#[macro_export]
2324
macro_rules! color_u8 {
2425
($r:expr, $g:expr, $b:expr, $a:expr) => {
@@ -101,8 +102,6 @@ impl Color {
101102
}
102103

103104
/// Build a color from 4 components between 0 and 255.
104-
/// Unfortunately it can't be const fn due to [this issue](https://github.com/rust-lang/rust/issues/57241).
105-
/// When const version is needed "color_u8" macro may be a workaround.
106105
pub const fn from_rgba(r: u8, g: u8, b: u8, a: u8) -> Color {
107106
Color::new(
108107
r as f32 / 255.,
@@ -112,7 +111,7 @@ impl Color {
112111
)
113112
}
114113

115-
/// Build a color from a hexadecimal u32
114+
/// Build a color from a hexadecimal u32.
116115
///
117116
/// # Example
118117
///
@@ -141,6 +140,7 @@ impl Color {
141140
Self::new(vec.x, vec.y, vec.z, vec.w)
142141
}
143142

143+
/// Create a copy of the current color, but with a different alpha value.
144144
pub const fn with_alpha(&self, alpha: f32) -> Color {
145145
Color::new(self.r, self.g, self.b, alpha)
146146
}

0 commit comments

Comments
 (0)