pptx-designer 1.0.0b4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. pptx_designer-1.0.0b4/LICENSE +21 -0
  2. pptx_designer-1.0.0b4/PKG-INFO +504 -0
  3. pptx_designer-1.0.0b4/README.md +461 -0
  4. pptx_designer-1.0.0b4/pyproject.toml +88 -0
  5. pptx_designer-1.0.0b4/setup.cfg +4 -0
  6. pptx_designer-1.0.0b4/src/pptx_designer/__init__.py +61 -0
  7. pptx_designer-1.0.0b4/src/pptx_designer/adapters/__init__.py +5 -0
  8. pptx_designer-1.0.0b4/src/pptx_designer/adapters/llm_config_adapter.py +77 -0
  9. pptx_designer-1.0.0b4/src/pptx_designer/adapters/slide_search_adapter.py +108 -0
  10. pptx_designer-1.0.0b4/src/pptx_designer/adapters/ui_ux_adapter.py +100 -0
  11. pptx_designer-1.0.0b4/src/pptx_designer/ai/__init__.py +30 -0
  12. pptx_designer-1.0.0b4/src/pptx_designer/ai/fetcher.py +729 -0
  13. pptx_designer-1.0.0b4/src/pptx_designer/ai/providers/__init__.py +17 -0
  14. pptx_designer-1.0.0b4/src/pptx_designer/ai/providers/dalle.py +17 -0
  15. pptx_designer-1.0.0b4/src/pptx_designer/ai/providers/gemini.py +17 -0
  16. pptx_designer-1.0.0b4/src/pptx_designer/ai/providers/gpt_image.py +17 -0
  17. pptx_designer-1.0.0b4/src/pptx_designer/ai/providers/kimi.py +17 -0
  18. pptx_designer-1.0.0b4/src/pptx_designer/ai/providers/seedream.py +17 -0
  19. pptx_designer-1.0.0b4/src/pptx_designer/ai/providers/wanx.py +17 -0
  20. pptx_designer-1.0.0b4/src/pptx_designer/cli/__init__.py +5 -0
  21. pptx_designer-1.0.0b4/src/pptx_designer/cli/main.py +256 -0
  22. pptx_designer-1.0.0b4/src/pptx_designer/compat/__init__.py +1 -0
  23. pptx_designer-1.0.0b4/src/pptx_designer/compiler/__init__.py +59 -0
  24. pptx_designer-1.0.0b4/src/pptx_designer/compiler/_affine.py +82 -0
  25. pptx_designer-1.0.0b4/src/pptx_designer/compiler/_compiler.py +1114 -0
  26. pptx_designer-1.0.0b4/src/pptx_designer/compiler/_css.py +241 -0
  27. pptx_designer-1.0.0b4/src/pptx_designer/compiler/_dash.py +164 -0
  28. pptx_designer-1.0.0b4/src/pptx_designer/compiler/_errors.py +2 -0
  29. pptx_designer-1.0.0b4/src/pptx_designer/compiler/_ir.py +127 -0
  30. pptx_designer-1.0.0b4/src/pptx_designer/compiler/_paint.py +161 -0
  31. pptx_designer-1.0.0b4/src/pptx_designer/compiler/_path.py +305 -0
  32. pptx_designer-1.0.0b4/src/pptx_designer/compiler/_sanitizer.py +144 -0
  33. pptx_designer-1.0.0b4/src/pptx_designer/compiler/_text.py +631 -0
  34. pptx_designer-1.0.0b4/src/pptx_designer/compiler/_theme.py +370 -0
  35. pptx_designer-1.0.0b4/src/pptx_designer/core/__init__.py +17 -0
  36. pptx_designer-1.0.0b4/src/pptx_designer/core/content.py +438 -0
  37. pptx_designer-1.0.0b4/src/pptx_designer/core/decider.py +273 -0
  38. pptx_designer-1.0.0b4/src/pptx_designer/core/pipeline.py +290 -0
  39. pptx_designer-1.0.0b4/src/pptx_designer/core/planner.py +346 -0
  40. pptx_designer-1.0.0b4/src/pptx_designer/core/professional_renderer.py +307 -0
  41. pptx_designer-1.0.0b4/src/pptx_designer/data/__init__.py +34 -0
  42. pptx_designer-1.0.0b4/src/pptx_designer/data/colors.csv +193 -0
  43. pptx_designer-1.0.0b4/src/pptx_designer/data/colors.py +3661 -0
  44. pptx_designer-1.0.0b4/src/pptx_designer/data/landing.csv +35 -0
  45. pptx_designer-1.0.0b4/src/pptx_designer/data/motion.csv +17 -0
  46. pptx_designer-1.0.0b4/src/pptx_designer/data/products.csv +193 -0
  47. pptx_designer-1.0.0b4/src/pptx_designer/data/styles.csv +85 -0
  48. pptx_designer-1.0.0b4/src/pptx_designer/data/styles.py +1274 -0
  49. pptx_designer-1.0.0b4/src/pptx_designer/data/typography.csv +75 -0
  50. pptx_designer-1.0.0b4/src/pptx_designer/data/typography.py +606 -0
  51. pptx_designer-1.0.0b4/src/pptx_designer/data/ui-reasoning.csv +162 -0
  52. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/__init__.py +31 -0
  53. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/base.py +168 -0
  54. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/connector_router.py +117 -0
  55. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/cycle.py +50 -0
  56. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/data_splitter.py +43 -0
  57. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/diagram_style.py +129 -0
  58. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/flowchart.py +92 -0
  59. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/funnel.py +42 -0
  60. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/hierarchy.py +63 -0
  61. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/layout_engine.py +45 -0
  62. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/matrix.py +66 -0
  63. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/pyramid.py +40 -0
  64. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/swot.py +68 -0
  65. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/table.py +63 -0
  66. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/text_measurer.py +95 -0
  67. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/timeline.py +72 -0
  68. pptx_designer-1.0.0b4/src/pptx_designer/diagrams/venn.py +49 -0
  69. pptx_designer-1.0.0b4/src/pptx_designer/effects/__init__.py +19 -0
  70. pptx_designer-1.0.0b4/src/pptx_designer/effects/animation.py +333 -0
  71. pptx_designer-1.0.0b4/src/pptx_designer/effects/decoration.py +229 -0
  72. pptx_designer-1.0.0b4/src/pptx_designer/effects/decoration_renderer.py +21 -0
  73. pptx_designer-1.0.0b4/src/pptx_designer/effects/image_effects.py +222 -0
  74. pptx_designer-1.0.0b4/src/pptx_designer/effects/image_processor.py +448 -0
  75. pptx_designer-1.0.0b4/src/pptx_designer/effects/shape_effects.py +599 -0
  76. pptx_designer-1.0.0b4/src/pptx_designer/effects/text_effects.py +180 -0
  77. pptx_designer-1.0.0b4/src/pptx_designer/enterprise/__init__.py +41 -0
  78. pptx_designer-1.0.0b4/src/pptx_designer/enterprise/block_renderer.py +43 -0
  79. pptx_designer-1.0.0b4/src/pptx_designer/enterprise/brand.py +37 -0
  80. pptx_designer-1.0.0b4/src/pptx_designer/enterprise/content_parser.py +115 -0
  81. pptx_designer-1.0.0b4/src/pptx_designer/enterprise/delivery_gate.py +116 -0
  82. pptx_designer-1.0.0b4/src/pptx_designer/enterprise/design_dna_extractor.py +107 -0
  83. pptx_designer-1.0.0b4/src/pptx_designer/enterprise/image_matcher.py +225 -0
  84. pptx_designer-1.0.0b4/src/pptx_designer/enterprise/precision_renderer.py +28 -0
  85. pptx_designer-1.0.0b4/src/pptx_designer/enterprise/proposal_generator.py +198 -0
  86. pptx_designer-1.0.0b4/src/pptx_designer/enterprise/scanner.py +88 -0
  87. pptx_designer-1.0.0b4/src/pptx_designer/enterprise/slide_extractor.py +66 -0
  88. pptx_designer-1.0.0b4/src/pptx_designer/enterprise/slide_utils.py +18 -0
  89. pptx_designer-1.0.0b4/src/pptx_designer/enterprise/template_analyzer.py +147 -0
  90. pptx_designer-1.0.0b4/src/pptx_designer/enterprise/version_manager.py +39 -0
  91. pptx_designer-1.0.0b4/src/pptx_designer/py.typed +0 -0
  92. pptx_designer-1.0.0b4/src/pptx_designer/renderer/__init__.py +5 -0
  93. pptx_designer-1.0.0b4/src/pptx_designer/renderer/boolean_shapes.py +196 -0
  94. pptx_designer-1.0.0b4/src/pptx_designer/renderer/chart_builder.py +30 -0
  95. pptx_designer-1.0.0b4/src/pptx_designer/renderer/diagram_engine.py +23 -0
  96. pptx_designer-1.0.0b4/src/pptx_designer/renderer/freeform_builder.py +247 -0
  97. pptx_designer-1.0.0b4/src/pptx_designer/renderer/layout.py +668 -0
  98. pptx_designer-1.0.0b4/src/pptx_designer/renderer/precision.py +1803 -0
  99. pptx_designer-1.0.0b4/src/pptx_designer/renderer/shape_utils.py +58 -0
  100. pptx_designer-1.0.0b4/src/pptx_designer/renderer/shapes.py +358 -0
  101. pptx_designer-1.0.0b4/src/pptx_designer/renderer/svg_compiler.py +15 -0
  102. pptx_designer-1.0.0b4/src/pptx_designer/renderer/theme.py +1007 -0
  103. pptx_designer-1.0.0b4/src/pptx_designer/renderer/theme_mapper.py +32 -0
  104. pptx_designer-1.0.0b4/src/pptx_designer/renderer/visual_effects.py +32 -0
  105. pptx_designer-1.0.0b4/src/pptx_designer/search/__init__.py +1 -0
  106. pptx_designer-1.0.0b4/src/pptx_designer/search/adapters.py +79 -0
  107. pptx_designer-1.0.0b4/src/pptx_designer/tools/__init__.py +5 -0
  108. pptx_designer-1.0.0b4/src/pptx_designer/tools/cards.py +274 -0
  109. pptx_designer-1.0.0b4/src/pptx_designer/tools/charts.py +381 -0
  110. pptx_designer-1.0.0b4/src/pptx_designer/tools/images.py +313 -0
  111. pptx_designer-1.0.0b4/src/pptx_designer/tools/layout.py +394 -0
  112. pptx_designer-1.0.0b4/src/pptx_designer/tools/shapes.py +597 -0
  113. pptx_designer-1.0.0b4/src/pptx_designer/tools/svg.py +73 -0
  114. pptx_designer-1.0.0b4/src/pptx_designer/tools/text.py +277 -0
  115. pptx_designer-1.0.0b4/src/pptx_designer/utils/__init__.py +1 -0
  116. pptx_designer-1.0.0b4/src/pptx_designer/utils/env.py +53 -0
  117. pptx_designer-1.0.0b4/src/pptx_designer.egg-info/PKG-INFO +504 -0
  118. pptx_designer-1.0.0b4/src/pptx_designer.egg-info/SOURCES.txt +124 -0
  119. pptx_designer-1.0.0b4/src/pptx_designer.egg-info/dependency_links.txt +1 -0
  120. pptx_designer-1.0.0b4/src/pptx_designer.egg-info/entry_points.txt +2 -0
  121. pptx_designer-1.0.0b4/src/pptx_designer.egg-info/requires.txt +16 -0
  122. pptx_designer-1.0.0b4/src/pptx_designer.egg-info/top_level.txt +1 -0
  123. pptx_designer-1.0.0b4/tests/test_ai_fetcher.py +138 -0
  124. pptx_designer-1.0.0b4/tests/test_basic.py +152 -0
  125. pptx_designer-1.0.0b4/tests/test_svg_compiler_integration.py +264 -0
  126. pptx_designer-1.0.0b4/tests/test_svg_tools.py +55 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Chaokun Sun
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,504 @@
1
+ Metadata-Version: 2.4
2
+ Name: pptx-designer
3
+ Version: 1.0.0b4
4
+ Summary: Python library for LLMs to generate pixel-perfect PowerPoint presentations with 40,000+ style combinations
5
+ Author-email: Chaokun Sun <sunchaokun@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/sunchaokun/pptx-designer
8
+ Project-URL: Documentation, https://pptx-designer.readthedocs.io
9
+ Project-URL: Repository, https://github.com/sunchaokun/pptx-designer
10
+ Project-URL: Changelog, https://github.com/sunchaokun/pptx-designer/blob/main/CHANGELOG.md
11
+ Project-URL: Issues, https://github.com/sunchaokun/pptx-designer/issues
12
+ Keywords: pptx,powerpoint,presentation,llm,ai,build-mode,svg,charts,diagrams,python-pptx
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: End Users/Desktop
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Office/Business
24
+ Classifier: Topic :: Multimedia :: Graphics :: Presentation
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.10
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: python-pptx>=1.0.2
30
+ Requires-Dist: lxml>=4.9.0
31
+ Requires-Dist: Pillow>=10.0
32
+ Requires-Dist: shapely>=2.0
33
+ Provides-Extra: images
34
+ Requires-Dist: httpx>=0.24.0; extra == "images"
35
+ Provides-Extra: ai-images
36
+ Requires-Dist: openai>=1.0.0; extra == "ai-images"
37
+ Provides-Extra: dev
38
+ Requires-Dist: pytest>=7.0; extra == "dev"
39
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
40
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
41
+ Requires-Dist: mypy>=1.0; extra == "dev"
42
+ Dynamic: license-file
43
+
44
+ <div align="center">
45
+
46
+ # pptx-designer
47
+
48
+ **A code-first Python library for editable PowerPoint generation in LLM coding workflows**
49
+
50
+ [![PyPI version](https://img.shields.io/pypi/v/pptx-designer.svg)](https://pypi.org/project/pptx-designer/)
51
+ [![Python](https://img.shields.io/pypi/pyversions/pptx-designer.svg)](https://pypi.org/project/pptx-designer/)
52
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
53
+
54
+ Turn reviewed Python code into editable `.pptx` files with composable presentation primitives, design data, and native PowerPoint objects.
55
+
56
+ [Installation](#installation) · [Quick Start](#quick-start) · [Build Mode](#build-mode) · [LLM Authoring Guide](docs/llm-authoring-guide.md) · [Documentation](docs/README.md)
57
+
58
+ </div>
59
+
60
+ ---
61
+
62
+ ## Why pptx-designer?
63
+
64
+ More software is now written with an LLM in the loop. That makes the generated **code**—rather than an opaque prompt result—the useful unit of review, versioning, testing, and iteration. `pptx-designer` is a standard Python package built for that workflow: an assistant can compose explicit function calls, and a developer can inspect, modify, test, and rerun the same file.
65
+
66
+ It is deliberately not a presentation SaaS or a prompt-to-image black box. The output is a `.pptx` built from PowerPoint-native objects whenever the chosen component can express them.
67
+
68
+ | Design choice | What it means in practice |
69
+ |---|---|
70
+ | **Code is the source of truth** | Layout, wording, colours, and data live in Python and can be reviewed in Git. |
71
+ | **LLM-friendly public APIs** | Small, named, composable helpers reduce ambiguity when code is generated or edited by an assistant. |
72
+ | **Deterministic build path** | The same inputs, package version, fonts, and runtime produce a repeatable build target. |
73
+ | **Editable by default** | Shapes, text, diagrams, and supported SVG elements are emitted as native PPT objects where possible. |
74
+ | **Progressive control** | Start with `generate_ppt()`; move to Build mode when a slide needs exact composition. |
75
+ | **Optional AI services** | Core layout and drawing do not require an API key; image generation/search is opt-in. |
76
+
77
+ ### Scope and honest boundaries
78
+
79
+ `pptx-designer` adds a higher-level, presentation-oriented layer on top of `python-pptx`; it does not replace PowerPoint's rendering engine or implement every presentation/SVG feature. Native editability and visual fidelity depend on the component and target Office environment. The SVG compiler intentionally supports an editable subset, not browser-complete SVG. Treat generated PPTX files as build artifacts: open them in the target application and review important slides before delivery.
80
+
81
+ ---
82
+
83
+ ## Installation
84
+
85
+ ```bash
86
+ pip install pptx-designer
87
+ ```
88
+
89
+ Optional extras:
90
+
91
+ ```bash
92
+ pip install pptx-designer[images] # Stock photo search (Unsplash/Pexels)
93
+ pip install pptx-designer[ai-images] # AI image generation (OpenAI, etc.)
94
+ ```
95
+
96
+ **Requirements**: Python 3.10+
97
+
98
+ ---
99
+
100
+ ## Quick Start
101
+
102
+ ### A code-first slide
103
+
104
+ When an AI coding assistant generates PPT code, it produces:
105
+
106
+ ```python
107
+ from pptx_designer.tools.shapes import rect
108
+ from pptx_designer.tools.text import text, multiline
109
+ from pptx_designer.tools.cards import kpi_card
110
+ from pptx_designer.tools.layout import page_header
111
+ from pptx_designer.tools.images import cover_image
112
+ from pptx_designer.core.pipeline import Presentation
113
+
114
+ C = {
115
+ "primary": "#1D78FA",
116
+ "accent": "#FF6B35",
117
+ "text_dark": "#1A1A1A",
118
+ "text_body": "#4A4A4A",
119
+ "background": "#FFFFFF",
120
+ }
121
+
122
+ prs = Presentation()
123
+ slide = prs.slides.add_slide(prs.slide_layouts[6])
124
+
125
+ page_header(slide, "Q4 Revenue Report", "Financial Summary", C=C)
126
+ kpi_card(slide, 1.0, 2.0, 3.5, 1.5, "$12.8M", "Revenue", "+23%", C=C)
127
+ kpi_card(slide, 5.0, 2.0, 3.5, 1.5, "89%", "Retention", "+5pp", C=C)
128
+ rect(slide, 0.5, 6.8, 12.3, 0.08, fill=C["primary"])
129
+
130
+ prs.save("output/q4_report.pptx")
131
+ ```
132
+
133
+ ### A generated deck from structured content
134
+
135
+ ```python
136
+ from pptx_designer import generate_ppt
137
+
138
+ # Structured content makes the generated deck predictable and reviewable.
139
+ result = generate_ppt(
140
+ content={
141
+ "title": "Q4 Revenue Report",
142
+ "pages": [
143
+ {"goal": "hook", "title": "Q4 2026", "subtitle": "Record Quarter"},
144
+ {"goal": "content", "title": "Key Metrics", "bullets": ["Revenue: $12.8M", "Growth: +23%"]},
145
+ ]
146
+ },
147
+ style="professional",
148
+ output="output/report.pptx",
149
+ )
150
+
151
+ # A simple query uses the package's built-in planner; no LLM provider is required.
152
+ result = generate_ppt("AI startup pitch deck", style="dark cyberpunk")
153
+ ```
154
+
155
+ ---
156
+
157
+ ## Build Mode
158
+
159
+ All presentations are built using **composable atoms** — simple, predictable functions that create shapes, text, images, and charts.
160
+
161
+ ### Shapes
162
+
163
+ ```python
164
+ from pptx_designer.tools.shapes import rect, rrect, oval, hexagon, diamond, star5
165
+
166
+ rect(slide, left=1, top=1, width=4, height=2, fill="#3B82F6")
167
+ rrect(slide, left=1, top=3.3, width=4, height=2, fill="#2563EB")
168
+ oval(slide, left=6, top=1, width=2, height=2, fill="#10B981")
169
+ hexagon(slide, cx=9, cy=2, size=1.5, fill="#F59E0B")
170
+ ```
171
+
172
+ ### Text
173
+
174
+ ```python
175
+ from pptx_designer.tools.text import text, multiline, gradient_text, dramatic_text
176
+
177
+ text(slide, left=1, top=1, width=8, height=1, txt="Hello World", font_size=32, bold=True)
178
+ multiline(slide, left=1, top=2, width=8, height=3, lines=["Line 1", "Line 2", "Line 3"], font_size=14)
179
+ gradient_text(slide, left=1, top=1, width=8, height=1, txt="Gradient", preset="gold-shine", font_size=48)
180
+ ```
181
+
182
+ ### Charts
183
+
184
+ ```python
185
+ from pptx_designer.tools.charts import bar_chart
186
+
187
+ bar_chart(slide, left=2, top=2, data=[("Q1", 0.85, "85%"), ("Q2", 0.92, "92%")])
188
+ ```
189
+
190
+ ### Diagrams
191
+
192
+ ```python
193
+ from pptx_designer.diagrams import DiagramStyle, FlowchartDiagram, Region, TimelineDiagram
194
+
195
+ region = Region(left=1, top=2, width=10, height=5)
196
+ style = DiagramStyle()
197
+
198
+ FlowchartDiagram(
199
+ data={"nodes": [{"label": "Discover"}, {"label": "Build"}, {"label": "Review"}]},
200
+ style=style,
201
+ region=Region(left=1, top=2, width=10, height=2),
202
+ ).render(slide)
203
+
204
+ TimelineDiagram(
205
+ data={"events": [{"year": "2024", "title": "Launch"}, {"year": "2025", "title": "Scale"}]},
206
+ style=style,
207
+ region=Region(left=1, top=4.5, width=10, height=2),
208
+ ).render(slide)
209
+ ```
210
+
211
+ ### SVG → PPTX
212
+
213
+ ```python
214
+ from pptx_designer.tools.svg import svg_chart
215
+
216
+ svg = """<svg viewBox="0 0 400 200" xmlns="http://www.w3.org/2000/svg">
217
+ <rect x="20" y="20" width="360" height="160" rx="16" fill="#2563EB"/>
218
+ <text x="200" y="112" text-anchor="middle" font-size="28"
219
+ font-weight="bold" fill="#FFFFFF">Editable SVG</text>
220
+ </svg>"""
221
+
222
+ result = svg_chart(slide, svg, x=1, y=1, w=8, h=4)
223
+ print(result.shape_count, result.warnings)
224
+ ```
225
+
226
+ The compiler creates native PowerPoint shapes and text for its supported SVG subset. It supports common geometry, paths, text/tspan, transforms, gradients, `defs`/`use`, and a constrained clipping path workflow. Filters, masks, patterns, animations, external resources, and some SVG paint semantics are not full-fidelity features. Always inspect `result.warnings` for a production SVG. See the [SVG guide](docs/svg-guide.md) for supported input, error handling, and limits.
227
+
228
+ ### Effects
229
+
230
+ ```python
231
+ from pptx_designer.effects import text_fx, shape_fx
232
+
233
+ text_fx.apply_shadow(shape, blur=8, distance=3, color="#000000")
234
+ shape_fx.apply_3d(shape, depth=10, material="powder")
235
+ shape_fx.apply_pattern(shape, "cross", fg="#000000", bg="#FFFFFF")
236
+ ```
237
+
238
+ ---
239
+
240
+ ## LLM coding workflow
241
+
242
+ The library is designed for an assistant to write ordinary Python—not to hide layout decisions behind a remote generation service. A reliable workflow is:
243
+
244
+ 1. Define slide content, data, and design constraints in code.
245
+ 2. Ask the LLM to compose public `pptx_designer` APIs.
246
+ 3. Review the generated Python as normal application code.
247
+ 4. Run it, inspect the `.pptx`, and keep the code and tests in version control.
248
+
249
+ This creates a practical feedback loop: a user can edit a title or value in PowerPoint for a one-off change, or edit the keyed Python call and rebuild when the change should be reproducible.
250
+
251
+ ### 1. Explicit function signatures
252
+
253
+ ```python
254
+ def rect(slide, left, top, width, height, fill, line=None, C=None) -> Shape
255
+ def text(slide, left, top, width, height, txt, font_size=12, color="text_body", bold=False, ...) -> Shape
256
+ def kpi_card(slide, left, top, width, height, number, label, trend="", trend_up=True, C=None, ...) -> list[Shape]
257
+ ```
258
+
259
+ Named arguments and focused helpers give an LLM a constrained target and give reviewers readable code.
260
+
261
+ ### 2. Composable presentation primitives
262
+
263
+ Each helper has a narrow responsibility. An LLM can combine them like building blocks, while a developer retains control over every call:
264
+
265
+ ```python
266
+ # LLM generates this code
267
+ page_header(slide, "Title", "Subtitle", C=C)
268
+ kpi_card(slide, 1, 2, 3, 1.5, "$12M", "Revenue", "+20%", C=C)
269
+ kpi_card(slide, 5, 2, 3, 1.5, "89%", "Retention", "+5pp", C=C)
270
+ rect(slide, 0.5, 6.8, 12.3, 0.08, fill=C["primary"])
271
+ ```
272
+
273
+ ### 3. Theme data and explicit overrides
274
+
275
+ The built-in palette, typography, and style data help an assistant begin from coherent defaults. For production work, pin explicit choices when visual consistency matters:
276
+
277
+ ```python
278
+ from pptx_designer.renderer.theme import ThemeComposer
279
+
280
+ theme = ThemeComposer().compose(style="dark cyberpunk")
281
+ # Returns: colors, typography, decoration, layout_variant
282
+ ```
283
+
284
+ ### 4. No API keys for core drawing features
285
+
286
+ All shape/text/chart/diagram/effect functions work offline. AI image generation is optional.
287
+
288
+ ### Prompting an LLM safely
289
+
290
+ When using pptx-designer with AI coding assistants, use this system prompt:
291
+
292
+ ```
293
+ You are a PPT generation expert using pptx-designer.
294
+
295
+ Rules:
296
+ 1. Use only documented public `pptx_designer` imports; do not invent helpers or private modules.
297
+ 2. Create a `Presentation()`, add a blank slide, and save the result with `prs.save(path)`.
298
+ 3. Use named arguments for positions and dimensions. Coordinates are inches.
299
+ 4. Keep colours in a `C` dictionary or select an explicit theme.
300
+ 5. Prefer native shapes, text, charts, and diagrams. Check `SVGResult.warnings` after compiling SVG.
301
+ 6. Generate a runnable Python file and do not claim the PPT is correct until it has been opened or rendered for review.
302
+
303
+ Available modules:
304
+ - pptx_designer.tools.shapes: rect, rrect, oval, hexagon, diamond, star5, triangle, arrow
305
+ - pptx_designer.tools.text: text, multiline, gradient_text, dramatic_text, vertical_text
306
+ - pptx_designer.tools.charts: bar_chart, comparison_bars
307
+ - pptx_designer.tools.cards: kpi_card, highlight_cards, code_block, section_divider, hero_slide
308
+ - pptx_designer.tools.layout: page_header, top_bar, page_number
309
+ - pptx_designer.data: PALETTES (192 colors), TYPOGRAPHY (74 fonts), STYLES (84 presets)
310
+ ```
311
+
312
+ ---
313
+
314
+ ## Style system
315
+
316
+ The library ships palette, typography, and style-preset data. Natural-language style selection is a convenience for exploration; explicit values are more appropriate for a reproducible build:
317
+
318
+ ```python
319
+ from pptx_designer.renderer.theme import ThemeComposer
320
+
321
+ # Natural language
322
+ theme = ThemeComposer().compose(style="warm fintech")
323
+
324
+ # Exact control
325
+ theme = ThemeComposer().compose(
326
+ palette="cyber-neon",
327
+ fonts="tech-mono",
328
+ decoration="neon-glow",
329
+ layout="sidebar-left",
330
+ )
331
+ ```
332
+
333
+ ### Built-in design data
334
+
335
+ | Database | Count | Access |
336
+ |----------|------:|--------|
337
+ | Color palettes | 192 | `from pptx_designer.data import PALETTES` |
338
+ | Font pairs | 74 | `from pptx_designer.data import TYPOGRAPHY` |
339
+ | Style presets | 84 | `from pptx_designer.data import STYLES` |
340
+
341
+ Built-in theme atoms (for ThemeComposer):
342
+
343
+ | Atom | Count | Examples |
344
+ |------|------:|---------|
345
+ | Hardcoded palettes | 30 | ocean-blue, cyber-neon, golden-luxury |
346
+ | Hardcoded fonts | 15 | modern-sans, tech-mono, elegant-serif |
347
+ | Decorations | 10 | accent-bar, neon-glow, brush-stroke |
348
+ | Layouts | 12 | standard, sidebar-left, grid-2x2 |
349
+
350
+ ---
351
+
352
+ ## Template and enterprise utilities
353
+
354
+ The package also includes project-scanning and proposal utilities for template- and brand-led workflows. These APIs are optional: the code-first Build mode remains the common foundation.
355
+
356
+ ```python
357
+ from pptx_designer.enterprise import ProjectScanner, ProposalGenerator
358
+
359
+ # Scan project for assets
360
+ scanner = ProjectScanner()
361
+ assets = scanner.scan("./my-project")
362
+
363
+ # Generate style proposals
364
+ proposals = ProposalGenerator().generate(
365
+ query="Q4 business review",
366
+ template=assets.template_path,
367
+ )
368
+
369
+ # Generate with confirmed style
370
+ from pptx_designer import generate_ppt
371
+ result = generate_ppt(
372
+ content=assets.content_raw,
373
+ template=assets.template_path,
374
+ confirmed_proposal="A",
375
+ )
376
+ ```
377
+
378
+ ---
379
+
380
+ ## Configuration
381
+
382
+ ### Image generation and `.env`
383
+
384
+ Put a `.env` beside your own `build.py` / project files (or in one of its
385
+ parent directories), then keep it out of Git. Do **not** put credentials in
386
+ the installed `pptx_designer` package directory: upgrades and virtual
387
+ environments will replace it.
388
+
389
+ [`.env.example`](.env.example) is the checked-in reference file. Copy it to
390
+ your own project root, then replace only the provider you plan to use:
391
+
392
+ ```powershell
393
+ Copy-Item .env.example .env
394
+ ```
395
+
396
+ ```bash
397
+ cp .env.example .env
398
+ ```
399
+
400
+ The package reads the nearest `.env` from the working directory upward.
401
+ Process environment variables take precedence over values in `.env`.
402
+
403
+ ```dotenv
404
+ # .env in your presentation project
405
+ PPT_IMAGE_LLM_PROVIDER=gpt-image
406
+ OPENAI_API_KEY=your-api-key
407
+ # OPENAI_IMAGE_MODEL=gpt-image-1
408
+ ```
409
+
410
+ Test the configuration without writing image-request code yourself:
411
+
412
+ ```powershell
413
+ pptx-designer image "editorial fragrance bottle on black stone" --image-mode auto -v
414
+ ```
415
+
416
+ `auto` resolves sources in this order:
417
+
418
+ 1. A `host_image_generator` supplied by an Agent host.
419
+ 2. Explicit Python arguments or CLI options.
420
+ 3. Project `.env` and process environment variables.
421
+ 4. An Agent provider configuration that explicitly references an environment key.
422
+ 5. Stock-image search, then no image / the calling layout's placeholder.
423
+
424
+ When `PPT_IMAGE_LLM_PROVIDER` is omitted, `auto` selects a provider from one
425
+ configured provider key (`OPENAI_API_KEY`, `ARK_API_KEY`, `GEMINI_API_KEY`,
426
+ `DASHSCOPE_API_KEY`, or `MOONSHOT_API_KEY`).
427
+
428
+ ```python
429
+ from pptx_designer import fetch_image
430
+
431
+ asset = fetch_image(
432
+ "editorial fragrance bottle on black stone",
433
+ mode="auto",
434
+ goal="hook",
435
+ )
436
+ print(asset["path"]) # local file path, or None when every source declines
437
+ ```
438
+
439
+ Agent hosts can also inject a `host_image_generator` callback. This is the
440
+ safe bridge for a host-owned image tool (such as an Agent image-generation
441
+ capability) when no image API is configured: the callback must return a local
442
+ image file path, which `pptx-designer` then places in the slide. The library
443
+ does not attempt to invoke Agent tools or login credentials by itself. This
444
+ hook is for Agent/Skill implementers, not ordinary `build.py` users:
445
+
446
+ ```python
447
+ from pptx_designer import fetch_image
448
+
449
+ def generate_with_host_tool(*, keywords, emotion, goal, width, height):
450
+ # The Agent host calls its own image tool and returns the saved local path.
451
+ return "C:/project/assets/generated/hero.png"
452
+
453
+ asset = fetch_image(
454
+ "quiet modern architecture at dawn",
455
+ mode="auto",
456
+ host_image_generator=generate_with_host_tool,
457
+ )
458
+ ```
459
+
460
+ A Codex provider entry is considered only when it references an environment
461
+ key. Login/session tokens are never treated as image API keys, and the
462
+ provider's ordinary text model is never treated as an image model. Set an
463
+ explicit `image_model` in the Agent configuration when a non-default image
464
+ model is required.
465
+
466
+ | Variable | Provider | Description |
467
+ |----------|----------|-------------|
468
+ | `ARK_API_KEY` | Seedream (ByteDance) | Image generation |
469
+ | `OPENAI_API_KEY` | OpenAI | GPT Image / DALL-E |
470
+ | `GEMINI_API_KEY` | Google | Gemini images |
471
+ | `DASHSCOPE_API_KEY` | Alibaba | Wanx images |
472
+ | `UNSPLASH_ACCESS_KEY` | Unsplash | Stock photos |
473
+ | `PEXELS_API_KEY` | Pexels | Stock photos |
474
+
475
+ ---
476
+
477
+ ## Development
478
+
479
+ ```bash
480
+ git clone https://github.com/sunchaokun/pptx-designer.git
481
+ cd pptx-designer
482
+ pip install -e ".[dev]"
483
+
484
+ python -m pytest tests/ -q
485
+ python -m ruff check src/pptx_designer/compiler tests/test_compiler tests/test_svg_tools.py tests/test_svg_compiler_integration.py
486
+ ```
487
+
488
+ ## Documentation
489
+
490
+ - [Getting started](docs/getting-started.md)
491
+ - [API reference](docs/api-reference.md)
492
+ - [LLM authoring guide](docs/llm-authoring-guide.md)
493
+ - [SVG compiler guide](docs/svg-guide.md)
494
+ - [Changelog](CHANGELOG.md)
495
+
496
+ ## Advanced examples
497
+
498
+ Explore complete four-page, editable decks in [examples/](examples/README.md): a luxury fragrance lookbook, a couture editorial deck, and an architecture vision book. Every example includes the build script, original image assets, and its generated `.pptx` output.
499
+
500
+ ---
501
+
502
+ ## License
503
+
504
+ MIT License — see [LICENSE](LICENSE) for details.