Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: add transparency to framebuffer on linux #2172

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

drakbar
Copy link

@drakbar drakbar commented Sep 10, 2023


name: Linux Viewport Tranparent Framebuffer
about: add transparency to framebuffer on linux
title: Linux: add transparency to viewport framebuffer
assignees: ''


Description:

This feature enables adjustment of the viewport's clear color alpha channel. Assigning a value of 0 is consider fully transparent while a value of 255 is fully opaque. This is a linux only feature. The following sample code is a demonstration of the effect.

import dearpygui.dearpygui as dpg

clear_color = {
    "red"  : 0, "green" : 0,
    "blue" : 0, "alpha" : 255,
}

dpg.create_context()
dpg.create_viewport(title="Transparency Demo", width=800, height=600)
dpg.set_viewport_clear_color([*clear_color.values()])
dpg.setup_dearpygui()

def channel_cb(sender, app_data):
    key   = dpg.get_item_label(sender)
    value = dpg.get_value(sender)
    clear_color[key] = value
    dpg.set_viewport_clear_color([*clear_color.values()])

with dpg.window(label="Transparent Framebuffer", width=200, height=150):
    dpg.add_slider_int(label="red",callback=channel_cb,default_value=0,min_value=0,max_value=255)
    dpg.add_slider_int(label="green",callback=channel_cb,default_value=0,min_value=0,max_value=255)
    dpg.add_slider_int(label="blue",callback=channel_cb,default_value=0,min_value=0,max_value=255)
    dpg.add_slider_int(label="alpha",callback=channel_cb,default_value=255,min_value=0,max_value=255)

dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
demo.webm

Concerning Areas:

This code is a linux only feature. Similar effects should be achievable in the other operating system specific areas of the code base.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant