Spaces:
Running
Running
File size: 877 Bytes
e874472 fa3bcce e874472 26f993f e874472 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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()
|