diff options
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/background.rs | 6 | ||||
-rw-r--r-- | core/src/color.rs | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/core/src/background.rs b/core/src/background.rs index 98047172..2f75e45c 100644 --- a/core/src/background.rs +++ b/core/src/background.rs @@ -7,3 +7,9 @@ pub enum Background { Color(Color), // TODO: Add gradient and image variants } + +impl From<Color> for Background { + fn from(color: Color) -> Self { + Background::Color(color) + } +}
\ No newline at end of file diff --git a/core/src/color.rs b/core/src/color.rs index 7b3649ad..c28e784f 100644 --- a/core/src/color.rs +++ b/core/src/color.rs @@ -37,6 +37,13 @@ impl Color { } } + /// Creates a [`Color`] from its RGB components. + /// + /// [`Color`]: struct.Color.html + pub fn from_rgb(r: f32, g: f32, b: f32) -> Color { + Color { r, g, b, a: 1.0 } + } + /// Converts the [`Color`] into its linear values. /// /// [`Color`]: struct.Color.html |