summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2019-12-04 04:28:07 +0100
committerLibravatar GitHub <noreply@github.com>2019-12-04 04:28:07 +0100
commitd1eb187e2673150b6c3f9fed0c15a1804ce0d75b (patch)
tree18ba66323f0aa2f3b8c25b80d1d74acfa41c13a2 /core
parent6c145bbb239e87569bf4aa797ea7f8d34e25cf62 (diff)
parent2144109dd7f9ab811393d3d725ba1cb7371aa672 (diff)
downloadiced-d1eb187e2673150b6c3f9fed0c15a1804ce0d75b.tar.gz
iced-d1eb187e2673150b6c3f9fed0c15a1804ce0d75b.tar.bz2
iced-d1eb187e2673150b6c3f9fed0c15a1804ce0d75b.zip
Merge pull request #90 from hecrj/feature/image-from-bytes
Load images from memory and image viewer example
Diffstat (limited to '')
-rw-r--r--core/CHANGELOG.md5
-rw-r--r--core/src/color.rs12
2 files changed, 17 insertions, 0 deletions
diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md
index 30050238..c0796e66 100644
--- a/core/CHANGELOG.md
+++ b/core/CHANGELOG.md
@@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
+### Added
+- `Color::from_rgb8` to easily build a `Color` from its hexadecimal representation. [#90]
+
+[#90]: https://github.com/hecrj/iced/pull/90
+
## [0.1.0] - 2019-11-25
### Added
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