summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-30 02:14:56 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-11-30 02:14:56 +0100
commitcdd34e1e4b741a97dc6da8813a00d792eda8172a (patch)
treead074a7c840d379aadcf4efb9fb0c25df30479a4 /core
parent505588d5851fed8a3bb334edacfa6d96c545d562 (diff)
downloadiced-cdd34e1e4b741a97dc6da8813a00d792eda8172a.tar.gz
iced-cdd34e1e4b741a97dc6da8813a00d792eda8172a.tar.bz2
iced-cdd34e1e4b741a97dc6da8813a00d792eda8172a.zip
Implement `image` viewer example
Diffstat (limited to 'core')
-rw-r--r--core/src/color.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/src/color.rs b/core/src/color.rs
index ec48c185..7b3649ad 100644
--- a/core/src/color.rs
+++ b/core/src/color.rs
@@ -25,6 +25,18 @@ impl Color {
a: 1.0,
};
+ /// Creates a [`Color`] from its RGB8 components.
+ ///
+ /// [`Color`]: struct.Color.html
+ pub fn from_rgb8(r: u8, g: u8, b: u8) -> Color {
+ Color {
+ r: f32::from(r) / 255.0,
+ g: f32::from(g) / 255.0,
+ b: f32::from(b) / 255.0,
+ a: 1.0,
+ }
+ }
+
/// Converts the [`Color`] into its linear values.
///
/// [`Color`]: struct.Color.html