circulartext commited on
Commit
47d69ec
·
verified ·
1 Parent(s): 643efe4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +87 -43
app.py CHANGED
@@ -9,51 +9,76 @@ generator = pipeline('text-generation', model='distilgpt2') # Lightweight model
9
  SPECIAL_WORDS = ['weather', 'sun', 'middle', 'summer', 'heat']
10
 
11
  def generate_circular_text_design(word):
12
- """Generate a simple animated design for a word using CSS animations."""
13
  # Controlled randomization parameters
14
  fonts = [
15
  "'Dosis', sans-serif",
16
  "'Josefin Sans', sans-serif",
17
  "'Orbitron', sans-serif",
18
- "'Roboto Condensed', sans-serif"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  ]
20
- font_size = random.choice([18, 20, 22, 24])
21
- skew_angle = random.choice([-15, -10, 0, 10, 15])
22
- base_color = f'#{random.randint(0, 0xFFFFFF):06x}'
23
-
24
- # Unique animation name
25
- animation_name = f"animation_{random.randint(0, 10000)}"
26
-
27
- # CSS Keyframes
28
- keyframes = f"""
29
- @keyframes {animation_name} {{
30
- 0% {{ transform: skew({skew_angle}deg); color: {base_color}; }}
31
- 50% {{ transform: skew({-skew_angle}deg); color: {base_color}; }}
32
- 100% {{ transform: skew({skew_angle}deg); color: {base_color}; }}
33
- }}
34
- """
35
-
36
- # Style properties
37
- style = {
38
- 'font-family': random.choice(fonts),
39
- 'font-size': f'{font_size}px',
40
- 'color': base_color,
41
- 'display': 'inline-block',
42
- 'animation': f'{animation_name} 2s infinite',
43
- 'margin': '0 2px'
44
- }
45
-
46
- # Convert style to inline CSS
47
- style_str = '; '.join([f'{k}: {v}' for k, v in style.items()])
48
-
49
- # Construct HTML with embedded style and animation
50
- styled_word = f'''
51
- <style>
52
- {keyframes}
53
- </style>
54
- <span style="{style_str}">{word}</span>
55
- '''
56
- return styled_word
 
 
 
 
 
 
 
57
 
58
  def process_text(input_text):
59
  """Process text and apply special styling to matching words."""
@@ -87,11 +112,30 @@ def process_text(input_text):
87
  final_output = f"""
88
  <html>
89
  <head>
90
- <!-- Include only necessary fonts -->
91
- <link href='https://fonts.googleapis.com/css2?family=Dosis&family=Josefin+Sans&family=Orbitron&family=Roboto+Condensed&display=swap' rel='stylesheet'>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  </head>
93
- <body style='background-color: #000; color: #fff; padding: 20px; font-size: 18px; line-height: 1.6; font-family: "Josefin Sans", sans-serif;'>
94
- <div style='max-width: 800px; margin: auto;'>{output_html}</div>
95
  </body>
96
  </html>
97
  """
 
9
  SPECIAL_WORDS = ['weather', 'sun', 'middle', 'summer', 'heat']
10
 
11
  def generate_circular_text_design(word):
12
+ """Generate a styled design for a word by styling each letter individually."""
13
  # Controlled randomization parameters
14
  fonts = [
15
  "'Dosis', sans-serif",
16
  "'Josefin Sans', sans-serif",
17
  "'Orbitron', sans-serif",
18
+ "'Roboto Condensed', sans-serif",
19
+ "'VT323', monospace",
20
+ "'Rajdhani', sans-serif",
21
+ "'Anton', sans-serif",
22
+ "'Caveat', cursive",
23
+ "'Patrick Hand', cursive",
24
+ "'Nothing You Could Do', cursive",
25
+ "'Reenie Beanie', cursive",
26
+ "'Patrick Hand', cursive",
27
+ "'Raleway', sans-serif",
28
+ "'Open Sans Condensed', sans-serif",
29
+ "'Poiret One', cursive",
30
+ "'Indie Flower', cursive",
31
+ "'Pacifico', cursive",
32
+ "'Teko', sans-serif",
33
+ "'Abril Fatface', cursive",
34
+ "'Gloria Hallelujah', cursive",
35
+ "'Righteous', cursive",
36
+ "'Annie Use Your Telescope', cursive"
37
  ]
