
Deck Design Ppt
- 9 installs
- 53 repo stars
- Updated July 9, 2026
- appautomaton/presentation
deck-design-ppt is a Claude skill that creates new presentation decks as native editable PPTX files with consulting-quality design.
About
This skill creates new presentation decks as native editable PPTX files with consulting-quality design. A developer or consultant uses it to build a pitch deck, board update, or strategy deck from a brief or topic where the output must be editable in PowerPoint or Keynote. It uses slide masters, theme colors, a 21-pattern communication library, and pptxgenjs to make every element an editable PowerPoint object, and produces a markdown outline before building.
- Creates native editable PPTX decks with consulting-quality design
- Every element is PowerPoint-native (text boxes, shapes, charts)
- Ships a 21-pattern library and five style palettes
Deck Design Ppt by the numbers
- 9 all-time installs (skills.sh)
- Ranked #1,469 of 1,880 Design & UI/UX skills by installs in the Skillselion catalog
- Data as of Jul 28, 2026 (Skillselion catalog sync)
deck-design-ppt capabilities & compatibility
- Capabilities
- deck generation · ui design · presentations
- Use cases
- presentations · ui design
What deck-design-ppt says it does
Create new presentation decks as native editable PPTX files with consulting-quality design.
npx skills add https://github.com/appautomaton/presentation --skill deck-design-pptAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 9 |
|---|---|
| repo stars | ★ 53 |
| Last updated | July 9, 2026 |
| Repository | appautomaton/presentation ↗ |
What it does
Build a native editable PPTX pitch or strategy deck from a brief using slide masters and a pattern library.
Who is it for?
Building a new editable slide deck or pitch deck from a brief where PowerPoint editability matters.
Skip if: Editing existing .pptx files (use the pptx skill) or pixel-perfect PDF output (use deck-design-pdf).
When should I use this skill?
You want a new editable PowerPoint deck from a brief or topic.
What you get
A native editable .pptx is generated via pptxgenjs with slide masters and pattern-based layouts.
- Editable .pptx deck
- Deck outline markdown
By the numbers
- 21 communication patterns (15 P-series, 6 C-series)
- Five style palettes
- Three density levels L1/L2/L3
Files
Deck Design — Operational Playbook
What This Skill Does
- Input: a deck brief + any structured data the user has (tables, time series, bridges, evaluation criteria, etc.).
- Output: a native editable `.pptx` file with slide masters, theme colors, and all content as PowerPoint-native objects (text boxes, shapes, charts). Every element is individually editable in PowerPoint.
The brief
The brief is everything the user provides about what they want. Before generating anything, extract these signals:
| Signal | Examples | Defaults if absent |
|---|---|---|
| Objective | "pitch to Series A investors", "board strategy update", "SBIR Phase II proposal deck" | General presentation |
| Audience | "DoD program managers", "VC partners", "internal team" | General professional |
| Brand identity | Logo colors, company name, client palette | Palette defaults |
| Tone / firm style | "McKinsey-style", "clean and modern", "urgent/high-stakes" | Infer from audience + objective |
| Density | "dense and evidence-heavy", "keep it simple", specific L1/L2/L3 | Infer from audience + objective |
| Data | Tables, metrics, timelines, comparisons, evaluations | None — build from research or request more |
Not every brief contains all signals. Extract what's there, infer what you can, and use defaults for the rest. Do not ask the user to fill out a checklist. If the user provides a custom palette, brand guide, or design spec, follow it — the built-in styles are defaults, not constraints.
Storyboard intake (from consultant skill)
When the input is a storyboard artifact (from the consultant skill), the brief extraction is already done. Map directly:
| Storyboard field | deck-design-ppt step |
|---|---|
| Firm overlay | Style (Phase 1, step 2) |
| Density level | Density (Phase 1, step 3) |
| Per-slide data shape | Pattern routing (Phase 1, step 6) |
| Per-slide structured data | Build script data objects (Phase 2, step 8) |
Skip Phase 1 steps 1 and 5. The storyboard provides the content decisions; deck-design-ppt provides the visual execution.
Pattern library (21 communication patterns)
| Tier | Namespace | What it answers | Use when |
|---|---|---|---|
| Tier 1 | P-series (p01 … p15) | "What communication move is this slide making?" | All decks |
| Tier 2 | C-series (c01 … c06) | "What dense consulting composition does this slide require?" | MBB-style engagement deliverables |
All patterns work across all 5 styles — the palette controls the visual identity, not the pattern.
Patterns are reference implementations, not constraints. Use them when they fit the content. When a slide needs a layout that no pattern covers, build custom using pptxgenjs directly — the grid constants, theme tokens, and slide master chrome still apply. The pattern library is a starting vocabulary, not a ceiling.
How To Generate A Deck (Algorithm)
Phase 1 — Understand
1. Analyze the brief. Extract signals from The brief. Research what the brief references — web search for market data, benchmarks, competitors; user-provided data is the primary source. 2. Pick style: consulting-mckinsey / consulting-bcg / consulting-bain / founder / sequoia. See Style Routing. 3. Pick density level. See Density Profiles. 4. Load firm reference (consulting decks only). See Firm Style. 5. Extract data shapes (table, timeline, bridge, grid ratings, etc.). 6. Route each slide to a pattern using the Routing Table, or build custom if no pattern fits.
Phase 1.5 — Outline
Before writing any code, produce a deck outline in markdown. This prevents sparse slides, content overlap, and mid-build surprises.
The outline must include: 1. Governing thought — one sentence that states the deck's answer. 2. Slide list — for each slide: action title, pattern, content summary, and data shape. 3. Flow test — read all action titles in sequence. Do they tell a complete story without the slide bodies? If not, fix the narrative before proceeding. 4. Density check — for each slide, confirm the content fills the body zone without overflowing. Patterns use dynamic vertical centering — content that is too sparse will float; content that exceeds slot budgets will crowd. 5. Data sufficiency — for each slide, confirm you have the data its pattern needs (chart series, metric values, table rows). If not, research to fill gaps before building.
Save the outline as {slug}-outline.md alongside the build script. It serves as both a planning artifact and documentation for future edits.
Phase 2 — Build
7. Read the slot budget for each pattern just-in-time: masters/patterns/<pattern>.slots.md. 8. Write the build script. Assemble the slide list with structured data for each pattern:
const { createDeck } = require('./skills/deck-design-ppt/masters');
createDeck('consulting-mckinsey', [
{ pattern: 'p01-cover', data: { title: '...', subtitle: '...' } },
{ pattern: 'p10-agenda', data: { items: [...] } },
{ pattern: 'p04-scorecard', data: { title: '...', cards: [...] } },
{ pattern: 'p03-evidence', data: { chart: {...}, callouts: [...] } },
{ pattern: 'c05-divider', data: { sectionNum: '02', title: '...' } },
{ pattern: 'p08-closer', data: { title: '...', nextSteps: [...] } },
], 'strategy-update.pptx');9. Run it: node build-deck.js — produces the .pptx directly. No HTML, no browser, no rendering step.
Phase 3 — QA
10. Generate thumbnail grid for visual review and fix any issues:
Use the pptx skill's thumbnail script to generate a preview grid of the deck.
Output Organization
Save deliverables to the current working directory (or a user-specified output folder). Use kebab-case naming derived from the deck title:
{slug}.pptx— the deliverablebuild-{slug}.js— the build script (reproducible){slug}-outline.md— the deck outline (content plan)
Intermediate artifacts (QA thumbnails, temp rasterizations) go to the system temp directory — do not leave them in the workspace.
Architecture
Self-contained: package.json + node_modules/ are inside the skill folder. All require() calls resolve locally — no workspace-level install needed. Run npm install inside this skill folder if node_modules/ is missing.
The build kit lives in masters/:
| File | Purpose |
|---|---|
masters/index.js | createDeck(palette, slides, output) — orchestrator |
masters/grid.js | Spatial constants (margins, body zone, footer Y). One grid, all patterns use it. |
masters/theme.js | Palette name → theme object (colors, fonts, flags) |
masters/layouts.js | Defines slide masters (COVER, CONTENT, DIVIDER, CLOSER) parameterized by theme |
masters/patterns/*.js | 21 pattern functions — each fills content into the body zone |
masters/patterns/*.slots.md | Character budgets per pattern (loaded just-in-time) |
masters/examples/*.js | 8 advanced visual reference scripts (dumbbell, gauge, process flow, composite, scenario, multi-panel, data table, gantt) |
Slide masters are parameterized by the theme — one set of master definitions works for all 5 styles. The theme controls:
- Header bar (yes/no + color)
- Footer rule, logo, page number colors
- Canvas background
- Accent color for titles, highlights
Pattern functions receive a slide (already has master chrome), the pptx instance, content data, and the theme. They only place content in the body zone — never touch the header, footer, or margins.
Grid constants (grid.js) define the spatial contract:
bodyY/bodyEndY— body zone boundariesmarginL/contentW— horizontal marginsfooterRuleY/footerTextY— footer positionscenterY(contentH)— vertically center content in body zone
Style Routing
| If the deck is… | Use palette | Notes |
|---|---|---|
| Consulting / board / exec update / engagement deliverable | consulting-mckinsey, consulting-bcg, or consulting-bain | Match firm by content shape |
| Startup pitch / product narrative / growth story | founder | Clean, modern blue |
| Crisis / urgency / downturn memo / "burn/runway" rhetoric | sequoia | Dark, dramatic, red accent |
Palette files in palettes/ define colors, fonts, chart rules, and mode variations.
Firm Style (Consulting Decks)
For every consulting deck, pick the firm style whose philosophy best fits the content:
| Content shape | Best fit | Why |
|---|---|---|
| Conclusion-first, variance analysis, "what happened and why" | McKinsey | Verdict-driven titles + waterfall exhibits |
| Framework evaluation, multi-criteria scoring, "how options compare" | BCG | Evaluation matrices + panel mini-headers |
| Diagnostic, decision support, "here are the facts, here's what we think" | Bain | Facts-vs-Perspectives frame |
Load the corresponding firm reference:
| Firm style | Reference |
|---|---|
| McKinsey | references/mckinsey.md |
| BCG | references/bcg.md |
| Bain | references/bain.md |
When density level requires references/craft.md (L2+), the firm file layers on top.
Density Profiles
| Context | Level | Pattern scope | Also read |
|---|---|---|---|
| Startup pitch, roadshow, board update | L1 Narrative | P-series only | — |
| Corporate strategy, business review | L2 Structured | P + selective C-series | references/craft.md §1–§4 |
| MBB engagement, due diligence, deep analysis | L3 Dense | Full library; C-series expected | references/craft.md §1–§7 |
Routing Table
| User input shape / intent | Pattern | Notes |
|---|---|---|
| Cover page / identity | p01-cover | Slide 1 in almost every deck |
| 2×2 positioning / quadrant map | p02-matrix | Needs 2 axes + 4–8 items |
| Claim + chart proof (line, bar) | p03-evidence | Native PowerPoint chart + sidebar callouts |
| 4–8 KPIs / metrics / health check | p04-scorecard | Cards with number + label + trend |
| Timeline / progression | p05-narrative-arc | Milestones on a horizontal axis |
| Binary choice (A vs B) | p06-fork | Criteria grid with recommendation |
| Process / mechanism / flywheel | p07-machine | Numbered steps with connector |
| Closing ask / next step | p08-closer | Centered recommendation + bullets |
| Comparison table (rows × columns) | p09-data-table | Financial tables, delta coloring |
| Agenda / table of contents | p10-agenda | Section list with active highlight |
| Product / platform demo | p11-product-showcase | Product area + feature cards |
| Team / founders / engagement team | p12-team-grid | 4 cards with name + role + bio |
| Dense evidence: exhibit + sidebar | c01-multi-evidence | Chart + metrics row + drivers sidebar |
| Start/end with intermediate deltas | c02-waterfall | Stacked bar bridge + interpretation panels |
| Color-coded evaluation grid | c03-eval-grid | Criteria × options with RAG fills |
| Facts vs perspectives (two-column) | c04-facts-perspectives | 57/43 split — data left, judgment right |
| Section divider (full-bleed) | c05-divider | Dark background, section number + title |
| Stacked vertical bar chart | p13-stacked-bar | Segmented bars with legend, annotation sidebar |
| Ranked horizontal bars | p14-horizontal-bar | Data-driven widths, highlight row, value labels |
| Bubble matrix (size = magnitude) | p15-bubble-matrix | Area-proportional circles on rows × columns grid |
| Gantt / workplan timeline | c06-workplan | Calendar grid, row spans, milestone markers |
Advanced visuals (build custom — masters/examples/)
No pre-built pattern. Study the script, adapt the technique.
| Visual type | Script | Technique |
|---|---|---|
| Dumbbell chart (before→after) | dumbbell-chart.js | Axis scaling, arrow shapes, SVG gradient bg |
| Gauge / arc indicators | gauge-arcs.js | Arc math, stacked distribution bars, bar-anchored text |
| Process flow diagram | process-flow-diagram.js | Node graphs, icon rasterization, SVG gradients |
| Multi-zone composite | multi-zone-composite.js | Zone layout, data-driven bars, rich text footer columns |
| Scenario comparison cards | scenario-cards.js | Nested columns, multi-level bullets |
| Multi-panel segmented bars | multi-panel-analysis.js | Stacked bars, dashed brackets, rotated labels |
| Data table with takeaways | outsourcing-mix-table.js | Row fills, chip highlights, chevron connectors |
| Gantt workplan | gantt-workplan.js | Calendar grid, requirement bubbles, status markers |
Composition Rules
- Start with
p01-cover(most decks) orc05-divider(mid-deck section entry). - Do not repeat the same pattern back-to-back. Alternate patterns by content type.
- One slide = one argument. Every action title advances a distinct claim.
- Use interstitials intentionally:
p10-agendaat section openings;c05-dividerfor chapter breaks. - Footnotes: bracket style (
[1]), restart numbering per slide. - Density level governs composition. Do not use L3 techniques on an L1 deck.
- Section rhythm. For decks >8 slides, group into 3-4 sections. Open each section with
p10-agenda(active item) orc05-divider. Close with a synthesis slide before the next section. - Firm composition minimums. McKinsey: ≥1 waterfall (
c02) per variance analysis. BCG: panel mini-headers on every multi-panel slide. Bain: ≥40% of analytic slides usec04-facts-perspectivesin diagnostic mode. - Chart variety. Do not use the same chart type (bar, line, table) on consecutive slides. Alternate data shapes to maintain visual engagement.
- Content fit. Each pattern's slot budget (
*.slots.md) defines character limits and item counts. Before routing, verify your content fits: too few items produces a sparse slide; too many causes crowding. When in doubt, check the slot file's data schema and item ranges. - Visual balance. Content is vertically centered in the body zone (between title and footer). Short content centers naturally; dense content fills the zone. If a slide looks top-heavy or bottom-heavy in QA, adjust the content volume — don't force positioning.
- Spatial constraints. PPTX uses absolute positioning — no responsive layout. Content must fit between
bodyYandbodyEndY. Anchor elements to zone boundaries and usevalign+fit:'shrink'— never manually estimate text heights for Y positioning.
Slot Budgets (Progressive Loading)
Slot budgets are stored per-pattern at masters/patterns/<pattern>.slots.md. Load just-in-time when building each slide — do not read all 21 upfront.
What NOT To Do
- Do not create HTML slide files. Use the
createDeck()API directly. - Do not use Playwright or browser rendering for slide content. All slide content must be native PPTX objects (text, shapes, charts) so the output is editable. Exception: rasterizing assets with no PPTX-native equivalent (e.g., SVG gradients, icon fonts) — see
masters/examples/for techniques. - Do not scatter colors — define a consistent palette once and reference it throughout.
- Do not position headers or footers in pattern functions — the slide master handles chrome.
@font-face {
font-family: "Arimo";
font-style: normal;
font-weight: 400 700;
font-display: swap;
src: url("./Arimo-wght.ttf") format("truetype");
}
@font-face {
font-family: "Arimo";
font-style: italic;
font-weight: 400 700;
font-display: swap;
src: url("./Arimo-Italic-wght.ttf") format("truetype");
}
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Copyright 2015 The Public Sans Project Authors (https://github.com/uswds/public-sans)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
@font-face {
font-family: "Public Sans";
font-style: normal;
font-weight: 100 900;
font-display: swap;
src: url("./PublicSans-wght.ttf") format("truetype");
}
@font-face {
font-family: "Public Sans";
font-style: italic;
font-weight: 100 900;
font-display: swap;
src: url("./PublicSans-Italic-wght.ttf") format("truetype");
}
Copyright 2010-2020 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
@font-face {
font-family: "Source Sans 3";
font-style: normal;
font-weight: 200 900;
font-display: swap;
src: url("./SourceSans3-wght.ttf") format("truetype");
}
@font-face {
font-family: "Source Sans 3";
font-style: italic;
font-weight: 200 900;
font-display: swap;
src: url("./SourceSans3-Italic-wght.ttf") format("truetype");
}
Copyright 2014 The Source Serif 4 Project Authors (https://github.com/adobe-fonts/source-serif)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
@font-face {
font-family: "Source Serif 4";
font-style: normal;
font-weight: 200 900;
font-display: swap;
src: url("./SourceSerif4-Variable.ttf") format("truetype");
}
@font-face {
font-family: "Source Serif 4";
font-style: italic;
font-weight: 200 900;
font-display: swap;
src: url("./SourceSerif4-Italic-Variable.ttf") format("truetype");
}
const G = require('./grid');
function estimateLines(text, charsPerLine = 72) {
if (!text) return 0;
return String(text)
.split(/\r?\n/)
.reduce((total, rawLine) => {
const line = rawLine.trim();
if (!line) return total + 1;
let lines = 1;
let width = 0;
line.split(/\s+/).forEach((word) => {
const nextWidth = width === 0 ? word.length : width + 1 + word.length;
if (nextWidth > charsPerLine) {
lines += 1;
width = word.length;
} else {
width = nextWidth;
}
});
return total + lines;
}, 0);
}
function estimateTextHeight(text, options = {}) {
if (!text) return 0;
const charsPerLine = options.charsPerLine ?? 72;
const lineH = options.lineH ?? 0.16;
const padding = options.padding ?? 0.04;
const minH = options.minH ?? lineH;
return Math.max(minH, estimateLines(text, charsPerLine) * lineH + padding);
}
function getContentFrame(data, options = {}) {
const titleY = options.titleY ?? G.titleY;
const bodyEndY = options.bodyEndY ?? G.bodyEndY;
const titleH = estimateTextHeight(data.title, {
charsPerLine: options.titleCharsPerLine ?? 74,
lineH: options.titleLineH ?? 0.21,
padding: options.titlePadding ?? 0.04,
minH: options.titleMinH ?? 0.3,
});
const subtitleH = data.subtitle
? estimateTextHeight(data.subtitle, {
charsPerLine: options.subtitleCharsPerLine ?? 88,
lineH: options.subtitleLineH ?? 0.14,
padding: options.subtitlePadding ?? 0.02,
minH: options.subtitleMinH ?? 0.16,
})
: 0;
const subtitleY = titleY + titleH + (data.subtitle ? options.titleToSubtitleGap ?? 0.04 : 0);
const headerBottom = data.subtitle ? subtitleY + subtitleH : titleY + titleH;
const bodyY = Math.max(options.minBodyY ?? G.bodyY, headerBottom + (options.headerToBodyGap ?? 0.1));
const bodyH = Math.max(0.2, bodyEndY - bodyY);
return {
titleY,
titleH,
subtitleY,
subtitleH,
bodyY,
bodyH,
bodyEndY,
centerY(contentH, centerOptions = {}) {
const minPad = centerOptions.minPad ?? 0.04;
return Math.max(bodyY + minPad, bodyY + (bodyH - contentH) / 2);
},
};
}
function drawContentHeader(slide, data, theme, options = {}) {
const frame = getContentFrame(data, options);
if (data.sectionTag) {
slide.addText(data.sectionTag, {
x: G.marginL,
y: options.tagY ?? G.tagY,
w: G.contentW,
h: 0.15,
fontSize: options.tagFontSize ?? 8,
fontFace: theme.font,
color: theme.textFine,
bold: true,
charSpacing: 1,
margin: 0,
fit: 'shrink',
});
}
slide.addText(data.title, {
x: G.marginL,
y: frame.titleY,
w: G.contentW,
h: frame.titleH,
fontSize: options.titleFontSize ?? 15,
fontFace: theme.fontDisplay,
color: theme.accent,
bold: true,
margin: 0,
fit: 'shrink',
valign: 'top',
breakLine: false,
});
if (data.subtitle) {
slide.addText(data.subtitle, {
x: G.marginL,
y: frame.subtitleY,
w: G.contentW,
h: frame.subtitleH,
fontSize: options.subtitleFontSize ?? 10,
fontFace: theme.font,
color: theme.textSec,
margin: 0,
fit: 'shrink',
valign: 'top',
});
}
return frame;
}
module.exports = {
drawContentHeader,
estimateLines,
estimateTextHeight,
getContentFrame,
};
// This script rebuilds the Indiana workforce automation slide as an editable PPTX.
// The background glow is rasterized to a temp PNG, while all text, lines, labels,
// and dumbbell-chart elements are native PowerPoint objects for maintainability.
const fs = require('fs');
const os = require('os');
const path = require('path');
const pptxgen = require('pptxgenjs');
const sharp = require('sharp');
const stripPptxMetadata = require(path.join(__dirname, '..', 'strip-pptx-metadata.js'));
const OUTPUT_PATH = process.argv[2]
? path.resolve(process.argv[2])
: path.join(__dirname, 'indiana-Workforce-02-30-automation.pptx');
const SLIDE = {
width: 960,
height: 540,
widthIn: 10,
heightIn: 5.625
};
const FONTS = {
serif: 'Source Serif 4',
sans: 'Source Sans 3'
};
const COLORS = {
bgBaseStart: '#02243f',
bgBaseMid: '#0d2c76',
bgBaseEnd: '#1634a7',
bgRightGlowStart: '#375dff',
bgRightGlowMid: '#1838b0',
bgRightGlowEnd: '#091e62',
bgLeftGlowStart: '#00414e',
bgLeftGlowMid: '#002d42',
bgLeftGlowEnd: '#001f38',
fg: '#f2f4fb',
line: '#5f7099',
lineStrong: '#98a4b9',
axisLine: '#d7ddec',
axisMarker: '#8ea1cf',
cyan: '#12aef0',
lavender: '#b8c8ff',
arrow: '#070b14',
allRowBg: '#8b8f98',
allRowText: '#05070c',
footWhite: '#f1f5fc',
deltaWhite: '#f5f5f5'
};
// Slide-level anchors keep the reconstructed plot aligned to the reference design.
// Chart data lives below in `sections`; these numbers are the visual frame it sits inside.
const LAYOUT = {
titleLeft: 34,
titleTop: 14,
titleWidth: 900,
titleHeight: 66,
legendTop: 76,
legendDotTop: 81,
legendDotSize: 10,
legendItem1DotLeft: 47,
legendItem1TextLeft: 67,
legendItem1Width: 390,
legendItem2DotLeft: 476,
legendItem2TextLeft: 496,
legendItem2Width: 380,
accelLeft: 34,
accelTop: 108,
accelWidth: 560,
subtitleLeft: 34,
subtitleTop: 128,
subtitleWidth: 820,
headerLeftLabelLeft: 40,
headerOccLeft: 296,
headerTop: 167,
headerWidth: 220,
axisLeft: 516,
axisTop: 178,
axisWidth: 404,
axisLineHeight: 2,
tickHeight: 7,
tickWidth: 2,
tickLabelTop: 155,
axisMarkerHeight: 18,
axisMarkerTop: 171,
headerRuleLeft: 34,
headerRuleTop: 191,
headerRuleWidth: 886,
headerRuleHeight: 1,
sectionRuleLeft: 34,
sectionRuleWidth: 886,
sectionRuleHeight: 2,
rowRuleLeft: 295,
rowRuleWidth: 625,
rowRuleHeight: 1,
groupTitleLeft: 40,
groupTitleWidth: 250,
occupationLeft: 293,
occupationWidth: 287,
occupationHeight: 18,
occupationAnchorOffset: 7,
deltaLabelWidth: 28,
deltaLabelHeight: 16,
deltaLabelTopOffset: 9,
allRowBgLeft: 292,
allRowBgTop: 475,
allRowBgWidth: 628,
allRowBgHeight: 17,
footnoteLeft: 34,
footnoteBottom: 24,
sourceBottom: 8
};
const AXIS = {
min: 0,
max: 40,
markerValue: Number((((232 / LAYOUT.axisWidth) * 40)).toFixed(4)),
ticks: [0, 10, 20, 30, 40]
};
function axisPxToValue(pixelX) {
return Number((((pixelX - LAYOUT.axisLeft) / LAYOUT.axisWidth) * (AXIS.max - AXIS.min)).toFixed(4));
}
function axisValueToPx(value) {
return Number((LAYOUT.axisLeft + ((value - AXIS.min) / (AXIS.max - AXIS.min)) * LAYOUT.axisWidth).toFixed(2));
}
function makeRow({
occupation,
labelTop,
chartTop = labelTop,
startPx,
endPx,
deltaLabel,
separatorTop,
all = false,
deltaColor = COLORS.fg
}) {
return {
occupation,
labelTop,
chartTop,
withoutGenAi: axisPxToValue(startPx),
withGenAi: axisPxToValue(endPx),
deltaLabel,
separatorTop,
all,
deltaColor
};
}
// Canonical dumbbell-table model: section titles, occupation labels, and adoption values live here.
// Rows still keep a few explicit y-anchors because the original slide uses bespoke spacing, not a uniform table grid.
const sections = [
{
titleTop: 213,
titleLines: [
'High increase in labor demand and high',
'change of work activities'
],
dividerTop: 262,
rows: [
makeRow({ occupation: 'STEM professionals', labelTop: 204, startPx: 659, endPx: 816, deltaLabel: '16', separatorTop: 213 }),
makeRow({ occupation: 'Education and workforce training', labelTop: 221, startPx: 590, endPx: 753, deltaLabel: '16', separatorTop: 229 }),
makeRow({ occupation: 'Creatives and arts management', labelTop: 237, startPx: 619, endPx: 768, deltaLabel: '15', separatorTop: 246 }),
makeRow({ occupation: 'Business and legal professionals', labelTop: 253, chartTop: 254, startPx: 674, endPx: 819, deltaLabel: '14' })
]
},
{
titleTop: 338,
titleLines: [
'High increase in labor demand and',
'modest change of work activities'
],
dividerTop: 442,
rows: [
makeRow({ occupation: 'Managers', labelTop: 270, startPx: 655, endPx: 751, deltaLabel: '9', separatorTop: 278 }),
makeRow({ occupation: 'Community services', labelTop: 286, chartTop: 287, startPx: 701, endPx: 793, deltaLabel: '9', separatorTop: 295 }),
makeRow({ occupation: 'Agriculture', labelTop: 303, startPx: 786, endPx: 818, deltaLabel: '3', separatorTop: 311 }),
makeRow({ occupation: 'Health Professionals', labelTop: 319, startPx: 639, endPx: 702, deltaLabel: '6', separatorTop: 327 }),
makeRow({ occupation: 'Builders', labelTop: 336, startPx: 772, endPx: 835, deltaLabel: '6', separatorTop: 344 }),
makeRow({ occupation: 'Property Maintenance', labelTop: 352, startPx: 639, endPx: 701, deltaLabel: '6', separatorTop: 360 }),
makeRow({ occupation: 'Health aides, technicians, and wellness', labelTop: 369, startPx: 677, endPx: 717, deltaLabel: '4', separatorTop: 377 }),
makeRow({ occupation: 'Food services', labelTop: 385, startPx: 834, endPx: 889, deltaLabel: '5', separatorTop: 393 }),
makeRow({ occupation: 'Transportation services', labelTop: 401, chartTop: 402, startPx: 724, endPx: 779, deltaLabel: '5', separatorTop: 410 }),
makeRow({ occupation: 'Mechanical installation and repair', labelTop: 418, startPx: 794, endPx: 847, deltaLabel: '5', separatorTop: 426 }),
makeRow({ occupation: 'Production work', labelTop: 434, startPx: 825, endPx: 871, deltaLabel: '4' })
]
},
{
titleTop: 445,
titleLines: [
'Modest decrease in labor demand',
'with modest change of work activities'
],
rows: [
makeRow({ occupation: 'Customer service and sales', labelTop: 451, startPx: 745, endPx: 805, deltaLabel: '6', separatorTop: 459 }),
makeRow({ occupation: 'Office support', labelTop: 467, startPx: 830, endPx: 897, deltaLabel: '7', separatorTop: 476 }),
makeRow({ occupation: 'All sectors', labelTop: 483, chartTop: 484, startPx: 731, endPx: 812, deltaLabel: '8', all: true, deltaColor: COLORS.deltaWhite })
]
}
];
const TEXT = {
titleLines: [
'2. By 2030, 30 percent of hours worked today could be automated',
'in the U.S.'
],
legend1: 'Automation adoption without generative AI acceleration',
legend2: 'Automation adoption with generative AI acceleration',
accel: `XX \u2013 Acceleration in automation adoption from generative AI`,
subtitle: 'Midpoint automation adoption by 2030 as a share of time spent on work activities, US, %',
headerLeft: 'Change in Labor Demand & Adoption',
headerOcc: 'Occupation',
footnote: '1. Totals are weighted by 2022 employment in each occupation',
source: 'Source: O*NET; US Bureau of Labor Statistics; McKinsey Global Institute analysis'
};
function pxToInX(value) {
return Number(((value / SLIDE.width) * SLIDE.widthIn).toFixed(4));
}
function pxToInY(value) {
return Number(((value / SLIDE.height) * SLIDE.heightIn).toFixed(4));
}
function pxToPt(value) {
return Number(((value * 72) / 96).toFixed(2));
}
function pptColor(hex) {
return hex.replace('#', '').toUpperCase();
}
async function createBackgroundPng(outputPath) {
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${SLIDE.width}" height="${SLIDE.height}" viewBox="0 0 ${SLIDE.width} ${SLIDE.height}">
<defs>
<linearGradient id="base" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stop-color="${COLORS.bgBaseStart}"/>
<stop offset="54%" stop-color="${COLORS.bgBaseMid}"/>
<stop offset="100%" stop-color="${COLORS.bgBaseEnd}"/>
</linearGradient>
<radialGradient id="glowRight" cx="50%" cy="50%" r="50%">
<stop offset="0%" stop-color="${COLORS.bgRightGlowStart}" stop-opacity="0.9"/>
<stop offset="40%" stop-color="${COLORS.bgRightGlowMid}" stop-opacity="0.56"/>
<stop offset="72%" stop-color="${COLORS.bgRightGlowEnd}" stop-opacity="0"/>
</radialGradient>
<radialGradient id="glowLeft" cx="50%" cy="50%" r="50%">
<stop offset="0%" stop-color="${COLORS.bgLeftGlowStart}" stop-opacity="0.62"/>
<stop offset="48%" stop-color="${COLORS.bgLeftGlowMid}" stop-opacity="0.2"/>
<stop offset="75%" stop-color="${COLORS.bgLeftGlowEnd}" stop-opacity="0"/>
</radialGradient>
</defs>
<rect width="100%" height="100%" fill="url(#base)"/>
<ellipse cx="940.8" cy="64.8" rx="600" ry="350" fill="url(#glowRight)"/>
<ellipse cx="38.4" cy="496.8" rx="350" ry="280" fill="url(#glowLeft)"/>
</svg>`;
await sharp(Buffer.from(svg))
.png()
.toFile(outputPath);
}
function addTextBox(slide, text, options) {
slide.addText(text, {
margin: 0,
color: pptColor(COLORS.fg),
fontFace: FONTS.sans,
...options
});
}
function addMultilineText(slide, lines, options) {
slide.addText(
lines.map((line, index) => ({
text: line,
options: { breakLine: index < lines.length - 1 }
})),
{
margin: 0,
color: pptColor(COLORS.fg),
fontFace: FONTS.sans,
...options
}
);
}
function addTitle(slide) {
slide.addText(
TEXT.titleLines.map((line, index) => ({
text: line,
options: { breakLine: index < TEXT.titleLines.length - 1, bold: true }
})),
{
x: pxToInX(LAYOUT.titleLeft),
y: pxToInY(LAYOUT.titleTop),
w: pxToInX(LAYOUT.titleWidth),
h: pxToInY(LAYOUT.titleHeight),
margin: 0,
fontFace: FONTS.serif,
fontSize: pxToPt(30),
lineSpacingMultiple: 1.05,
color: pptColor('#f3f6fd')
}
);
}
function addLegend(slide, pptx) {
const items = [
{
dotLeft: LAYOUT.legendItem1DotLeft,
textLeft: LAYOUT.legendItem1TextLeft,
width: LAYOUT.legendItem1Width,
color: COLORS.cyan,
label: TEXT.legend1
},
{
dotLeft: LAYOUT.legendItem2DotLeft,
textLeft: LAYOUT.legendItem2TextLeft,
width: LAYOUT.legendItem2Width,
color: COLORS.lavender,
label: TEXT.legend2
}
];
items.forEach((item) => {
slide.addShape(pptx.ShapeType.ellipse, {
x: pxToInX(item.dotLeft),
y: pxToInY(LAYOUT.legendDotTop),
w: pxToInX(LAYOUT.legendDotSize),
h: pxToInY(LAYOUT.legendDotSize),
fill: { color: pptColor(item.color) },
line: { color: pptColor(item.color), transparency: 100, width: 0 }
});
addTextBox(slide, item.label, {
x: pxToInX(item.textLeft),
y: pxToInY(LAYOUT.legendTop),
w: pxToInX(item.width),
h: pxToInY(20),
fontSize: pxToPt(14),
fit: 'shrink',
wrap: false,
valign: 'mid',
color: pptColor('#f1f5fd')
});
});
}
function addHeaders(slide) {
addTextBox(slide, TEXT.accel, {
x: pxToInX(LAYOUT.accelLeft),
y: pxToInY(LAYOUT.accelTop),
w: pxToInX(LAYOUT.accelWidth),
h: pxToInY(20),
fontSize: pxToPt(15),
fit: 'shrink',
wrap: false,
valign: 'mid',
color: pptColor('#eef3fb')
});
addTextBox(slide, TEXT.subtitle, {
x: pxToInX(LAYOUT.subtitleLeft),
y: pxToInY(LAYOUT.subtitleTop),
w: pxToInX(LAYOUT.subtitleWidth),
h: pxToInY(20),
fontSize: pxToPt(17),
bold: true,
fit: 'shrink',
wrap: false,
valign: 'mid',
color: pptColor('#f3f5fd')
});
addTextBox(slide, TEXT.headerLeft, {
x: pxToInX(LAYOUT.headerLeftLabelLeft),
y: pxToInY(LAYOUT.headerTop),
w: pxToInX(230),
h: pxToInY(16),
fontSize: pxToPt(14),
bold: true
});
addTextBox(slide, TEXT.headerOcc, {
x: pxToInX(LAYOUT.headerOccLeft),
y: pxToInY(LAYOUT.headerTop),
w: pxToInX(100),
h: pxToInY(16),
fontSize: pxToPt(14),
bold: true
});
}
function addAxis(slide, pptx) {
slide.addShape(pptx.ShapeType.rect, {
x: pxToInX(LAYOUT.axisLeft),
y: pxToInY(LAYOUT.axisTop),
w: pxToInX(LAYOUT.axisWidth),
h: pxToInY(LAYOUT.axisLineHeight),
fill: { color: pptColor(COLORS.axisLine) },
line: { color: pptColor(COLORS.axisLine), transparency: 100, width: 0 }
});
AXIS.ticks.forEach((tick) => {
const tickLeft = axisValueToPx(tick);
const labelX = tick === AXIS.max ? tickLeft - 10 : tickLeft - 14;
addTextBox(slide, String(tick), {
x: pxToInX(labelX),
y: pxToInY(LAYOUT.tickLabelTop),
w: pxToInX(28),
h: pxToInY(20),
fontSize: pxToPt(18),
bold: true,
color: pptColor(COLORS.fg)
});
slide.addShape(pptx.ShapeType.rect, {
x: pxToInX(tickLeft - 1),
y: pxToInY(LAYOUT.axisTop),
w: pxToInX(LAYOUT.tickWidth),
h: pxToInY(LAYOUT.tickHeight),
fill: { color: pptColor(COLORS.axisLine) },
line: { color: pptColor(COLORS.axisLine), transparency: 100, width: 0 }
});
});
slide.addShape(pptx.ShapeType.rect, {
x: pxToInX(axisValueToPx(AXIS.markerValue) - 1),
y: pxToInY(LAYOUT.axisMarkerTop),
w: pxToInX(2),
h: pxToInY(LAYOUT.axisMarkerHeight),
fill: { color: pptColor(COLORS.axisMarker) },
line: { color: pptColor(COLORS.axisMarker), transparency: 100, width: 0 }
});
}
function addRules(slide, pptx) {
slide.addShape(pptx.ShapeType.rect, {
x: pxToInX(LAYOUT.headerRuleLeft),
y: pxToInY(LAYOUT.headerRuleTop),
w: pxToInX(LAYOUT.headerRuleWidth),
h: pxToInY(LAYOUT.headerRuleHeight),
fill: { color: pptColor('#8996b7') },
line: { color: pptColor('#8996b7'), transparency: 100, width: 0 }
});
sections.forEach((section) => {
if (typeof section.dividerTop === 'number') {
slide.addShape(pptx.ShapeType.rect, {
x: pxToInX(LAYOUT.sectionRuleLeft),
y: pxToInY(section.dividerTop),
w: pxToInX(LAYOUT.sectionRuleWidth),
h: pxToInY(LAYOUT.sectionRuleHeight),
fill: { color: pptColor(COLORS.lineStrong) },
line: { color: pptColor(COLORS.lineStrong), transparency: 100, width: 0 }
});
}
section.rows.forEach((row) => {
if (typeof row.separatorTop === 'number') {
slide.addShape(pptx.ShapeType.rect, {
x: pxToInX(LAYOUT.rowRuleLeft),
y: pxToInY(row.separatorTop),
w: pxToInX(LAYOUT.rowRuleWidth),
h: pxToInY(LAYOUT.rowRuleHeight),
fill: { color: pptColor(COLORS.line) },
line: { color: pptColor(COLORS.line), transparency: 100, width: 0 }
});
}
});
});
}
function addGroupTitles(slide) {
sections.forEach((section) => {
addMultilineText(slide, section.titleLines, {
x: pxToInX(LAYOUT.groupTitleLeft),
y: pxToInY(section.titleTop),
w: pxToInX(LAYOUT.groupTitleWidth),
h: pxToInY(34),
fontSize: pxToPt(14),
bold: true,
italic: true,
lineSpacingMultiple: 1.05,
color: pptColor('#f3f5fb')
});
});
}
function addAllRowBackground(slide, pptx) {
slide.addShape(pptx.ShapeType.rect, {
x: pxToInX(LAYOUT.allRowBgLeft),
y: pxToInY(LAYOUT.allRowBgTop),
w: pxToInX(LAYOUT.allRowBgWidth),
h: pxToInY(LAYOUT.allRowBgHeight),
fill: { color: pptColor(COLORS.allRowBg) },
line: { color: pptColor(COLORS.allRowBg), transparency: 100, width: 0 }
});
}
function addOccupationLabels(slide) {
sections.forEach((section) => {
section.rows.forEach((row) => {
const labelY = row.labelTop - LAYOUT.occupationAnchorOffset;
if (row.all) {
slide.addText([
{ text: 'All sectors', options: { bold: true, color: pptColor(COLORS.allRowText) } },
{ text: '1', options: { superscript: true, fontSize: pxToPt(11), bold: true, color: pptColor(COLORS.allRowText) } }
], {
x: pxToInX(LAYOUT.occupationLeft),
y: pxToInY(labelY),
w: pxToInX(150),
h: pxToInY(LAYOUT.occupationHeight),
margin: 0,
fontFace: FONTS.sans,
fontSize: pxToPt(15),
wrap: false,
fit: 'shrink',
valign: 'top',
color: pptColor(COLORS.allRowText)
});
return;
}
addTextBox(slide, row.occupation, {
x: pxToInX(LAYOUT.occupationLeft),
y: pxToInY(labelY),
w: pxToInX(LAYOUT.occupationWidth),
h: pxToInY(LAYOUT.occupationHeight),
fontSize: pxToPt(15),
fit: 'shrink',
wrap: false,
valign: 'top',
color: pptColor('#f3f6fd')
});
});
});
}
function addDumbbellRow(slide, pptx, row) {
const startX = axisValueToPx(row.withoutGenAi);
const endX = axisValueToPx(row.withGenAi);
const deltaLabelLeft = ((startX + endX) / 2) - (LAYOUT.deltaLabelWidth / 2);
// Each row is rendered natively as a dumbbell: start dot, arrow bar, end dot, and delta label.
// This preserves editability while staying visually close to the HTML reference.
slide.addShape(pptx.ShapeType.line, {
x: pxToInX(startX + 4),
y: pxToInY(row.chartTop),
w: pxToInX(Math.max(endX - startX - 10, 0)),
h: 0,
line: {
color: pptColor(COLORS.arrow),
width: 1.5,
beginArrowType: 'none',
endArrowType: 'triangle'
}
});
slide.addShape(pptx.ShapeType.ellipse, {
x: pxToInX(startX - 4),
y: pxToInY(row.chartTop - 4),
w: pxToInX(9),
h: pxToInY(9),
fill: { color: pptColor(COLORS.cyan) },
line: { color: pptColor(COLORS.cyan), transparency: 100, width: 0 }
});
slide.addShape(pptx.ShapeType.ellipse, {
x: pxToInX(endX - 4),
y: pxToInY(row.chartTop - 4),
w: pxToInX(9),
h: pxToInY(9),
fill: { color: pptColor(COLORS.lavender) },
line: { color: pptColor(COLORS.lavender), transparency: 100, width: 0 }
});
addTextBox(slide, row.deltaLabel, {
x: pxToInX(deltaLabelLeft),
y: pxToInY(row.chartTop - LAYOUT.deltaLabelTopOffset),
w: pxToInX(LAYOUT.deltaLabelWidth),
h: pxToInY(LAYOUT.deltaLabelHeight),
fontSize: pxToPt(15),
bold: true,
align: 'center',
valign: 'mid',
color: pptColor(row.deltaColor)
});
}
function addDumbbells(slide, pptx) {
sections.forEach((section) => {
section.rows.forEach((row) => addDumbbellRow(slide, pptx, row));
});
}
function addFooter(slide) {
addTextBox(slide, TEXT.footnote, {
x: pxToInX(LAYOUT.footnoteLeft),
y: pxToInY(SLIDE.height - LAYOUT.footnoteBottom - 10),
w: pxToInX(460),
h: pxToInY(12),
fontSize: pxToPt(10),
bold: true,
color: pptColor(COLORS.footWhite)
});
addTextBox(slide, TEXT.source, {
x: pxToInX(LAYOUT.footnoteLeft),
y: pxToInY(SLIDE.height - LAYOUT.sourceBottom - 10),
w: pxToInX(520),
h: pxToInY(12),
fontSize: pxToPt(10),
bold: true,
color: pptColor(COLORS.fg)
});
}
async function buildSlide(externalPptx) {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'indiana-workforce-automation-'));
const backgroundPath = path.join(tempDir, 'indiana-workforce-02-30-automation-bg.png');
try {
await createBackgroundPng(backgroundPath);
const pptx = externalPptx || new pptxgen();
if (!externalPptx) pptx.layout = 'LAYOUT_16x9';
const slide = pptx.addSlide();
slide.addImage({ path: backgroundPath, x: 0, y: 0, w: SLIDE.widthIn, h: SLIDE.heightIn });
addTitle(slide);
addLegend(slide, pptx);
addHeaders(slide);
addAxis(slide, pptx);
addRules(slide, pptx);
addGroupTitles(slide);
addAllRowBackground(slide, pptx);
addOccupationLabels(slide);
addDumbbells(slide, pptx);
addFooter(slide);
if (!externalPptx) {
fs.mkdirSync(path.dirname(OUTPUT_PATH), { recursive: true });
await pptx.writeFile({ fileName: OUTPUT_PATH });
await stripPptxMetadata(OUTPUT_PATH);
fs.rmSync(tempDir, { recursive: true, force: true });
console.log(`Wrote: ${OUTPUT_PATH}`);
}
return pptx;
} catch (error) {
console.error(`Build failed. Temp files kept at: ${tempDir}`);
throw error;
}
}
module.exports = { buildSlide };
if (require.main === module) buildSlide().catch((e) => { console.error(e); process.exitCode = 1; });
// Virginia detailed workplan slide — fully native editable PPTX.
// Demonstrates: gantt-like plan driven from row model, calendar grid, status triangles,
// deliverable markers, requirement bubbles, biweekly status indicators.
const path = require('path');
const pptxgen = require('pptxgenjs');
const stripPptxMetadata = require(path.join(__dirname, '..', 'strip-pptx-metadata.js'));
let pptx = new pptxgen();
const OUTPUT_PATH = process.argv[2]
? path.resolve(process.argv[2])
: path.join(__dirname, 'Spend-Virginia-31-Detailed-Workplan.pptx');
const SLIDE = { widthPx: 960, heightPx: 540, widthIn: 10, heightIn: 5.625 };
const FONTS = { body: 'Carlito' };
const COLORS = {
bg: 'F4F4F4', frame: '9B9B9B', green: '35BA7A', greenSoft: 'B9D8B8',
greenDark: '0D6A46', greenText: '3CB884', cellGray: 'E6E6E6',
text: '565656', gridV: 'CBCBCB', gridH: 'D8E4D4',
bubble: 'D3D3D3', bubbleText: '666666', white: 'FFFFFF', rightText: '6F6F6F',
};
// --- Layout zones ---
const HEADER = { left: 50, top: 31, width: 400, height: 28 };
const CONTENT = {
headerLeft: 42, headerTop: 77, headerWidth: 874, headerHeight: 25,
reqListLeft: 42, reqListTop: 127, reqListWidth: 365, reqRowHeight: 29,
bubbleSize: 25, bubbleTextGap: 17,
gridLeft: 407, gridTop: 127, gridWidth: 509, gridHeight: 319,
dayRowTop: 102, dayRowHeight: 25,
};
const FOOTER = { biweeklyTop: 463, trianglesTop: 463, keyTop: 499, deliverableTop: 500 };
const DAYS = ['1-15', '16-30', '31-45', '46-60', '61-75', '76-90'];
const ROWS = [
{ id: '1a', text: 'Build addressable spend baseline', start: 0, span: 2 },
{ id: '1b', text: 'Analyze baseline across all categories', start: 1, span: 1 },
{ id: '1c', text: 'Run benchmarking analysis for each category', start: 1, span: 3 },
{ id: '1d', text: 'Develop list of actions to reduce spend', start: 1, span: 3 },
{ id: '1e', text: 'Provide high-level implementation roadmap', start: 2, span: 3 },
{ id: '1f', text: 'Identify improvements in source-to-pay process', start: 2, span: 3 },
{ id: '1g', text: 'Identify ways to achieve full savings potential', start: 2, span: 3 },
{ id: '1h', text: 'Recommend timelines to complete initiatives', start: 3, span: 2 },
{ id: '1i', text: 'Identify barriers / obstacles to execution', start: 3, span: 2 },
{ id: '1j', text: 'Provide Phase 1 final report', start: 4, span: 2 },
{ id: '1k', text: 'Provide proposal for Phase 1 implementation', start: 5, span: 1 },
];
const STATUS_TRIANGLES = [480, 565, 650, 735, 820, 905];
const DELIVERABLES = [
{ label: 'Baseline', x: 525, iconFirst: true },
{ label: 'Interim Report', x: 655, iconFirst: true },
{ label: 'Final Report', x: 790, iconFirst: false },
];
function pxToInX(v) { return Number(((v / SLIDE.widthPx) * SLIDE.widthIn).toFixed(4)); }
function pxToInY(v) { return Number(((v / SLIDE.heightPx) * SLIDE.heightIn).toFixed(4)); }
function pxToPt(v) { return Number(((v * 72) / 96).toFixed(2)); }
function addTextBox(slide, text, options = {}) {
slide.addText(text, { margin: 0, fontFace: FONTS.body, color: COLORS.text, breakLine: false, valign: 'mid', ...options });
}
function drawDeliverableIcon(slide, x, y) {
slide.addShape(pptx.ShapeType.ellipse, {
x: pxToInX(x), y: pxToInY(y), w: pxToInX(24), h: pxToInY(24),
line: { color: COLORS.greenDark, pt: 0.5 }, fill: { color: COLORS.greenDark },
});
addTextBox(slide, '\u2606', {
x: pxToInX(x), y: pxToInY(y + 1), w: pxToInX(24), h: pxToInY(20),
fontSize: pxToPt(18), color: COLORS.white, align: 'center',
});
}
// --- Header ---
function renderHeader(slide) {
addTextBox(slide, 'Execution Plan - Phase 1', {
x: pxToInX(HEADER.left), y: pxToInY(HEADER.top),
w: pxToInX(HEADER.width), h: pxToInY(HEADER.height),
fontSize: pxToPt(24), bold: true, color: COLORS.green,
});
}
// --- Content ---
function renderContent(slide) {
const C = CONTENT;
const dayCellWidth = C.gridWidth / DAYS.length;
// Green header bar
slide.addShape(pptx.ShapeType.rect, {
x: pxToInX(C.headerLeft), y: pxToInY(C.headerTop),
w: pxToInX(C.headerWidth), h: pxToInY(C.headerHeight), fill: { color: COLORS.green },
});
addTextBox(slide, 'Requirement', {
x: pxToInX(C.headerLeft + 12), y: pxToInY(C.headerTop + 5),
w: pxToInX(160), h: pxToInY(18), fontSize: pxToPt(15), bold: true, color: COLORS.white,
});
addTextBox(slide, 'Days', {
x: pxToInX(C.gridLeft), y: pxToInY(C.headerTop + 4),
w: pxToInX(C.gridWidth), h: pxToInY(18), fontSize: pxToPt(14), bold: true, color: COLORS.white, align: 'center',
});
// Day row
DAYS.forEach((day, i) => {
const x = C.gridLeft + dayCellWidth * i;
slide.addShape(pptx.ShapeType.rect, {
x: pxToInX(x), y: pxToInY(C.dayRowTop), w: pxToInX(dayCellWidth), h: pxToInY(C.dayRowHeight),
line: i === DAYS.length - 1 ? undefined : { color: COLORS.gridV, pt: 0.75, dash: 'dot' },
fill: { color: COLORS.cellGray },
});
addTextBox(slide, day, {
x: pxToInX(x), y: pxToInY(C.dayRowTop + 3), w: pxToInX(dayCellWidth), h: pxToInY(18),
fontSize: pxToPt(12), bold: true, color: COLORS.text, align: 'center',
});
});
// Vertical grid lines
for (let i = 1; i < DAYS.length; i++) {
slide.addShape(pptx.ShapeType.line, {
x: pxToInX(C.gridLeft + dayCellWidth * i), y: pxToInY(C.gridTop),
w: 0, h: pxToInY(C.gridHeight), line: { color: COLORS.gridV, pt: 1, dash: 'dot' },
});
}
// Requirement rows
ROWS.forEach((row, i) => {
const rowTop = C.reqListTop + i * C.reqRowHeight;
// Horizontal separator
if (i > 0) {
slide.addShape(pptx.ShapeType.line, {
x: pxToInX(C.gridLeft), y: pxToInY(rowTop), w: pxToInX(C.gridWidth), h: 0,
line: { color: COLORS.gridH, pt: 1, dash: 'dot' },
});
}
// ID bubble
slide.addShape(pptx.ShapeType.ellipse, {
x: pxToInX(C.reqListLeft + 14), y: pxToInY(rowTop + 2),
w: pxToInX(C.bubbleSize), h: pxToInY(C.bubbleSize),
line: { color: COLORS.bubble, pt: 0.5 }, fill: { color: COLORS.bubble },
});
addTextBox(slide, row.id, {
x: pxToInX(C.reqListLeft + 14), y: pxToInY(rowTop + 5),
w: pxToInX(C.bubbleSize), h: pxToInY(18),
fontSize: pxToPt(13), color: COLORS.bubbleText, align: 'center',
});
// Requirement text
addTextBox(slide, row.text, {
x: pxToInX(C.reqListLeft + 14 + C.bubbleSize + C.bubbleTextGap), y: pxToInY(rowTop + 3),
w: pxToInX(300), h: pxToInY(22),
fontSize: pxToPt(14), bold: true, color: COLORS.text,
});
// Gantt fill
slide.addShape(pptx.ShapeType.rect, {
x: pxToInX(C.gridLeft + dayCellWidth * row.start), y: pxToInY(rowTop),
w: pxToInX(dayCellWidth * row.span), h: pxToInY(C.reqRowHeight),
fill: { color: COLORS.greenSoft },
});
});
// Copyright sidebar
addTextBox(slide, 'Copyright \u00A9 2022 by Boston Consulting Group, All rights reserved.', {
x: pxToInX(934), y: pxToInY(123), w: pxToInX(10), h: pxToInY(315),
fontSize: pxToPt(7.5), color: COLORS.rightText, vert: 'vert270', align: 'center',
});
}
// --- Footer ---
function renderFooter(slide) {
const F = FOOTER;
// Bi-weekly label
addTextBox(slide, 'Bi-Weekly Status Updates', {
x: pxToInX(223), y: pxToInY(F.biweeklyTop), w: pxToInX(250), h: pxToInY(18),
fontSize: pxToPt(13), italic: true, bold: true, color: COLORS.greenText, align: 'center',
});
// Status triangles
STATUS_TRIANGLES.forEach(left => {
slide.addShape(pptx.ShapeType.triangle, {
x: pxToInX(left - 11), y: pxToInY(F.trianglesTop), w: pxToInX(22), h: pxToInY(18),
line: { color: '45BE8F', pt: 0.5 }, fill: { color: '45BE8F' },
});
});
// Key deliverables label
addTextBox(slide, 'Key Deliverables', {
x: pxToInX(280), y: pxToInY(F.keyTop), w: pxToInX(180), h: pxToInY(18),
fontSize: pxToPt(13), italic: true, bold: true, color: COLORS.greenDark, align: 'center',
});
// Deliverable items
DELIVERABLES.forEach(item => {
if (item.iconFirst) {
drawDeliverableIcon(slide, item.x, F.deliverableTop);
addTextBox(slide, item.label, {
x: pxToInX(item.x + 34), y: pxToInY(F.deliverableTop + 1),
w: pxToInX(120), h: pxToInY(22),
fontSize: pxToPt(13), bold: true, color: COLORS.greenDark,
});
} else {
addTextBox(slide, item.label, {
x: pxToInX(item.x), y: pxToInY(F.deliverableTop + 1),
w: pxToInX(90), h: pxToInY(22),
fontSize: pxToPt(13), bold: true, color: COLORS.greenDark,
});
drawDeliverableIcon(slide, item.x + 90, F.deliverableTop);
}
});
}
// --- Entry point ---
async function buildSlide(externalPptx) {
if (externalPptx) pptx = externalPptx;
if (!externalPptx) {
pptx.layout = 'LAYOUT_16x9';
pptx.lang = 'en-US';
pptx.theme = { headFontFace: FONTS.body, bodyFontFace: FONTS.body, lang: 'en-US' };
}
const slide = pptx.addSlide();
slide.background = { color: COLORS.bg };
slide.addShape(pptx.ShapeType.rect, {
x: 0, y: 0, w: SLIDE.widthIn, h: SLIDE.heightIn,
line: { color: COLORS.frame, pt: 1 }, fill: { color: COLORS.bg },
});
renderHeader(slide);
renderContent(slide);
renderFooter(slide);
if (!externalPptx) {
await pptx.writeFile({ fileName: OUTPUT_PATH });
await stripPptxMetadata(OUTPUT_PATH);
}
return pptx;
}
module.exports = { buildSlide };
if (require.main === module) buildSlide().catch((e) => { console.error(e); process.exitCode = 1; });
// AP Health comparison slide — fully native editable PPTX.
// All elements (gauges, stacked bars, text, legends) are native PowerPoint objects.
// One `countryRows` data model drives country order, gauge scores, arc colors, and segment percentages.
const path = require('path');
const fs = require('fs');
const pptxgen = require('pptxgenjs');
const stripPptxMetadata = require(path.join(__dirname, '..', 'strip-pptx-metadata.js'));
const OUTPUT_PATH = process.argv[2]
? path.resolve(process.argv[2])
: path.join(__dirname, 'aphealth2020-14-healthcare-sys.pptx');
// --- Scaling ---
const SOURCE_WIDTH = 1300;
const SOURCE_HEIGHT = 726;
const TARGET_WIDTH = 960;
const TARGET_HEIGHT = 540;
const TARGET_WIDTH_IN = 10;
const TARGET_HEIGHT_IN = 5.625;
const SCALE_X = TARGET_WIDTH / SOURCE_WIDTH;
const SCALE_Y = TARGET_HEIGHT / SOURCE_HEIGHT;
const AVG_SCALE = (SCALE_X + SCALE_Y) / 2;
function sx(v) { return Number((v * SCALE_X).toFixed(2)); }
function sy(v) { return Number((v * SCALE_Y).toFixed(2)); }
function sFont(v) { return Number((v * AVG_SCALE).toFixed(2)); }
function pxToInX(v) { return Number(((v / TARGET_WIDTH) * TARGET_WIDTH_IN).toFixed(4)); }
function pxToInY(v) { return Number(((v / TARGET_HEIGHT) * TARGET_HEIGHT_IN).toFixed(4)); }
// --- Zone boundaries ---
const HEADER_HEIGHT = sy(20);
const FOOTER_TOP = sy(571);
const FOOTER_HEIGHT = Number((TARGET_HEIGHT - FOOTER_TOP).toFixed(2));
function contentY(sourceY) { return Number((sy(sourceY) - HEADER_HEIGHT).toFixed(2)); }
// --- Colors ---
const C = {
bg: 'E8E8E8', text: '1F1F22', dark: '5B5D61', mid: 'AFB1B4',
ring: 'AFB1B4', red: 'F12C21', border: 'DEDEDE',
};
// --- Layout ---
const L = {
leftRailLeft: sx(28), leftRailWidth: sx(8),
topRailTop: contentY(70), topRailHeight: sy(234),
bottomRailTop: contentY(332), bottomRailHeight: sy(224),
leftPanelLeft: sx(53), sideSubWidth: 146, sideLegendWidth: 146.88,
countryColumnWidth: sx(146), countryRuleWidth: sx(114),
countryRuleHeight: Math.max(1.5, sy(3)), countryRuleMarginTop: sy(10),
gaugeWidth: sx(106), gaugeHeight: sy(106),
consumerDistTop: sy(182), physicianDistTop: sy(452),
naTop: sy(347), distWidth: sx(145), distHeight: sy(70),
footerLeft: sx(30),
footerWidth: Number((TARGET_WIDTH - (sx(30) * 2)).toFixed(2)),
footerSourceWidth: Number(((TARGET_WIDTH - (sx(30) * 2)) / 1.02).toFixed(2)),
};
const F = {
sideTitle: sFont(30), sideSub: sFont(21.5), sideLegend: sFont(19.2),
countryName: sFont(25), segment: sFont(18.6), segmentNarrow: sFont(16.8),
segmentTiny: sFont(15.4), notes: sFont(16.4), na: sFont(33),
gaugeValuePt: Number((((31 * AVG_SCALE) * 72) / 96).toFixed(2)),
};
// --- Data ---
const CONSUMER_PANEL = { title: 'Consumer', subText: 'Net Promoter Score\u00AE for places of treatment visited in the past 6 months' };
const PHYSICIAN_PANEL = { title: 'Physician', subText: 'Net Promoter Score for their workplace as a place of treatment' };
const LEGEND_LINES = [
{ text: 'Promoter', color: C.red },
{ text: 'Passive', color: 'B3B4B8' },
{ text: 'Detractor', color: '4F5053' },
];
const countryRows = [
{ name: 'Australia', left: 260,
consumer: { valueText: '23%', color: 'dark', segments: [{ tone: 'red', value: 42, display: '42%' }, { tone: 'mid', value: 38, display: '38' }, { tone: 'dark', value: 20, display: '20' }] },
physician: { valueText: '44%', color: 'dark', segments: [{ tone: 'red', value: 57, display: '57%' }, { tone: 'mid', value: 29, display: '29' }, { tone: 'dark', value: 14, display: '14' }] } },
{ name: 'Singapore', left: 434,
consumer: { valueText: '19', color: 'dark', segments: [{ tone: 'red', value: 38, display: '38%' }, { tone: 'mid', value: 43, display: '43' }, { tone: 'dark', value: 19, display: '19' }] },
physician: { na: true } },
{ name: 'India', left: 609,
consumer: { valueText: '28', color: 'dark', segments: [{ tone: 'red', value: 47, display: '47' }, { tone: 'mid', value: 34, display: '34' }, { tone: 'dark', value: 19, display: '19' }] },
physician: { valueText: '42', color: 'dark', segments: [{ tone: 'red', value: 54, display: '54%' }, { tone: 'mid', value: 33, display: '33' }, { tone: 'dark', value: 13, display: '13' }] } },
{ name: 'Indonesia', left: 783,
consumer: { valueText: '14', color: 'dark', segments: [{ tone: 'red', value: 33, display: '33%' }, { tone: 'mid', value: 49, display: '49' }, { tone: 'dark', value: 19, display: '19' }] },
physician: { valueText: '1', color: 'red', segments: [{ tone: 'red', value: 21, display: '21%', sizeClass: 'micro' }, { tone: 'mid', value: 60, display: '60' }, { tone: 'dark', value: 19, display: '19' }] } },
{ name: 'China', left: 956,
consumer: { valueText: '30', color: 'dark', segments: [{ tone: 'red', value: 46, display: '46%' }, { tone: 'mid', value: 39, display: '39' }, { tone: 'dark', value: 16, display: '16' }] },
physician: { valueText: '22', color: 'dark', segments: [{ tone: 'red', value: 43, display: '43%' }, { tone: 'mid', value: 35, display: '35' }, { tone: 'dark', value: 22, display: '22' }] } },
{ name: 'Thailand', left: 1130,
consumer: { valueText: '5', color: 'red', segments: [{ tone: 'red', value: 35, display: '35%' }, { tone: 'mid', value: 35, display: '35' }, { tone: 'dark', value: 30, display: '30' }] },
physician: { na: true } },
];
// --- Stacked bar segment widths (last segment absorbs rounding) ---
function computeSegmentWidths(segments) {
let used = 0;
return segments.map((seg, i) => {
if (i === segments.length - 1) return Number((L.distWidth - used).toFixed(2));
const w = Number(((seg.value / 100) * L.distWidth).toFixed(2));
used += w;
return w;
});
}
// --- Gauge arc math ---
function gaugeSweepDegrees(valueText) {
const score = Math.max(0, parseFloat(String(valueText)) || 0);
return Number(Math.max(8, (6.19 * score) - (0.07 * score * score)).toFixed(2));
}
function gaugeAngleRange(valueText) {
const sweep = gaugeSweepDegrees(valueText);
return [270, Number(((270 + sweep) % 360).toFixed(2))];
}
// --- Drawing functions ---
function addGauge(slide, pptx, countryLeftSource, gaugeTopSource, gaugeData) {
const xPx = sx(countryLeftSource);
const yPx = Number((sy(gaugeTopSource) - 5.5).toFixed(2));
const x = pxToInX(xPx), y = pxToInY(yPx);
const w = pxToInX(L.gaugeWidth), h = pxToInY(L.gaugeHeight);
const color = gaugeData.color === 'red' ? C.red : C.dark;
slide.addShape(pptx.ShapeType.ellipse, { x, y, w, h, fill: { color: C.bg, transparency: 100 }, line: { color: C.ring, width: 0.95 } });
slide.addShape(pptx.ShapeType.arc, { x, y, w, h, angleRange: gaugeAngleRange(gaugeData.valueText), fill: { color: C.bg, transparency: 100 }, line: { color, width: 2.15 } });
slide.addText(gaugeData.valueText, { x, y: Number((y + h * 0.02).toFixed(4)), w, h, margin: 0, align: 'center', valign: 'mid', fontFace: 'Arial', fontSize: F.gaugeValuePt, bold: true, color, breakLine: false });
}
function addBackground(slide, pptx) {
const H = HEADER_HEIGHT;
slide.background = { color: C.bg };
// Red rails
slide.addShape(pptx.ShapeType.rect, { x: pxToInX(L.leftRailLeft), y: pxToInY(H + L.topRailTop), w: pxToInX(L.leftRailWidth), h: pxToInY(L.topRailHeight), fill: { color: C.red } });
slide.addShape(pptx.ShapeType.rect, { x: pxToInX(L.leftRailLeft), y: pxToInY(H + L.bottomRailTop), w: pxToInX(L.leftRailWidth), h: pxToInY(L.bottomRailHeight), fill: { color: C.red } });
// Panel text: two boxes per panel, same bounds as bar, valign top/bottom
const panelX = pxToInX(L.leftPanelLeft);
const panelW = pxToInX(L.sideSubWidth);
const titlePt = Number(((F.sideTitle * 72) / 96).toFixed(2));
const subPt = Number(((F.sideSub * 72) / 96).toFixed(2));
const legendPt = Number(((F.sideLegend * 72) / 96).toFixed(2));
function addPanel(barTopPx, barHeightPx, panel) {
const y = pxToInY(H + barTopPx);
const h = pxToInY(barHeightPx);
// Title + subtitle: top-aligned
slide.addText([
{ text: panel.title, options: { fontSize: titlePt, bold: true, color: '222327', breakLine: true, paraSpaceAfter: 2 } },
{ text: panel.subText, options: { fontSize: subPt, bold: false, color: '242428' } },
], { x: panelX, y, w: panelW, h, fontFace: 'Arial', margin: 0, valign: 'top', lineSpacingMultiple: 1.08, fit: 'shrink' });
// Legend: bottom-aligned
slide.addText(LEGEND_LINES.map((l, i) => ({
text: l.text, options: { color: l.color, bold: true, breakLine: i < LEGEND_LINES.length - 1 },
})), { x: panelX, y, w: panelW, h, fontFace: 'Arial', fontSize: legendPt, margin: 0, valign: 'bottom', lineSpacingMultiple: 1.12, fit: 'shrink' });
}
addPanel(L.topRailTop, L.topRailHeight, CONSUMER_PANEL);
addPanel(L.bottomRailTop, L.bottomRailHeight, PHYSICIAN_PANEL);
}
function addDistribution(slide, pptx, countryLeftPx, topPx, segments) {
const widths = computeSegmentWidths(segments);
const toneColor = { red: C.red, mid: C.mid, dark: C.dark };
const toneText = { red: 'FFFFFF', mid: '2B2D30', dark: 'F3F3F3' };
let cursor = 0;
segments.forEach((seg, i) => {
const w = widths[i];
const x = pxToInX(sx(countryLeftPx) + cursor);
const y = pxToInY(topPx);
const wIn = pxToInX(w), hIn = pxToInY(L.distHeight);
const fontPt = w <= sx(24) ? Number(((F.segmentTiny * 72) / 96).toFixed(2))
: w <= sx(32) ? Number(((F.segmentNarrow * 72) / 96).toFixed(2))
: Number(((F.segment * 72) / 96).toFixed(2));
slide.addShape(pptx.ShapeType.rect, { x, y, w: wIn, h: hIn, fill: { color: toneColor[seg.tone] } });
if (i < segments.length - 1) slide.addShape(pptx.ShapeType.rect, { x: x + wIn, y, w: pxToInX(0.75), h: hIn, fill: { color: C.border } });
slide.addText(seg.display, { x, y, w: wIn, h: hIn, fontSize: fontPt, fontFace: 'Arial', color: toneText[seg.tone], bold: true, align: 'center', valign: 'middle', margin: 0, fit: 'shrink' });
cursor += w;
});
// Outer border
slide.addShape(pptx.ShapeType.rect, { x: pxToInX(sx(countryLeftPx)), y: pxToInY(topPx), w: pxToInX(L.distWidth), h: pxToInY(L.distHeight), line: { color: C.border, width: 0.5 } });
}
function addCountries(slide, pptx) {
const H = HEADER_HEIGHT;
const namePt = Number(((F.countryName * 72) / 96).toFixed(2));
const naPt = Number(((F.na * 72) / 96).toFixed(2));
for (const country of countryRows) {
const x = pxToInX(sx(country.left));
slide.addText(country.name, { x, y: pxToInY(H), w: pxToInX(L.countryColumnWidth), h: pxToInY(sy(28)), fontSize: namePt, fontFace: 'Arial', color: '25262A', bold: true, margin: 0, fit: 'shrink' });
slide.addShape(pptx.ShapeType.rect, { x, y: pxToInY(H + L.countryRuleMarginTop + sy(24)), w: pxToInX(L.countryRuleWidth), h: pxToInY(L.countryRuleHeight), fill: { color: '2D2F33' } });
addDistribution(slide, pptx, country.left, H + L.consumerDistTop, country.consumer.segments);
if (country.physician.na) {
slide.addText('N/A', { x, y: pxToInY(H + L.naTop), w: pxToInX(L.gaugeWidth), h: pxToInY(sy(36)), fontSize: naPt, fontFace: 'Arial', color: 'B3B4B8', bold: true, align: 'center', margin: 0 });
} else {
addDistribution(slide, pptx, country.left, H + L.physicianDistTop, country.physician.segments);
}
}
}
function addGauges(slide, pptx) {
for (const country of countryRows) {
addGauge(slide, pptx, country.left, 70, country.consumer);
if (!country.physician.na) addGauge(slide, pptx, country.left, 338, country.physician);
}
}
function addFooter(slide) {
const pt = Number(((F.notes * 72) / 96).toFixed(2));
const x = pxToInX(L.footerLeft);
const w = pxToInX(L.footerWidth);
const y = pxToInY(FOOTER_TOP + sy(4));
slide.addText(
'Notes: Consumer Net Promoter Score calculated as a percentage of consumers answering 9 or 10 minus percentage of consumers answering 0\u20136 to the question: \u201COn a scale of 0 to 10 \u2026 how likely are you to recommend the following medical facility/facilities to a friend or colleague as a place for treatment?\u201D; physician Net Promoter Score calculated similarly; weighted average taken to aggregate individual centres to a country level Net Promoter Score; Net Promoter Score\u00AE is a registered trademark of Bain & Company, Inc., Fred Reichheld and Satmetrix Systems, Inc.',
{ x, y, w, h: pxToInY(FOOTER_HEIGHT - sy(20)), fontSize: pt, fontFace: 'Arial', color: C.text, margin: 0, lineSpacingMultiple: 1.23, fit: 'shrink', valign: 'top' }
);
slide.addText('Source: Bain Front Line of Healthcare Asia-Pacific Survey, 2019 (patient n=1,823; physician n=257)', {
x, y: pxToInY(FOOTER_TOP + FOOTER_HEIGHT - sy(20)), w: pxToInX(L.footerSourceWidth), h: pxToInY(sy(18)),
fontSize: pt, fontFace: 'Arial', color: C.text, margin: 0, fit: 'shrink',
});
}
// --- Entry point ---
async function buildSlide(externalPptx) {
const pptx = externalPptx || new pptxgen();
if (!externalPptx) pptx.layout = 'LAYOUT_16x9';
const slide = pptx.addSlide();
addBackground(slide, pptx);
addCountries(slide, pptx);
addGauges(slide, pptx);
addFooter(slide);
if (!externalPptx) {
fs.mkdirSync(path.dirname(OUTPUT_PATH), { recursive: true });
await pptx.writeFile({ fileName: OUTPUT_PATH });
await stripPptxMetadata(OUTPUT_PATH);
console.log(`Wrote: ${OUTPUT_PATH}`);
}
return pptx;
}
module.exports = { buildSlide };
if (require.main === module) buildSlide().catch((e) => { console.error(e); process.exitCode = 1; });
// Louisiana DOT attrition slide — fully native editable PPTX.
// Demonstrates: multi-panel layout, segmented stacked bars, dashed overlay brackets,
// axis labels with dot terminators, bullet observations panel, data-driven segment widths.
const path = require('path');
const pptxgen = require('pptxgenjs');
const stripPptxMetadata = require(path.join(__dirname, '..', 'strip-pptx-metadata.js'));
let pptx = new pptxgen();
const OUTPUT_PATH = process.argv[2]
? path.resolve(process.argv[2])
: path.join(__dirname, 'Louisiana-DOT-01.pptx');
const SLIDE = { widthPt: 720, heightPt: 405, widthIn: 10, heightIn: 5.625 };
const FONTS = { body: 'Inter' };
const COLORS = {
bg: 'F3F3F3', frame: '9B9B9B', green: '37A055', greenDark: '298240',
text: '404040', gray: '7A7A7A', rule: 'A6A6A6', lightRule: 'D9D9D9',
p1Light: 'E0E0E0', p1Dark: '666666',
g1: '98D773', g2: '6ECA5D', g3: '4F9B43', g4: '387C2B',
b1: 'BEE0F5', b2: '5FC4D0', b3: '327EBC', b4: '496495',
white: 'FFFFFF',
};
const LAYOUT = {
padLeft: 25, padRight: 25, padTop: 20, padBottom: 15,
titleHeight: 32, panelTop: 67,
p1Width: 140, dividerGap: 15, dividerWidth: 1, p2Width: 330, p3Width: 129,
};
const CONTENT = {
title: [
'74% of senior engineers and product managers have left road and bridge for',
'other internal DOTD roles',
],
panel1: {
header: ['Road and bridge', 'section engineering', 'and PM roles'],
total: '113',
segments: [
{ label: ['Vacant', 'Eng & PM'], value: '27%', share: 0.27, color: COLORS.p1Light, textColor: '333333', dashed: true },
{ label: ['Filled', 'Eng & PM'], value: '73%', share: 0.73, color: COLORS.p1Dark, textColor: COLORS.white },
],
axisLabel: ['Filled and vacant', 'engineering and', 'PM roles'],
yLabels: [
{ top: 0.03, lines: ['Total Eng', 'and PM', "TO's"] },
{ top: 0.25, lines: ['Vacant', 'Eng & PM'] },
{ top: 0.73, lines: ['Filled', 'Eng & PM'] },
],
},
panel2: {
header: ['Since 2020, 35 senior engineering and PM function in road', 'and bridge design have left the group\u00B9'],
total: '35',
leftBar: {
axisLabel: 'Cause of Attrition',
dashedLabel: 'Internal DOTD moves',
dashedShare: 0.74,
segments: [
{ value: '45%', share: 0.45, color: COLORS.g1, label: ['Lateral to', 'another section'] },
{ value: '29%', share: 0.29, color: COLORS.g2, label: ['Promoted to', 'a different section'] },
{ value: '18%', share: 0.18, color: COLORS.g3, label: ['Resigned to', 'work for consultant'] },
{ value: '8%', share: 0.08, color: COLORS.g4, label: ['Retired'] },
],
},
rightBar: {
axisLabel: 'Titles of Attrition',
dashedLabel: 'Turnover of Eng 6 and above',
dashedStart: 0.21,
segments: [
{ value: '21%', share: 0.21, color: COLORS.b1, label: ['Engineer 5'], textColor: '333333' },
{ value: '37%', share: 0.37, color: COLORS.b2, label: ['Engineer 6'], textColor: COLORS.white },
{ value: '32%', share: 0.32, color: COLORS.b3, label: ['E6 DCL'], textColor: COLORS.white },
{ value: '11%', share: 0.11, color: COLORS.b4, label: ['Engineer 7'], textColor: COLORS.white },
],
},
},
panel3: {
header: ['Observations'],
bullets: [
['22% vacancy of', 'engineering and PM', 'roles in road and', 'bridge section'],
['74% of attrition due to', 'lateral or promotion to', 'another DOTD section'],
['18% of positions', 'resigned to work in', 'private sector'],
["80% of staff that left", 'came from title at', 'Engineering 6 or above'],
],
},
footer: '1. Excluded entry and mid-level engineering roles Source: Analysis provided by DOTD Engineering',
};
function ptToIn(v) { return Number((v / 72).toFixed(4)); }
function addTextBox(slide, text, options = {}) {
slide.addText(text, { margin: 0, fontFace: FONTS.body, color: COLORS.text, breakLine: false, valign: 'mid', ...options });
}
function drawRule(slide, xPt, yPt, widthPt) {
slide.addShape(pptx.ShapeType.line, {
x: ptToIn(xPt), y: ptToIn(yPt), w: ptToIn(widthPt - 4), h: 0,
line: { color: COLORS.rule, pt: 1 },
});
slide.addShape(pptx.ShapeType.ellipse, {
x: ptToIn(xPt + widthPt - 4), y: ptToIn(yPt - 2), w: ptToIn(4), h: ptToIn(4),
line: { color: COLORS.rule, pt: 0.5 }, fill: { color: COLORS.rule },
});
}
function renderPanel1(slide, p1X, panelTop) {
addTextBox(slide, CONTENT.panel1.header.join('\n'), {
x: ptToIn(p1X), y: ptToIn(panelTop), w: ptToIn(120), h: ptToIn(32),
fontSize: 11, bold: true, color: '333333',
});
drawRule(slide, p1X, panelTop + 36, 112);
const barX = p1X + 43, barY = panelTop + 82, barW = 50, barH = 200;
addTextBox(slide, CONTENT.panel1.total, {
x: ptToIn(barX), y: ptToIn(barY - 12), w: ptToIn(barW), h: ptToIn(10),
fontSize: 10, bold: true, color: '555555', align: 'center',
});
addTextBox(slide, CONTENT.panel1.yLabels[0].lines.join('\n'), {
x: ptToIn(p1X - 2), y: ptToIn(barY - 2), w: ptToIn(30), h: ptToIn(30),
fontSize: 8, color: COLORS.gray, align: 'right',
});
let segTop = barY;
CONTENT.panel1.segments.forEach((seg, i) => {
const h = barH * seg.share;
slide.addShape(pptx.ShapeType.rect, {
x: ptToIn(barX), y: ptToIn(segTop), w: ptToIn(barW), h: ptToIn(h),
line: seg.dashed ? { color: '888888', pt: 1, dash: 'dash' } : { color: seg.color, pt: 0 },
fill: { color: seg.color },
});
addTextBox(slide, seg.value, {
x: ptToIn(barX), y: ptToIn(segTop + h / 2 - 7), w: ptToIn(barW), h: ptToIn(14),
fontSize: 9, bold: true, color: seg.textColor, align: 'center',
});
const lbl = CONTENT.panel1.yLabels[i + 1];
addTextBox(slide, lbl.lines.join('\n'), {
x: ptToIn(p1X - 2), y: ptToIn(barY + barH * lbl.top - 8), w: ptToIn(30), h: ptToIn(22),
fontSize: 8, color: COLORS.gray, align: 'right',
});
segTop += h;
});
slide.addShape(pptx.ShapeType.line, {
x: ptToIn(barX - 15), y: ptToIn(barY + barH + 3), w: ptToIn(80), h: 0,
line: { color: '888888', pt: 1 },
});
addTextBox(slide, CONTENT.panel1.axisLabel.join('\n'), {
x: ptToIn(barX - 12), y: ptToIn(barY + barH + 5), w: ptToIn(80), h: ptToIn(24),
fontSize: 7.5, bold: true, color: '444444', align: 'center',
});
}
function renderPanel2(slide, p2X, panelTop) {
addTextBox(slide, CONTENT.panel2.header.join('\n'), {
x: ptToIn(p2X), y: ptToIn(panelTop), w: ptToIn(LAYOUT.p2Width), h: ptToIn(32),
fontSize: 11, bold: true, color: '333333',
});
drawRule(slide, p2X, panelTop + 36, 290);
const leftBarX = p2X + 18, rightBarX = p2X + 201;
const p2BarTop = panelTop + 82, p2BarH = 200, p2BarW = 50;
[
{ x: leftBarX, config: CONTENT.panel2.leftBar, total: CONTENT.panel2.total, dashedTopShare: 0, dashedHeightShare: CONTENT.panel2.leftBar.dashedShare, dashedColor: COLORS.green },
{ x: rightBarX, config: CONTENT.panel2.rightBar, total: CONTENT.panel2.total, dashedTopShare: CONTENT.panel2.rightBar.dashedStart, dashedHeightShare: 1 - CONTENT.panel2.rightBar.dashedStart, dashedColor: COLORS.b3 },
].forEach((bar) => {
addTextBox(slide, bar.total, {
x: ptToIn(bar.x), y: ptToIn(p2BarTop - 12), w: ptToIn(p2BarW), h: ptToIn(10),
fontSize: 10, bold: true, color: '555555', align: 'center',
});
// Dashed bracket
const dashedY = p2BarTop + p2BarH * bar.dashedTopShare;
const dashedH = p2BarH * bar.dashedHeightShare;
slide.addShape(pptx.ShapeType.rect, {
x: ptToIn(bar.x - 24), y: ptToIn(dashedY), w: ptToIn(126), h: ptToIn(dashedH),
line: { color: bar.dashedColor, pt: 1, dash: 'dash' }, fill: { color: COLORS.bg, transparency: 100 },
});
// Rotated label — w = bracket height (line width after 270° rotation)
const labelCenterX = bar.x - 12;
const labelCenterY = dashedY + dashedH / 2;
addTextBox(slide, bar.config.dashedLabel, {
x: ptToIn(labelCenterX - dashedH / 2), y: ptToIn(labelCenterY - 7),
w: ptToIn(dashedH), h: ptToIn(14),
fontSize: 7, bold: true, color: bar.dashedColor, rotate: 270, align: 'center',
});
// Bar segments
let cursor = p2BarTop;
bar.config.segments.forEach((seg) => {
const h = p2BarH * seg.share;
slide.addShape(pptx.ShapeType.rect, {
x: ptToIn(bar.x), y: ptToIn(cursor), w: ptToIn(p2BarW), h: ptToIn(h),
line: { color: seg.color, pt: 0 }, fill: { color: seg.color },
});
addTextBox(slide, seg.value, {
x: ptToIn(bar.x), y: ptToIn(cursor + h / 2 - 7), w: ptToIn(p2BarW), h: ptToIn(14),
fontSize: 9, bold: true, color: seg.textColor || COLORS.white, align: 'center',
});
// Segment labels — right of bar
addTextBox(slide, seg.label.join('\n'), {
x: ptToIn(bar.x + p2BarW + 6), y: ptToIn(cursor + h / 2 - 10), w: ptToIn(74), h: ptToIn(22),
fontSize: 8, color: '444444',
});
cursor += h;
});
slide.addShape(pptx.ShapeType.line, {
x: ptToIn(bar.x - 20), y: ptToIn(p2BarTop + p2BarH + 1), w: ptToIn(100), h: 0,
line: { color: '888888', pt: 1 },
});
addTextBox(slide, bar.config.axisLabel, {
x: ptToIn(bar.x - 8), y: ptToIn(p2BarTop + p2BarH + 6), w: ptToIn(78), h: ptToIn(12),
fontSize: 8, bold: true, color: '444444', align: 'center',
});
});
}
function renderPanel3(slide, p3X, panelTop) {
addTextBox(slide, CONTENT.panel3.header[0], {
x: ptToIn(p3X), y: ptToIn(panelTop + 10), w: ptToIn(LAYOUT.p3Width), h: ptToIn(12),
fontSize: 11, bold: true, color: '333333',
});
drawRule(slide, p3X, panelTop + 36, 116);
let bulletY = panelTop + 56;
CONTENT.panel3.bullets.forEach((bullet) => {
slide.addShape(pptx.ShapeType.ellipse, {
x: ptToIn(p3X + 2), y: ptToIn(bulletY + 4), w: ptToIn(4), h: ptToIn(4),
line: { color: COLORS.green, pt: 0.4 }, fill: { color: COLORS.green },
});
addTextBox(slide, bullet.join('\n'), {
x: ptToIn(p3X + 16), y: ptToIn(bulletY), w: ptToIn(110), h: ptToIn(46),
fontSize: 10.5, color: COLORS.text,
});
bulletY += 52;
});
}
function renderDividers(slide, divider1X, divider2X, panelTop) {
slide.addShape(pptx.ShapeType.line, {
x: ptToIn(divider1X), y: ptToIn(panelTop + 65), w: 0, h: ptToIn(228),
line: { color: COLORS.lightRule, pt: 1 },
});
slide.addShape(pptx.ShapeType.line, {
x: ptToIn(divider2X), y: ptToIn(panelTop + 15), w: 0, h: ptToIn(264),
line: { color: COLORS.lightRule, pt: 1 },
});
slide.addShape(pptx.ShapeType.ellipse, {
x: ptToIn(divider2X - 9), y: ptToIn(panelTop + 136), w: ptToIn(18), h: ptToIn(18),
line: { color: COLORS.green, pt: 0.5 }, fill: { color: COLORS.green },
});
addTextBox(slide, '\u203A', {
x: ptToIn(divider2X - 9), y: ptToIn(panelTop + 135), w: ptToIn(18), h: ptToIn(16),
fontSize: 14, bold: true, color: COLORS.white, align: 'center',
});
}
async function buildSlide(externalPptx) {
if (externalPptx) pptx = externalPptx;
if (!externalPptx) {
pptx.layout = 'LAYOUT_16x9';
pptx.lang = 'en-US';
pptx.theme = { headFontFace: FONTS.body, bodyFontFace: FONTS.body, lang: 'en-US' };
}
const slide = pptx.addSlide();
slide.background = { color: COLORS.bg };
slide.addShape(pptx.ShapeType.rect, {
x: 0, y: 0, w: SLIDE.widthIn, h: SLIDE.heightIn,
line: { color: COLORS.frame, pt: 1 }, fill: { color: COLORS.bg },
});
// Title
addTextBox(slide, CONTENT.title.join('\n'), {
x: ptToIn(LAYOUT.padLeft), y: ptToIn(LAYOUT.padTop),
w: ptToIn(SLIDE.widthPt - LAYOUT.padLeft - LAYOUT.padRight), h: ptToIn(LAYOUT.titleHeight),
fontSize: 18.5, color: COLORS.green, bold: true,
});
// Panel positions
const p1X = LAYOUT.padLeft;
const divider1X = p1X + LAYOUT.p1Width + LAYOUT.dividerGap;
const p2X = divider1X + LAYOUT.dividerWidth + LAYOUT.dividerGap;
const divider2X = p2X + LAYOUT.p2Width + LAYOUT.dividerGap;
const p3X = divider2X + LAYOUT.dividerWidth + LAYOUT.dividerGap;
const panelTop = LAYOUT.panelTop;
renderPanel1(slide, p1X, panelTop);
renderPanel2(slide, p2X, panelTop);
renderPanel3(slide, p3X, panelTop);
renderDividers(slide, divider1X, divider2X, panelTop);
// Footer
addTextBox(slide, CONTENT.footer, {
x: ptToIn(LAYOUT.padLeft), y: ptToIn(396),
w: ptToIn(SLIDE.widthPt - LAYOUT.padLeft - LAYOUT.padRight), h: ptToIn(10),
fontSize: 5.5, color: '888888',
});
if (!externalPptx) {
await pptx.writeFile({ fileName: OUTPUT_PATH });
await stripPptxMetadata(OUTPUT_PATH);
}
return pptx;
}
module.exports = { buildSlide };
if (require.main === module) buildSlide().catch((e) => { console.error(e); process.exitCode = 1; });
// Altagamma US market slide — fully native editable PPTX.
// Multi-zone layout: header with title, chart panel with quarterly bars, factor panel with icons, footer band.
// Demonstrates: multi-zone composition, data-driven bar chart, icon placeholders, rich text footer columns.
const fs = require('fs');
const path = require('path');
const pptxgen = require('pptxgenjs');
const stripPptxMetadata = require(path.join(__dirname, '..', 'strip-pptx-metadata.js'));
const OUTPUT_PATH = process.argv[2]
? path.resolve(process.argv[2])
: path.join(__dirname, 'altagamma2024-us-market.pptx');
// --- Scaling ---
const SOURCE_WIDTH = 1902;
const SOURCE_HEIGHT = 1058;
const TARGET_WIDTH = 960;
const TARGET_HEIGHT = 540;
const TARGET_WIDTH_IN = 10;
const TARGET_HEIGHT_IN = 5.625;
const SCALE_X = TARGET_WIDTH / SOURCE_WIDTH;
const SCALE_Y = TARGET_HEIGHT / SOURCE_HEIGHT;
const AVG_SCALE = (SCALE_X + SCALE_Y) / 2;
function sx(v) { return Number((v * SCALE_X).toFixed(2)); }
function sy(v) { return Number((v * SCALE_Y).toFixed(2)); }
function pxToInX(v) { return Number(((v / TARGET_WIDTH) * TARGET_WIDTH_IN).toFixed(4)); }
function pxToInY(v) { return Number(((v / TARGET_HEIGHT) * TARGET_HEIGHT_IN).toFixed(4)); }
// --- Colors ---
const C = {
red: 'C83A2A', dark: '141414', chartBg: 'E7E7E8', chartRightBg: 'ECECEE',
chartLine: 'D2D2D4', muted: '7D7D80', yearRed: 'BD384D',
barBlack: '000000', barAccent: 'A03A5F', barQ4: '8A4A91',
panelSep: 'D0D0D2', q4Split: 'F5F5F6',
footerOverlay: '0C0A12', footerSep: 'D0D0D6', footerTitle: 'BF3258', footerBody: 'F2F2F5',
iconPlaceholder: '444444',
};
// --- Layout ---
const HEADER_H = sy(198);
const CONTENT_H = sy(592);
const FOOTER_H = Number((TARGET_HEIGHT - HEADER_H - CONTENT_H).toFixed(2));
const CHART_LEFT_W = sx(1415);
const CHART_RIGHT_W = Number((TARGET_WIDTH - CHART_LEFT_W).toFixed(2));
const BASELINE_Y = sy(294); // zero line within chart content area
const FONTS = {
eyebrowPt: Number((((18 * AVG_SCALE) * 72) / 96).toFixed(2)),
titlePt: Number((((63 * AVG_SCALE) * 72) / 96).toFixed(2)),
chartTitlePt: Number((((28 * AVG_SCALE) * 72) / 96).toFixed(2)),
chartSubPt: Number((((17 * AVG_SCALE) * 72) / 96).toFixed(2)),
yearPt: Number((((31 * AVG_SCALE) * 72) / 96).toFixed(2)),
quarterPt: Number((((17 * AVG_SCALE) * 72) / 96).toFixed(2)),
factorTitlePt: Number((((28 * AVG_SCALE) * 72) / 96).toFixed(2)),
factorTextPt: Number((((20 * AVG_SCALE) * 72) / 96).toFixed(2)),
footerHeadPt: Number((((31 * AVG_SCALE) * 72) / 96).toFixed(2)),
footerBodyPt: Number((((20 * AVG_SCALE) * 72) / 96).toFixed(2)),
};
// --- Data ---
const chartBars = [
{ left: 52, height: 202, dir: 'pos', width: 64, color: C.barBlack },
{ left: 168, height: 168, dir: 'pos', width: 64, color: C.barBlack },
{ left: 284, height: 156, dir: 'pos', width: 64, color: C.barBlack },
{ left: 400, height: 58, dir: 'pos', width: 64, color: C.barBlack },
{ left: 516, height: 18, dir: 'pos', width: 64, color: C.barBlack },
{ left: 632, height: 64, dir: 'neg', width: 64, color: C.barBlack },
{ left: 748, height: 94, dir: 'neg', width: 64, color: C.barBlack },
{ left: 864, height: 34, dir: 'neg', width: 64, color: C.barBlack },
{ left: 980, height: 32, dir: 'neg', width: 64, color: C.barAccent },
{ left: 1098, height: 8, dir: 'pos', width: 58, color: C.barAccent },
{ left: 1214, height: 12, dir: 'neg', width: 58, color: C.barAccent },
{ left: 1328, height: 14, width: 66, color: C.barQ4, fixedTop: 286, splitLine: true },
];
const yearLabels = [
{ left: 46, text: '2022' }, { left: 510, text: '2023' }, { left: 980, text: '2024E', accent: true },
];
const quarterLabels = [
{ left: 64, text: 'Q1' }, { left: 180, text: 'Q2' }, { left: 296, text: 'Q3' }, { left: 412, text: 'Q4' },
{ left: 528, text: 'Q1' }, { left: 644, text: 'Q2' }, { left: 760, text: 'Q3' }, { left: 876, text: 'Q4' },
{ left: 998, text: 'Q1' }, { left: 1108, text: 'Q2' }, { left: 1224, text: 'Q3' }, { left: 1332, text: 'Q4E' },
];
const yearSeparators = [470, 950];
const factorRows = [
{ top: 116, icon: '\u2702', headline: 'Fed cut of interest rates refueling consumer spending', body: '' },
{ top: 242, icon: '\u270B', headline: 'Presidential election', body: 'ending turbulent season, with potential boost to economy' },
{ top: 368, icon: '\u{1F91D}', headline: 'Reducing inflation', body: 'freeing up disposable income' },
{ top: 494, icon: '\u{1F4B5}', headline: 'Potential tax cut', body: 'further fueling retail spending.. yet import tax on the rise?' },
];
const footerColumns = [
{ heading: 'Downtrading of non-VIC', body: 'Luxury consumers downgrading toward more value-for-money luxury and non-luxury brands, especially within department stores and outlet malls' },
{ heading: 'Unbalanced tourism impacting the region', body: 'Slow recovery of inbound flows, Latin American accelerating in Southern US, yet Chinese losing ground in Canada, while US consumers fly toward Europe' },
{ heading: 'Experientiality & uniqueness on the rise', body: 'Hyper-personalized customer service gaining relevance as paramount purchase criterion for new generations, alongside increasing quest for product uniqueness' },
{ heading: 'Sunbelt first, East over West', body: 'Continuing wealth flows toward "new" areas driving South performance, East outperforming West' },
];
// --- Drawing ---
function addHeader(slide) {
const x = pxToInX(sx(48));
slide.addText('WAVES OF TRANSITION', {
x, y: pxToInY(sy(22)), w: pxToInX(sx(420)), h: pxToInY(sy(24)),
margin: 0, fontFace: 'Arial', fontSize: FONTS.eyebrowPt, bold: true, color: C.red, charSpace: Number((9 * AVG_SCALE).toFixed(2)),
});
slide.addText('US market on improving trajectory,', {
x, y: pxToInY(sy(72)), w: pxToInX(sx(1720)), h: pxToInY(sy(56)),
margin: 0, fontFace: 'Arial', fontSize: FONTS.titlePt, fit: 'shrink', bold: true, color: '000000',
});
slide.addText('despite traffic halt and relevant outbound tourist flows', {
x, y: pxToInY(sy(134)), w: pxToInX(sx(1800)), h: pxToInY(sy(58)),
margin: 0, fontFace: 'Arial', fontSize: FONTS.titlePt, fit: 'shrink', bold: false, color: '000000',
});
}
function addChartPanel(slide, pptx) {
const contentY = HEADER_H;
// Chart left background
slide.addShape(pptx.ShapeType.rect, {
x: 0, y: pxToInY(contentY), w: pxToInX(CHART_LEFT_W), h: pxToInY(CONTENT_H), fill: { color: C.chartBg },
});
// Chart right background
slide.addShape(pptx.ShapeType.rect, {
x: pxToInX(CHART_LEFT_W), y: pxToInY(contentY), w: pxToInX(CHART_RIGHT_W), h: pxToInY(CONTENT_H), fill: { color: C.chartRightBg },
});
// Panel separator
slide.addShape(pptx.ShapeType.rect, {
x: pxToInX(CHART_LEFT_W), y: pxToInY(contentY), w: pxToInX(1.5), h: pxToInY(CONTENT_H), fill: { color: C.panelSep },
});
// Chart title + subtitle
slide.addText('Americas quarter on quarter growth', {
x: pxToInX(sx(44)), y: pxToInY(contentY + sy(20)), w: pxToInX(sx(600)), h: pxToInY(sy(30)),
margin: 0, fontFace: 'Arial', fontSize: FONTS.chartTitlePt, bold: true, color: '111111', fit: 'shrink',
});
slide.addText('% | Q1-22, Q4-24E', {
x: pxToInX(sx(44)), y: pxToInY(contentY + sy(54)), w: pxToInX(sx(300)), h: pxToInY(sy(18)),
margin: 0, fontFace: 'Arial', fontSize: FONTS.chartSubPt, color: C.muted,
});
// Baseline (zero line)
slide.addShape(pptx.ShapeType.rect, {
x: pxToInX(sx(42)), y: pxToInY(contentY + BASELINE_Y),
w: pxToInX(sx(1362)), h: pxToInY(Math.max(1.25, sy(2))), fill: { color: C.chartLine },
});
// Bars
chartBars.forEach(bar => {
const x = pxToInX(sx(bar.left));
const w = pxToInX(sx(bar.width));
const h = pxToInY(sy(bar.height));
const barColor = bar.color.replace('#', '');
let y;
if (bar.fixedTop !== undefined) {
y = pxToInY(contentY + sy(bar.fixedTop));
} else if (bar.dir === 'pos') {
y = pxToInY(contentY + BASELINE_Y - sy(bar.height));
} else {
y = pxToInY(contentY + BASELINE_Y);
}
slide.addShape(pptx.ShapeType.rect, { x, y, w, h, fill: { color: barColor } });
// Split line for Q4E bar
if (bar.splitLine) {
slide.addShape(pptx.ShapeType.rect, {
x, y: Number((y + h * 0.46).toFixed(4)), w, h: pxToInY(Math.max(1, sy(2))), fill: { color: C.q4Split },
});
}
});
// Year separators
yearSeparators.forEach(left => {
slide.addShape(pptx.ShapeType.rect, {
x: pxToInX(sx(left)), y: pxToInY(contentY + sy(425)),
w: pxToInX(Math.max(1, sx(2))), h: pxToInY(sy(66)), fill: { color: C.panelSep },
});
});
// Year labels
yearLabels.forEach(yl => {
slide.addText(yl.text, {
x: pxToInX(sx(yl.left)), y: pxToInY(contentY + sy(420)), w: pxToInX(sx(120)), h: pxToInY(sy(34)),
margin: 0, fontFace: 'Arial', fontSize: FONTS.yearPt, bold: true, color: yl.accent ? C.yearRed : '111111',
});
});
// Quarter labels
quarterLabels.forEach(ql => {
slide.addText(ql.text, {
x: pxToInX(sx(ql.left)), y: pxToInY(contentY + sy(468)), w: pxToInX(sx(50)), h: pxToInY(sy(18)),
margin: 0, fontFace: 'Arial', fontSize: FONTS.quarterPt, color: '1C1C1E',
});
});
}
function addFactorPanel(slide, pptx) {
// Right panel bounds (inches)
const panelLeftIn = pxToInX(CHART_LEFT_W) + 0.1;
const panelTopIn = pxToInY(HEADER_H) + 0.08;
const panelBottomIn = pxToInY(HEADER_H + CONTENT_H) - 0.05;
const panelWIn = TARGET_WIDTH_IN - panelLeftIn - 0.1;
const iconSizeIn = 0.4;
const textLeftIn = panelLeftIn + iconSizeIn + 0.08;
const textWIn = TARGET_WIDTH_IN - textLeftIn - 0.1;
// Title
const titleH = 0.42;
slide.addText('With some sweet factors rising over the horizon', {
x: panelLeftIn, y: panelTopIn, w: panelWIn, h: titleH,
margin: 0, fontFace: 'Arial', fontSize: FONTS.factorTitlePt, bold: true, color: '111111', fit: 'shrink', valign: 'top',
});
// Distribute 4 factors evenly in remaining space
const factorsTop = panelTopIn + titleH + 0.06;
const factorsH = panelBottomIn - factorsTop;
const rowH = factorsH / factorRows.length;
factorRows.forEach((factor, i) => {
const rowY = factorsTop + i * rowH;
// Separator line
if (i > 0) {
slide.addShape(pptx.ShapeType.rect, {
x: panelLeftIn, y: rowY, w: panelWIn, h: 0.01, fill: { color: C.panelSep },
});
}
// Icon placeholder
const iconY = rowY + 0.06;
slide.addShape(pptx.ShapeType.rect, {
x: panelLeftIn, y: iconY, w: iconSizeIn, h: iconSizeIn, fill: { color: 'F0F0F0' },
});
slide.addText(factor.icon, {
x: panelLeftIn, y: iconY, w: iconSizeIn, h: iconSizeIn,
fontSize: 18, align: 'center', valign: 'middle', margin: 0,
});
// Factor text — same Y as icon, height fills the row
const textH = rowH - 0.1;
const runs = [{ text: factor.headline, options: { bold: true, breakLine: Boolean(factor.body) } }];
if (factor.body) runs.push({ text: factor.body, options: { bold: false } });
slide.addText(runs, {
x: textLeftIn, y: iconY, w: textWIn, h: textH,
margin: 0, fontFace: 'Arial', fontSize: FONTS.factorTextPt, lineSpacingMultiple: 1.1, fit: 'shrink', color: '161616', valign: 'top',
});
});
}
function addFooter(slide, pptx) {
const footerYIn = pxToInY(HEADER_H + CONTENT_H);
const footerHIn = pxToInY(FOOTER_H);
const colWIn = TARGET_WIDTH_IN / 4;
const padIn = 0.12;
const innerWIn = colWIn - padIn * 2;
const headingHIn = 0.42;
// Footer dark background
slide.addShape(pptx.ShapeType.rect, {
x: 0, y: footerYIn, w: TARGET_WIDTH_IN, h: footerHIn, fill: { color: C.footerOverlay },
});
// Top rule
slide.addShape(pptx.ShapeType.rect, {
x: 0, y: footerYIn, w: TARGET_WIDTH_IN, h: 0.02, fill: { color: '07070A', transparency: 40 },
});
// Column dividers
for (let i = 1; i < 4; i++) {
slide.addShape(pptx.ShapeType.rect, {
x: colWIn * i, y: footerYIn, w: 0.01, h: footerHIn, fill: { color: C.footerSep, transparency: 62 },
});
}
// Separate heading + body text boxes per column
footerColumns.forEach((col, i) => {
const xIn = colWIn * i + padIn;
const headYIn = footerYIn + 0.1;
const bodyYIn = headYIn + headingHIn + 0.04;
const bodyHIn = footerHIn - 0.1 - headingHIn - 0.04 - 0.08;
// Heading — larger font, natural wrap
slide.addText(col.heading, {
x: xIn, y: headYIn, w: innerWIn, h: headingHIn,
margin: 0, fontFace: 'Arial', fontSize: FONTS.footerHeadPt, bold: true, color: C.footerTitle,
valign: 'top', fit: 'shrink', lineSpacingMultiple: 1.1,
});
// Body — separate box below heading
slide.addText(col.body, {
x: xIn, y: bodyYIn, w: innerWIn, h: Math.max(0.2, bodyHIn),
margin: 0, fontFace: 'Arial', fontSize: FONTS.footerBodyPt, color: C.footerBody,
valign: 'top', fit: 'shrink', lineSpacingMultiple: 1.14,
});
});
}
// --- Entry point ---
async function buildSlide(externalPptx) {
const pptx = externalPptx || new pptxgen();
if (!externalPptx) pptx.layout = 'LAYOUT_16x9';
const slide = pptx.addSlide();
addHeader(slide);
addChartPanel(slide, pptx);
addFactorPanel(slide, pptx);
addFooter(slide, pptx);
if (!externalPptx) {
fs.mkdirSync(path.dirname(OUTPUT_PATH), { recursive: true });
await pptx.writeFile({ fileName: OUTPUT_PATH });
await stripPptxMetadata(OUTPUT_PATH);
console.log(`Wrote: ${OUTPUT_PATH}`);
}
return pptx;
}
module.exports = { buildSlide };
if (require.main === module) buildSlide().catch((e) => { console.error(e); process.exitCode = 1; });
// Louisiana DOT outsourcing-mix slide — fully native editable PPTX.
// Demonstrates: data table with column headers, row fills, gold chips, narrative blocks,
// takeaway cards with chevron connectors, header/content/footer bands.
const path = require('path');
const pptxgen = require('pptxgenjs');
const stripPptxMetadata = require(path.join(__dirname, '..', 'strip-pptx-metadata.js'));
let pptx = new pptxgen();
const OUTPUT_PATH = process.argv[2]
? path.resolve(process.argv[2])
: path.join(__dirname, 'Louisiana-DOT-15-Implied-outsourcing-mix.pptx');
const SLIDE = { widthPt: 720, heightPt: 405, widthIn: 10, heightIn: 5.625 };
const FONTS = { body: 'Source Sans 3' };
const COLORS = {
bg: 'FFFFFF', frame: 'B8B8B8', bar: '5CB87A',
grayHeader: '6E6F73', greenHeader: '5CB87A', mintHeader: 'CFE6CC', mintText: '2E6E3A',
title: '5CB87A', text: '575757', sep: 'CDCDCD',
tint: 'E8E8E8', tintB: 'DDDDDE', source: '7F7F7F',
gold: 'D9D08C', rule: 'A6A6A6', white: 'FFFFFF',
};
const LAYOUT = {
marginX: 30, topBarHeight: 4, titleTop: 10, titleHeight: 48,
spacerWidth: 210, footerBottom: 6,
};
const TABLE = { headerTop: 117, headerHeight: 29, rowHeight: 17, labelWidth: 210 };
const CONTENT = {
title: 'As capital program grows, DOTD will naturally experience shift toward higher outsourcing mix given constraints on hiring',
narrative: [
['Currently, DOTD is at a', '55/45 mix of', 'outsourced vs. internal', 'indirect spend...'],
['... however, more funding', 'will require heavy', 'leverage of consultants', 'given challenges in hiring', 'and retention...'],
['... which will naturally', 'result in a shift over time', "to a 'higher-outsourcing'", 'model that DOTD will', 'need to adapt to'],
],
columns: [
{ title: 'Current LaDOTD', fill: 'gray' },
{ title: 'Incremental $1B', fill: 'green' },
{ title: 'Future LaDOTD', fill: 'mint' },
],
rows: [
{ label: 'Capital awarded', values: ['$1.1B', '+$1B', '$2.1B'], bold: true, fill: 'white' },
{ label: '$ Internal Resources/Capital awarded', values: ['10%', '', '5%'], fill: 'tint' },
{ label: '$ Consulting Services/Capital awarded', values: ['12%', '26%', '19%'], fill: 'tint' },
{ label: 'Total Indirect spend/Capital awarded', values: ['22%', '26%', '24%'], bold: true, fill: 'tintB' },
{ label: '$ Internal Resources Total', values: ['$115M', '', '$115M (+$0M)'], fill: 'white' },
{ label: '$ Consulting Services Total', values: ['$135M', '(+$260M)', '$395M (+$260M)'], fill: 'white' },
{ label: 'Total Implied Budget', values: ['$250M', '(+$260M)', '$510M (+$260M)'], bold: true, fill: 'white' },
{ label: 'Outsourcing Mix (Consultant vs. Internal)', values: ['55/45', '', '80/20'], bold: true, fill: 'white', chips: [0, 2] },
],
note: '(+/- $XX) Change from current state',
noteSide: 'Note: Numbers may not add exactly due to rounding',
takeaways: [
['Some opportunity for', 'improving efficiency in', 'current mix of outsourcing', 'based on benchmarks'],
['Any internal efficiency gains can', 'be re-invested to optimize', 'operating model to manage', 'higher capital with consulting', 'support'],
['New model can be executed with', 'current DOTD infrastructure,', 'however model should balance', 'internal expertise and consultant', 'management'],
],
source: 'Source: DOT annual reports; Expert calls',
};
function ptToIn(v) { return Number((v / 72).toFixed(4)); }
function addTextBox(slide, text, options = {}) {
slide.addText(text, { margin: 0, fontFace: FONTS.body, color: COLORS.text, breakLine: false, valign: 'mid', ...options });
}
function headerFill(fill) {
if (fill === 'gray') return { color: COLORS.grayHeader, text: COLORS.white };
if (fill === 'green') return { color: COLORS.greenHeader, text: COLORS.white };
return { color: COLORS.mintHeader, text: COLORS.mintText };
}
function rowFill(fill) {
if (fill === 'tint') return COLORS.tint;
if (fill === 'tintB') return COLORS.tintB;
return COLORS.bg;
}
async function buildSlide(externalPptx) {
if (externalPptx) pptx = externalPptx;
if (!externalPptx) {
pptx.layout = 'LAYOUT_16x9';
pptx.lang = 'en-US';
pptx.theme = { headFontFace: FONTS.body, bodyFontFace: FONTS.body, lang: 'en-US' };
}
const slide = pptx.addSlide();
slide.background = { color: COLORS.bg };
slide.addShape(pptx.ShapeType.rect, {
x: 0, y: 0, w: SLIDE.widthIn, h: SLIDE.heightIn,
line: { color: COLORS.frame, pt: 0.75 }, fill: { color: COLORS.bg },
});
// Header bar
slide.addShape(pptx.ShapeType.rect, {
x: 0, y: 0, w: SLIDE.widthIn, h: ptToIn(LAYOUT.topBarHeight), fill: { color: COLORS.bar },
});
// Title
addTextBox(slide, CONTENT.title, {
x: ptToIn(LAYOUT.marginX), y: ptToIn(LAYOUT.titleTop),
w: ptToIn(SLIDE.widthPt - LAYOUT.marginX * 2), h: ptToIn(LAYOUT.titleHeight),
fontSize: 19, bold: true, color: COLORS.title,
});
const contentWidth = SLIDE.widthPt - LAYOUT.marginX * 2;
const colWidth = (contentWidth - LAYOUT.spacerWidth) / 3;
const dataLeft = LAYOUT.marginX + LAYOUT.spacerWidth;
// Narrative blocks
CONTENT.narrative.forEach((block, i) => {
addTextBox(slide, block.join('\n'), {
x: ptToIn(dataLeft + i * colWidth + 5), y: ptToIn(68),
w: ptToIn(colWidth - 10), h: ptToIn(34),
fontSize: 9.2, bold: true, color: COLORS.title,
});
});
// Column headers
CONTENT.columns.forEach((col, i) => {
const style = headerFill(col.fill);
const x = dataLeft + i * colWidth;
slide.addShape(pptx.ShapeType.rect, {
x: ptToIn(x), y: ptToIn(TABLE.headerTop), w: ptToIn(colWidth - 1.5), h: ptToIn(TABLE.headerHeight),
fill: { color: style.color },
});
addTextBox(slide, col.title, {
x: ptToIn(x), y: ptToIn(TABLE.headerTop + 5), w: ptToIn(colWidth - 1.5), h: ptToIn(18),
fontSize: 13, bold: true, color: style.text, align: 'center',
});
});
// Data rows
CONTENT.rows.forEach((row, ri) => {
const y = TABLE.headerTop + TABLE.headerHeight + ri * TABLE.rowHeight;
const fillColor = rowFill(row.fill);
slide.addShape(pptx.ShapeType.rect, {
x: ptToIn(LAYOUT.marginX), y: ptToIn(y), w: ptToIn(contentWidth), h: ptToIn(TABLE.rowHeight),
fill: { color: fillColor },
});
slide.addShape(pptx.ShapeType.line, {
x: ptToIn(LAYOUT.marginX), y: ptToIn(y + TABLE.rowHeight), w: ptToIn(contentWidth), h: 0,
line: { color: ri === CONTENT.rows.length - 1 ? '999999' : COLORS.sep, pt: ri === CONTENT.rows.length - 1 ? 1.5 : 0.5 },
});
addTextBox(slide, row.label, {
x: ptToIn(LAYOUT.marginX + 5), y: ptToIn(y + 1), w: ptToIn(TABLE.labelWidth - 10), h: ptToIn(TABLE.rowHeight - 2),
fontSize: 10.5, color: COLORS.text, bold: Boolean(row.bold),
});
row.values.forEach((value, ci) => {
const x = dataLeft + ci * colWidth;
if (row.chips && row.chips.includes(ci) && value) {
const chipW = 44;
slide.addShape(pptx.ShapeType.rect, {
x: ptToIn(x + (colWidth - chipW) / 2), y: ptToIn(y + 1), w: ptToIn(chipW), h: ptToIn(15.5),
fill: { color: COLORS.gold },
});
}
addTextBox(slide, value, {
x: ptToIn(x), y: ptToIn(y + 1), w: ptToIn(colWidth), h: ptToIn(TABLE.rowHeight - 2),
fontSize: 11, color: COLORS.text, bold: Boolean(row.bold), align: 'center',
});
});
});
// Notes
addTextBox(slide, CONTENT.note, {
x: ptToIn(LAYOUT.marginX), y: ptToIn(255), w: ptToIn(180), h: ptToIn(10),
fontSize: 7.5, italic: true, bold: true, color: COLORS.source,
});
addTextBox(slide, CONTENT.noteSide, {
x: ptToIn(LAYOUT.marginX + 8), y: ptToIn(329), w: ptToIn(150), h: ptToIn(30),
fontSize: 7.5, italic: true, bold: true, color: COLORS.source, align: 'center',
});
// Takeaway cards
CONTENT.takeaways.forEach((takeaway, i) => {
const x = dataLeft + i * colWidth;
slide.addShape(pptx.ShapeType.line, {
x: ptToIn(x + 10), y: ptToIn(320), w: ptToIn(colWidth - 20), h: 0,
line: { color: COLORS.rule, pt: 0.55 },
});
slide.addShape(pptx.ShapeType.ellipse, {
x: ptToIn(x + colWidth / 2 - 9.75), y: ptToIn(308), w: ptToIn(19.5), h: ptToIn(19.5),
line: { color: COLORS.bar, pt: 0.5 }, fill: { color: COLORS.bar },
});
slide.addText('\u2304', {
x: ptToIn(x + colWidth / 2 - 5), y: ptToIn(308), w: ptToIn(10), h: ptToIn(12),
margin: 0, fontFace: FONTS.body, fontSize: 12, color: COLORS.white, bold: true, align: 'center',
});
addTextBox(slide, takeaway.join('\n'), {
x: ptToIn(x + 6), y: ptToIn(334), w: ptToIn(colWidth - 12), h: ptToIn(58),
fontSize: 8, color: COLORS.text, align: 'center', valign: 'top',
});
});
// Footer source
addTextBox(slide, CONTENT.source, {
x: ptToIn(LAYOUT.marginX), y: ptToIn(SLIDE.heightPt - LAYOUT.footerBottom - 8),
w: ptToIn(220), h: ptToIn(8), fontSize: 8, color: COLORS.source,
});
if (!externalPptx) {
await pptx.writeFile({ fileName: OUTPUT_PATH });
await stripPptxMetadata(OUTPUT_PATH);
}
return pptx;
}
module.exports = { buildSlide };
if (require.main === module) buildSlide().catch((e) => { console.error(e); process.exitCode = 1; });
/**
* Grid — spatial contract for all slide layouts.
*
* Every pattern function uses these constants to position content.
* Change a value here → all 17 patterns adjust automatically.
*
* Slide canvas: 10" × 5.625" (pptxgenjs LAYOUT_16x9)
*/
const GRID = {
// Slide dimensions
slideW: 10,
slideH: 5.625,
// Header
headerH: 0.083, // 6pt header bar
// Margins (symmetric top/bottom)
marginL: 0.56,
marginR: 0.56,
contentW: 8.88, // 10 - 0.56 - 0.56
// Title zone
tagY: 0.33, // section tag baseline
titleY: 0.48, // action title baseline
subtitleY: 0.72, // subtitle / context line
// Body zone
bodyY: 0.90, // body content starts
bodyEndY: 4.95, // body content must end
bodyH: 4.05, // bodyEndY - bodyY
// Footer zone (symmetric with top margin)
footerRuleY: 5.20, // thin rule
footerTextY: 5.30, // source, logo, page number
// Cell padding (for tables, grids)
cellPad: 0.15,
};
/**
* Center content vertically within the body zone.
* @param {number} contentH - total height of content block (inches)
* @returns {number} - Y position to start content
*/
GRID.centerY = function(contentH) {
return this.bodyY + (this.bodyH - contentH) / 2;
};
/**
* Center content vertically within the full slide (for covers, dividers).
* @param {number} contentH - total height of content block (inches)
* @returns {number} - Y position to start content
*/
GRID.centerSlideY = function(contentH) {
return (this.slideH - contentH) / 2;
};
module.exports = GRID;
/**
* html2pptx — render an HTML file to a slide background image.
*
* Takes an HTML file, screenshots it via playwright-core + system Chrome,
* and places the screenshot as a background image on a new pptx slide.
* Returns { slide } so native pptx elements can be layered on top.
*
* Usage:
* const { slide } = await html2pptx(htmlPath, pptx, { tmpDir });
*/
const fs = require('fs');
const path = require('path');
const { chromium } = require('playwright-core');
async function html2pptx(htmlPath, pptx, options = {}) {
const tmpDir = options.tmpDir || require('os').tmpdir();
const screenshotPath = path.join(tmpDir, 'slide-bg.png');
const browser = await chromium.launch({ channel: 'chrome', headless: true });
const page = await browser.newPage({ viewport: { width: 960, height: 540 } });
const fileUrl = `file://${path.resolve(htmlPath)}`;
await page.goto(fileUrl, { waitUntil: 'networkidle' });
await page.screenshot({ path: screenshotPath, fullPage: false });
await browser.close();
const slide = pptx.addSlide();
slide.addImage({
path: screenshotPath,
x: 0, y: 0, w: 10, h: 5.625,
});
return { slide };
}
module.exports = html2pptx;
/**
* Deck Design — Master Builder
*
* Usage:
* const { createDeck } = require('./skills/deck-design-ppt/masters');
*
* createDeck('consulting-mckinsey', [
* { pattern: 'p01-cover', data: { title: '...', subtitle: '...' } },
* { pattern: 'p04-scorecard', data: { title: '...', cards: [...] } },
* { pattern: 'c05-divider', data: { sectionNum: '02', title: '...' } },
* ], 'output/deck.pptx');
*/
const pptxgen = require('pptxgenjs');
const { loadTheme } = require('./theme');
const { defineLayouts } = require('./layouts');
const G = require('./grid');
// Pattern registry — maps pattern names to layout master names
const LAYOUT_MAP = {
'p01-cover': 'COVER',
'p08-closer': 'CLOSER',
'c05-divider': 'DIVIDER',
// Everything else uses CONTENT
};
// Lazy-load pattern functions
const patternCache = {};
function getPattern(name) {
if (!patternCache[name]) {
try {
patternCache[name] = require(`./patterns/${name}`);
} catch (e) {
throw new Error(`Unknown pattern "${name}". Check masters/patterns/${name}.js exists.`);
}
}
return patternCache[name];
}
/**
* Create a deck from a palette name and slide definitions.
*
* @param {string} paletteName - e.g., 'consulting-mckinsey'
* @param {Array} slides - [{ pattern: string, data: object }]
* @param {string} outputPath - e.g., 'output/deck.pptx'
* @returns {Promise<string>} - resolves with output path
*/
async function createDeck(paletteName, slides, outputPath) {
const theme = loadTheme(paletteName);
// Propagate org name from cover slide data to theme (for footer chrome)
const coverSlide = slides.find(s => s.pattern === 'p01-cover');
if (coverSlide && coverSlide.data && coverSlide.data.org) {
theme.org = coverSlide.data.org;
}
const pptx = new pptxgen();
pptx.layout = 'LAYOUT_16x9';
pptx.author = theme.author || 'appcubic';
pptx.subject = theme.name ? `${theme.name} Deck` : 'Presentation';
// Define masters
defineLayouts(pptx, theme);
// Build slides
for (const slideDef of slides) {
const masterName = LAYOUT_MAP[slideDef.pattern] || 'CONTENT';
const slide = pptx.addSlide({ masterName });
const patternFn = getPattern(slideDef.pattern);
patternFn(slide, pptx, slideDef.data, theme);
}
// Write
await pptx.writeFile({ fileName: outputPath });
console.log(`Wrote: ${outputPath} (${slides.length} slides, ${paletteName})`);
return outputPath;
}
module.exports = { createDeck, loadTheme, G };
C01 — Multi-evidence — Slot Budgets (Consulting-only)
- For: dense "exhibit + metrics + sidebar" consulting page.
- Slots (budgets):
h2action title: <= 140 chars (this layout can carry a longer title)..subtitle: <= 90 chars.- Exhibit kicker/title: kicker is fixed; title <= 110 chars.
- Chart groups: 3–5.
xlab<= 10 chars. - Metrics: exactly 3 cards.
.metric-value: <= 12 chars..metric-label: <= 60 chars (2 lines max).- Sidebar bullets: 3–5 per box; each <= 80 chars.
- Computed (from data): bar heights.
- Choose a y-axis max (
Ymax) matching the top tick. height_pt = round((value / Ymax) * 150).- Values up to ~80% of Ymax fit without clipping.
Data schema:
{
sectionTag?, title, subtitle?,
chart: { type, series, colors, ... },
metrics?: [{ label, value }],
sidebar: { drivers: [string], implications?: [string] },
source?
}// Stub — metadata stripping is optional for preview builds.
module.exports = async function stripPptxMetadata(filePath) { return filePath; };
{
"name": "deck-design-ppt",
"private": true,
"dependencies": {
"playwright-core": "^1.52.0",
"pptxgenjs": "^4.0.1",
"sharp": "^0.33.5"
}
}
Related skills
FAQ
Is the output editable?
Yes, it produces a native editable .pptx where every element is a PowerPoint-native object.
When to use this vs deck-design-pdf?
Use this for editable PowerPoint/Keynote slides; use deck-design-pdf for pixel-perfect PDF output.