circulartext commited on
Commit
d95ec32
·
verified ·
1 Parent(s): 34be810

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -33
app.py CHANGED
@@ -55,18 +55,22 @@ def generate_transition_style(word, animation_id):
55
  # Create unique animation name
56
  animation_name = f"sneakStyle_{animation_id}_{i}"
57
 
58
- # Create keyframes that go: normal → styled → normal
59
  keyframes_css += f"""
60
  @keyframes {animation_name} {{
61
  0% {{
62
- font-family: 'Josefin Sans', sans-serif;
63
- font-size: 16px;
64
- letter-spacing: 0px;
65
- color: #000000;
66
- text-shadow: 0px 0px 0px #000;
67
- transform: skew(0deg) scale(1);
68
- top: 0px;
69
- margin-top: 0.00cm;
 
 
 
 
70
  }}
71
  25% {{
72
  font-family: {styled_font_family};
@@ -99,43 +103,41 @@ def generate_transition_style(word, animation_id):
99
  margin-top: {styled_margin_top};
100
  }}
101
  100% {{
102
- font-family: 'Josefin Sans', sans-serif;
103
- font-size: 16px;
104
- letter-spacing: 0px;
105
- color: #000000;
106
- text-shadow: 0px 0px 0px #000;
107
- transform: skew(0deg) scale(1);
108
- top: 0px;
109
- margin-top: 0.00cm;
 
 
 
 
 
 
 
110
  }}
111
  }}
112
  """
113
 
 
114
  style = {
115
- 'font-family': "'Josefin Sans', sans-serif", # Start normal
116
- 'line-height': '1.6',
117
- 'font-size': '16px',
118
- 'letter-spacing': '0px',
119
- 'text-shadow': '0px 0px 0px #000',
120
- 'transform': 'skew(0deg)',
121
- 'margin-top': '0.00cm',
122
  'position': 'relative',
123
- 'top': '0px',
124
- 'color': '#000000',
125
- 'display': 'inline-block',
126
- 'margin': '0 1px',
127
- 'vertical-align': 'middle',
128
  'animation': f'{animation_name} 3s ease-in-out forwards',
129
  'animation-delay': f'{i * 0.1}s'
130
  }
131
 
132
  style_str = '; '.join([f'{k}: {v}' for k, v in style.items()])
133
- styled_letter = f'<span class="styled-letter" style="{style_str}">{letter}</span>'
134
  styled_letters.append(styled_letter)
135
 
 
136
  return f"""
137
  <style>{keyframes_css}</style>
138
- <span class="special-word">{" ".join(styled_letters)}</span>
139
  """
140
 
141
  def display_normal_text():
@@ -169,7 +171,7 @@ def display_normal_text():
169
  """
170
 
171
  def trigger_movement():
172
- """Apply transition styling to selected words - they style then return to normal automatically."""
173
  global current_text, special_words, original_paragraphs, animation_counter
174
 
175
  if not special_words or not original_paragraphs:
@@ -213,7 +215,7 @@ def trigger_movement():
213
 
214
  # Create Gradio interface using Blocks
215
  with gr.Blocks() as demo:
216
- gr.Markdown("# CircularText Styler\nText with smooth sneaking style transitions - words style then smoothly return to normal.")
217
 
218
  output_html = gr.HTML()
219
  with gr.Row():
 
55
  # Create unique animation name
56
  animation_name = f"sneakStyle_{animation_id}_{i}"
57
 
58
+ # Create keyframes that go: normal → styled → normal (with complete reset)
59
  keyframes_css += f"""
60
  @keyframes {animation_name} {{
61
  0% {{
62
+ font-family: inherit;
63
+ font-size: inherit;
64
+ letter-spacing: normal;
65
+ color: inherit;
66
+ text-shadow: none;
67
+ transform: none;
68
+ top: auto;
69
+ margin-top: 0;
70
+ margin-left: 0;
71
+ margin-right: 0;
72
+ font-weight: inherit;
73
+ font-style: inherit;
74
  }}
75
  25% {{
76
  font-family: {styled_font_family};
 
103
  margin-top: {styled_margin_top};
104
  }}
105
  100% {{
106
+ font-family: inherit;
107
+ font-size: inherit;
108
+ letter-spacing: normal;
109
+ color: inherit;
110
+ text-shadow: none;
111
+ transform: none;
112
+ top: auto;
113
+ margin-top: 0;
114
+ margin-left: 0;
115
+ margin-right: 0;
116
+ font-weight: inherit;
117
+ font-style: inherit;
118
+ display: inline;
119
+ position: static;
120
+ vertical-align: baseline;
121
  }}
122
  }}
123
  """
124
 
125
+ # Start with completely normal styling that will be overridden by animation
126
  style = {
127
+ 'display': 'inline',
 
 
 
 
 
 
128
  'position': 'relative',
 
 
 
 
 
129
  'animation': f'{animation_name} 3s ease-in-out forwards',
130
  'animation-delay': f'{i * 0.1}s'
131
  }
132
 
133
  style_str = '; '.join([f'{k}: {v}' for k, v in style.items()])
134
+ styled_letter = f'<span style="{style_str}">{letter}</span>'
135
  styled_letters.append(styled_letter)
136
 
137
+ # Return just the letters with animation, no wrapper spans
138
  return f"""
139
  <style>{keyframes_css}</style>
140
+ {"".join(styled_letters)}
141
  """
142
 
143
  def display_normal_text():
 
171
  """
172
 
173
  def trigger_movement():
174
+ """Apply transition styling to selected words - they style then return to completely normal."""
175
  global current_text, special_words, original_paragraphs, animation_counter
176
 
177
  if not special_words or not original_paragraphs:
 
215
 
216
  # Create Gradio interface using Blocks
217
  with gr.Blocks() as demo:
218
+ gr.Markdown("# CircularText Styler\nText with smooth sneaking style transitions - words style then blend back perfectly with original text.")
219
 
220
  output_html = gr.HTML()
221
  with gr.Row():