Update app.py
Browse files
app.py
CHANGED
|
@@ -15,29 +15,22 @@ def hex_to_rgb(hex_color: str) -> tuple[int, int, int]:
|
|
| 15 |
hex_color = hex_color.lstrip('#')
|
| 16 |
return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
|
| 17 |
|
| 18 |
-
def
|
| 19 |
-
base_rgb = hex_to_rgb(
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
shades = []
|
| 23 |
-
# Generate 10 shades (from c100 to c950)
|
| 24 |
-
for i in range(100, 1050, 100):
|
| 25 |
-
factor = i / 1000
|
| 26 |
-
new_v = max(0, min(hsv[2] * factor, 1)) # Ensure the value is within [0, 1]
|
| 27 |
-
rgb_shade = colorsys.hsv_to_rgb(hsv[0], hsv[1], new_v)
|
| 28 |
-
shades.append(tuple(int(v * 255) for v in rgb_shade))
|
| 29 |
|
|
|
|
| 30 |
return colors.Color(*shades)
|
| 31 |
|
| 32 |
class MPGPoster(Base):
|
| 33 |
def __init__(
|
| 34 |
self,
|
| 35 |
*,
|
| 36 |
-
primary_hue: colors.Color | str =
|
| 37 |
-
background_hue: colors.Color | str =
|
| 38 |
-
secondary_dark_hue: colors.Color | str =
|
| 39 |
-
secondary_light_hue: colors.Color | str =
|
| 40 |
-
tertiary_highlight_hue: colors.Color | str =
|
| 41 |
spacing_size: sizes.Size | str = sizes.spacing_md,
|
| 42 |
radius_size: sizes.Size | str = sizes.radius_md,
|
| 43 |
text_size: sizes.Size | str = sizes.text_lg,
|
|
|
|
| 15 |
hex_color = hex_color.lstrip('#')
|
| 16 |
return tuple(int(hex_color[i:i+2], 16) for i in (0, 2, 4))
|
| 17 |
|
| 18 |
+
def create_color_shades(hex_color: str) -> colors.Color:
|
| 19 |
+
base_rgb = hex_to_rgb(hex_color)
|
| 20 |
+
shades = [base_rgb] * 10 # Duplicate the base color for simplicity
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
# You can adjust this to create actual different shades if needed
|
| 23 |
return colors.Color(*shades)
|
| 24 |
|
| 25 |
class MPGPoster(Base):
|
| 26 |
def __init__(
|
| 27 |
self,
|
| 28 |
*,
|
| 29 |
+
primary_hue: colors.Color | str = create_color_shades("#f47317"),
|
| 30 |
+
background_hue: colors.Color | str = create_color_shades("#f6f6f6ff"),
|
| 31 |
+
secondary_dark_hue: colors.Color | str = create_color_shades("#006c66"),
|
| 32 |
+
secondary_light_hue: colors.Color | str = create_color_shades("#6ad5bc"),
|
| 33 |
+
tertiary_highlight_hue: colors.Color | str = create_color_shades("#fbf22c"),
|
| 34 |
spacing_size: sizes.Size | str = sizes.spacing_md,
|
| 35 |
radius_size: sizes.Size | str = sizes.radius_md,
|
| 36 |
text_size: sizes.Size | str = sizes.text_lg,
|