mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 14:58:05 +08:00
Make node trait consume self
This commit is contained in:
@@ -14,11 +14,11 @@ pub struct Color {
|
||||
}
|
||||
|
||||
impl Color {
|
||||
pub const BLACK: Color = Color::from_unsafe(0., 0., 0.);
|
||||
pub const WHITE: Color = Color::from_unsafe(1., 1., 1.);
|
||||
pub const RED: Color = Color::from_unsafe(1., 0., 0.);
|
||||
pub const GREEN: Color = Color::from_unsafe(0., 1., 0.);
|
||||
pub const BLUE: Color = Color::from_unsafe(0., 0., 1.);
|
||||
pub const BLACK: Color = Color::from_rgbf32_unchecked(0., 0., 0.);
|
||||
pub const WHITE: Color = Color::from_rgbf32_unchecked(1., 1., 1.);
|
||||
pub const RED: Color = Color::from_rgbf32_unchecked(1., 0., 0.);
|
||||
pub const GREEN: Color = Color::from_rgbf32_unchecked(0., 1., 0.);
|
||||
pub const BLUE: Color = Color::from_rgbf32_unchecked(0., 0., 1.);
|
||||
|
||||
/// Returns `Some(Color)` if `red`, `green`, `blue` and `alpha` have a valid value. Negative numbers (including `-0.0`), NaN, and infinity are not valid values and return `None`.
|
||||
/// Alpha values greater than `1.0` are not valid.
|
||||
@@ -40,7 +40,12 @@ impl Color {
|
||||
}
|
||||
|
||||
/// Return an opaque `Color` from given `f32` RGB channels.
|
||||
pub const fn from_unsafe(red: f32, green: f32, blue: f32) -> Color {
|
||||
pub const fn from_rgbaf32_unchecked(red: f32, green: f32, blue: f32, alpha: f32) -> Color {
|
||||
Color { red, green, blue, alpha }
|
||||
}
|
||||
|
||||
/// Return an opaque `Color` from given `f32` RGB channels.
|
||||
pub const fn from_rgbf32_unchecked(red: f32, green: f32, blue: f32) -> Color {
|
||||
Color { red, green, blue, alpha: 1. }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user