Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

feat(svg_to_pptx): refine click animations and SVG grouping guidance

hugohe3920d28270cae
diff --git a/docs/faq.md b/docs/faq.md
index b932c2c6..c09349d1 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -79,17 +79,21 @@ Enter a slide → click once → semantic groups cascade in by z-order. To enabl
# Cascade every element with fade (recommended starting point)
python3 skills/ppt-master/scripts/svg_to_pptx.py <project> --animation fade
-# Auto-vary effects within a slide (title fades, content rotates fly/zoom/wipe...)
+# Auto-vary visible effects within a slide (title fades; content cycles through a curated pool)
python3 skills/ppt-master/scripts/svg_to_pptx.py <project> --animation mixed
-# Slower pace: 0.5s per element, 0.2s gap between elements
+# Slower pace: 0.5s per click-revealed element
python3 skills/ppt-master/scripts/svg_to_pptx.py <project> --animation fade \
--animation-duration 0.5 --animation-stagger 0.2
```
-12 single effects: `appear / fade / fly / zoom / wipe / split / blinds / dissolve / peek / wheel / box / circle`, plus `mixed` and `random` auto-vary modes.
+22 single effects: `appear / fade / fly / cut / zoom / wipe / split / blinds / checkerboard / dissolve / random_bars / peek / wheel / box / circle / diamond / plus / strips / wedge / stretch / expand / swivel`, plus `mixed` and `random` auto-vary modes.
-**Anchor logic**: animations are anchored on top-level SVG `<g id="...">` groups (e.g. `<g id="cover-title">`, `<g id="card-1">`) — this is the cleanest cascade granularity. Slides whose root is flat `<rect>` / `<text>` / `<path>` (no top-level `<g>` wrappers) **fall back automatically**: if there are ≤20 top-level visible elements, each becomes one animation anchor; beyond 20 (typical of dense consulting pages / charts), animation is skipped on that slide — cascading dozens of atoms in series would just be noise. So Executors are recommended to wrap logical sections in `<g id>` regardless of animation, since it also improves PowerPoint's group-select / group-move ergonomics.
+`mixed` is deterministic: the first animated group on each slide uses `fade`, then later groups cycle through a curated visible-effect pool across the whole deck. `random` samples from the same visible-effect pool. The pool excludes `appear` because it is too subtle for presenter-controlled reveals.
+
+`--animation-stagger` is kept for backward compatibility but is ignored by click-by-click timing. Use `--animation-duration` to control how obvious each reveal feels.
+
+**Anchor logic**: animations are anchored on top-level SVG `<g id="...">` groups (e.g. `<g id="cover-title">`, `<g id="card-1">`) — this is the cleanest cascade granularity. Aim for 3–8 semantic groups per slide. Slides whose root is flat `<rect>` / `<text>` / `<path>` (no top-level `<g>` wrappers) **fall back automatically**: if there are ≤8 top-level visible elements, each becomes one animation anchor; beyond 8, animation is skipped on that slide. So Executors should wrap logical sections in `<g id>` regardless of animation, since it also improves PowerPoint's group-select / group-move ergonomics.
**Note**: per-element animations only apply in native shapes mode (the default); `--only legacy` produces one image per slide and has no element anchors to animate.
diff --git a/docs/zh/faq.md b/docs/zh/faq.md
index e6d373e7..20809fbd 100644
--- a/docs/zh/faq.md
+++ b/docs/zh/faq.md
@@ -79,17 +79,21 @@ python3 skills/ppt-master/scripts/svg_to_pptx.py <project> --auto-advance 5
# 全部元素淡入级联(推荐起步)
python3 skills/ppt-master/scripts/svg_to_pptx.py <project> --animation fade
-# 同页内自动混搭多种效果(标题 fade,内容轮换 fly/zoom/wipe...)
+# 同页内自动混搭明显可见的效果(标题 fade,内容按精选池轮换)
python3 skills/ppt-master/scripts/svg_to_pptx.py <project> --animation mixed
-# 调慢节奏:每元素入场 0.5s、间隔 0.2s
+# 调慢节奏:每次点击出现的元素入场 0.5s
python3 skills/ppt-master/scripts/svg_to_pptx.py <project> --animation fade \
--animation-duration 0.5 --animation-stagger 0.2
```
-12 种单效果可选:`appear / fade / fly / zoom / wipe / split / blinds / dissolve / peek / wheel / box / circle`,外加 `mixed`、`random` 两种自动混搭模式。
+22 种单效果可选:`appear / fade / fly / cut / zoom / wipe / split / blinds / checkerboard / dissolve / random_bars / peek / wheel / box / circle / diamond / plus / strips / wedge / stretch / expand / swivel`,外加 `mixed`、`random` 两种自动混搭模式。
-**锚点逻辑**:动画以 SVG 顶层 `<g id="语义名">` 分组为单位(如 `<g id="cover-title">`、`<g id="card-1">`),这是最干净的级联粒度。如果某页根节点是平铺的 `<rect>`/`<text>`/`<path>`(没有顶层 `<g>` 包裹),导出器会**自动降级**:当顶层可见元素 ≤20 个时,每个元素作为一个动画锚点;超过 20 个(典型如咨询风密集页/图表页)则跳过动画 —— 几十个图元串行入场会变成噪声,跳过比硬上更合理。所以 Executor 输出建议把逻辑组都用 `<g id>` 包起来,既利于动画,也利于 PowerPoint 里成组选择/移动。
+`mixed` 是确定性轮换:每页第一个动画组使用 `fade`,后续组按精选的明显效果池在整份 deck 内连续轮换。`random` 从同一个明显效果池中随机抽取。效果池会排除 `appear`,因为它对演示点击入场来说太不明显。
+
+`--animation-stagger` 仅保留作兼容旧命令,当前逐次点击入场逻辑会忽略它。需要让动画更明显时,使用 `--animation-duration` 调整每个入场效果的持续时间。
+
+**锚点逻辑**:动画以 SVG 顶层 `<g id="语义名">` 分组为单位(如 `<g id="cover-title">`、`<g id="card-1">`),这是最干净的级联粒度。建议每页控制在 3–8 个语义组。如果某页根节点是平铺的 `<rect>`/`<text>`/`<path>`(没有顶层 `<g>` 包裹),导出器会**自动降级**:当顶层可见元素 ≤8 个时,每个元素作为一个动画锚点;超过 8 个则跳过该页动画。所以 Executor 输出应该把逻辑组都用 `<g id>` 包起来,既利于动画,也利于 PowerPoint 里成组选择/移动。
**注意**:页内动画只在 native shapes 模式(默认)生效,`--only legacy` 整页一张图无可锚定元素。
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.md
index 83b59d80..e1d6d4a2 100644
--- a/skills/ppt-master/references/shared-standards.md
+++ b/skills/ppt-master/references/shared-standards.md
@@ -245,10 +245,12 @@ Color: use the deck's primary brand color for emphasis. Reserve green/red for ac
### Element Grouping (Mandatory)
-Wrap logically related elements in `<g>`. Produces PowerPoint groups in PPTX, making slides easier to select/move/edit.
+Wrap logically related elements in top-level `<g id="...">` groups. Produces PowerPoint groups in PPTX, making slides easier to select/move/edit and providing stable anchors for optional click-by-click entrance animation.
> ⚠️ Only `<g opacity="...">` is banned (§2). Plain `<g>` for grouping is required.
+**Animation-ready rule**: direct children of `<svg>` should be semantic groups, not raw drawing atoms. Aim for **3–8 top-level `<g id>` groups per slide**; each group should correspond to one presenter click if page-level animation is enabled.
+
**What to group**:
| Grouping Unit | Contains |
@@ -261,6 +263,13 @@ Wrap logically related elements in `<g>`. Produces PowerPoint groups in PPTX, ma
| Page footer | Page number + branding |
| Decorative cluster | Related decorative shapes (rings, orbs, dots) |
+**Do not**:
+
+- Put the whole slide into one giant `<g>`; that leaves only one animation step.
+- Leave many top-level `<rect>` / `<text>` / `<path>` elements ungrouped; fallback animation is capped at 8 primitives and dense flat pages may skip animation.
+- Split every icon, text line, or decorative mark into separate top-level groups; that creates too many click steps.
+- Use anonymous top-level groups. Every top-level semantic group needs a descriptive `id`.
+
**Example**:
```xml
@@ -274,7 +283,7 @@ Wrap logically related elements in `<g>`. Produces PowerPoint groups in PPTX, ma
</g>
```
-**Naming**: descriptive `id` on top-level `<g>` is **required** (e.g., `card-1`, `step-discover`, `header`, `footer`). Each top-level `<g id>` becomes one anchor for per-element entrance animation in PPTX export; without it, the exporter falls back to top-level primitives (capped) or skips animation on dense pages.
+**Naming**: descriptive `id` on top-level `<g>` is **required** (e.g., `card-1`, `step-discover`, `header`, `footer`). Each top-level `<g id>` becomes one anchor for per-element entrance animation in PPTX export; without it, the exporter falls back to at most 8 top-level primitives or skips animation on dense pages.
---
diff --git a/skills/ppt-master/scripts/docs/svg-pipeline.md b/skills/ppt-master/scripts/docs/svg-pipeline.md
index 1b0bc546..da9fcecc 100644
--- a/skills/ppt-master/scripts/docs/svg-pipeline.md
+++ b/skills/ppt-master/scripts/docs/svg-pipeline.md
@@ -35,6 +35,7 @@ python3 scripts/svg_to_pptx.py <project_path> -s final --only legacy
python3 scripts/svg_to_pptx.py <project_path> -s final --no-notes
python3 scripts/svg_to_pptx.py <project_path> -t none
python3 scripts/svg_to_pptx.py <project_path> -s final --auto-advance 3
+python3 scripts/svg_to_pptx.py <project_path> -s final --animation mixed --animation-duration 0.8
```
Behavior:
@@ -45,6 +46,11 @@ Behavior:
- Explicit `-o/--output` keeps the legacy side-by-side `_svg.pptx` next to the chosen path and skips `backup/`
- Recommended source directory: `svg_final/`
- Speaker notes are embedded automatically unless `--no-notes` is used
+- Page transitions are controlled by `-t/--transition`; per-element entrance animations are controlled by `-a/--animation`
+- Per-element animation applies to top-level SVG `<g id="...">` groups in z-order, with one presenter click revealing one semantic group; aim for 3–8 groups per slide
+- Flat SVG roots without top-level groups fall back to at most 8 visible primitives; beyond that, animation is skipped on the slide
+- `mixed` is deterministic: the first animated group on each slide uses `fade`, then later groups cycle through a curated visible-effect pool across the whole deck; `random` samples from that same pool
+- `--animation-stagger` is retained for old commands but ignored by click-by-click timing; use `--animation-duration` for reveal pacing
Dependency:
diff --git a/skills/ppt-master/scripts/pptx_animations.py b/skills/ppt-master/scripts/pptx_animations.py
index 5a114b8d..901b3fb9 100644
--- a/skills/ppt-master/scripts/pptx_animations.py
+++ b/skills/ppt-master/scripts/pptx_animations.py
@@ -14,13 +14,14 @@ Supported transition effects:
- random: Random
Supported entrance animations (per-element):
- appear, fade, fly, zoom, wipe, split, blinds,
- dissolve, peek, wheel, box, circle
+ appear, fade, fly, cut, zoom, wipe, split, blinds, checkerboard,
+ dissolve, random_bars, peek, wheel, box, circle, diamond, plus,
+ strips, wedge, stretch, expand, swivel
Animation modes used by the builder:
- single effect name (one of the above) — apply to every element
- - 'mixed' — first element fade, the rest cycle through a curated pool
- - 'random' — pick a random effect per element
+ - 'mixed' — first element fades, the rest cycle through a curated visible pool
+ - 'random' — pick a random effect from the same visible pool per element
Dependencies: None (pure XML generation)
"""
@@ -124,24 +125,37 @@ def create_transition_xml(
# Effects with filter=None render as plain "Appear" (visibility flip only).
#
ANIMATIONS: Dict[str, Dict[str, Any]] = {
- 'appear': {'name': 'Appear', 'filter': None},
- 'fade': {'name': 'Fade', 'filter': 'fade'},
- 'fly': {'name': 'Fly In', 'filter': 'slide', 'prLst': 'from(b)'},
- 'zoom': {'name': 'Zoom', 'filter': 'image'},
- 'wipe': {'name': 'Wipe', 'filter': 'wipe', 'prLst': 'from(l)'},
- 'split': {'name': 'Split', 'filter': 'barn', 'prLst': 'inHorizontal'},
- 'blinds': {'name': 'Blinds', 'filter': 'blinds', 'prLst': 'horizontal'},
- 'dissolve': {'name': 'Dissolve', 'filter': 'dissolve'},
- 'peek': {'name': 'Peek', 'filter': 'wipe', 'prLst': 'from(b)'},
- 'wheel': {'name': 'Wheel', 'filter': 'wheel', 'prLst': 'spokes(1)'},
- 'box': {'name': 'Box', 'filter': 'box', 'prLst': 'in'},
- 'circle': {'name': 'Circle', 'filter': 'circle', 'prLst': 'in'},
+ 'appear': {'name': 'Appear', 'filter': None, 'presetID': 1, 'presetSubtype': 0},
+ 'fade': {'name': 'Fade', 'filter': 'fade', 'presetID': 10, 'presetSubtype': 0},
+ 'fly': {'name': 'Fly In', 'filter': 'slide(fromBottom)', 'presetID': 2, 'presetSubtype': 4},
+ 'cut': {'name': 'Cut In', 'filter': 'slide(fromLeft)', 'presetID': 42, 'presetSubtype': 8},
+ 'zoom': {'name': 'Zoom', 'filter': 'image', 'presetID': 23, 'presetSubtype': 0},
+ 'wipe': {'name': 'Wipe', 'filter': 'wipe(left)', 'presetID': 22, 'presetSubtype': 1},
+ 'split': {'name': 'Split', 'filter': 'barn(inVertical)', 'presetID': 16, 'presetSubtype': 21},
+ 'blinds': {'name': 'Blinds', 'filter': 'blinds(horizontal)', 'presetID': 3, 'presetSubtype': 10},
+ 'checkerboard': {'name': 'Checkerboard', 'filter': 'checkerboard(across)', 'presetID': 5, 'presetSubtype': 6},
+ 'dissolve': {'name': 'Dissolve', 'filter': 'dissolve', 'presetID': 9, 'presetSubtype': 0},
+ 'random_bars': {'name': 'Random Bars', 'filter': 'randombar(horizontal)', 'presetID': 14, 'presetSubtype': 10},
+ 'peek': {'name': 'Peek', 'filter': 'wipe(down)', 'presetID': 12, 'presetSubtype': 4},
+ 'wheel': {'name': 'Wheel', 'filter': 'wheel(4)', 'presetID': 21, 'presetSubtype': 0},
+ 'box': {'name': 'Box', 'filter': 'box(in)', 'presetID': 4, 'presetSubtype': 0},
+ 'circle': {'name': 'Circle', 'filter': 'circle(in)', 'presetID': 6, 'presetSubtype': 0},
+ 'diamond': {'name': 'Diamond', 'filter': 'diamond(in)', 'presetID': 8, 'presetSubtype': 0},
+ 'plus': {'name': 'Plus', 'filter': 'plus(in)', 'presetID': 13, 'presetSubtype': 0},
+ 'strips': {'name': 'Strips', 'filter': 'strips(downRight)', 'presetID': 18, 'presetSubtype': 12},
+ 'wedge': {'name': 'Wedge', 'filter': 'wedge', 'presetID': 20, 'presetSubtype': 0},
+ 'stretch': {'name': 'Stretch', 'filter': 'stretch(across)', 'presetID': 17, 'presetSubtype': 0},
+ 'expand': {'name': 'Expand', 'filter': 'stretch(across)', 'presetID': 50, 'presetSubtype': 0},
+ 'swivel': {'name': 'Swivel', 'filter': 'wheel(1)', 'presetID': 19, 'presetSubtype': 0},
}
-# Pool used by 'mixed' / 'random' modes. Excludes 'appear' (no visible motion)
-# and keeps the first slot ('fade') for the title-like first element.
-_MIXED_POOL = ['fade', 'fly', 'zoom', 'wipe', 'peek', 'blinds',
- 'dissolve', 'split', 'wheel', 'box']
+# Pool used by 'mixed' / 'random' modes. Excludes 'appear' because it has no
+# visible motion; mixed handles the first title-like element as fade separately.
+_MIXED_POOL = [
+ 'blinds', 'checkerboard', 'dissolve', 'fly', 'cut',
+ 'random_bars', 'box', 'split', 'strips', 'wedge', 'wheel',
+ 'wipe', 'expand', 'fade', 'swivel', 'zoom',
+]
def create_timing_xml(
@@ -211,7 +225,7 @@ def create_timing_xml(
<p:par>
<p:cTn id="1" dur="indefinite" nodeType="tmRoot">
<p:childTnLst>
- <p:seq concurrent="1" nextAc="seek">
+ <p:seq concurrent="1" nextAc="none">
<p:cTn id="2" dur="indefinite" nodeType="mainSeq">
<p:childTnLst>
<p:par>
@@ -247,7 +261,12 @@ def _build_effect_xml(
set_id: int,
eff_id: int,
) -> str:
- """Inner <p:set>/<p:animEffect> pair for one target."""
+ """Inner effect block for one target.
+
+ Entrance effects are emitted as one animation pane row per target. Plain
+ Appear uses a visibility set; motion/filter effects use animEffect directly
+ to avoid duplicate rows for the same shape in PowerPoint.
+ """
anim_info = ANIMATIONS.get(animation, ANIMATIONS['fade'])
set_block = f'''<p:set>
<p:cBhvr>
@@ -261,9 +280,8 @@ def _build_effect_xml(
</p:set>'''
if anim_info['filter'] is None:
return set_block
- pr_attr = f' prLst="{anim_info["prLst"]}"' if 'prLst' in anim_info else ''
return set_block + f'''
-<p:animEffect transition="in" filter="{anim_info["filter"]}"{pr_attr}>
+<p:animEffect transition="in" filter="{anim_info["filter"]}">
<p:cBhvr>
<p:cTn id="{eff_id}" dur="{duration_ms}"/>
<p:tgtEl><p:spTgt spid="{shape_id}"/></p:tgtEl>
@@ -275,14 +293,13 @@ def create_sequence_timing_xml(
targets: list,
duration: float = 0.3,
) -> str:
- """Generate a multi-target entrance sequence triggered by one click.
+ """Generate a click-by-click multi-target entrance sequence.
Args:
targets: list of (shape_id, delay_ms, animation_name) tuples,
- in the order they should play. The first element triggers on
- click; subsequent elements use ``afterEffect`` chaining and
- their ``delay_ms`` becomes the gap after the previous element
- finishes.
+ in the order they should play. Each element is a separate
+ ``clickEffect`` so one presenter click reveals one semantic group.
+ ``delay_ms`` is ignored in this mode.
duration: per-element entrance duration in seconds.
Returns:
@@ -294,22 +311,35 @@ def create_sequence_timing_xml(
dur_ms = int(duration * 1000)
steps = []
+ next_id = 3
for i, target in enumerate(targets):
- shape_id, delay_ms, animation = target
+ shape_id, _delay_ms, animation = target
if animation not in ANIMATIONS:
animation = 'fade'
- node_type = 'clickEffect' if i == 0 else 'afterEffect'
- base = 3 + 4 * i
- outer_id, inner_id, set_id, eff_id = base, base + 1, base + 2, base + 3
+ anim_info = ANIMATIONS[animation]
+ wrapper_id = next_id
+ inner_id = next_id + 1
+ click_id = next_id + 2
+ set_id = next_id + 3
+ eff_id = next_id + 4
+ next_id += 5
effect_xml = _build_effect_xml(animation, shape_id, dur_ms, set_id, eff_id)
steps.append(f'''<p:par>
- <p:cTn id="{outer_id}" fill="hold" nodeType="{node_type}">
- <p:stCondLst><p:cond delay="{delay_ms}"/></p:stCondLst>
+ <p:cTn id="{wrapper_id}" fill="hold">
+ <p:stCondLst><p:cond delay="indefinite"/></p:stCondLst>
<p:childTnLst>
<p:par>
<p:cTn id="{inner_id}" fill="hold">
+ <p:stCondLst><p:cond delay="0"/></p:stCondLst>
<p:childTnLst>
- {effect_xml}
+ <p:par>
+ <p:cTn id="{click_id}" presetID="{anim_info.get('presetID', 1)}" presetClass="entr" presetSubtype="{anim_info.get('presetSubtype', 0)}" fill="hold" nodeType="clickEffect">
+ <p:stCondLst><p:cond delay="0"/></p:stCondLst>
+ <p:childTnLst>
+ {effect_xml}
+ </p:childTnLst>
+ </p:cTn>
+ </p:par>
</p:childTnLst>
</p:cTn>
</p:par>
@@ -324,7 +354,7 @@ def create_sequence_timing_xml(
return f''' <p:timing>
<p:tnLst>
<p:par>
- <p:cTn id="1" dur="indefinite" nodeType="tmRoot">
+ <p:cTn id="1" dur="indefinite" restart="never" nodeType="tmRoot">
<p:childTnLst>
<p:seq concurrent="1" nextAc="seek">
<p:cTn id="2" dur="indefinite" nodeType="mainSeq">
@@ -332,6 +362,8 @@ def create_sequence_timing_xml(
{all_steps}
</p:childTnLst>
</p:cTn>
+ <p:prevCondLst><p:cond evt="onPrev" delay="0"><p:tgtEl><p:sldTgt/></p:tgtEl></p:cond></p:prevCondLst>
+ <p:nextCondLst><p:cond evt="onNext" delay="0"><p:tgtEl><p:sldTgt/></p:tgtEl></p:cond></p:nextCondLst>
</p:seq>
</p:childTnLst>
</p:cTn>
@@ -343,12 +375,12 @@ def create_sequence_timing_xml(
</p:timing>'''
-def pick_animation_effect(mode: str, idx: int) -> str:
+def pick_animation_effect(mode: str, idx: int, offset: int = 0) -> str:
"""Resolve a per-element effect name from a mode string.
- A specific animation name returns itself (no variation).
- 'mixed': first element fixed to 'fade', rest cycle through ``_MIXED_POOL``
- starting at index 1 (so titles stay calm while content varies).
+ plus ``offset`` (so titles stay calm while content varies across slides).
- 'random': uniform random choice from ``_MIXED_POOL``.
- Unknown mode falls back to 'fade'.
"""
@@ -357,7 +389,7 @@ def pick_animation_effect(mode: str, idx: int) -> str:
if mode == 'mixed':
if idx == 0:
return 'fade'
- return _MIXED_POOL[(idx - 1) % (len(_MIXED_POOL) - 1) + 1]
+ return _MIXED_POOL[(idx - 1 + offset) % len(_MIXED_POOL)]
if mode == 'random':
import random
return random.choice(_MIXED_POOL)
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.py
index 356e1db5..49cbe728 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.py
@@ -255,10 +255,10 @@ def convert_svg_to_slide_shapes(
# Animation target fallback. Semantic <g id="..."> groups are the
# preferred anchors (set inside convert_g). When the SVG has none
# at the root we fall back to top-level primitives, but only when
- # the count is reasonable — dense pages (consulting decks, charts,
- # diagrams) routinely have 70–150 atoms at the root and animating
- # each one is unusable, so we silently skip animation past the cap.
- _ANIM_FALLBACK_CAP = 20
+ # the count is reasonable. Presenter-click animation should reveal
+ # semantic blocks, not atomized drawing primitives, so fallback is
+ # intentionally capped at a low count.
+ _ANIM_FALLBACK_CAP = 8
if not ctx.anim_targets and 0 < len(fallback_targets) <= _ANIM_FALLBACK_CAP:
ctx.anim_targets = fallback_targets
diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.py
index da0026b6..da515c2f 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.py
@@ -6,6 +6,7 @@ import hashlib
import re
import shutil
import tempfile
+import xml.etree.ElementTree as ET
import zipfile
from pathlib import Path
@@ -69,6 +70,57 @@ def _append_relationship(
return next_rid
+def _expand_anim_targets_to_group_children(
+ slide_xml: str,
+ anim_targets: list[tuple[int, str]],
+) -> list[tuple[list[int], str]]:
+ """Expand top-level group animation targets to their concrete child shapes.
+
+ PowerPoint for Mac may list animations assigned to ``p:grpSp`` in the
+ animation pane but fail to consume slideshow clicks for those group targets.
+ Animating ordinary child shapes in the same click step preserves the visual
+ "one semantic block per click" behavior while avoiding group-target playback
+ quirks.
+ """
+ ns = {'p': 'http://schemas.openxmlformats.org/presentationml/2006/main'}
+ root = ET.fromstring(slide_xml)
+ expanded: list[tuple[list[int], str]] = []
+
+ for target_id, svg_id in anim_targets:
+ if isinstance(target_id, (list, tuple)):
+ expanded.append(([int(v) for v in target_id], svg_id))
+ continue
+
+ group = None
+ for candidate in root.findall('.//p:grpSp', ns):
+ c_nv_pr = candidate.find('./p:nvGrpSpPr/p:cNvPr', ns)
+ if c_nv_pr is not None and c_nv_pr.get('id') == str(target_id):
+ group = candidate
+ break
+
+ if group is None:
+ expanded.append(([target_id], svg_id))
+ continue
+
+ child_ids: list[int] = []
+ for child in list(group):
+ if child.tag == f'{{{ns["p"]}}}sp':
+ c_nv_pr = child.find('./p:nvSpPr/p:cNvPr', ns)
+ elif child.tag == f'{{{ns["p"]}}}pic':
+ c_nv_pr = child.find('./p:nvPicPr/p:cNvPr', ns)
+ else:
+ c_nv_pr = None
+ if c_nv_pr is None:
+ continue
+ child_id = c_nv_pr.get('id')
+ if child_id and child_id.isdigit():
+ child_ids.append(int(child_id))
+
+ expanded.append((child_ids or [target_id], svg_id))
+
+ return expanded
+
+
def create_pptx_with_native_svg(
svg_files: list[Path],
output_path: Path,
@@ -102,7 +154,7 @@ def create_pptx_with_native_svg(
animation: Per-element entrance animation mode (single effect name,
'mixed', 'random', or None to disable). Native shapes mode only.
animation_duration: Per-element entrance duration in seconds.
- animation_stagger: Auto-cascade gap between elements in seconds.
+ animation_stagger: Legacy option ignored by click-by-click timing.
Returns:
Whether all slides were successfully created.
@@ -192,6 +244,7 @@ def create_pptx_with_native_svg(
has_any_image = False
media_cache: dict[tuple[str, str], str] = {}
notes_slides_created: set[int] = set()
+ mixed_animation_offset = 0
for i, svg_path in enumerate(svg_files, 1):
slide_num = i
@@ -228,9 +281,13 @@ def create_pptx_with_native_svg(
seq_targets = [
(sid,
0 if idx == 0 else stagger_ms,
- pick_animation_effect(animation, idx))
+ pick_animation_effect(
+ animation, idx, mixed_animation_offset,
+ ))
for idx, (sid, _svg_id) in enumerate(anim_targets)
]
+ if animation == 'mixed':
+ mixed_animation_offset += max(0, len(anim_targets) - 1)
timing_xml = '\n' + create_sequence_timing_xml(
seq_targets, duration=animation_duration,
)
diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_cli.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_cli.py
index aecf9f3d..961d6587 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_cli.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_cli.py
@@ -57,7 +57,9 @@ Transition effects (-t/--transition):
Per-element entrance animation (-a/--animation, native shapes mode):
{', '.join(animation_choices)}
Notes: applied to top-level <g id="..."> SVG groups in z-order.
- First click triggers the cascade; --animation-stagger sets the gap.
+ Each animated group uses an independent on-click trigger.
+ mixed uses a curated visible-effect sequence across the deck; random samples
+ from the same visible-effect pool.
Compatibility mode (enabled by default):
- Automatically generates PNG fallback images, SVG embedded as extension
@@ -96,7 +98,7 @@ Speaker notes (enabled by default):
parser.add_argument('-t', '--transition', type=str, choices=transition_choices, default='fade',
help='Page transition effect (default: fade, use "none" to disable)')
parser.add_argument('--transition-duration', type=float, default=0.4,
- help='Transition duration in seconds (default: 0.5)')
+ help='Transition duration in seconds (default: 0.4)')
parser.add_argument('--auto-advance', type=float, default=None,
help='Auto-advance interval in seconds (default: manual advance)')
@@ -108,7 +110,7 @@ Speaker notes (enabled by default):
parser.add_argument('--animation-duration', type=float, default=0.3,
help='Per-element entrance duration in seconds (default: 0.3)')
parser.add_argument('--animation-stagger', type=float, default=0.1,
- help='Auto-cascade gap between elements in seconds (default: 0.1)')
+ help='Legacy option; ignored by click-by-click timing')
parser.add_argument('--no-notes', action='store_true',
help='Disable speaker notes embedding (enabled by default)')