andreyorst / powerline.kak

Kakoune modeline, but with passion
MIT License
50 stars 8 forks source link

Alpha channel for `rgba:` colours is not rendered #22

Closed Qeole closed 2 years ago

Qeole commented 2 years ago

Problem description

Colours with alpha channel (for transparency), passed with "rgba:RRGGBBAA" are not rendered as expected in the modeline (the alpha channel is apparently ignored).

(Not sure if the issue is related to Powerline or to Kakoune, though. Could it be solved by reworking the plug-in to use faces instead of colours, as you mentioned in another open issue? Also I'm not sure many people try using colours with alpha in Powerline themes, but I figured it might offer a nice way to create some monochrome “gradient”, a bit like the Gruvbox colors for example, without having to find all the different hexa codes).

Steps to reproduce

hook global ModuleLoaded powerline %{ require-module powerline_test }

provide-module powerline_test %§
set-option -add global powerline_themes "test"

define-command -hidden powerline-theme-test %{
    declare-option -hidden str powerline_color00 "rgba:00000040" # fg: bufname
    declare-option -hidden str powerline_color03 "rgba:ffffffa0" # bg: bufname
}
§

plug "andreyorst/powerline.kak" defer powerline %{
    powerline-separator global triangle
} defer powerline_gruvbox %{
    powerline-theme test
} config %{
    powerline-start
}

What should happen

Kakoune supports alpha channels for colours, and I would expect some transparency to be applied, and the colours to blend in with the background, for example. Specifying alpha channels for :colorscheme themes works, for example.

What happens instead

Plain colours are used, the alpha channel is not taken into account, as if they had been specified in rgb:.

Environment information

Kakoune version: v2021.11.08-59-g9acd4e62dc48 OS version: Ubuntu 20.04 sh executable version: Not sure what Kakoune calls. I run with zsh 5.8 but sh is dash 0.5.10.2-6.

andreyorst commented 2 years ago

(Not sure if the issue is related to Powerline or to Kakoune, though.

Does transparency work with standard modeline? What is the expected outcome here — to be able to see the buffer contents thru the modeline? I'm worried that this will make the modeline indistinguishable from the text, or hard to decipher

Qeole commented 2 years ago

Does transparency work with standard modeline?

No. I've been experimenting some more, and the rgba colour is passed correctly from Powerline to Kakoune. Manually editing the modelinefmt when Powerline is disabled gives the same results. So the issue is not related to Powerline, apologies, we can probably close it.

When experimenting I also realise that transparency works somewhat: It doesn't work at all for the background colour, but the foreground colour uses it. Only it doesn't blend the colour with the background colour of the window, but uses (it seems) the default colour as a base instead.

What is the expected outcome here — to be able to see the buffer contents thru the modeline? I'm worried that this will make the modeline indistinguishable from the text, or hard to decipher

No, the objective is to have the text or the block blend in with the colour “below” them, which in my mind would be the background colour for the whole window. This way, I would be able to implement various shades of a colour by just changing the alpha channel. For example, I would re-create the Gruvbox theme with just one hexa code for the background, and then by varying the alpha value (see picture), instead of working out the hexa codes of each different shade.

modeline

But it looks like the foreground is not mixed with the background colour of the window (instead with default), and transparency for the background in the modeline does not work at all for some reason. I'll look some more and open an issue on the Kakoune repo if I don't figure it out.

andreyorst commented 2 years ago

I'm not sure about the implementation of the transparency feature in Kakoune, as I've never investigated what colors get mixed. But given that you were able to achieve some degree of transparency I guess it's not a powerline issue, so I'm closing this.

Qeole commented 2 years ago

Follow-up: This can work under certain conditions, namely if we use a base colour in the face and this base is expressed as rgb: or rgba:.

But we can maybe make this easier in Kakoune. See this PR for details https://github.com/mawww/kakoune/pull/4543

[EDIT] Oops, no, doesn't work :/