diff options
author | 2019-12-04 22:02:07 +0100 | |
---|---|---|
committer | 2019-12-04 22:02:07 +0100 | |
commit | 33ad332ce99fff5de8e50a5b5c98f3ce181c311a (patch) | |
tree | 256269a85712c96d6e43b02c9343a8265599b081 /core | |
parent | ed045b45ba9490b6020618fb13c7dbc3ea5032ab (diff) | |
download | iced-33ad332ce99fff5de8e50a5b5c98f3ce181c311a.tar.gz iced-33ad332ce99fff5de8e50a5b5c98f3ce181c311a.tar.bz2 iced-33ad332ce99fff5de8e50a5b5c98f3ce181c311a.zip |
Implemented `From<Color` for `Background`
Diffstat (limited to 'core')
-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 |