endaaman / tym

Lua-configurable terminal emulator
MIT License
185 stars 14 forks source link

Support for transparency in color_background #74

Closed eko234 closed 2 years ago

eko234 commented 2 years ago

Hi, I'm trying out tym and I wanted to know if you plan on providing support for transparent background colors, if I set a background_image and set color_background to NONE, it indeed is totally transparent, but when I try to use a rgba or hex color with transparency it doesn't work, it would be really cool if one could customize this, thanks for your work, have a nice one.

endaaman commented 2 years ago

Hello @eko234

Thanks for reporting. I tested by making the following config named as trans.lua

local tym = require('tym')

tym.set_config({
    color_background = 'rgba(255, 0, 0, 0.5)',
    color_window_background = 'rgba(0, 255, 0, 0.5)',
    padding_horizontal = 30,
  })

and starting tym with $ tym -u ./trans.lua, then I got the screenshot.

Screenshot_20220217_131711

We can confirm the terminal and padding areas are transparent by each own color.

It is the important point that we must provide the color in rbga(R, G, B, A) style to make it transparent. 32 bit hex like #FF0000AA does not work!

My environment is KDE plasma 5.23.5 (X11 ver), Qt 5.15 and tym 3.1.3.

tym also provides some helper functions that are tym.rgb_to_hex(r, g, b), tym.rgba_to_color(r, g, b, a), tym.color_to_rgba(color). The latter 2 convert the color into between rgba(R, G, B, A) string and integers of RGBA color values(e.g.'rgba(255, 0, 0, 128)' <-> 255 0 0 128). There is the example in Pro tips: Scroll mouse wheel to set window transparency/font scale in README.md

With reading this, if you stall have the problem, please let me know your configuration and desktop environment.