circulartext commited on
Commit
608768f
·
verified ·
1 Parent(s): 36c4c2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -14
app.py CHANGED
@@ -31,9 +31,9 @@ def generate_initial_design(word):
31
  "'Pacifico', cursive",
32
  "'Teko', sans-serif"
33
  ]
34
- font_sizes = ["17px", "19px", "21px", "23px", "25px", "27px"]
35
- font_tops = ["11px", "13px", "15px"]
36
- letter_spacings = ["-6px", "-4px", "-3px", "-2px", "-1px", "0px", "1px", "2px"]
37
  text_shadows = [
38
  "0px 0px 1px",
39
  "0px 0px 2px",
@@ -53,25 +53,31 @@ def generate_initial_design(word):
53
  for i, letter in enumerate(letters):
54
  style = {
55
  'font-family': random.choice(fonts),
56
- 'line-height': '138%',
57
  'font-size': random.choice(font_sizes),
58
  'letter-spacing': random.choice(letter_spacings),
59
  'text-shadow': random.choice(text_shadows),
60
  'transform': f'skew({random.choice(skew_angles)})',
61
- 'margin-top': random.choice(["-0.06cm", "-0.03cm", "0.00cm", "0.03cm", "0.06cm"]),
62
  'position': 'relative',
63
  'top': random.choice(font_tops),
64
  'color': '#000000',
65
  'display': 'inline-block',
66
  'margin': '0 1px',
67
- 'vertical-align': 'baseline'
68
  }
69
 
70
  style_str = '; '.join([f'{k}: {v}' for k, v in style.items()])
71
  styled_letter = f'<span class="styled-letter" style="{style_str}">{letter}</span>'
72
  styled_letters.append(styled_letter)
73
 
74
- return f'<span style="display: inline-flex; align-items: baseline; position: relative;">{" ".join(styled_letters)}</span>'
 
 
 
 
 
 
75
 
76
  def generate_movement_design(word):
77
  """Generate a completely new random design for the movement animation."""
@@ -87,9 +93,9 @@ def generate_movement_design(word):
87
  "'Orbitron', sans-serif",
88
  "'Raleway', sans-serif"
89
  ]
90
- font_sizes = ["17px", "19px", "21px", "23px", "25px", "27px"]
91
- font_tops = ["11px", "13px", "15px"]
92
- letter_spacings = ["-6px", "-4px", "-3px", "-2px", "-1px", "0px", "1px", "2px"]
93
  text_shadows = [
94
  "0px 0px 1px",
95
  "0px 0px 2px",
@@ -124,18 +130,18 @@ def generate_movement_design(word):
124
  for i, letter in enumerate(letters):
125
  style = {
126
  'font-family': random.choice(fonts),
127
- 'line-height': '138%',
128
  'font-size': random.choice(font_sizes),
129
  'letter-spacing': random.choice(letter_spacings),
130
  'text-shadow': random.choice(text_shadows),
131
  'transform': f'skew({random.choice(skew_angles)})',
132
- 'margin-top': random.choice(["-0.06cm", "-0.03cm", "0.00cm", "0.03cm", "0.06cm"]),
133
  'position': 'relative',
134
  'top': random.choice(font_tops),
135
  'color': random_color,
136
  'display': 'inline-block',
137
  'margin': '0 1px',
138
- 'vertical-align': 'baseline',
139
  'animation': f'{animation_name} 0.5s ease-in-out',
140
  'animation-delay': f'{i * 0.1}s'
141
  }
@@ -151,7 +157,10 @@ def generate_movement_design(word):
151
  transition: all 0.3s ease;
152
  }}
153
  </style>
154
- <span style="display: inline-flex; align-items: baseline; position: relative;">
 
 
 
155
  {" ".join(styled_letters)}
156
  </span>
157
  '''
 
31
  "'Pacifico', cursive",
32
  "'Teko', sans-serif"
33
  ]
34
+ font_sizes = ["18px", "19px", "20px"] # Narrower range
35
+ font_tops = ["0px", "1px", "-1px"] # Smaller adjustments
36
+ letter_spacings = ["-1px", "0px", "1px"] # Reduced range
37
  text_shadows = [
38
  "0px 0px 1px",
39
  "0px 0px 2px",
 
53
  for i, letter in enumerate(letters):
54
  style = {
55
  'font-family': random.choice(fonts),
56
+ 'line-height': '1.6', # Consistent with body text
57
  'font-size': random.choice(font_sizes),
58
  'letter-spacing': random.choice(letter_spacings),
59
  'text-shadow': random.choice(text_shadows),
60
  'transform': f'skew({random.choice(skew_angles)})',
61
+ 'margin-top': random.choice(["-0.02cm", "0.00cm", "0.02cm"]), # Reduced range
62
  'position': 'relative',
63
  'top': random.choice(font_tops),
64
  'color': '#000000',
65
  'display': 'inline-block',
66
  'margin': '0 1px',
67
+ 'vertical-align': 'middle'
68
  }
69
 
70
  style_str = '; '.join([f'{k}: {v}' for k, v in style.items()])
71
  styled_letter = f'<span class="styled-letter" style="{style_str}">{letter}</span>'
72
  styled_letters.append(styled_letter)
73
 
74
+ return f'''
75
+ <span style="display: inline-flex;
76
+ align-items: baseline;
77
+ vertical-align: middle;
78
+ margin: 0 2px;">
79
+ {" ".join(styled_letters)}
80
+ </span>'''
81
 
82
  def generate_movement_design(word):
83
  """Generate a completely new random design for the movement animation."""
 
93
  "'Orbitron', sans-serif",
94
  "'Raleway', sans-serif"
95
  ]
96
+ font_sizes = ["18px", "19px", "20px"] # Narrower range
97
+ font_tops = ["0px", "1px", "-1px"] # Smaller adjustments
98
+ letter_spacings = ["-1px", "0px", "1px"] # Reduced range
99
  text_shadows = [
100
  "0px 0px 1px",
101
  "0px 0px 2px",
 
130
  for i, letter in enumerate(letters):
131
  style = {
132
  'font-family': random.choice(fonts),
133
+ 'line-height': '1.6', # Consistent with body text
134
  'font-size': random.choice(font_sizes),
135
  'letter-spacing': random.choice(letter_spacings),
136
  'text-shadow': random.choice(text_shadows),
137
  'transform': f'skew({random.choice(skew_angles)})',
138
+ 'margin-top': random.choice(["-0.02cm", "0.00cm", "0.02cm"]), # Reduced range
139
  'position': 'relative',
140
  'top': random.choice(font_tops),
141
  'color': random_color,
142
  'display': 'inline-block',
143
  'margin': '0 1px',
144
+ 'vertical-align': 'middle',
145
  'animation': f'{animation_name} 0.5s ease-in-out',
146
  'animation-delay': f'{i * 0.1}s'
147
  }
 
157
  transition: all 0.3s ease;
158
  }}
159
  </style>
160
+ <span style="display: inline-flex;
161
+ align-items: baseline;
162
+ vertical-align: middle;
163
+ margin: 0 2px;">
164
  {" ".join(styled_letters)}
165
  </span>
166
  '''