PPTX
样式与主题
在幻灯片中应用配色方案、主题颜色和一致的样式
使用填充、轮廓和配色方案在演示文稿中应用一致的样式。
形状的纯色填充
import { generatePresentation } from "@office-open/pptx";
{
"slides": [
{
"children": [
{
"shape": {
"x": "1.3cm",
"y": "1.3cm",
"width": "13.2cm",
"height": "5.3cm",
"fill": { "type": "solid", "color": "2E74B5" },
"textBody": {
"text": "Blue shape",
"children": [
{
"children": [{ "text": "Blue background", "fill": "FFFFFF", "size": 20 }]
}
]
}
}
}
]
}
]
}
generatePresentation({
slides: [
{
children: [
{
shape: {
x: "1.3cm",
y: "1.3cm",
width: "13.2cm",
height: "5.3cm",
fill: { type: "solid", color: "2E74B5" },
textBody: {
children: [
{
paragraph: {
children: [{ text: "Blue background", fill: "FFFFFF", size: 20 }],
},
},
],
},
},
},
],
},
],
});
渐变填充
带角度的线性渐变:
{
"slides": [
{
"children": [
{
"shape": {
"x": "1.3cm",
"y": "1.3cm",
"width": "15.9cm",
"height": "6.6cm",
"fill": {
"type": "gradient",
"stops": [
{ "position": 0, "color": "0D47A1" },
{ "position": 50, "color": "1976D2" },
{ "position": 100, "color": "42A5F5" }
],
"angle": 45
}
}
}
]
}
]
}
generatePresentation({
slides: [
{
children: [
{
shape: {
x: "1.3cm",
y: "1.3cm",
width: "15.9cm",
height: "6.6cm",
fill: {
type: "gradient",
stops: [
{ position: 0, color: "0D47A1" },
{ position: 50, color: "1976D2" },
{ position: 100, color: "42A5F5" },
],
angle: 45,
},
},
},
],
},
],
});
路径渐变(径向):
{
"slides": [
{
"children": [
{
"shape": {
"x": "1.3cm",
"y": "1.3cm",
"width": "10.6cm",
"height": "10.6cm",
"geometry": "ellipse",
"fill": {
"type": "gradient",
"stops": [
{ "position": 0, "color": "FFFFFF" },
{ "position": 100, "color": "1565C0" }
],
"path": "circle"
}
}
}
]
}
]
}
generatePresentation({
slides: [
{
children: [
{
shape: {
x: "1.3cm",
y: "1.3cm",
width: "10.6cm",
height: "10.6cm",
geometry: "ellipse",
fill: {
type: "gradient",
stops: [
{ position: 0, color: "FFFFFF" },
{ position: 100, color: "1565C0" },
],
path: "circle",
},
},
},
],
},
],
});
无填充(透明)
{
"slides": [
{
"children": [
{
"shape": {
"x": "1.3cm",
"y": "1.3cm",
"width": "13.2cm",
"height": "5.3cm",
"fill": { "type": "none" },
"outline": { "color": "2E74B5", "width": 2 }
}
}
]
}
]
}
generatePresentation({
slides: [
{
children: [
{
shape: {
x: "1.3cm",
y: "1.3cm",
width: "13.2cm",
height: "5.3cm",
fill: { type: "none" },
outline: { color: "2E74B5", width: 2 },
},
},
],
},
],
});
轮廓
{
"slides": [
{
"children": [
{
"shape": {
"x": "1.3cm",
"y": "1.3cm",
"width": "13.2cm",
"height": "6.6cm",
"fill": { "type": "solid", "color": "E3F2FD" },
"outline": { "color": "1565C0", "width": 2 }
}
}
]
}
]
}
generatePresentation({
slides: [
{
children: [
{
shape: {
x: "1.3cm",
y: "1.3cm",
width: "13.2cm",
height: "6.6cm",
fill: { type: "solid", color: "E3F2FD" },
outline: { color: "1565C0", width: 2 },
},
},
],
},
],
});
配色方案提示
定义一致的调色板并复用它:
import { generatePresentation } from "@office-open/pptx";
const colors = {
primary: "2E74B5",
secondary: "70AD47",
accent: "ED7D31",
dark: "1F3864",
light: "D6E4F0",
white: "FFFFFF",
};
generatePresentation({
slides: [
{
children: [
{
shape: {
x: "1.3cm",
y: "1.3cm",
width: "13.2cm",
height: "5.3cm",
fill: { type: "solid", color: colors.primary },
textBody: {
children: [
{
paragraph: {
children: [{ text: "Title", fill: colors.white, bold: true, size: 24 }],
},
},
],
},
},
},
],
},
],
});
背景样式
在幻灯片级别应用背景样式:
{
"slides": [
{
"background": { "fill": "1F3864" },
"children": []
}
]
}
generatePresentation({
slides: [
{
background: { fill: "1F3864" },
children: [],
},
],
});
{
"slides": [
{
"background": {
"fill": {
"type": "gradient",
"stops": [
{ "position": 0, "color": "0D47A1" },
{ "position": 100, "color": "42A5F5" }
],
"angle": 135
}
},
"children": []
}
]
}
generatePresentation({
slides: [
{
background: {
fill: {
type: "gradient",
stops: [
{ position: 0, color: "0D47A1" },
{ position: 100, color: "42A5F5" },
],
angle: 135,
},
},
children: [],
},
],
});