V5.1: Premium SVG quality — filters, gradients, letter-spacing, visual hierarchy rules from real examples
Browse files- interface/app_gradio.py +35 -21
interface/app_gradio.py
CHANGED
|
@@ -248,21 +248,32 @@ def executor_phase(data, project_path, style, progress_cb=None):
|
|
| 248 |
icon_lib = icons.get("library", "chunk-filled")
|
| 249 |
icon_inv = ", ".join(icons.get("inventory", []))
|
| 250 |
|
| 251 |
-
# Shared executor instructions
|
| 252 |
-
executor_rules = f"""SVG RULES (MANDATORY):
|
| 253 |
-
- viewBox="0 0 1280 720" width="1280" height="720"
|
| 254 |
- Colors ONLY from spec_lock: {color_str}
|
| 255 |
- Title font: {font_title}. Body font: {font_body}
|
| 256 |
-
- Body size: {typo.get('body',20)}px, Title
|
| 257 |
-
- Icons:
|
| 258 |
- Available icons: {icon_inv}
|
| 259 |
- FORBIDDEN: <style>, class, foreignObject, animate, script, mask, @font-face, rgba(), <g opacity="">
|
| 260 |
-
- Use
|
| 261 |
-
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
-
|
| 265 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
|
| 267 |
total_notes = []
|
| 268 |
|
|
@@ -283,24 +294,27 @@ def executor_phase(data, project_path, style, progress_cb=None):
|
|
| 283 |
content_str = "\n".join(f" - {p}" for p in slide.get("content", []))
|
| 284 |
rhythm = slide.get("rhythm", "dense")
|
| 285 |
|
| 286 |
-
prompt = f"""Generate SVG slide
|
| 287 |
|
| 288 |
-
SLIDE
|
| 289 |
- Title: {slide['title']}
|
| 290 |
- Layout: {slide.get('layout','content')}
|
| 291 |
-
- Rhythm: {rhythm} ({'full-bleed
|
| 292 |
- Content:
|
| 293 |
{content_str}
|
| 294 |
-
- {img_ref or 'No image
|
| 295 |
|
| 296 |
{executor_rules}
|
| 297 |
|
| 298 |
-
|
| 299 |
-
{"
|
| 300 |
-
{"
|
| 301 |
-
{"
|
| 302 |
-
{"
|
| 303 |
-
{"
|
|
|
|
|
|
|
|
|
|
| 304 |
|
| 305 |
try:
|
| 306 |
svg_content = llm_chat(prompt, max_tokens=8000, temperature=0.3)
|
|
|
|
| 248 |
icon_lib = icons.get("library", "chunk-filled")
|
| 249 |
icon_inv = ", ".join(icons.get("inventory", []))
|
| 250 |
|
| 251 |
+
# Shared executor instructions — based on real PPT Master high-quality examples
|
| 252 |
+
executor_rules = f"""SVG TECHNICAL RULES (MANDATORY — violation = broken export):
|
| 253 |
+
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280 720" width="1280" height="720">
|
| 254 |
- Colors ONLY from spec_lock: {color_str}
|
| 255 |
- Title font: {font_title}. Body font: {font_body}
|
| 256 |
+
- Body size: {typo.get('body',20)}px, Title: {typo.get('title',40)}px, Subtitle: {typo.get('subtitle',26)}px, Annotation: {typo.get('annotation',14)}px
|
| 257 |
+
- Icons: <use data-icon="{icon_lib}/ICON_NAME" x="" y="" width="40" height="40" fill="COLOR"/>
|
| 258 |
- Available icons: {icon_inv}
|
| 259 |
- FORBIDDEN: <style>, class, foreignObject, animate, script, mask, @font-face, rgba(), <g opacity="">
|
| 260 |
+
- Use fill-opacity/stop-opacity instead of rgba. Use inline attributes only.
|
| 261 |
+
- Images: <image href="../images/FILENAME" preserveAspectRatio="xMidYMid slice"/>
|
| 262 |
+
|
| 263 |
+
VISUAL QUALITY RULES (for premium output):
|
| 264 |
+
- Use <defs> with linearGradient (3-4 stops with varying stop-opacity) for rich overlays
|
| 265 |
+
- Use radialGradient for subtle background glows (stop-opacity="0.06" to "0")
|
| 266 |
+
- Use <filter> for glow effects: feGaussianBlur + feFlood + feComposite + feMerge
|
| 267 |
+
- Use letter-spacing="3" on category labels / section headers for editorial feel
|
| 268 |
+
- Use vertical accent bars: <rect x="" y="" width="4" height="30" fill="PRIMARY"/>
|
| 269 |
+
- Use thin separators: <rect width="200" height="1" fill="BORDER"/> between sections
|
| 270 |
+
- Hierarchy: hero numbers at 80-120px bold, then 24px subtitle, then 16-18px body
|
| 271 |
+
- Cards: rounded rects (rx="12") with subtle stroke, padding 20-30px inside
|
| 272 |
+
- Top-level <g id="..."> grouping for each logical section (header, content, footer)
|
| 273 |
+
- Page number: bottom-right, annotation size, muted color
|
| 274 |
+
- Add decorative circles/dots at low opacity (0.06-0.15) for visual texture
|
| 275 |
+
- Text must be readable: ensure contrast between text color and background
|
| 276 |
+
- For breathing pages: big whitespace, one dominant element, dramatic"""
|
| 277 |
|
| 278 |
total_notes = []
|
| 279 |
|
|
|
|
| 294 |
content_str = "\n".join(f" - {p}" for p in slide.get("content", []))
|
| 295 |
rhythm = slide.get("rhythm", "dense")
|
| 296 |
|
| 297 |
+
prompt = f"""Generate a premium-quality SVG slide. This must look like a professionally designed presentation.
|
| 298 |
|
| 299 |
+
SLIDE {num}/{num_total}:
|
| 300 |
- Title: {slide['title']}
|
| 301 |
- Layout: {slide.get('layout','content')}
|
| 302 |
+
- Rhythm: {rhythm} ({'dramatic full-bleed, big whitespace, one dominant element, cinematic' if rhythm == 'breathing' else 'information-rich, structured cards/lists, clear visual hierarchy' if rhythm == 'dense' else 'structural, impactful, decorative'})
|
| 303 |
- Content:
|
| 304 |
{content_str}
|
| 305 |
+
- {img_ref or 'No image — use gradients, shapes, and strong typography as visual interest'}
|
| 306 |
|
| 307 |
{executor_rules}
|
| 308 |
|
| 309 |
+
DESIGN THIS SLIDE:
|
| 310 |
+
{"COVER PAGE: dramatic, large title (60-80px), cinematic image as background with multi-stop gradient overlay, accent line, subtitle below. Make it impactful and memorable." if slide.get('layout') == 'cover' else ""}
|
| 311 |
+
{"CLOSING PAGE: centered composition, large title, accent divider, final message. Elegant and memorable." if slide.get('layout') == 'closing' else ""}
|
| 312 |
+
{"TIMELINE: horizontal line with circular nodes, dates/phases below, title at top. Clean and structured." if slide.get('layout') == 'timeline' else ""}
|
| 313 |
+
{"COMPARISON: two-column layout with visual separator, contrasting elements side by side." if slide.get('layout') == 'comparison' else ""}
|
| 314 |
+
{"CONTENT PAGE: asymmetric layout (image right/left, text opposite). Use accent bar before title. Bullet points with colored circles. Cards with rx=12 for grouped info." if slide.get('layout') == 'content' else ""}
|
| 315 |
+
{"Use the image as background with dark gradient overlay (3-4 stops, progressive opacity)" if img_ref and rhythm == 'breathing' else f"Place image on one side (540px wide), text content on the other side" if img_ref else ""}
|
| 316 |
+
|
| 317 |
+
Reply with ONLY the SVG. Start <svg, end </svg>. No explanation."""
|
| 318 |
|
| 319 |
try:
|
| 320 |
svg_content = llm_chat(prompt, max_tokens=8000, temperature=0.3)
|