38
+ font_sizes = [17, 19, 21, 23, 25, 27]
39
+ font_tops = [11, 11, 13, 13, 15, 15]
40
+ letter_spacings = ["-6px", "-4px", "-3px", "-2px", "-1px", "0px", "1px", "2px"]
41
+ text_shadows = [
42
+ "0px 0px 1px",
43
+ "0px 0px 2px",
44
+ "1px 0px 0px",
45
+ "0px 0px 0px",
46
+ "0px 1px 0px",
47
+ "0px 2px 0px",
48
+ "0px 1px 1px",
49
+ "1px 1px 0px",
50
+ "1px 0px 1px"
51
+ ]
52
+ skew_angles = [-10, -5, 0, 5, 10, 15, 20, 25, 30]
53
+
54
+ # Create HTML for each letter with dynamic styling
55
+ letters = list(word)
56
+ styled_letters = []
57
+ for i, letter in enumerate(letters):
58
+ style = {
59
+ 'font-family': random.choice(fonts),
60
+ 'line-height': '110%',
61
+ 'font-size': f'{random.choice(font_sizes)}px',
62
+ 'letter-spacing': random.choice(letter_spacings),
63
+ 'text-shadow': random.choice(text_shadows),
64
+ 'transform': f'skew({random.choice(skew_angles)}deg)',
65
+ 'margin-top': f'{random.uniform(-0.1, 0.1):.2f}cm',
66
+ 'position': 'relative',
67
+ 'top': f'{random.choice(font_tops)}px',
68
+ 'color': f'#{random.randint(0, 0xFFFFFF):06x}',
69
+ 'display': 'inline-block',
70
+ 'margin': '0 1px'
71
+ }
72
+
73
+ # Convert style to inline CSS
74
+ style_str = '; '.join([f'{k}: {v}' for k, v in style.items()])
75
+
76
+ # Assign a unique class name for possible future reference (if needed)
77
+ styled_letter = f'<div class="styled-letter" style="{style_str}">{letter}</div>'
78
+ styled_letters.append(styled_letter)
79
+
80
+ # Wrap styled letters in a flex container
81
+ return f'<div style="display: flex; align-items: baseline;">{" ".join(styled_letters)}</div>'
82
 
83
  def process_text(input_text):
84
  """Process text and apply special styling to matching words."""
 
112
  final_output = f"""
113
  <html>
114
  <head>
115
+ <!-- Include all necessary fonts -->
116
+ <link href="https://fonts.googleapis.com/css2?family=VT323&display=swap" rel="stylesheet">
117
+ <link href="https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@100&display=swap" rel="stylesheet">
118
+ <link href="https://fonts.googleapis.com/css2?family=Rajdhani:wght@300&display=swap" rel="stylesheet">
119
+ <link href="https://fonts.googleapis.com/css2?family=Anton&display=swap" rel="stylesheet">
120
+ <link href="https://fonts.googleapis.com/css2?family=Caveat&display=swap" rel="stylesheet">
121
+ <link href="https://fonts.googleapis.com/css2?family=Patrick+Hand&display=swap" rel="stylesheet">
122
+ <link href="https://fonts.googleapis.com/css2?family=Nothing+You+Could+Do&display=swap" rel="stylesheet">
123
+ <link href="https://fonts.googleapis.com/css2?family=Reenie+Beanie&display=swap" rel="stylesheet">
124
+ <link href="https://fonts.googleapis.com/css2?family=Orbitron&display=swap" rel="stylesheet">
125
+ <link href="https://fonts.googleapis.com/css?family=Raleway:500" rel="stylesheet" type="text/css">
126
+ <link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:700|Oswald:300" rel="stylesheet" type="text/css">
127
+ <link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:700|Oswald:200" rel="stylesheet" type="text/css">
128
+ <link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" rel="stylesheet" type="text/css">
129
+ <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet" type="text/css">
130
+ <link href="https://fonts.googleapis.com/css?family=Poiret+One|Dosis:300|Fjalla+One" rel="stylesheet" type="text/css">
131
+ <link href="https://fonts.googleapis.com/css?family=Indie+Flower|Lobster" rel="stylesheet" type="text/css">
132
+ <link href="https://fonts.googleapis.com/css?family=Pacifico|Shadows+Into+Light|Dancing+Script|Amatic+SC" rel="stylesheet" type="text/css">
133
+ <link href="https://fonts.googleapis.com/css?family=Teko" rel="stylesheet" type="text/css">
134
+ <link href="https://fonts.googleapis.com/css?family=Abril+Fatface|Josefin+Sans|Gloria+Hallelujah|'Roboto Slab'|Righteous|Sacramento|Yellowtail" rel="stylesheet">
135
+ <link href="https://fonts.googleapis.com/css?family=Annie+Use+Your+Telescope|Just+Me+Again+Down+Here|Nixie+One|Six+Caps|Unkempt" rel="stylesheet">
136
  </head>
137
+ <body style='background-color: #000; color: #fff; font-size: 18px; line-height: 1.6; font-family: "Josefin Sans", sans-serif;'>
138
+ <div style='max-width: 800px; margin: auto; padding: 20px;'>{output_html}</div>
139
  </body>
140
  </html>
141
  """