rktjmp / lush.nvim

Create Neovim themes with real-time feedback, export anywhere.
MIT License
1.47k stars 48 forks source link

Transparent function #110

Closed Davincible closed 1 year ago

Davincible commented 1 year ago

Would be to nice get a function like this

hsl("#<hex>").alpha(0.15)

https://github.com/mvllow/modes.nvim/blob/2cd194d1033ba391d87d386735e15963adbc5f51/lua/modes/utils.lua#L23-L40

rktjmp commented 1 year ago

Does mix get you the same effect?

The linked function needs two colors and an alpha which is really a mix/blend strength as neovim doesn't support actual alpha channels (right?).

mix                                                             *lush-color-mix*

Mix one colour into another. Accepts a target color and strength, where the
target is a hsl, hsluv type and strength is between 0-100.

A strength of 0 effectively returns the original color, while 100 will return
the target color.
>
  color.mix(target, 50)
  color.mix(target, 0) == color
  color.mix(target, 100) == target
<

So usage is like

Normal { fg = red, bg = blue },
-- mix 0% bg into yellow, so 100% yellow, "no alpha"
Strong { fg = yellow.mix(Normal.bg, 0) },
-- mix 20% bg into yellow, so 80% yellow, 20% blue, ~80% "alpha"
Weak { fg = yellow.mix(Normal.bg, 20) }
rktjmp commented 1 year ago

Closing as I believe mix is equivalent in practice.

Californian commented 1 year ago

Sorry I'm pretty ignorant here, but isn't blend describing an alpha channel? https://github.com/neovim/neovim/issues/7064

I'm going through the tutorial now, but I don't know how to test blur in the lush spec; I tried Normal { fg = hsl("#FFFFFF"), blend = "50" } but that didn't seem to work (both as a string and number).

rktjmp commented 1 year ago

Please see :h blend

blend={integer}                 *highlight-blend*
    Override the blend level for a highlight group within the popupmenu
    or floating windows. Only takes effect if 'pumblend' or 'winblend'
    is set for the menu or window. See the help at the respective option.

Only effects popupmenu and floating window.

AFAIK if you want a transparent background in your terminal (as implied by trying to set blend on Normal), you need a terminal emulator and compositor that can do that, set the terminal background to be transparent and probably not set a Normal.bg value, never tried myself.