ppt-script-authoring
Design and build a deck as a python-pptx program: your own layout system, the source's own figures, charts you draw, and a template's design when the user gave one.
Install
Copy this folder into your Claude Code project (needs Node.js):
npx degit EverMind-AI/Raven/plugins-dist/ppt-engine/raven_ppt/skill/ppt-script-authoring .claude/skills/ppt-script-authoringOr install it for every project:
npx degit EverMind-AI/Raven/plugins-dist/ppt-engine/raven_ppt/skill/ppt-script-authoring ~/.claude/skills/ppt-script-authoringFile content
Made by its original authors and shared under Apache-2.0. We show it unchanged, with credit and a link to the source. Source ↗
---
name: ppt-script-authoring
description: "Design and build a deck as a python-pptx program: your own layout system, the source's own figures, charts you draw, and a template's design when the user gave one."
metadata: {"raven":{"emoji":"🎞️","always":true}}
---
# Deck authoring
You design the deck and you build it, by writing a python-pptx program that
`ppt_build` runs. Every page is yours: the grid, the type scale, the palette, the page
furniture, where a figure sits and how large. What refuses a deck and what only reports
is in §12.
## 1. Define the communication job
Infer the audience, the deck's job, the outcome you want, the central takeaway and
the evidence that supports it. Build a cumulative argument rather than an inventory
of topics: each content page performs one narrative job and makes one primary claim.
Write audience-facing titles that state the point. Open with the context, question
or stakes that make the deck worth sitting through. Close by resolving that opening
— a decision, an implication, a next question — on the last content page. The
template's closing page ends the deck after it, as its cover opens it: both are the
house frame and carry no argument of their own.
Pack the evidence before allocating pages. A page carries one claim and the developed
support that claim takes, and what makes the support developed is that it is more than
one kind of thing: evidence from the source, a mechanism or a comparison, an
implication or a constraint. Nothing counts the kinds, and how much copy a page ends up
with is measured rather than allocated (§2). If the evidence cannot support a complete
argument, merge the page rather than enlarging fragments.
The language, the audience and the length are the user's, and they are asked for
rather than inferred. `ppt_prepare` reads what the request already states and hands
back the rest as questions under `ask_user`. **Put them to the user with the `ask_user`
tool, all of them in one call, each with the option you would recommend marked.** The
answer comes back through the host: in a direct chat the user answers; in a delegated
run the host answers what the delegating conversation already settled and puts the rest
to the user. An answer that is empty, or that says the question was not sent, means
nobody is attached to this run: then take the option you marked recommended -- the
request's own scope, the materials' language, the length its kind of deck usually has --
and record it with `ppt_brief` as the assumption it is, so the deck says what it assumed.
Ask once: a question nobody answered is not answered by asking it again, and a run that
asks a question a turn spends a turn on each.
The length and the language are then measured against the
finished file and both refuse the deck (§12), so record what the user said rather than
what you inferred. The audience is not measured; it is the room you judge the deck for
when you look at the renders (§10).
The fourth thing to record is the one that gets dropped: whatever the user ruled out. `ppt_brief(forbidden=["no icons", "never name a competitor"])` is
quoted back to you in so many words on **every** build, which is what keeps a
prohibition agreed at turn three alive at turn forty; the same thing filed under
`notes` is kept with the brief and never restated. Only what the user actually ruled
out belongs there — a preference you inferred, recorded as a rule, is a constraint
nobody agreed to.
## 2. Write the outline before you write the program
**Go looking for the deck's pictures first, and look widely.** Not for a page but for
the pool the outline gets to choose from. `ppt_image_search` takes every query at once
-- `queries: ["...", "..."]`, up to twelve, searched together and grouped by query in the
reply -- so the whole pool is one call, not one call per picture. It returns each
candidate with its pixel size and the page it came from. Search the things the material
*names* as well as the things it links — a paper, a benchmark, a product, a release —
and the ordinary furniture too, the logo and the product shot, which every deck wants and
no material bothers to link. Bring in more than one page will use: `ppt_fetch` each, and
`ppt_figure_inspect` them, because a candidate you have not looked at is a candidate you
cannot choose.
`ppt_outline` records it, and the build refuses until it exists. This is the stage that
decides how much is on a page: without one, what a page says gets decided while its
geometry is being typed, and the page comes out thin.
Per page: the **claim** as a statement (which is also its title), what **carries**
it, the **figures** it places by id, and what it **says** in the deck's language, as
it will read on the page.
The outline does not decide a page's *shape*. It used to record a table's columns and
cells for any page whose `carries` mentioned a comparison, and a brief that asks for a
「对照表」 is ordinary — so a deck came back with five tables whose every cell was a
phrase, planned before anyone had seen the content laid out. What a page carries is
settled where it is drawn, with
[deck/build/references/tables.md](deck/build/references/tables.md) open. **Figures a
reader compares down a column are a table** — a benchmark, a price list, a
year-by-year rate — and that page should draw one. Words in every cell are cards.
`says` is where density is decided, and it is the field that gets under-written. A page
carries 200 to 467 characters of copy and the **median is 250** — a
five-row comparison, two takeaways and a caveat is that page, and it is a good page.
Plan for the median rather than the top of the range: the top of it is where the type
reaches its floor and `overset_copy` starts reporting. Points that are each half a line
add up to a page that is a title and some labels, and the build cannot rescue it:
geometry can arrange copy, never supply it. So write each point as the sentence a reader
gets, evidence included, and if a page has only one short line in it either the evidence
for it belongs there too or the page belongs merged into its neighbour.
Checking the plan here rather than after the build is the difference between a cheap
edit and an expensive one: what refuses an outline, and what it only reports, is in §12.
And `needs` is where gathering belongs — this is the first moment anything knows
what each page will show. Go through the outline page by page and name the picture
each one wants, then find them all in one `ppt_image_search` (`queries: [...]`, one per
page that wants a picture) and bring in what you pick with one `ppt_fetch`. A fetch joins the deck's own source set and is read on arrival, so there
is no separate ingest to remember; `ppt_ingest` is for bringing in another directory
of the user's, or re-reading after you have edited a source by hand.
A deck whose only imagery is what the materials happened to contain is a deck of
panels: the products it names have logos, the organisations have marks, the standards
have badges, and the architectures have diagrams their own documentation draws. Search
for those before deciding a page is text.
**What a page is missing is searched for, not filled in.** The two paths above gather
pictures; the same move answers a claim the sources leave without its evidence.
`web_search` for it, `web_fetch` the page that carries it, and keep where it came from
beside what you took. Nothing on a page is invented: not a number, not a source, not a
person, not a place. A gap you went looking for and did not find is worth keeping -- say
in `needs` what is missing and who has to supply it -- and a gap nobody looked for is a
page handing its own work back to the reader.
## 3. One visual identity, defined once
**What a finished page owes is written down, and it is what the review at the end judges
by: [deck/build/references/design-requirements.md](deck/build/references/design-requirements.md).
Open it now, before the first page.** Seven short sections -- room, edges, marks, figures,
tables, type, the claim -- each decidable from the render alone. Two of them are here as well:
- **A blank region has two kinds and they have different answers.** A shape bigger than
what it holds is fixed by measuring (`card_size`, `text_size`, `picture_size`,
`table_size`) and taking only that much. A *page* bigger than what it holds is not
fixed by shrinking anything -- taking a cover off room leaves the room -- and wants
either more that the page needs said, or this page and its neighbour becoming one page.
The test is one question: would making the shape smaller fill the page?
- **A table spans the box you hand it**, in the proportions its columns measure, and
spreads its rows into it down to five rows or so. So the box is the whole answer: give
a page-wide table `frame.body` and a two-column one a `split_left` column, never the
body with `weights` guessed to make up the difference.
Take the palette and font from `ppt_theme`. It is written into the build directory on
every build, so the import is plain — that directory is already on `sys.path`:
```python
from ppt_theme import THEMES, rgb
theme_id = next(iter(THEMES)) # one entry, and it is the template's
T = THEMES[theme_id]
BG, SURFACE = rgb(T["background"]), rgb(T["surface"])
INK, MUTED, ACCENT = rgb(T["foreground"]), rgb(T["muted"]), rgb(T["accent"])
SOFT, GRID, ACCENT_INK = rgb(T["accent_soft"]), rgb(T["grid"]), rgb(T["accent_ink"])
SERIES = [rgb(c) for c in T["chart_series"]] # six, in order
FONT = T["font_family"]
```
**Do not write a module into that directory whose name shadows a standard one.** A
`copy.py` beside your script breaks python-pptx's own import, and the traceback will
not mention your file.
**There is no palette to pick, and one to state.** A deck is always built inside a
template: `ppt_prepare` binds the one the user gave, and binds a bundled default when
the user gave none. The build directory then holds one theme, named after that file —
so `THEMES` has exactly one entry and its face is the template's own. Take that entry
by iteration; a theme id typed into `THEMES[...]` is a `KeyError`. Where the renders
show a ground or an accent the file does not declare, state what you see once with
`ppt_template(palette=...)` before the build, and every page and every derived tint
follow from it; a `T["background"] = ...` in the program changes one run's pages and
records nothing.
**Only three roles are read off the file** -- the ground, the ink and its first accent.
`surface`, `accent_soft`, `accent_ink`, `grid` and `muted` are mixed from those three.
What a file declares is not what its pages paint -- all ten bundled templates declare
`#F0F0F0` as their second light colour and none of them paints it -- so say what the
renders show:
`ppt_template(project=..., palette={"accent": "#155FFD", "surface": "#DDE8FF"})` holds
for the deck's whole life and reaches every page through `ppt_theme`.
**A partial palette is the ordinary one.** What you leave out is re-derived from what
you named: `palette={"accent": "#7A1FA2"}` in an amber template brings `surface`,
`accent_soft` and `accent_ink` back as tints of that purple. Reach for it for a deck
with a brand of its own, an accent the template does not carry, or a series the content
decides -- `chart_series` is the one role a stated accent does *not* move, so a
comparison drawn in your own two colours states them. A later call merges over the
earlier one, so state it before the first page.
The theme part is what the build checks, and you pass it by opening `PPT_TEMPLATE` at
all (§12). Nothing checks what colour you filled a shape with.
**The role names are open; a role's meaning is not.** These eight are the ones the
derivation knows how to finish:
| Role | What it is for |
| --- | --- |
| `background` | the ground a page is painted on |
| `surface`, `accent_soft` | planes content sits on |
| `foreground` | body type |
| `muted` | secondary type and source lines |
| `accent` | the focal point of a page |
| `accent_ink` | type in the accent's colour (below) |
| `grid` | hairlines |
You may add your own beside them: a deck comparing two things wants two colours for the
pair, and `palette={"ours": "#0B3D91", "theirs": "#F2E8D5"}` puts both in every page's
theme, where `card(..., tint="ours")` reaches them by name. What may not move is the
meaning — if the accent marks "our result" on one page it cannot mark "prior work" on
the next, and a pair named on page 3 is the same pair on page 11.
**A helper that holds the theme takes a colour by name.** `tint=` and
`colour=`/`mark_colour=` -- the signatures in §4 say which helper takes which -- each
take a role name, a key you added to the palette or to your own copy of the theme dict,
or a literal `#RRGGBB`. A name the theme does not carry is refused and says so, so a
misspelling is a message and not a colour.
`write` is the exception and the reason is in its signature: it is handed a box and a
string and no theme, so it takes the colour itself — `colour=theme["muted"]`,
`colour=theme["accent_ink"]`, or hex. `"muted"` there is six characters of a hex digit
and raises as one.
**A chart's `accent=` is not a colour.** It names *which item* to bring forward — a
category from the data you passed, `accent="Q3"` — and handing it `#RRGGBB` is refused
with the list of items it accepts.
A chart's colours are `chart_series`, and that is yours to set. Its order is the
contract — `chart_series[0]` is the series the page is about — so a comparison reads
by putting your own two colours in it: for the deck, `ppt_template(palette=
{"chart_series": ["#0B3D91", "#E4572E"]})`; for one page, copy the theme and set it
there before the call. A chart drawn from a theme you did not touch uses the
template's own series, which is the right default and not a rule.
**A card chooses its own ink.** `card` and `heading` set their type in whichever of the
theme's inks reads on the plane they were given, so `card(..., tint="accent")` on a
deep blue comes out with white type and the same call on a pale tint comes out dark.
You do not compute that, and you should not work around it: a `write` you place over a
plane yourself is yours to colour, and `theme["background"]` is the ink on a saturated
one.
**`accent` fills; `accent_ink` writes — on the page's own ground.** `accent_soft` is
the accent mixed towards the background, so a pale accent cannot be read on its own
tint. The theme carries `accent_ink` for this: the same hue, dark enough to write with
on the ground and on `accent_soft`, or the accent itself where that already reads.
Fills, markers and bars take `accent`; a number or heading in the accent's colour takes
`accent_ink`, by that name or as `theme["accent_ink"]`. On a plane of `accent` or a
page whose ground is saturated, `accent_ink` is a dark on a dark — a deep red heading
on a red page measured 1.09:1 — so type there is `theme["background"]`, the light ink.
**A paragraph set in one weight and one grey says nothing is more important than
anything else.** A reader scanning a slide takes the emphasised words first and reads
the rest only if those earned it, so every body paragraph that carries a number, a name
or a verdict marks that part and leaves the rest alone. What gets marked is the load:
the quantity and its unit, the one term the sentence turns on, the word that makes a
comparison a comparison. What does not is a phrase the author found interesting, and a
paragraph with four marked words has marked none.
Two marks and no third. **`accent_ink`, for the thing the page is about** -- one per
paragraph, at most two or three on a page, and if everything is in the accent the accent
has stopped meaning anything. **Bold, for a term the reader has to hold on to** -- a
label, a defined name, the head of a list item. Not italics, not underline, not a third
colour: a deck reads as one document when its emphasis has one vocabulary. A number that
carries the whole page is not emphasis at all -- it is the page's anchor, and it goes up
the size ladder as well (`no_anchor`).
`Run` is how a line says it, and §4 has the call. Where the whole block is the
emphasis -- a lead line, a pull quote, a card's heading -- `write`'s own `bold` and
`colour` are simpler and say the same thing.
**One font family, and its CJK companion.** Inside a template, the face `ppt_theme`
hands you is the template's own, whatever it is (微软雅黑, say), and that is the right
one to use: it is the house style, and the width measurement degrades to an estimate
for it rather than failing. Anything else is substituted on export and every position
you computed is wrong.
For a deck in Chinese that is only half the answer. `font_family` is a Latin face,
and Han characters set in one fall back to whatever the viewer has — a different
design at a different weight, and on the review renderer no Han glyphs at all. Every
theme carries `cjk_font_family` beside it — the template's own Han face where it names
one, and otherwise a face matched to the Latin one's class (`Noto Serif CJK SC` for a
serif, `Noto Sans CJK SC` for a sans) — and both names go on
the same run: `write(..., font=FONT, cjk_font=HAN)` from `ppt_layout` does it, or
set `a:ea` yourself. Then 目标查询 is set on purpose and `TarViS` in the same line
stays in the Latin face.
**A type scale with a big step at the top and fine steps below.** Same size for the
same role on every page. A 16.5pt title over 16pt body is not a scale; it is no
hierarchy at all. Two numbers in it are measured rather than chosen, because a deck is
read projected: body copy stays at or above **14pt**, and a caption, a source line or
any other short label may go to **10.8pt** but no further.
**A dominant element takes the top of the scale, and the top of it is above the title.**
A page whose point is one number sets that number at `NUMBER_PT`, the ramp's largest step
-- `the_largest_step_this_copy_takes(..., largest=NUMBER_PT)` is how to ask for it (§4) --
and it outranks the page title rather than sitting under it: a number set smaller than
the heading over it is not a dominant number, it is a caption on one. The inversion runs
the other way too, because copy is copy -- a concluding sentence set larger than its own
title makes the title the subordinate line. Where the size a page seems to want falls
between two steps, take the step above rather than a size off the ramp (§12).
Which floor a box answers to is decided from the box, not from you:
| The box | Floor |
| --- | --- |
| in the bottom 0.9in of the page -- furniture nobody reads from a seat | **8pt** |
| twenty characters or more, above that band -- copy | **14pt** |
| opening with `来源`, `注:`, `图`, `表`, `source:`, `figure` or `table` -- a caption in either language | **10.8** |
| shorter than twenty characters -- a label | **10.8** |
| fewer than four characters -- a page number or a chart tick | not measured |
The size measured is the one the *render* came out at, not the one you declared, so a
box too small for its copy is caught where autofit shrank it. Copy that will not fit
above the floor is a page with too much on it, and §12 says what to do instead of
shrinking it.
**One set of spacings, one surface treatment, one rule weight.** Fix them in the
setup beside the palette and call them everywhere: a larger gap between groups and a
smaller one inside a group, so grouping is legible from the spacing alone; one
restrained tint that planes are painted with; one thickness a hairline is drawn at.
Spacing that changes page to page reads as a deck assembled rather than designed, and
two groups with no more air between them than inside them come back as
`unseparated_blocks`.
**The header is the same on every page.** It is the one thing a reader sees eighteen
times, so the deck picks one header form and keeps it: the same kicker, the same
title position, the same treatment. Which form is yours, within the one the template
already has: its own title row, measured for you (§8). What a deck may not have is
three of them.
**Avoid -- the treatments that read as generated.** Each is a default reached for
instead of a decision, and each is legible as one from the back of the room:
- **A decorative rule or accent line under a title.** The title's own step in the scale
already separates it from the page; a line drawn under it adds a horizon that cuts the
heading off what it heads, and it appears on every page because it was never chosen
for any of them. `heading` draws none, and `rule` caps at 1.05in so it cannot become
one -- it is a short mark under a heading or beside a number. A page that genuinely
wants a divider gets a hairline under 4.5pt, or a thin `plane` for a full-width one.
- **A filled shape whose content is the space it covers.** A colour bar across the page,
a saturated strip down the edge of a card, a tinted panel painted over whatever room
was left with one sentence centred in it: each is a shape carrying no information,
which is what makes it read as filler -- a reader sees a region announced and finds
nothing in it, and the emptiness the shape was covering is now emphasised instead.
Grow the load-bearing content or redistribute it (§3.5). One filled bar is the deck's
own, the band the title row sits on; `band` (§12) says which shapes and at what size,
and `excessive_whitespace` measures what the panel was hiding.
The call is `card_size`, and a region is not a height: `card_size(w, icon=, title=,
body=)` answers how tall one card's own content makes it, so a row of them is
`max(card_size(...).h for each)` and the row is drawn at that. Take only that much of
the region and leave the rest to the next band -- a card handed `cells[i]` straight
out of `grid` is as tall as the region however little it holds, which is the void.
Cards take an `icon` for the same reason: three lines under a mark fill a card that
three lines alone leave two thirds empty, and the mark is what makes the row scannable
rather than three paragraphs side by side.
**The bar is usually not a mistake -- it is an answer to a page that felt empty**, and
wanting a full page is right. A stretched shape is the wrong way to get one, because it
fills the pixels and not the page: the reader still finds three short lines in a
half-page region, only now with a colour announcing it. What fills a page is content,
and the moves are these, in this order -- say more on the page (a line of detail under
each card title, the figure the number came from, the units, the year); give each card
an `icon`; use fewer, wider cards so the copy reaches their edges; put the figure or
the table in the room the cards left; or move a point here from a page that has one too
many. Only when none of those is true is the page genuinely short, and then the answer
is one page fewer, not one bar more. If you have already drawn the bar, the check is
the same either way: cover the shape's fill with your hand and ask whether the page
still says as much. If it does, the fill was doing nothing.
- **A title too close in size to its body copy.** The step at the top of the ramp is
what makes a title a title, and two sizes a point apart are one size to a reader.
`type_scale` and `type_drift` (§12) read the sizes back off the render.
- **Type too small to read projected.** The floors above are the measured half of this;
the other half is the page shrunk to a third of its size (§10).
- **The same page skeleton with only the words changed.** The header repeats on purpose
and nothing under it does: a cover, an agenda, a two-way comparison, a table page, a
full-bleed figure and a closing page are each recognisably a different kind of page.
`layout_variety` (§12) reads this off the shapes each page actually carries.
- **A filled chip behind every icon.** A row of identical coloured badges is the tell.
An icon is a mark beside type (§7); where a block wants a surface, give the whole
block one.
## 3.5 Structure follows the content
Decide what carries the point before placing anything.
**Every content page carries a visual element** -- a source figure, a chart you drew, a
drawn table, a diagram, or a region led by icons. A title over a column of copy is the
page that comes out when nothing was decided. The deck-wide count, its threshold and what
counts are `evidence`'s (§12); the decision here is which element this page's claim is
made of.
**Reference — not a constraint.** The table below is vocabulary, not a lookup. A page
may take one row, several rows together, or a composition no row names; no row carries
a coverage quota and nothing counts which ones a deck used.
| Content logic | What carries it |
|---|---|
| Real product, interface, experiment or published plot | a source figure |
| Source-backed numeric comparison or trend | a chart you draw |
| Tabular data or comparable rows and columns -- figures a reader compares down a column | a drawn table or comparison matrix; not for four labelled points, which are cards or a list |
| Familiar capabilities or categories | icon-led regions |
| Sequential steps or milestones | a timeline, a numbered column, or stages as unequal blocks; §7.5 |
| Two genuinely contrasted alternatives | paired regions on one baseline |
| One memorable conclusion | a single dominant statement |
| One dominant number | the number at display size, reasoning beside it |
Then compose around it. Give the load-bearing element the space its role deserves
and let the rest defer; a page where every region carries equal weight has argued
nothing. Vary composition because the content varies, not to fill a quota, and keep
a series of comparable cases on one shape so the reader can compare them. Give a
conclusion or decision its own baseline, weight or restrained accent instead of styling
every component identically.
Prefer one coherent composition over a dashboard of unrelated panels. Do not draw boxes
merely to avoid a prose page.
**Three blocks of copy in one body need something drawn between them.** Two read as a
pair from their positions alone -- a claim and its qualifier, a before and an after.
Three stop doing that, and their grouping becomes a grid the reader has to infer from
x-offsets. One device is the whole floor and any of them counts: `card_group` for blocks
that are the same kind of thing, `plane` behind the one region that answers the page,
`rule` between two halves that are not cards, or a figure the copy is set against.
A plane under a picture takes the page's own ground -- on a dark page a dark surface,
never a pale one -- and a picture that carries its own ground goes on the page without one.
Measured over the 105 content pages the bundled templates ship: 104 draw at least one,
the median page draws seven, and every page that draws exactly one draws a picture.
`undivided_body` (§12) reports the page that draws none. This is not the previous
paragraph's box-for-its-own-sake -- it is the difference between three groups a reader
can see and three paragraphs a reader has to sort.
**With a template bound, a page takes its shape from an example page first** (§8): the
outline names the example each content page starts from, and composing is for the page no
example or borrowable page can carry. **A composed page takes its shape from the catalogue.** Open
[deck/build/references/layouts.md](deck/build/references/layouts.md) while deciding. Its
Part 1 is eleven skeletons -- every id folded into the one it varies, with the share of
the body each division measured on the pages that were drawn -- and the outline names
what you chose: `layout` takes the one structure id, `layers` the modifiers stacked on
it, and `anti_pattern` the way this page would go wrong. A page cloned from a template
example leaves `layout` empty, because its structure is the example's.
**Every band of the page is declared, and the hierarchy is legible.** A composed page
divides into regions before it divides into shapes: count them, and give each the layer
that says what it is (`layers`), because the band nobody planned is the one that comes
back as bare paragraphs.
Then rank them so the reader sees it before reading a word -- which region is the claim,
which supports it, which is aside.
Cards, planes and helper presets are primitives, not a required page grammar. Do not wrap
every component in a filled rectangle just to make its boundary visible; use hierarchy,
alignment, whitespace and meaningful rules first.
**Fill the page.** A 13.3 x 7.5in canvas holds far more than a title and four
bullets, and content that stops two thirds of the way down is the most common
failure there is. Whitespace you chose is a margin around content that fills the
frame; whitespace left over reads as unfinished. When a page comes back with a large
accidental empty field, grow the load-bearing content, introduce a second visual
layer, or redistribute what is already there -- never decoration, restated copy or
smaller type, each of which makes the page worse than the gap did.
When the source already carries a real table, comparable rows or a set of parallel items
with several attributes, that information shape is part of the evidence: do not flatten
it because the text happens to fit.
On a figure-and-text page, let the figure dominate and turn the supporting copy into
scan points with clear labels -- as many as the region beside the figure actually
holds, which `points_size` answers before the page is drawn rather than after (§4).
Put those points on one or more restrained theme-coloured surfaces so the image and
explanation read as distinct layers; do not leave a bare paragraph floating beside the
figure. The cards defer to the figure -- they are supporting structure, not a row of
equal dashboard tiles.
**The caption goes in the page's foot, not under the figure.** A line of small type
under every picture puts a second row of furniture in the middle of the body, and on a
page with two figures it puts two -- the reader's eye leaves the figure, reads a label,
and comes back. Collect what the figures need into `footer()`'s `note`, joined with
`;`: `footer(slide, frame.footer, T, note="来源:xxx;图 1 主街三段式动线")`. Where the note
will not fit, keep the source and the one caption that carries a fact, and drop the rest
-- never shrink the type to fit it in; `footer` measures the note and refuses a second
line rather than drawing it into the margin. A number or a label *on* the figure is not
a caption and stays where it is, and so is the label that says *which* cell of a small
multiple this is: five identically framed figures are compared by their labels, and
moving those to the foot leaves the reader counting cells.
It is measured, not only a preference. A caption strip under a figure at the foot of the
body puts its own top edge inside the band `footer_findings` reads as the page's foot --
on five reference pages, three of them at 6.40in and 6.44in. Three fifths is over the
share that reading takes as a habit, so the deck was judged to have feet, and then
reported as `unnumbered_pages` because a caption carries no `slidenum`. A caption under a
figure manufactures a false foot and a false warning at once.
**Asking for the foot costs more than the caption frees.** `page(footer=True)` takes
`_FOOTER_H + GUTTER` = 0.58in off the body -- 5.25in becomes 4.67in -- and a caption
strip is about 0.40in. So a page that gains a foot has a *smaller* body than before, by
about 0.18in, and its bands have to be measured again: two reference passages were laid
out against 5.25in and `take` refused them at the band where the room ran out. Re-measure
with `short_by` before drawing, and where a band has to go, cut a heading whose cards
already name themselves rather than the content.
Every placed figure is still accounted for, and a figure can carry two claims
that are not the same kind. Its **source caption** is what the source printed under it:
quote it, credit it. The **`visual_caption`** `ppt_figure_inspect` wrote is a description
of the pixels and nobody's caption: write your own line from it, never present it as the
source's words, and never put a name in front of it the materials do not establish -- a
figure credited to the product it happens to sit beside is the failure this exists to
stop. A caption says what is shown, not a claim the pixels do not prove.
## 4. The program
It goes at `deck/build/build.py` — that whole path, relative to the
workspace; `ppt_prepare` reports it as `write_the_program_to`. A bare
`build/build.py` lands somewhere the build does not look. `write_file` creates it,
`write_file` with `mode="append"` extends it, `edit_file` revises it. Never restate
the whole file to change part of it.
**Write it in pieces, not in one call -- and in few pieces.** `write_file` for the setup
and the first five pages, then `mode="append"` for five pages at a time, with
`ppt_build(draft=true)` in the same reply as each append -- the calls in one reply run in
the order you list them, so the write and the build together are one turn: a draft builds
what exists, measures it and hands back the renders without holding a part-written deck to
the agreed length and without publishing. Four appends and four drafts is a twenty-page deck.
Use `write_file`, not `exec`, to write the program. Drop `draft` when the deck is whole and you want the gates. A twenty-page
program sent in one call is cut before it arrives, and a draft shows you a page while
there are three rather than twenty.
It runs in the build directory with python-pptx and Pillow and reads its paths from the
environment: `PPT_OUTPUT` (save there and nowhere else); `PPT_FIGURES_DIR` (the figures
ingest extracted, and the only way to one — take
`FIGURES = os.environ["PPT_FIGURES_DIR"]` in the setup and write `f"{FIGURES}/fig2.png"`
wherever a page places a figure, with the name the figure list gives after `file` — the id
before it is the catalogue's key, not a file; there is no `figures` directory under `deck/build`);
and, with a template bound, two paths that are not interchangeable — `PPT_TEMPLATE` is
the template with its example pages **removed**, the deck you build into
(`prs = Presentation(os.environ['PPT_TEMPLATE'])`), and `PPT_TEMPLATE_SOURCE` is the
user's original with those pages still in it, the only thing `prototype` can read a page
out of (`tpl = Presentation(os.environ['PPT_TEMPLATE_SOURCE'])`). Handing `prototype` the
deck you build into raises `this template ships 0 pages`.
`PPT_BUNDLED_TEMPLATES` is the folder the bundled templates ship in; `bundled(name)` reads it,
so a page borrowed from another template (§8) needs no path in the program.
`PPT_SLIDE_BLOCKS` and `PPT_SLIDE_LINES` are the build's own bookkeeping -- the `# SLIDE n`
spans it runs one at a time (§4) and the record of which line drew which page -- and
nothing in the program reads them.
**One block per page, opened with a `# SLIDE <n>` banner.** Shared helpers above the
blocks; the page's own composition inside the page's own block. Two shapes are refused: a
`build.py` that runs another file, and a loop that draws every page from one call site.
Both leave no code belonging to one page, so nothing can match a render to the code that
drew it, report a defect against the block that caused it, or fix one page without
touching another.
**The whole program, ending included.** Every other example here and in the references is
a page fragment; this is the file they go inside, and its last line is the one that gets
left out. A program that draws twenty pages and never saves them leaves no deck.
```python
import os
from pptx import Presentation
from ppt_layout import BODY_PT, heading, page, points, write
from ppt_theme import THEMES, rgb
prs = Presentation(os.environ["PPT_TEMPLATE"]) # the template, its example pages gone
T = THEMES[next(iter(THEMES))] # one entry, and it is the template's
FACE, HAN = T["font_family"], T["cjk_font_family"]
INK = rgb(T["foreground"])
HOUSE = "Title Only" # house_style's layout_for_a_page_you_draw
LAYOUT = next(one for one in prs.slide_layouts if one.name == HOUSE)
def content_page(): # the one skeleton every page shares
return prs.slides.add_slide(LAYOUT), page() # the template's background comes with it
# SLIDE 1
slide, frame = content_page()
heading(slide, frame, T, "四类任务,一套权重", "01 结论", font=FACE, cjk_font=HAN)
write(slide, frame.body, "切任务只换输入查询,不重训。", size=BODY_PT, colour=INK,
font=FACE, cjk_font=HAN)
# SLIDE 2
slide, frame = content_page()
heading(slide, frame, T, "证据", "02 消融", font=FACE, cjk_font=HAN)
points(slide, frame.body, T, ["去掉时序颈:44.7 对 46.3", "去掉语义查询:不收敛"],
font=FACE, cjk_font=HAN)
prs.save(os.environ["PPT_OUTPUT"]) # the last line of every program
```
**`prs.save(os.environ["PPT_OUTPUT"])` is the last line of every program**, draft builds
included. Nothing saves for you and nothing else is the place to save to.
Then write the helpers *your* pages need. Beyond the header, the source line and the
page number, page types have no reason to share a skeleton (§3).
**Default — a `*` after the geometry in every helper you write.**
`def card(slide, x, y, w, h, *, fill=SOFT, bold=False, align="left")` — the boxes stay
positional because they are always the same four numbers in the same order, and
everything after them is named at the call site. Seven or eight positional parameters is
the largest single cause of a build that will not run at all: an empty string where a bold
flag goes, an argument short, a keyword the function never had. `ppt_layout`'s own helpers
are shaped this way.
**The agenda is the page that goes wrong most often.** It is a map of the argument:
the movements the talk makes, each named with one line saying what it settles.
*Default — five to seven of them*, and nothing counts them; the outline's own sections
usually run to eight to twelve, so a deck may well want more. What is not a default:
it is **not an index of slide numbers**. "3 Introduction, 4 Limitations, 5 Overview…"
enumerates the file rather than the talk, and tells an audience nothing the page numbers
do not.
**Ask how wide the text is instead of guessing at it.** The commonest geometry bug in a
generated deck: a box sized to what the string looks like wraps it onto a second line, the
second line pushes into whatever sits below, and the page reads as broken rather than as
tight. `text_size` is the width and height the copy really takes and `fits` is the
yes-or-no, both answered before anything is placed. Where a line must not break whatever
happens -- a number, a label, a kicker, a card heading -- say so on the frame `write` hands
back: `write(...).shape.word_wrap = False`, where `.shape` is the text frame itself. Extra
width costs nothing; an unfilled text box has no fill and no outline.
**`print()` is how those answers reach you.** Whatever the program writes to stdout comes
back in the build reply, on a failed build as well as one that worked -- so `text_size`,
`fits`, `formula_type_size`, `len(units(slide))` and the theme your script actually
resolved are one `print` from being visible. Print the measurement, not the whole theme:
the last 20,000 characters are what comes back. It is also the only way to find a page
that runs and draws the wrong thing.
The agenda's geometry breaks the same three ways every time, so compute it:
- **A two-digit number needs a box that fits two digits.** `01` and `10` fold into two
stacked characters in a box sized for `1`. Set `write(...).shape.word_wrap = False`, or
give the box the width the widest label needs.
- **Lay repeated rows on a pitch.** With `n` rows in height `H` the pitch is `H / n`, the
label sits at `y = top + i * pitch`, its description at a fixed offset below.
- **A label and its description are one block.** If the description can run to two lines,
the pitch has to allow for two, or row `i + 1` lands on top of it.
The same three apply to any page built from repeated rows or cards.
### The helpers, by signature
Everything below is already beside your script: what each helper takes, what it hands
back, and what it can be asked before it draws. Read this rather than the modules (51k
tokens of source, in context for the rest of the run), and a helper that is neither here
nor in a reference this page links is one you should not be calling. The drawing base
`ppt_charts` is built on is left out below and is in §6.
Import them by name. What follows is the whole set this page and its references call, so
a snippet copied from either has its import here; take the lines the page you are drawing
needs, and an import you never call costs nothing. A name used in an example and absent
from every import line is a `NameError` at build time, so the import travels with the snippet.
```python
from ppt_theme import THEMES, rgb
from ppt_layout import (
BODY_PT, Box, CANVAS_H, CANVAS_W, Drawn, Frame, GUTTER, Inches, KICKER_PT, LABEL_PT,
LEAD_PT, MARGIN, MSO_SHAPE, NUMBER_PT, PAD, Pt, Run, TITLE_PT, card, card_body_box,
card_size, fits, footer, formula, heading, mark, page, picture_fit, picture_size, plane,
points, rule, stack, table, table_size, text_size, the_largest_step_this_copy_takes,
what_this_page_gave_up, write
)
from ppt_shapes import connect, preset, timeline
from ppt_icons import add_icon, find_icons, the_ink_an_icon_covers
from ppt_charts import (
TooSmall, column, contrast, fmt, hline, horizontal_bar, ink_on, key, line_height, linear,
number, pick_size, poly, rect, shades, span, text_width, type_face, vline, waterfall,
write_label
)
from ppt_template import (
add_unit, backdrop, bundled, clear_region, clone_page, clone_shape, drop_shape,
layout_pictures, page_box, prototype, raise_type, remove_unit, replace_picture, replace_text,
shape_at, shape_near, shape_saying, shapes_in, units, wash
)
```
Every `deck/build/references/...` link on this page is a file in the build directory,
beside the modules it documents, and that whole path is what `read_file` takes -- the file
tools resolve against the workspace, not the directory your program runs in. A table drawn
without reading its reference gets the bare default.
`ppt_layout`, always present:
| | |
| --- | --- |
| `page(kicker=True, footer=False)` | → `Frame(kicker, title, body, footer)`, four boxes inside the safe area; ask for the footer on a page that cites or carries a page number, and the body gives up the strip for it |
| `footer(slide, box, theme, *, note=None, number=True, colour=None, font=None, cjk_font=None)` | draws that strip: a hairline across it, `note` on the left, and the page number on the right as a real `slidenum` field. **`note` is one line** -- the strip is the page's bottom edge and a second line goes into the margin, so a note too long for the lane (the strip less 1.6in for the number) comes back as this call refusing, with the width it had and the width it needed. Every bundled template defines a page-number placeholder on its master and puts one on no page, and python-pptx does not clone a footer placeholder onto a slide — so a deck gets page numbers only if the script draws them |
| `Frame(kicker, title, body, footer)` | the same four boxes as a value you can build. `page()` is the ordinary page and not the only one: a frame you make yourself is what a left rail, a full-bleed opener or a title over two thirds of the canvas is made of, and every helper that takes a frame takes yours without knowing the difference |
| `frame.laying(*heights, gutter=GUTTER)` | **the default way to lay a content page's body.** A cursor down the body with the leftover already spent between the bands, so the last band ends on the body's own floor. Pass the bands, take them back in the same order, and **no `skip` between them** -- the gaps are what the leftover became. Two bands or more; one band has no gap to spend and comes back centred, which is `holding`'s case |
| `frame.holding(*heights)` | the same frame with its body cut to the run these heights add up to, and the leftover split as air above and below that run instead of a band of white along the page's foot. The bands and the gaps between them, in the order they occur; a list works too. For the path where the page measures its bands and takes them off a cursor -- **not** for a run something else already spreads into the whole body (`card_group(..., down=True)`), whose cards would then touch. Only the body moves, so it can be asked before or after `heading`, and a run with no slack comes back unchanged |
| `Box.corners(x0, y0, x1, y1)` | a box from its **two corners** |
| `Box.at(x, y, w=, h=)` | a box from a corner and a **size**; the size is keyword-only. It reads back under the same four names (`box.x`, `box.y`, `box.w`, `box.h`) as well as `box.x0..y1` |
| `box.rows(n, gutter=GUTTER, weights=None)`, `box.columns(...)` | n boxes filling this one |
| `box.grid(cols, rows, gutter=GUTTER)` | row-major cells |
| `box.split_left(fraction, gutter=GUTTER)`, `box.split_top(...)` | two boxes, the first taking `fraction` |
| `box.inset(dx=PAD, dy=None)` | a smaller box inside this one |
| `stack(box, gutter=0)` | a cursor down a region: `.take(height)`, `.rest()`, `.skip(height)`, `.left`, `.short_by(*heights)`, `.spread(*heights)`, `.centre(*heights)`; bands are adjacent, `skip` is the gap |
| `picture_fit(slide, image, box, theme, *, caption=None, size=LABEL_PT, align="center", font=None, cjk_font=None)` | a picture scaled to fit the box whole, centred. `caption` draws a strip under it and **the deck's captions do not go there** -- they go in `footer(note=)`; it is for the label that says which cell of a small multiple this is |
| `heading(slide, frame, theme, title, kicker=None, *, tint="surface", bleed=True, size=TITLE_PT, anchor="middle", font=None, cjk_font=None)` | §6.5 — `anchor` is the template's, not this default; §8 |
| `write(slide, box, text, *, size=BODY_PT, colour="#000000", font=None, cjk_font=None, bold=False, align="left", anchor="top", spacing=1.15)` | `text` may be a list of paragraphs |
| `points(slide, box, theme, items, *, size=BODY_PT, numbered=False, mark="•", colour=None, font=None, cjk_font=None, mark_colour=None, spacing=1.25)` | §6.5 — it takes the theme, so the faces are optional here |
| `card(slide, box, theme, *, icon=None, title="", body=(), tint="surface", size=BODY_PT, title_size=LEAD_PT, font=None, cjk_font=None)` | §7 |
| `card_group(slide, box, theme, items, *, down=False, gutter=GUTTER)` | a row of cards across the region, or a column down it with `down=True`. Each item is a dict of `card`'s own arguments, so every field it carries reaches the card; a row is levelled with `card_size` and centred, a column keeps each card's own height and `spread`s the leftover. §7 |
| `formula(slide, box, text, theme, *, size=BODY_PT, align="left", anchor="top", font=None, cjk_font=None)` | §9 |
| `plane(slide, box, theme, tint="surface", radius=True, opacity=1.0)` | a painted region, rounded. **A group of copy that sits on the page's own ground has no edge, and a reader cannot see where one group ends and the next begins** -- three columns of body copy under a band came back as "the components have no boundaries". Put every group that is not page furniture on a plane; `radius=False` only for a band running to the trim |
| `rule(slide, box, theme, thickness=0.03, colour=None)` | a hairline **0.06in below** the box and **at most 1.05in long** — a short mark under a heading or beside a number, not a divider across a region. For a full-width line draw a thin `plane`, or take the box a chart hands back |
| `table(slide, box, rows, theme, *, weights=None, size=LABEL_PT, numeric_from=None, style="header_tint", emphasize_rows=(), emphasize_columns=(), group_rows=None, indent_rows=(), total_rows=(), marks=None, header_size=None, align=None, rule_pt=None, grid_pt=None, row_height=None, header_height=None, padding=None, fill=True, column_rules=True, banding=False, fills=None)` | §6 |
| `Run(text, size=None, bold=None, colour=None)` | one stretch of a line with its own size, weight or colour — a paragraph handed to `write` may be a list of these instead of a string |
| `mark(slide, box, theme, kind, value=None, *, colour=None)` | [deck/build/references/tables.md](deck/build/references/tables.md) |
| `overlaps(boxes, tolerance=0.01)` | → the `(i, j)` pairs that overlap |
Constants: `CANVAS_W`, `CANVAS_H`, `MARGIN`, `GUTTER`, `PAD`; the ramp `TITLE_PT`,
`LEAD_PT`, `BODY_PT`, `LABEL_PT`, `KICKER_PT`, `NUMBER_PT`, `BODY_FLOOR_PT`.
### What comes back, and how to ask before you draw
Every helper that *draws* hands back a `Drawn` — the five that compute instead hand
back what they computed: `page()` a `Frame`, `stack()` a `Stack`, `overlaps()` a list
of `(i, j)` pairs, a `Box` divider a `Box` or a list of them, and `mark()` a `Marks`,
which is a list of the shapes it made carrying `.box` for the ink they actually cover
— the one measurement that says whether a marked column is wide enough to read. A
`card_group` reads the same way: the cards' own `Drawn`s in order, carrying `.box` for
the run as a whole.
For the drawing ones: `.shape` is the python-pptx object it made and `.box` is **what it
actually covered**, not the box you passed in -- a rule sits below the box it underlines, a
picture keeps its own aspect, and copy that did not fit comes back taller than its box. An
attribute the tuple does not carry is looked for on the shape and then on the box, so
`write(...).paragraphs`, `table(...).columns` and `heading(...).x1` read straight through.
Place the next thing on the page off the last thing's `.box`, never off the number you
chose for it; `overlaps` takes those boxes and names the pairs that collide.
And every one of them can be asked before it draws, which is what turns a render
round into an `if`:
| | |
| --- | --- |
| `lines_needed(text, width, *, size=BODY_PT, font=None, bold=False)` | how many lines this copy wraps onto at that width |
| `text_size(text, width, *, size=BODY_PT, font=None, bold=False, spacing=1.15)` | the box the copy really needs, at the origin: `.h` is what to ask a stack for, `.w` is what the longest line actually sets |
| `points_size(items, width, *, size=BODY_PT, font=None, spacing=1.25)` | the same for a bulleted list, whose hanging mark and paragraph spacing `text_size` knows nothing about |
| `fits(what, box, *, size=BODY_PT, font=None, bold=False, spacing=1.15)` | yes or no. `what` is copy, or any box one of these handed back |
| `table_size(rows, theme, *, weights=None, size=LABEL_PT, style="header_tint", numeric_from=None, group_rows=None, marks=None, header_size=None, indent_rows=(), row_height=None, header_height=None, padding=None, fill=True, box=None)` | where the table ends, before a cell of it is drawn. With `box` it is placed at that box's corner and held to its width |
| `picture_size(image, box, *, caption=None, size=LABEL_PT)` | the room the figure needs inside `box`, off the image's own pixels. Pass `caption` only where `picture_fit` is going to draw one, or the reservation is for a strip nothing fills |
| `formula_type_size(text, width, *, size=BODY_PT, font=None)` | the size `formula` will really set it at; one that comes back at `BODY_FLOOR_PT` wants a wider column, not another build |
| `the_largest_step_this_copy_takes(text, box, *, font=None, bold=False, spacing=1.15, wrap=False, largest=TITLE_PT)` | the biggest step of the ramp the copy still fits that box at — the only call that answers upwards. `wrap=False` keeps it on the lines you gave it; `wrap=True` is for copy meant to reflow. `largest` is the step to stop at and you name it: `TITLE_PT` for a label in a shape, `LEAD_PT` for a line that leads a band, `BODY_PT` for copy, `NUMBER_PT` when the copy is the figure. It is not inferred — a character count cannot tell a long word from a sentence |
| `what_this_page_gave_up()` | every concession the measuring calls made on this page since you last asked, and it clears the list as it answers. A ramp walk that reached `BODY_FLOOR_PT` and a formula that broke at a separator both come back here: they returned a size rather than raising, so the page looks measured and the copy was quietly cut down to fit. Call it once a page is drawn and read what it says before the build does |
| `card_body_box(box, *, icon=None, title="", title_size=LEAD_PT)` | where a card's copy starts, once the icon and the title have taken their line |
| `card_size(width, *, icon=None, title="", body=(), size=BODY_PT, title_size=LEAD_PT, font=None)` | how tall a card has to be for what goes in it — `max(card_size(w, **c).h for c in cards)` levels a row without padding it out to the page, which is what `card_group` does for you; reach for this on its own for a group that is not a plain row or column |
| `stack(box).room` | what is still unspoken for, as a box, **without taking it** — `fits(picture_size(fig, down.room), down.room)` is the whole question |
| `stack(box).short_by(*heights)` | how many inches the whole plan runs over, or 0.0 — measure every band, ask this, **then** draw. `rest()` spends the region it answers with; `room` is the same box and does not |
| `stack(box).slack(*heights)` | the same arithmetic the other way: how many inches the region has left once these bands are in it |
| `stack(box).centre(*heights)` | half that leftover above the run, half below, and hands the cursor back to chain. For a single run that sits against something beside it |
| `stack(box).spread(*heights)` | the leftover becomes the gaps *between* the bands, so the run ends on the region's bottom edge. **A lane of cards, and two columns that have to come out level.** Never less than `GUTTER` between them, so a run with no leftover overruns instead of welding — count the n-1 gaps into `short_by` and shorten the bands. No `skip` after it, which overruns by exactly what was skipped |
**A short label in a big box: ask, do not name a step.** Every call above except the last
measures downwards. What that leaves out is the label its box is far too big for: naming
the smallest step of the ramp puts a stage label at 14pt in a shape 1.25in tall. Two or
three characters in a box over an inch tall want
`the_largest_step_this_copy_takes(label, one.box, font=F)`. Everything playing one role on
the page shares one size, so ask for each and take the `min`.
**Ask `lines_needed` before you fix a band's height.** Copy that runs long does not
shrink (§8) -- it runs out of its box and over whatever is under it.
`lines_needed(title, frame.title.w, size=TITLE_PT)` coming back 2 is the row below moving
down or the box getting wider, decided before anything is drawn.
`ppt_charts` answers the same kind of question about a chart, by running it against a
slide that draws nothing:
| | |
| --- | --- |
| `the_smallest_box_a_chart_needs(chart, theme, *data, **knobs)` | the smallest box this chart takes **this** data in, as a `Box` at the origin |
| `whether_a_chart_fits(chart, box, theme, *data, **knobs)` | whether it would take the box you have at all |
| `what_a_chart_will_do(chart, box, theme, *data, **knobs)` | the `Drawn` a real draw would return, with nothing written |
A chart's `Drawn` **is** a `Box` — the plot itself, what is left once the category labels,
the axis readings and the key have taken theirs — and it carries `where` (the chart's own
scale, so a rule at 80% goes where the chart put 80%), `names_not_written` and
`readings_not_written` (what it dropped for want of room), `marks_not_to_scale` (bubbles
drawn at the floor instead of to area) and `type_pt` (the step of the ramp its labels
landed on — a reading, never a setting). `nothing_was_dropped` is those three in one
boolean.
A chart that will not take its box raises `TooSmall`, carrying `short`: the deficit in
inches as `(across, down)`. **It raises before it draws anything**, so a `try/except`
around one has no wreckage to clear -- and `whether_a_chart_fits` is that `try/except`
already written.
`ppt_charts`, always present — twenty-three charts drawn as shapes. Each takes the slide,
a `Box` out of the grid, the theme, and its data; each fills the box, and there is no
size, face or colour to pass: type comes off the ramp above and steps down when a label
does not fit, colour comes off the theme. Signatures and the data shape each one reads:
[deck/build/references/charts.md](deck/build/references/charts.md) (§6).
`ppt_shapes`, always present — the 109 Office preset geometries a business page can
use, by their DrawingML names, and the two layouts built on them. Signatures in
[deck/build/references/shapes.md](deck/build/references/shapes.md), with §7.5.
`ppt_template`, only when a template is bound:
| | |
| --- | --- |
| `prototype(template, number)` | the template's page `number`, counting from 1 |
| `bundled(name)` | another bundled template by file name, for a page borrowed from it (§8); found through `PPT_BUNDLED_TEMPLATES`, which `ppt_build` sets |
| `clone_page(presentation, prototype)` | **copy a template page into the deck, its words and all -- the one way a template page is put to work**; §8 |
| `units(container)`, `arrangement(run)` | the page's repeating units; how a run is laid out |
| `boxes(run)` | each unit's `(left, top, width, height)` in inches, page order — a size, **not** a `ppt_layout.Box`, so `boxes(run)[0][2]` is a width and not a far edge |
| `place(unit, box)` | move one unit; the box is `(left, top, width, height)` in inches, and a `ppt_layout.Box` is accepted and converted from its two corners |
| `shape_at(slide, number)`, `drop_shape(shape)` | one shape by index, counting from 1; remove it |
| `shape_near(container, left, top, tol=0.08, with_text=False)` | one shape by where the page shows it, in inches |
| `shape_saying(container, prefix)` | one shape by the copy it starts with |
| `page_position(shape)` | `(left, top)` in inches on the page, groups resolved |
| `page_box(shape)` | where a shape is drawn, as the **two corners** a region is given in, with the scale its group applies -- so it drops straight into `clear_region` |
| `shapes_in(container, box, *, share=0.5, with_text=False)` | every shape drawn in `box` -- a `ppt_layout.Box` or a `page_box(shape)`, never four bare numbers -- groups walked into -- `shape_near`'s plural, and the way to find by place rather than by words; `share` is how much of a shape must be inside to count, and `share=0` asks what touches the box at all |
| `clear_region(container, box, *, share=0.5, keep=())` | empty `box` -- `Box.corners(...)`, `Box.at(...)` or `page_box(shape)`, since four bare numbers cannot say which reading they are and are refused -- so you can draw in it: `drop_shape` for everything `shapes_in` finds, returning what it removed and, in `left_standing`, what still lies over the box. `keep` spares a shape by the words it shows or by its `# [n]` |
| `raise_type(slide, floor=BODY_FLOOR_PT, min_chars=COPY_CHARS)` | lift copy the template states under the readability floor (`BODY_FLOOR_PT` is 14pt) and let its box grow to hold it |
| `replace_text(target, text, new=None)`, `replace_picture(shape, image, fit="contain", *, anchor="centre", trim=None, zoom=1.0, alpha=None, box=None)` | in place, keeping how the template set it; `alpha` washes the new picture the way `backdrop` does, for the frame that is the page. `shape` may be a drawing rather than a frame -- a group of freeforms, a cartoon -- or a list of shapes making one: the picture takes its box and its depth and the drawing goes |
| `backdrop(slide, image, *, alpha=1.0, scrim=0.62, ink=None, light_type=True, box=None, anchor="centre", trim=None, zoom=1.0)` | a photograph behind everything on the page, cover-cropped to the canvas (or `box`), at full strength under a plane of the theme's ink at `scrim`, with ev