Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
# Color options with their hex codes
|
4 |
+
COLORS = {
|
5 |
+
"red": "#FF0000",
|
6 |
+
"yellow": "#FFD700",
|
7 |
+
"green": "#00FF00",
|
8 |
+
"blue": "#0000FF",
|
9 |
+
"indigo": "#4B0082",
|
10 |
+
"purple": "#800080",
|
11 |
+
"pink": "#FFC0CB",
|
12 |
+
"gray": "#808080"
|
13 |
+
}
|
14 |
+
|
15 |
+
def create_gradient(color_from, color_to):
|
16 |
+
# Create HTML with gradient background
|
17 |
+
html = f"""
|
18 |
+
<div style="
|
19 |
+
width: 200px;
|
20 |
+
height: 200px;
|
21 |
+
background: linear-gradient(45deg, {COLORS[color_from]}, {COLORS[color_to]});
|
22 |
+
border-radius: 8px;
|
23 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
24 |
+
"></div>
|
25 |
+
"""
|
26 |
+
return html
|
27 |
+
|
28 |
+
# Create the Gradio interface
|
29 |
+
with gr.Blocks() as demo:
|
30 |
+
gr.Markdown("# Gradient Color Preview")
|
31 |
+
gr.Markdown("Select colors to preview how they would look in your space's thumbnail.")
|
32 |
+
|
33 |
+
with gr.Row():
|
34 |
+
color_from = gr.Dropdown(
|
35 |
+
choices=list(COLORS.keys()),
|
36 |
+
value="blue",
|
37 |
+
label="Color From"
|
38 |
+
)
|
39 |
+
color_to = gr.Dropdown(
|
40 |
+
choices=list(COLORS.keys()),
|
41 |
+
value="purple",
|
42 |
+
label="Color To"
|
43 |
+
)
|
44 |
+
|
45 |
+
preview = gr.HTML(label="Preview")
|
46 |
+
|
47 |
+
# Update preview when colors change
|
48 |
+
color_from.change(
|
49 |
+
fn=create_gradient,
|
50 |
+
inputs=[color_from, color_to],
|
51 |
+
outputs=preview
|
52 |
+
)
|
53 |
+
color_to.change(
|
54 |
+
fn=create_gradient,
|
55 |
+
inputs=[color_from, color_to],
|
56 |
+
outputs=preview
|
57 |
+
)
|
58 |
+
|
59 |
+
# Initial preview
|
60 |
+
preview.value = create_gradient("blue", "purple")
|
61 |
+
|
62 |
+
if __name__ == "__main__":
|
63 |
+
demo.launch()
|