Spaces:
Sleeping
Sleeping
import gradio as gr | |
# Function to change background color based on RGB values | |
def change_bg_color(r, g, b): | |
color = f"rgb({r}, {g}, {b})" | |
return f"<div style='background-color:{color}; width:100vw; height:100vh;'></div>" | |
# Create Gradio interface | |
with gr.Blocks(fill_width=True) as demo: | |
with gr.Row(): | |
r_slider = gr.Slider(0, 255, label="Red", value=128) | |
g_slider = gr.Slider(0, 255, label="Green", value=128) | |
b_slider = gr.Slider(0, 255, label="Blue", value=128) | |
output = gr.HTML() | |
# Update background color when any slider changes | |
r_slider.change(change_bg_color, inputs=[r_slider, g_slider, b_slider], outputs=output) | |
g_slider.change(change_bg_color, inputs=[r_slider, g_slider, b_slider], outputs=output) | |
b_slider.change(change_bg_color, inputs=[r_slider, g_slider, b_slider], outputs=output) | |
demo.launch() | |