#!/usr/bin/env python3 """ The Art of Design — generates presentation.pptx, a visually rich 6-slide deck built entirely from raw OOXML shape trees: deep gradient backgrounds, decorative circles, gradient accent lines, stat cards, a quote slide, a process timeline, and a closing slide. SDK twin of presentation.sh (officecli CLI). Both produce an equivalent presentation.pptx. This one drives the **officecli Python SDK** (`pip install officecli-sdk`): one resident is started and every slide + every raw-set shape injection is shipped over the named pipe in a single `doc.batch(...)` round-trip. The deck is built with the `raw-set` escape hatch (the same one the .sh uses): each item is a batch dict whose `part` names the target slide and whose `xpath`/`action`/`xml` fields drive `IDocumentHandler.RawSet` — exactly the fields you'd pass to `officecli raw-set`. Slides themselves are plain `add slide` items under `/presentation`. Usage: pip install officecli-sdk # plus the `officecli` binary on PATH python3 presentation.py """ import os import sys # --- locate the SDK: prefer an installed `officecli-sdk`, else the in-repo copy try: import officecli # pip install officecli-sdk except ImportError: sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "sdk", "python")) import officecli FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "presentation.pptx") def slide(): """One `add slide` item in batch-shape. Slides hang off the presentation root, so the parent is "/" (the resident/batch model; the CLI's positional /presentation maps to the same root).""" return {"command": "add", "parent": "/", "type": "slide"} def bg(n, xml): """raw-set: prepend a into slide n's .""" return {"command": "raw-set", "part": f"/slide[{n}]", "xpath": "//p:cSld", "action": "prepend", "xml": xml} def shape(n, xml): """raw-set: append a shape into slide n's /.""" return {"command": "raw-set", "part": f"/slide[{n}]", "xpath": "//p:cSld/p:spTree", "action": "append", "xml": xml} print(f"Building {FILE} ...") with officecli.create(FILE, "--force") as doc: items = [] # ========================================================================= # SLIDE 1 — Title Slide # ========================================================================= items.append(slide()) # Full-bleed dark gradient background items.append(bg(1, ''' ''')) # Decorative circle — top right (large, semi-transparent teal) items.append(shape(1, ''' ''')) # Decorative circle — bottom left (lavender) items.append(shape(1, ''' ''')) # Gradient accent line items.append(shape(1, ''' ''')) # Main title items.append(shape(1, ''' The Art of Design ''')) # Subtitle items.append(shape(1, ''' Crafting Beautiful Experiences SIMPLICITY · ELEGANCE · FUNCTION ''')) # Diamond accent items.append(shape(1, ''' ''')) # ========================================================================= # SLIDE 2 — Three Pillars # ========================================================================= items.append(slide()) items.append(bg(2, '' '')) # Section title items.append(shape(2, ''' Three Pillars of Great Design ''')) # Subtitle items.append(shape(2, ''' Every exceptional design is built upon these core principles ''')) # Card 1 — Simplicity items.append(shape(2, ''' Simplicity Less is more. Strip away the unnecessary to let the essential shine through. ''')) # Card 2 — Hierarchy items.append(shape(2, ''' Hierarchy Guide the eye with size, color, and space. Create a clear visual flow. ''')) # Card 3 — Harmony items.append(shape(2, ''' Harmony Consistent color, type, and layout create a professional, cohesive experience. ''')) # ========================================================================= # SLIDE 3 — Data Showcase # ========================================================================= items.append(slide()) items.append(bg(3, '' '' '' '')) # Title items.append(shape(3, ''' Data-Driven Design ''')) # Gradient accent bar items.append(shape(3, ''' ''')) # Stat card 1 — 98% items.append(shape(3, ''' 98% User Satisfaction ''')) # Stat card 2 — 2.5M items.append(shape(3, ''' 2.5M Monthly Active Users ''')) # Stat card 3 — 47ms items.append(shape(3, ''' 47ms Avg Response Time ''')) # Bottom description items.append(shape(3, ''' Numbers tell stories. Through thoughtful visual design, every data point communicates its meaning at first glance. ''')) # ========================================================================= # SLIDE 4 — Quote Slide # ========================================================================= items.append(slide()) items.append(bg(4, '' '' '' '' '')) # Large quote mark items.append(shape(4, ''' ''')) # Quote text items.append(shape(4, ''' Good design is obvious. Great design is transparent. ''')) # Attribution items.append(shape(4, ''' — Joe Sparano ''')) # Decorative line under quote items.append(shape(4, ''' ''')) # ========================================================================= # SLIDE 5 — Process / Timeline # ========================================================================= items.append(slide()) items.append(bg(5, '' '')) # Title items.append(shape(5, ''' Design Process ''')) # Horizontal rainbow connector items.append(shape(5, ''' ''')) # Step circles + labels (loop — mirrors the bash for-loop) labels = ["Research", "Ideate", "Design", "Validate"] colors = ["00B4D8", "E0AAFF", "FFD166", "06D6A0"] xpos = [1400000, 3600000, 5800000, 8000000] for i in range(4): x = xpos[i] c = colors[i] label = labels[i] n = i + 1 cid = 510 + i * 2 cid2 = 511 + i * 2 items.append(shape(5, f''' 0{n} ''')) items.append(shape(5, f''' {label} ''')) # Bottom text items.append(shape(5, ''' Every step is iterative. From research to validation, we refine until perfection. ''')) # ========================================================================= # SLIDE 6 — Closing # ========================================================================= items.append(slide()) items.append(bg(6, '' '' '' '' '')) # Gradient ring items.append(shape(6, ''' ''')) # Thank You items.append(shape(6, ''' Thank You ''')) # Closing subtitle items.append(shape(6, ''' Design is not just what it looks like — it’s how it works. ''')) # Three accent diamonds items.append(shape(6, ''' ''')) items.append(shape(6, ''' ''')) items.append(shape(6, ''' ''')) # One round-trip: 6 slides + every background and shape injection. # stop_on_error so an out-of-order raw-set surfaces immediately (a slide # must exist before its shapes can be appended to it). resp = doc.batch(items, stop_on_error=True) summary = resp.get("data", {}).get("summary", {}) if isinstance(resp, dict) else {} print(f" shipped {len(items)} slide/raw-set items " f"({summary.get('succeeded', '?')} ok, {summary.get('failed', '?')} failed)") if summary.get("failed"): for row in resp["data"]["results"]: if not row.get("success"): print(f" FAILED #{row['index']}: {row.get('error')}", file=sys.stderr) raise SystemExit(1) # context exit closes the resident, flushing the deck to disk. print(f"Generated: {FILE}")