Paulo Melo: 1
Change App background to Transparent
1 files changed, 1 insertions(+), 1 deletions(-)
The background is now either transparent or black.
This was the approach suggested by Elias Naur.
Another solution is to leave it as it was and change the gpu/gpu.go
file at line 1004 by removing the opacity test and at line 1011 by removing the opaque()
Note, I just realized that it could also be a window option. So something like:
w := app.NewWindow(app.ClearColor(color.NRGBA{A: 0x00, R: 0x00, G:
0x00, B: 0x00}))
And potentially:
w := app.NewWindow(app.NoClear())
I considered the window option, but preferred the Go-like zero clear
color and the explicit one-liner for setting the background; after all,
not all windows have a white background. Some may even change the
background at runtime, and I'd rather lead people to paint.Fill than an
option.
Like Egon points out, however, it's a bit unsatisfying to need
paint.Fill in almost every program. Further, the default value is subtly
different than it appears: transparent black (0, 0, 0, 0) is not the
same as black (0, 0, 0, 1).
How about we change the default color to transparent black *only* where
Gio is embedded with something else? I did a similar change for the GLFW
example[0] so it could mix custom GL with Gio. You could do the same for
webassembly, because there is always a webpage below the canvas.
Elias
[0] https://gioui.org/commit/84b586ae6ce6de
On Mon, Feb 15, 2021 at 8:23 PM paulo melo <paulo.durrer.melo@gmail.com> wrote:
Elias,
on my initial tests I’ve found the following using the default background as White.
I tryed to explicitly set the background to transparent and found that on the gpu.go file there was a lock to only accept opaque colors.
If we remove this opaque lock I’ve found that it works. Is there any special reason to have this lock?
I believe that this solution should be the best. By default the background is White and if we want it to be another color or transparent we set it as needed.
Do you agree?
What is the lock you're referring to? What did you try that didn't work?
Elias
On 16 Feb 2021, at 08:56, Elias Naur <mail@eliasnaur.com> wrote:
On Mon Feb 15, 2021 at 21:06, Egon Elbre wrote: