Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom window background/clear color (incl. transparency) support, fixes #272 #371

Merged
merged 1 commit into from
Jun 1, 2020

Conversation

valpackett
Copy link
Contributor

@valpackett valpackett commented May 31, 2020

wgpu would currently ignore the alpha: gfx-rs/wgpu#687

glow (and naively patched wgpu) requires premultiplied alpha, so if you don't multiply the RGB by the A right now, the semi-transparent color would be wrong (too bright).

winit with_transparent doesn't seem necessary — on wayland at least.


for testing:

--- i/examples/counter/src/main.rs
+++ w/examples/counter/src/main.rs
@@ -1,7 +1,12 @@
-use iced::{button, Align, Button, Column, Element, Sandbox, Settings, Text};
+use iced::{
+    button, Align, Button, Color, Column, Element, Sandbox, Settings, Text,
+};

 pub fn main() {
-    Counter::run(Settings::default())
+    Counter::run(Settings {
+        background_color: Color::new(0.1, 0.2, 0.3, 0.3),
+        ..Settings::default()
+    })
 }

 #[derive(Default)]

Screenshot showing both patched wgpu and glow with the same too-bright color (this is not how 0.1,0.2,0.3 is supposed to look like) as a result of not premultiplying alpha:

Screen_2020-05-31-16:46:20-fs8

Of course for Color::TRANSPARENT everything is fine.

…fixes iced-rs#272

wgpu would currently ignore the alpha: gfx-rs/wgpu#687

glow (and naively patched wgpu) requires premultiplied alpha, so if you don't
multiply the RGB by the A right now, the semi-transparent color would be wrong
(too bright).

winit with_transparent doesn't seem necessary.
@hecrj hecrj added the feature New feature or request label Jun 1, 2020
@hecrj hecrj added this to the 0.2.0 milestone Jun 1, 2020
Copy link
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the very least, this adds support for changing the opaque background color.

We can iterate further to properly support transparency. Thanks!

@hecrj hecrj merged commit 2ba9598 into iced-rs:master Jun 1, 2020
@hecrj
Copy link
Member

hecrj commented Jun 1, 2020

Hmm... After thinking a bit more about it, I believe the background color should be able to change at runtime.

I imagine we could add it as an additional Application method. Thus, I am reverting this change for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants