diff options
author | 2022-11-03 04:41:27 +0100 | |
---|---|---|
committer | 2022-11-03 04:41:27 +0100 | |
commit | 9a02d60ba51a91049466caa46db73d741520e051 (patch) | |
tree | a281f5d996b20b65d7b01529f9241a311c21d393 | |
parent | 62465842099908f9e50b8edabfec709b37b1ade3 (diff) | |
download | iced-9a02d60ba51a91049466caa46db73d741520e051.tar.gz iced-9a02d60ba51a91049466caa46db73d741520e051.tar.bz2 iced-9a02d60ba51a91049466caa46db73d741520e051.zip |
Convert colors to linear RGB in `gradient` pipelines
Diffstat (limited to '')
-rw-r--r-- | glow/src/triangle/gradient.rs | 10 | ||||
-rw-r--r-- | wgpu/src/triangle/gradient.rs | 15 |
2 files changed, 13 insertions, 12 deletions
diff --git a/glow/src/triangle/gradient.rs b/glow/src/triangle/gradient.rs index ad41dffd..5225612e 100644 --- a/glow/src/triangle/gradient.rs +++ b/glow/src/triangle/gradient.rs @@ -86,10 +86,12 @@ impl Program { for (index, stop) in linear.color_stops.iter().enumerate().take(16) { - stops[index * 8] = stop.color.r; - stops[(index * 8) + 1] = stop.color.g; - stops[(index * 8) + 2] = stop.color.b; - stops[(index * 8) + 3] = stop.color.a; + let [r, g, b, a] = stop.color.into_linear(); + + stops[index * 8] = r; + stops[(index * 8) + 1] = g; + stops[(index * 8) + 2] = b; + stops[(index * 8) + 3] = a; stops[(index * 8) + 4] = stop.offset; stops[(index * 8) + 5] = 0.; stops[(index * 8) + 6] = 0.; diff --git a/wgpu/src/triangle/gradient.rs b/wgpu/src/triangle/gradient.rs index 92c176af..6698bb4e 100644 --- a/wgpu/src/triangle/gradient.rs +++ b/wgpu/src/triangle/gradient.rs @@ -168,14 +168,13 @@ impl Pipeline { let stops: Vec<ColorStop> = linear .color_stops .iter() - .map(|stop| ColorStop { - offset: stop.offset, - color: Vec4::new( - stop.color.r, - stop.color.g, - stop.color.b, - stop.color.a, - ), + .map(|stop| { + let [r, g, b, a] = stop.color.into_linear(); + + ColorStop { + offset: stop.offset, + color: Vec4::new(r, g, b, a), + } }) .collect(); |