Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
# Function to change background color based on RGB values
|
4 |
+
def change_bg_color(r, g, b):
|
5 |
+
color = f"rgb({r}, {g}, {b})"
|
6 |
+
return f"<div style='background-color:{color}; height:200px;'></div>"
|
7 |
+
|
8 |
+
# Create Gradio interface
|
9 |
+
with gr.Blocks() as demo:
|
10 |
+
with gr.Row():
|
11 |
+
r_slider = gr.Slider(0, 255, label="Red", value=128)
|
12 |
+
g_slider = gr.Slider(0, 255, label="Green", value=128)
|
13 |
+
b_slider = gr.Slider(0, 255, label="Blue", value=128)
|
14 |
+
|
15 |
+
output = gr.HTML()
|
16 |
+
|
17 |
+
# Update background color when any slider changes
|
18 |
+
r_slider.change(change_bg_color, inputs=[r_slider, g_slider, b_slider], outputs=output)
|
19 |
+
g_slider.change(change_bg_color, inputs=[r_slider, g_slider, b_slider], outputs=output)
|
20 |
+
b_slider.change(change_bg_color, inputs=[r_slider, g_slider, b_slider], outputs=output)
|
21 |
+
|
22 |
+
demo.launch()
|