summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-10-07 03:56:16 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-10-07 03:56:16 +0200
commitc9510db551893775d3233340dd114d971e24323a (patch)
treea48fe9009c0fa604ea5e861ee3a8aa35ae3d64c3 /core
parent70c17b053b10741f6018b2559bb46c5f289cadb9 (diff)
downloadiced-c9510db551893775d3233340dd114d971e24323a.tar.gz
iced-c9510db551893775d3233340dd114d971e24323a.tar.bz2
iced-c9510db551893775d3233340dd114d971e24323a.zip
Render colored quads
Diffstat (limited to 'core')
-rw-r--r--core/src/color.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/src/color.rs b/core/src/color.rs
index 5cc3a084..2b64c78d 100644
--- a/core/src/color.rs
+++ b/core/src/color.rs
@@ -16,4 +16,23 @@ impl Color {
b: 0.0,
a: 1.0,
};
+
+ pub fn into_linear(self) -> [f32; 4] {
+ // As described in:
+ // https://en.wikipedia.org/wiki/SRGB#The_reverse_transformation
+ fn linear_component(u: f32) -> f32 {
+ if u < 0.04045 {
+ u / 12.92
+ } else {
+ ((u + 0.055) / 1.055).powf(2.4)
+ }
+ }
+
+ [
+ linear_component(self.r),
+ linear_component(self.g),
+ linear_component(self.b),
+ self.a,
+ ]
+ }
}