From 33ad332ce99fff5de8e50a5b5c98f3ce181c311a Mon Sep 17 00:00:00 2001 From: Malte Veerman Date: Wed, 4 Dec 2019 22:02:07 +0100 Subject: Implemented `From 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 -- cgit