@hirokisakabe/pom 9.1.0 → 9.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/buildContext.js +2 -4
- package/dist/buildContext.js.map +1 -1
- package/dist/buildPptx.d.ts.map +1 -1
- package/dist/buildPptx.js +2 -6
- package/dist/buildPptx.js.map +1 -1
- package/dist/extractSlideMastersAsPptx.js +1 -1
- package/dist/renderPptx/glimpseTextBoxes.js +646 -0
- package/dist/renderPptx/glimpseTextBoxes.js.map +1 -0
- package/dist/renderPptx/nodes/flow.js +95 -90
- package/dist/renderPptx/nodes/flow.js.map +1 -1
- package/dist/renderPptx/nodes/icon.js +33 -24
- package/dist/renderPptx/nodes/icon.js.map +1 -1
- package/dist/renderPptx/nodes/image.js +5 -22
- package/dist/renderPptx/nodes/image.js.map +1 -1
- package/dist/renderPptx/nodes/list.js +96 -111
- package/dist/renderPptx/nodes/list.js.map +1 -1
- package/dist/renderPptx/nodes/matrix.js +92 -70
- package/dist/renderPptx/nodes/matrix.js.map +1 -1
- package/dist/renderPptx/nodes/processArrow.js +68 -35
- package/dist/renderPptx/nodes/processArrow.js.map +1 -1
- package/dist/renderPptx/nodes/pyramid.js +34 -16
- package/dist/renderPptx/nodes/pyramid.js.map +1 -1
- package/dist/renderPptx/nodes/shape.js +63 -37
- package/dist/renderPptx/nodes/shape.js.map +1 -1
- package/dist/renderPptx/nodes/svg.js +2 -5
- package/dist/renderPptx/nodes/svg.js.map +1 -1
- package/dist/renderPptx/nodes/text.js +16 -45
- package/dist/renderPptx/nodes/text.js.map +1 -1
- package/dist/renderPptx/nodes/timeline.js +108 -74
- package/dist/renderPptx/nodes/timeline.js.map +1 -1
- package/dist/renderPptx/nodes/tree.js +78 -79
- package/dist/renderPptx/nodes/tree.js.map +1 -1
- package/dist/renderPptx/renderPptx.js +4 -5
- package/dist/renderPptx/renderPptx.js.map +1 -1
- package/dist/renderPptx/utils/backgroundBorder.js +85 -49
- package/dist/renderPptx/utils/backgroundBorder.js.map +1 -1
- package/dist/renderPptx/utils/glimpsePicture.js +130 -0
- package/dist/renderPptx/utils/glimpsePicture.js.map +1 -0
- package/dist/renderPptx/utils/glimpseShape.js +90 -0
- package/dist/renderPptx/utils/glimpseShape.js.map +1 -0
- package/dist/renderPptx/utils/glimpseTextBox.js +126 -0
- package/dist/renderPptx/utils/glimpseTextBox.js.map +1 -0
- package/dist/renderPptx/utils/straightLine.js +29 -14
- package/dist/renderPptx/utils/straightLine.js.map +1 -1
- package/dist/renderPptx/utils/visualStyle.js +1 -24
- package/dist/renderPptx/utils/visualStyle.js.map +1 -1
- package/dist/types.js +1 -1
- package/package.json +4 -4
- package/dist/renderPptx/glowEffects.js +0 -152
- package/dist/renderPptx/glowEffects.js.map +0 -1
- package/dist/renderPptx/gradientFills.js +0 -167
- package/dist/renderPptx/gradientFills.js.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { pxToIn
|
|
1
|
+
import { pxToIn } from "../units.js";
|
|
2
2
|
import { withContentBounds } from "../utils/contentArea.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { addGlimpseTextBox } from "../utils/glimpseTextBox.js";
|
|
4
|
+
import { addGlimpseShape, createShapeBoundsInput, noShapeOutline, solidShapeFill } from "../utils/glimpseShape.js";
|
|
5
5
|
import { ARROW_DEPTH_RATIO } from "../../shared/processArrowConstants.js";
|
|
6
6
|
import { measureProcessArrow } from "../../calcYogaLayout/measureCompositeNodes.js";
|
|
7
|
+
import { stripHash } from "../utils/visualStyle.js";
|
|
7
8
|
import { resolveScaledContentArea } from "../utils/scaleToFit.js";
|
|
8
9
|
//#region src/renderPptx/nodes/processArrow.ts
|
|
9
10
|
function renderProcessArrowNode(node, ctx) {
|
|
@@ -85,29 +86,45 @@ function renderHorizontalProcessArrow(node, ctx, steps, stepCount, itemWidth, it
|
|
|
85
86
|
},
|
|
86
87
|
{ close: true }
|
|
87
88
|
];
|
|
88
|
-
ctx
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
addGlimpseShape(ctx, {
|
|
90
|
+
preset: "rect",
|
|
91
|
+
...createShapeBoundsInput({
|
|
92
|
+
x: stepX,
|
|
93
|
+
y: stepY,
|
|
94
|
+
w: itemWidth,
|
|
95
|
+
h: itemHeight
|
|
96
|
+
}),
|
|
97
|
+
fill: solidShapeFill(fillColor),
|
|
98
|
+
outline: noShapeOutline()
|
|
99
|
+
}, {
|
|
100
|
+
x: stepX,
|
|
101
|
+
y: stepY,
|
|
102
|
+
w: itemWidth,
|
|
103
|
+
h: itemHeight
|
|
104
|
+
}, {
|
|
105
|
+
fillColor,
|
|
106
|
+
customGeometry: {
|
|
107
|
+
width: pxToIn(itemWidth),
|
|
108
|
+
height: pxToIn(itemHeight),
|
|
109
|
+
points
|
|
110
|
+
}
|
|
96
111
|
});
|
|
97
112
|
const textOffsetLeft = isFirst ? 0 : arrowDepth;
|
|
98
113
|
const textWidth = Math.max(1, itemWidth - arrowDepth - textOffsetLeft);
|
|
99
|
-
ctx
|
|
100
|
-
x:
|
|
101
|
-
y:
|
|
102
|
-
w:
|
|
103
|
-
h:
|
|
104
|
-
|
|
114
|
+
addGlimpseTextBox(ctx, {
|
|
115
|
+
x: stepX + textOffsetLeft,
|
|
116
|
+
y: stepY,
|
|
117
|
+
w: textWidth,
|
|
118
|
+
h: itemHeight
|
|
119
|
+
}, {
|
|
120
|
+
text: step.label,
|
|
121
|
+
fontSize: (node.fontSize ?? 14) * scaleFactor,
|
|
105
122
|
fontFace: node.fontFamily ?? "Noto Sans JP",
|
|
106
123
|
color: textColor,
|
|
107
124
|
bold: node.bold ?? false,
|
|
108
125
|
italic: node.italic,
|
|
109
|
-
underline:
|
|
110
|
-
strike:
|
|
126
|
+
underline: node.underline,
|
|
127
|
+
strike: node.strike,
|
|
111
128
|
highlight: node.highlight,
|
|
112
129
|
align: "center",
|
|
113
130
|
valign: "middle"
|
|
@@ -173,29 +190,45 @@ function renderVerticalProcessArrow(node, ctx, steps, stepCount, itemWidth, item
|
|
|
173
190
|
},
|
|
174
191
|
{ close: true }
|
|
175
192
|
];
|
|
176
|
-
ctx
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
193
|
+
addGlimpseShape(ctx, {
|
|
194
|
+
preset: "rect",
|
|
195
|
+
...createShapeBoundsInput({
|
|
196
|
+
x: stepX,
|
|
197
|
+
y: stepY,
|
|
198
|
+
w: itemWidth,
|
|
199
|
+
h: itemHeight
|
|
200
|
+
}),
|
|
201
|
+
fill: solidShapeFill(fillColor),
|
|
202
|
+
outline: noShapeOutline()
|
|
203
|
+
}, {
|
|
204
|
+
x: stepX,
|
|
205
|
+
y: stepY,
|
|
206
|
+
w: itemWidth,
|
|
207
|
+
h: itemHeight
|
|
208
|
+
}, {
|
|
209
|
+
fillColor,
|
|
210
|
+
customGeometry: {
|
|
211
|
+
width: pxToIn(itemWidth),
|
|
212
|
+
height: pxToIn(itemHeight),
|
|
213
|
+
points
|
|
214
|
+
}
|
|
184
215
|
});
|
|
185
216
|
const textOffsetTop = isFirst ? 0 : arrowDepth;
|
|
186
217
|
const textHeight = Math.max(1, itemHeight - arrowDepth - textOffsetTop);
|
|
187
|
-
ctx
|
|
188
|
-
x:
|
|
189
|
-
y:
|
|
190
|
-
w:
|
|
191
|
-
h:
|
|
192
|
-
|
|
218
|
+
addGlimpseTextBox(ctx, {
|
|
219
|
+
x: stepX,
|
|
220
|
+
y: stepY + textOffsetTop,
|
|
221
|
+
w: itemWidth,
|
|
222
|
+
h: textHeight
|
|
223
|
+
}, {
|
|
224
|
+
text: step.label,
|
|
225
|
+
fontSize: (node.fontSize ?? 14) * scaleFactor,
|
|
193
226
|
fontFace: node.fontFamily ?? "Noto Sans JP",
|
|
194
227
|
color: textColor,
|
|
195
228
|
bold: node.bold ?? false,
|
|
196
229
|
italic: node.italic,
|
|
197
|
-
underline:
|
|
198
|
-
strike:
|
|
230
|
+
underline: node.underline,
|
|
231
|
+
strike: node.strike,
|
|
199
232
|
highlight: node.highlight,
|
|
200
233
|
align: "center",
|
|
201
234
|
valign: "middle"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processArrow.js","names":[],"sources":["../../../src/renderPptx/nodes/processArrow.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { stripHash } from \"../utils/visualStyle.ts\";\nimport { pxToIn, pxToPt } from \"../units.ts\";\nimport { convertUnderline, convertStrike } from \"../textOptions.ts\";\nimport { measureProcessArrow } from \"../../calcYogaLayout/measureCompositeNodes.ts\";\nimport { resolveScaledContentArea } from \"../utils/scaleToFit.ts\";\nimport {\n ARROW_DEPTH_RATIO,\n DEFAULT_PROCESS_ARROW_ITEM_WIDTH,\n DEFAULT_PROCESS_ARROW_ITEM_HEIGHT,\n} from \"../../shared/processArrowConstants.ts\";\nimport { withContentBounds } from \"../utils/contentArea.ts\";\n\ntype ProcessArrowPositionedNode = Extract<\n PositionedNode,\n { type: \"processArrow\" }\n>;\n\nexport function renderProcessArrowNode(\n node: ProcessArrowPositionedNode,\n ctx: RenderContext,\n): void {\n const direction = node.direction ?? \"horizontal\";\n const steps = node.steps;\n const stepCount = steps.length;\n\n if (stepCount === 0) return;\n\n const defaultColor = \"4472C4\"; // PowerPoint標準の青\n const defaultTextColor = \"FFFFFF\";\n const itemWidth = node.itemWidth ?? DEFAULT_PROCESS_ARROW_ITEM_WIDTH;\n const itemHeight = node.itemHeight ?? DEFAULT_PROCESS_ARROW_ITEM_HEIGHT;\n const arrowDepth = itemHeight * ARROW_DEPTH_RATIO;\n const gap = node.gap ?? -arrowDepth;\n\n // スケール係数を計算(コンテンツ領域基準)\n const { content, scaleFactor } = resolveScaledContentArea(\n node,\n measureProcessArrow(node),\n ctx,\n );\n\n const scaledItemWidth = itemWidth * scaleFactor;\n const scaledItemHeight = itemHeight * scaleFactor;\n const scaledGap = gap * scaleFactor;\n const scaledArrowDepth = arrowDepth * scaleFactor;\n\n // コンテンツ領域を使用するための仮想ノードを作成\n const contentNode = withContentBounds(node, content);\n\n if (direction === \"horizontal\") {\n renderHorizontalProcessArrow(\n contentNode,\n ctx,\n steps,\n stepCount,\n scaledItemWidth,\n scaledItemHeight,\n scaledGap,\n scaledArrowDepth,\n defaultColor,\n defaultTextColor,\n scaleFactor,\n );\n } else {\n renderVerticalProcessArrow(\n contentNode,\n ctx,\n steps,\n stepCount,\n scaledItemWidth,\n scaledItemHeight,\n scaledGap,\n scaledArrowDepth,\n defaultColor,\n defaultTextColor,\n scaleFactor,\n );\n }\n}\n\nfunction renderHorizontalProcessArrow(\n node: ProcessArrowPositionedNode,\n ctx: RenderContext,\n steps: ProcessArrowPositionedNode[\"steps\"],\n stepCount: number,\n itemWidth: number,\n itemHeight: number,\n gap: number,\n arrowDepth: number,\n defaultColor: string,\n defaultTextColor: string,\n scaleFactor: number,\n): void {\n const totalWidth = stepCount * itemWidth + (stepCount - 1) * gap;\n const startX = node.x + (node.w - totalWidth) / 2;\n const centerY = node.y + node.h / 2;\n\n steps.forEach((step, index) => {\n const stepX = startX + index * (itemWidth + gap);\n const stepY = centerY - itemHeight / 2;\n const fillColor = stripHash(step.color) ?? defaultColor;\n const textColor = stripHash(step.textColor) ?? defaultTextColor;\n\n // custGeom でシェブロン形状を描画\n const isFirst = index === 0;\n const points = isFirst\n ? [\n // homePlate 風: 左辺フラット、右辺が矢印\n { x: 0, y: 0 },\n { x: pxToIn(itemWidth - arrowDepth), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight / 2) },\n { x: pxToIn(itemWidth - arrowDepth), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight) },\n { close: true as const },\n ]\n : [\n // chevron 風: 左辺に切り欠き、右辺が矢印\n { x: 0, y: 0 },\n { x: pxToIn(itemWidth - arrowDepth), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight / 2) },\n { x: pxToIn(itemWidth - arrowDepth), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight) },\n { x: pxToIn(arrowDepth), y: pxToIn(itemHeight / 2) },\n { close: true as const },\n ];\n\n ctx.slide.addShape(\"custGeom\" as never, {\n x: pxToIn(stepX),\n y: pxToIn(stepY),\n w: pxToIn(itemWidth),\n h: pxToIn(itemHeight),\n points,\n fill: { color: fillColor },\n line: { type: \"none\" as const },\n });\n\n // テキストを図形の中央(矢印部分を除いた領域)に配置\n const textOffsetLeft = isFirst ? 0 : arrowDepth;\n const textWidth = Math.max(1, itemWidth - arrowDepth - textOffsetLeft);\n\n ctx.slide.addText(step.label, {\n x: pxToIn(stepX + textOffsetLeft),\n y: pxToIn(stepY),\n w: pxToIn(textWidth),\n h: pxToIn(itemHeight),\n fontSize: pxToPt((node.fontSize ?? 14) * scaleFactor),\n fontFace: node.fontFamily ?? \"Noto Sans JP\",\n color: textColor,\n bold: node.bold ?? false,\n italic: node.italic,\n underline: convertUnderline(node.underline),\n strike: convertStrike(node.strike),\n highlight: node.highlight,\n align: \"center\",\n valign: \"middle\",\n });\n });\n}\n\nfunction renderVerticalProcessArrow(\n node: ProcessArrowPositionedNode,\n ctx: RenderContext,\n steps: ProcessArrowPositionedNode[\"steps\"],\n stepCount: number,\n itemWidth: number,\n itemHeight: number,\n gap: number,\n arrowDepth: number,\n defaultColor: string,\n defaultTextColor: string,\n scaleFactor: number,\n): void {\n const totalHeight = stepCount * itemHeight + (stepCount - 1) * gap;\n const startY = node.y + (node.h - totalHeight) / 2;\n const centerX = node.x + node.w / 2;\n\n steps.forEach((step, index) => {\n const stepX = centerX - itemWidth / 2;\n const stepY = startY + index * (itemHeight + gap);\n const fillColor = stripHash(step.color) ?? defaultColor;\n const textColor = stripHash(step.textColor) ?? defaultTextColor;\n\n const isFirst = index === 0;\n const points = isFirst\n ? [\n // rect 風: 上辺フラット、下辺が矢印\n { x: 0, y: 0 },\n { x: pxToIn(itemWidth), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight - arrowDepth) },\n { x: pxToIn(itemWidth / 2), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight - arrowDepth) },\n { close: true as const },\n ]\n : [\n // pentagon 風: 上辺に切り欠き、下辺が矢印\n { x: pxToIn(itemWidth / 2), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(arrowDepth) },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight - arrowDepth) },\n { x: pxToIn(itemWidth / 2), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight - arrowDepth) },\n { x: 0, y: pxToIn(arrowDepth) },\n { close: true as const },\n ];\n\n ctx.slide.addShape(\"custGeom\" as never, {\n x: pxToIn(stepX),\n y: pxToIn(stepY),\n w: pxToIn(itemWidth),\n h: pxToIn(itemHeight),\n points,\n fill: { color: fillColor },\n line: { type: \"none\" as const },\n });\n\n // テキストを図形の中央(矢印部分を除いた領域)に配置\n const textOffsetTop = isFirst ? 0 : arrowDepth;\n const textHeight = Math.max(1, itemHeight - arrowDepth - textOffsetTop);\n\n ctx.slide.addText(step.label, {\n x: pxToIn(stepX),\n y: pxToIn(stepY + textOffsetTop),\n w: pxToIn(itemWidth),\n h: pxToIn(textHeight),\n fontSize: pxToPt((node.fontSize ?? 14) * scaleFactor),\n fontFace: node.fontFamily ?? \"Noto Sans JP\",\n color: textColor,\n bold: node.bold ?? false,\n italic: node.italic,\n underline: convertUnderline(node.underline),\n strike: convertStrike(node.strike),\n highlight: node.highlight,\n align: \"center\",\n valign: \"middle\",\n });\n });\n}\n"],"mappings":";;;;;;;;AAmBA,SAAgB,uBACd,MACA,KACM;CACN,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,QAAQ,KAAK;CACnB,MAAM,YAAY,MAAM;CAExB,IAAI,cAAc,GAAG;CAErB,MAAM,eAAe;CACrB,MAAM,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,aAAa,KAAK,IAAI,GAAG,aAAa,aAAa,aAAa;EAEtE,IAAI,MAAM,QAAQ,KAAK,OAAO;GAC5B,GAAG,OAAO,KAAK;GACf,GAAG,OAAO,QAAQ,aAAa;GAC/B,GAAG,OAAO,SAAS;GACnB,GAAG,OAAO,UAAU;GACpB,UAAU,QAAQ,KAAK,YAAY,MAAM,WAAW;GACpD,UAAU,KAAK,cAAc;GAC7B,OAAO;GACP,MAAM,KAAK,QAAQ;GACnB,QAAQ,KAAK;GACb,WAAW,iBAAiB,KAAK,SAAS;GAC1C,QAAQ,cAAc,KAAK,MAAM;GACjC,WAAW,KAAK;GAChB,OAAO;GACP,QAAQ;EACV,CAAC;CACH,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"processArrow.js","names":[],"sources":["../../../src/renderPptx/nodes/processArrow.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { stripHash } from \"../utils/visualStyle.ts\";\nimport { pxToIn } from \"../units.ts\";\nimport { measureProcessArrow } from \"../../calcYogaLayout/measureCompositeNodes.ts\";\nimport { resolveScaledContentArea } from \"../utils/scaleToFit.ts\";\nimport {\n ARROW_DEPTH_RATIO,\n DEFAULT_PROCESS_ARROW_ITEM_WIDTH,\n DEFAULT_PROCESS_ARROW_ITEM_HEIGHT,\n} from \"../../shared/processArrowConstants.ts\";\nimport { withContentBounds } from \"../utils/contentArea.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n noShapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\nimport { addGlimpseTextBox } from \"../utils/glimpseTextBox.ts\";\n\ntype ProcessArrowPositionedNode = Extract<\n PositionedNode,\n { type: \"processArrow\" }\n>;\n\nexport function renderProcessArrowNode(\n node: ProcessArrowPositionedNode,\n ctx: RenderContext,\n): void {\n const direction = node.direction ?? \"horizontal\";\n const steps = node.steps;\n const stepCount = steps.length;\n\n if (stepCount === 0) return;\n\n const defaultColor = \"4472C4\"; // PowerPoint標準の青\n const defaultTextColor = \"FFFFFF\";\n const itemWidth = node.itemWidth ?? DEFAULT_PROCESS_ARROW_ITEM_WIDTH;\n const itemHeight = node.itemHeight ?? DEFAULT_PROCESS_ARROW_ITEM_HEIGHT;\n const arrowDepth = itemHeight * ARROW_DEPTH_RATIO;\n const gap = node.gap ?? -arrowDepth;\n\n // スケール係数を計算(コンテンツ領域基準)\n const { content, scaleFactor } = resolveScaledContentArea(\n node,\n measureProcessArrow(node),\n ctx,\n );\n\n const scaledItemWidth = itemWidth * scaleFactor;\n const scaledItemHeight = itemHeight * scaleFactor;\n const scaledGap = gap * scaleFactor;\n const scaledArrowDepth = arrowDepth * scaleFactor;\n\n // コンテンツ領域を使用するための仮想ノードを作成\n const contentNode = withContentBounds(node, content);\n\n if (direction === \"horizontal\") {\n renderHorizontalProcessArrow(\n contentNode,\n ctx,\n steps,\n stepCount,\n scaledItemWidth,\n scaledItemHeight,\n scaledGap,\n scaledArrowDepth,\n defaultColor,\n defaultTextColor,\n scaleFactor,\n );\n } else {\n renderVerticalProcessArrow(\n contentNode,\n ctx,\n steps,\n stepCount,\n scaledItemWidth,\n scaledItemHeight,\n scaledGap,\n scaledArrowDepth,\n defaultColor,\n defaultTextColor,\n scaleFactor,\n );\n }\n}\n\nfunction renderHorizontalProcessArrow(\n node: ProcessArrowPositionedNode,\n ctx: RenderContext,\n steps: ProcessArrowPositionedNode[\"steps\"],\n stepCount: number,\n itemWidth: number,\n itemHeight: number,\n gap: number,\n arrowDepth: number,\n defaultColor: string,\n defaultTextColor: string,\n scaleFactor: number,\n): void {\n const totalWidth = stepCount * itemWidth + (stepCount - 1) * gap;\n const startX = node.x + (node.w - totalWidth) / 2;\n const centerY = node.y + node.h / 2;\n\n steps.forEach((step, index) => {\n const stepX = startX + index * (itemWidth + gap);\n const stepY = centerY - itemHeight / 2;\n const fillColor = stripHash(step.color) ?? defaultColor;\n const textColor = stripHash(step.textColor) ?? defaultTextColor;\n\n // custGeom でシェブロン形状を描画\n const isFirst = index === 0;\n const points = isFirst\n ? [\n // homePlate 風: 左辺フラット、右辺が矢印\n { x: 0, y: 0 },\n { x: pxToIn(itemWidth - arrowDepth), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight / 2) },\n { x: pxToIn(itemWidth - arrowDepth), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight) },\n { close: true as const },\n ]\n : [\n // chevron 風: 左辺に切り欠き、右辺が矢印\n { x: 0, y: 0 },\n { x: pxToIn(itemWidth - arrowDepth), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight / 2) },\n { x: pxToIn(itemWidth - arrowDepth), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight) },\n { x: pxToIn(arrowDepth), y: pxToIn(itemHeight / 2) },\n { close: true as const },\n ];\n\n addGlimpseShape(\n ctx,\n {\n preset: \"rect\",\n ...createShapeBoundsInput({\n x: stepX,\n y: stepY,\n w: itemWidth,\n h: itemHeight,\n }),\n fill: solidShapeFill(fillColor),\n outline: noShapeOutline(),\n },\n { x: stepX, y: stepY, w: itemWidth, h: itemHeight },\n {\n fillColor,\n customGeometry: {\n width: pxToIn(itemWidth),\n height: pxToIn(itemHeight),\n points,\n },\n },\n );\n\n // テキストを図形の中央(矢印部分を除いた領域)に配置\n const textOffsetLeft = isFirst ? 0 : arrowDepth;\n const textWidth = Math.max(1, itemWidth - arrowDepth - textOffsetLeft);\n\n addGlimpseTextBox(\n ctx,\n {\n x: stepX + textOffsetLeft,\n y: stepY,\n w: textWidth,\n h: itemHeight,\n },\n {\n text: step.label,\n fontSize: (node.fontSize ?? 14) * scaleFactor,\n fontFace: node.fontFamily ?? \"Noto Sans JP\",\n color: textColor,\n bold: node.bold ?? false,\n italic: node.italic,\n underline: node.underline,\n strike: node.strike,\n highlight: node.highlight,\n align: \"center\",\n valign: \"middle\",\n },\n );\n });\n}\n\nfunction renderVerticalProcessArrow(\n node: ProcessArrowPositionedNode,\n ctx: RenderContext,\n steps: ProcessArrowPositionedNode[\"steps\"],\n stepCount: number,\n itemWidth: number,\n itemHeight: number,\n gap: number,\n arrowDepth: number,\n defaultColor: string,\n defaultTextColor: string,\n scaleFactor: number,\n): void {\n const totalHeight = stepCount * itemHeight + (stepCount - 1) * gap;\n const startY = node.y + (node.h - totalHeight) / 2;\n const centerX = node.x + node.w / 2;\n\n steps.forEach((step, index) => {\n const stepX = centerX - itemWidth / 2;\n const stepY = startY + index * (itemHeight + gap);\n const fillColor = stripHash(step.color) ?? defaultColor;\n const textColor = stripHash(step.textColor) ?? defaultTextColor;\n\n const isFirst = index === 0;\n const points = isFirst\n ? [\n // rect 風: 上辺フラット、下辺が矢印\n { x: 0, y: 0 },\n { x: pxToIn(itemWidth), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight - arrowDepth) },\n { x: pxToIn(itemWidth / 2), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight - arrowDepth) },\n { close: true as const },\n ]\n : [\n // pentagon 風: 上辺に切り欠き、下辺が矢印\n { x: pxToIn(itemWidth / 2), y: 0 },\n { x: pxToIn(itemWidth), y: pxToIn(arrowDepth) },\n { x: pxToIn(itemWidth), y: pxToIn(itemHeight - arrowDepth) },\n { x: pxToIn(itemWidth / 2), y: pxToIn(itemHeight) },\n { x: 0, y: pxToIn(itemHeight - arrowDepth) },\n { x: 0, y: pxToIn(arrowDepth) },\n { close: true as const },\n ];\n\n addGlimpseShape(\n ctx,\n {\n preset: \"rect\",\n ...createShapeBoundsInput({\n x: stepX,\n y: stepY,\n w: itemWidth,\n h: itemHeight,\n }),\n fill: solidShapeFill(fillColor),\n outline: noShapeOutline(),\n },\n { x: stepX, y: stepY, w: itemWidth, h: itemHeight },\n {\n fillColor,\n customGeometry: {\n width: pxToIn(itemWidth),\n height: pxToIn(itemHeight),\n points,\n },\n },\n );\n\n // テキストを図形の中央(矢印部分を除いた領域)に配置\n const textOffsetTop = isFirst ? 0 : arrowDepth;\n const textHeight = Math.max(1, itemHeight - arrowDepth - textOffsetTop);\n\n addGlimpseTextBox(\n ctx,\n {\n x: stepX,\n y: stepY + textOffsetTop,\n w: itemWidth,\n h: textHeight,\n },\n {\n text: step.label,\n fontSize: (node.fontSize ?? 14) * scaleFactor,\n fontFace: node.fontFamily ?? \"Noto Sans JP\",\n color: textColor,\n bold: node.bold ?? false,\n italic: node.italic,\n underline: node.underline,\n strike: node.strike,\n highlight: node.highlight,\n align: \"center\",\n valign: \"middle\",\n },\n );\n });\n}\n"],"mappings":";;;;;;;;;AAyBA,SAAgB,uBACd,MACA,KACM;CACN,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,QAAQ,KAAK;CACnB,MAAM,YAAY,MAAM;CAExB,IAAI,cAAc,GAAG;CAErB,MAAM,eAAe;CACrB,MAAM,mBAAmB;CACzB,MAAM,YAAY,KAAK,aAAA;CACvB,MAAM,aAAa,KAAK,cAAA;CACxB,MAAM,aAAa,aAAa;CAChC,MAAM,MAAM,KAAK,OAAO,CAAC;CAGzB,MAAM,EAAE,SAAS,gBAAgB,yBAC/B,MACA,oBAAoB,IAAI,GACxB,GACF;CAEA,MAAM,kBAAkB,YAAY;CACpC,MAAM,mBAAmB,aAAa;CACtC,MAAM,YAAY,MAAM;CACxB,MAAM,mBAAmB,aAAa;CAGtC,MAAM,cAAc,kBAAkB,MAAM,OAAO;CAEnD,IAAI,cAAc,cAChB,6BACE,aACA,KACA,OACA,WACA,iBACA,kBACA,WACA,kBACA,cACA,kBACA,WACF;MAEA,2BACE,aACA,KACA,OACA,WACA,iBACA,kBACA,WACA,kBACA,cACA,kBACA,WACF;AAEJ;AAEA,SAAS,6BACP,MACA,KACA,OACA,WACA,WACA,YACA,KACA,YACA,cACA,kBACA,aACM;CACN,MAAM,aAAa,YAAY,aAAa,YAAY,KAAK;CAC7D,MAAM,SAAS,KAAK,KAAK,KAAK,IAAI,cAAc;CAChD,MAAM,UAAU,KAAK,IAAI,KAAK,IAAI;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AU;GAAE;GAC9C;IAAE,GAAG,OAAO,SAAS;IAAG,GAAG,OAAO,aAAa,UAAU;GAAE;GAC3D;IAAE,GAAG,OAAO,YAAY,CAAC;IAAG,GAAG,OAAO,UAAU;GAAE;GAClD;IAAE,GAAG;IAAG,GAAG,OAAO,aAAa,UAAU;GAAE;GAC3C;IAAE,GAAG;IAAG,GAAG,OAAO,UAAU;GAAE;GAC9B,EAAE,OAAO,KAAc;EACzB;EAEJ,gBACE,KACA;GACE,QAAQ;GACR,GAAG,uBAAuB;IACxB,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;GACL,CAAC;GACD,MAAM,eAAe,SAAS;GAC9B,SAAS,eAAe;EAC1B,GACA;GAAE,GAAG;GAAO,GAAG;GAAO,GAAG;GAAW,GAAG;EAAW,GAClD;GACE;GACA,gBAAgB;IACd,OAAO,OAAO,SAAS;IACvB,QAAQ,OAAO,UAAU;IACzB;GACF;EACF,CACF;EAGA,MAAM,gBAAgB,UAAU,IAAI;EACpC,MAAM,aAAa,KAAK,IAAI,GAAG,aAAa,aAAa,aAAa;EAEtE,kBACE,KACA;GACE,GAAG;GACH,GAAG,QAAQ;GACX,GAAG;GACH,GAAG;EACL,GACA;GACE,MAAM,KAAK;GACX,WAAW,KAAK,YAAY,MAAM;GAClC,UAAU,KAAK,cAAc;GAC7B,OAAO;GACP,MAAM,KAAK,QAAQ;GACnB,QAAQ,KAAK;GACb,WAAW,KAAK;GAChB,QAAQ,KAAK;GACb,WAAW,KAAK;GAChB,OAAO;GACP,QAAQ;EACV,CACF;CACF,CAAC;AACH"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { pxToIn
|
|
2
|
-
import {
|
|
1
|
+
import { pxToIn } from "../units.js";
|
|
2
|
+
import { addGlimpseTextBox } from "../utils/glimpseTextBox.js";
|
|
3
|
+
import { addGlimpseShape, createShapeBoundsInput, noShapeOutline, solidShapeFill } from "../utils/glimpseShape.js";
|
|
3
4
|
import { measurePyramid } from "../../calcYogaLayout/measureCompositeNodes.js";
|
|
5
|
+
import { stripHash } from "../utils/visualStyle.js";
|
|
4
6
|
import { resolveScaledContentArea } from "../utils/scaleToFit.js";
|
|
5
7
|
//#region src/renderPptx/nodes/pyramid.ts
|
|
6
8
|
function renderPyramidNode(node, ctx) {
|
|
@@ -58,21 +60,37 @@ function renderPyramidNode(node, ctx) {
|
|
|
58
60
|
},
|
|
59
61
|
{ close: true }
|
|
60
62
|
];
|
|
61
|
-
ctx
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
addGlimpseShape(ctx, {
|
|
64
|
+
preset: "rect",
|
|
65
|
+
...createShapeBoundsInput({
|
|
66
|
+
x: bboxX,
|
|
67
|
+
y: layerY,
|
|
68
|
+
w: bboxW,
|
|
69
|
+
h: layerHeight
|
|
70
|
+
}),
|
|
71
|
+
fill: solidShapeFill(fillColor),
|
|
72
|
+
outline: noShapeOutline()
|
|
73
|
+
}, {
|
|
74
|
+
x: bboxX,
|
|
75
|
+
y: layerY,
|
|
76
|
+
w: bboxW,
|
|
77
|
+
h: layerHeight
|
|
78
|
+
}, {
|
|
79
|
+
fillColor,
|
|
80
|
+
customGeometry: {
|
|
81
|
+
width: pxToIn(bboxW),
|
|
82
|
+
height: pxToIn(layerHeight),
|
|
83
|
+
points
|
|
84
|
+
}
|
|
69
85
|
});
|
|
70
|
-
ctx
|
|
71
|
-
x:
|
|
72
|
-
y:
|
|
73
|
-
w:
|
|
74
|
-
h:
|
|
75
|
-
|
|
86
|
+
addGlimpseTextBox(ctx, {
|
|
87
|
+
x: bboxX,
|
|
88
|
+
y: layerY,
|
|
89
|
+
w: bboxW,
|
|
90
|
+
h: layerHeight
|
|
91
|
+
}, {
|
|
92
|
+
text: level.label,
|
|
93
|
+
fontSize: (node.fontSize ?? 14) * scaleFactor,
|
|
76
94
|
fontFace: node.fontFamily ?? "Noto Sans JP",
|
|
77
95
|
color: textColor,
|
|
78
96
|
bold: node.bold ?? false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pyramid.js","names":[],"sources":["../../../src/renderPptx/nodes/pyramid.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { stripHash } from \"../utils/visualStyle.ts\";\nimport { pxToIn
|
|
1
|
+
{"version":3,"file":"pyramid.js","names":[],"sources":["../../../src/renderPptx/nodes/pyramid.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { stripHash } from \"../utils/visualStyle.ts\";\nimport { pxToIn } from \"../units.ts\";\nimport { measurePyramid } from \"../../calcYogaLayout/measureCompositeNodes.ts\";\nimport { resolveScaledContentArea } from \"../utils/scaleToFit.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n noShapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\nimport { addGlimpseTextBox } from \"../utils/glimpseTextBox.ts\";\n\ntype PyramidPositionedNode = Extract<PositionedNode, { type: \"pyramid\" }>;\n\nexport function renderPyramidNode(\n node: PyramidPositionedNode,\n ctx: RenderContext,\n): void {\n const direction = node.direction ?? \"up\";\n const levels = node.levels;\n const levelCount = levels.length;\n\n if (levelCount === 0) return;\n\n const defaultColor = \"4472C4\";\n const defaultTextColor = \"FFFFFF\";\n\n // スケール係数を計算(コンテンツ領域基準)\n const { content, scaleFactor } = resolveScaledContentArea(\n node,\n measurePyramid(node),\n ctx,\n );\n\n const baseWidth = 400 * scaleFactor;\n const layerHeight = 50 * scaleFactor;\n const gap = 2 * scaleFactor;\n\n const totalHeight = levelCount * layerHeight + (levelCount - 1) * gap;\n const startX = content.x + (content.w - baseWidth) / 2;\n const startY = content.y + (content.h - totalHeight) / 2;\n\n for (let i = 0; i < levelCount; i++) {\n const level = levels[i];\n const fillColor = stripHash(level.color) ?? defaultColor;\n const textColor = stripHash(level.textColor) ?? defaultTextColor;\n\n const layerY = startY + i * (layerHeight + gap);\n\n // direction=\"up\": i=0 が最上段(最も狭い=三角形)、i=levelCount-1 が最下段(最も広い)\n // direction=\"down\": i=0 が最上段(最も広い)、i=levelCount-1 が最下段(最も狭い=三角形)\n // 頂点層の上辺は幅0(三角形)、それ以外は台形\n let topWidthRatio: number;\n let bottomWidthRatio: number;\n\n if (direction === \"up\") {\n topWidthRatio = i / levelCount;\n bottomWidthRatio = (i + 1) / levelCount;\n } else {\n topWidthRatio = (levelCount - i) / levelCount;\n bottomWidthRatio = (levelCount - i - 1) / levelCount;\n }\n\n const topWidth = baseWidth * topWidthRatio;\n const bottomWidth = baseWidth * bottomWidthRatio;\n\n const topLeftX = startX + (baseWidth - topWidth) / 2;\n const topRightX = topLeftX + topWidth;\n const bottomLeftX = startX + (baseWidth - bottomWidth) / 2;\n const bottomRightX = bottomLeftX + bottomWidth;\n\n // custGeom のバウンディングボックス\n const bboxX = Math.min(topLeftX, bottomLeftX);\n const bboxW = Math.max(topRightX, bottomRightX) - bboxX;\n\n // points はバウンディングボックス内の相対インチ座標\n const points = [\n { x: pxToIn(topLeftX - bboxX), y: 0 },\n { x: pxToIn(topRightX - bboxX), y: 0 },\n { x: pxToIn(bottomRightX - bboxX), y: pxToIn(layerHeight) },\n { x: pxToIn(bottomLeftX - bboxX), y: pxToIn(layerHeight) },\n { close: true as const },\n ];\n\n addGlimpseShape(\n ctx,\n {\n preset: \"rect\",\n ...createShapeBoundsInput({\n x: bboxX,\n y: layerY,\n w: bboxW,\n h: layerHeight,\n }),\n fill: solidShapeFill(fillColor),\n outline: noShapeOutline(),\n },\n { x: bboxX, y: layerY, w: bboxW, h: layerHeight },\n {\n fillColor,\n customGeometry: {\n width: pxToIn(bboxW),\n height: pxToIn(layerHeight),\n points,\n },\n },\n );\n\n // テキストを図形の中央に重ねて描画\n addGlimpseTextBox(\n ctx,\n {\n x: bboxX,\n y: layerY,\n w: bboxW,\n h: layerHeight,\n },\n {\n text: level.label,\n fontSize: (node.fontSize ?? 14) * scaleFactor,\n fontFace: node.fontFamily ?? \"Noto Sans JP\",\n color: textColor,\n bold: node.bold ?? false,\n align: \"center\",\n valign: \"middle\",\n autoFit: true,\n },\n );\n }\n}\n"],"mappings":";;;;;;;AAgBA,SAAgB,kBACd,MACA,KACM;CACN,MAAM,YAAY,KAAK,aAAa;CACpC,MAAM,SAAS,KAAK;CACpB,MAAM,aAAa,OAAO;CAE1B,IAAI,eAAe,GAAG;CAEtB,MAAM,eAAe;CACrB,MAAM,mBAAmB;CAGzB,MAAM,EAAE,SAAS,gBAAgB,yBAC/B,MACA,eAAe,IAAI,GACnB,GACF;CAEA,MAAM,YAAY,MAAM;CACxB,MAAM,cAAc,KAAK;CACzB,MAAM,MAAM,IAAI;CAEhB,MAAM,cAAc,aAAa,eAAe,aAAa,KAAK;CAClE,MAAM,SAAS,QAAQ,KAAK,QAAQ,IAAI,aAAa;CACrD,MAAM,SAAS,QAAQ,KAAK,QAAQ,IAAI,eAAe;CAEvD,KAAK,IAAI,IAAI,GAAG,IAAI,YAAY,KAAK;EACnC,MAAM,QAAQ,OAAO;EACrB,MAAM,YAAY,UAAU,MAAM,KAAK,KAAK;EAC5C,MAAM,YAAY,UAAU,MAAM,SAAS,KAAK;EAEhD,MAAM,SAAS,SAAS,KAAK,cAAc;EAK3C,IAAI;EACJ,IAAI;EAEJ,IAAI,cAAc,MAAM;GACtB,gBAAgB,IAAI;GACpB,oBAAoB,IAAI,KAAK;EAC/B,OAAO;GACL,iBAAiB,aAAa,KAAK;GACnC,oBAAoB,aAAa,IAAI,KAAK;EAC5C;EAEA,MAAM,WAAW,YAAY;EAC7B,MAAM,cAAc,YAAY;EAEhC,MAAM,WAAW,UAAU,YAAY,YAAY;EACnD,MAAM,YAAY,WAAW;EAC7B,MAAM,cAAc,UAAU,YAAY,eAAe;EACzD,MAAM,eAAe,cAAc;EAGnC,MAAM,QAAQ,KAAK,IAAI,UAAU,WAAW;EAC5C,MAAM,QAAQ,KAAK,IAAI,WAAW,YAAY,IAAI;EAGlD,MAAM,SAAS;GACb;IAAE,GAAG,OAAO,WAAW,KAAK;IAAG,GAAG;GAAE;GACpC;IAAE,GAAG,OAAO,YAAY,KAAK;IAAG,GAAG;GAAE;GACrC;IAAE,GAAG,OAAO,eAAe,KAAK;IAAG,GAAG,OAAO,WAAW;GAAE;GAC1D;IAAE,GAAG,OAAO,cAAc,KAAK;IAAG,GAAG,OAAO,WAAW;GAAE;GACzD,EAAE,OAAO,KAAc;EACzB;EAEA,gBACE,KACA;GACE,QAAQ;GACR,GAAG,uBAAuB;IACxB,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;GACL,CAAC;GACD,MAAM,eAAe,SAAS;GAC9B,SAAS,eAAe;EAC1B,GACA;GAAE,GAAG;GAAO,GAAG;GAAQ,GAAG;GAAO,GAAG;EAAY,GAChD;GACE;GACA,gBAAgB;IACd,OAAO,OAAO,KAAK;IACnB,QAAQ,OAAO,WAAW;IAC1B;GACF;EACF,CACF;EAGA,kBACE,KACA;GACE,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;EACL,GACA;GACE,MAAM,MAAM;GACZ,WAAW,KAAK,YAAY,MAAM;GAClC,UAAU,KAAK,cAAc;GAC7B,OAAO;GACP,MAAM,KAAK,QAAQ;GACnB,OAAO;GACP,QAAQ;GACR,SAAS;EACX,CACF;CACF;AACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { pxToPt } from "../units.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { pxToEmu, pxToPt } from "../units.js";
|
|
2
|
+
import { getContentArea } from "../utils/contentArea.js";
|
|
3
|
+
import { toColorInput } from "../glimpseTextBoxes.js";
|
|
4
|
+
import { addGlimpseShape, createShapeBoundsInput, createShapeRotationInput, noneShapeFill, shapeOutline, solidShapeFill } from "../utils/glimpseShape.js";
|
|
5
|
+
import { asEmu, asHundredthPt, asPt } from "@pptx-glimpse/document";
|
|
5
6
|
//#region src/renderPptx/nodes/shape.ts
|
|
6
7
|
/**
|
|
7
8
|
* outline (Text と同じ書式の `outline.size` / `outline.color`) と
|
|
@@ -22,41 +23,66 @@ function resolveShapeLine(line, outline) {
|
|
|
22
23
|
dashType: line?.dashType
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
function toUnderlineInput(underline) {
|
|
27
|
+
if (underline === void 0 || underline === false) return void 0;
|
|
28
|
+
if (underline === true) return true;
|
|
29
|
+
return {
|
|
30
|
+
style: underline.style,
|
|
31
|
+
color: toColorInput(underline.color)
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function buildShapeTextProperties(node) {
|
|
35
|
+
return {
|
|
36
|
+
fontFace: node.fontFamily ?? "Noto Sans JP",
|
|
37
|
+
fontSize: asPt(pxToPt(node.fontSize ?? 24)),
|
|
38
|
+
color: toColorInput(node.color),
|
|
39
|
+
bold: node.bold,
|
|
40
|
+
italic: node.italic,
|
|
41
|
+
underline: toUnderlineInput(node.underline),
|
|
42
|
+
strike: node.strike,
|
|
43
|
+
baseline: node.subscript ? "subscript" : node.superscript ? "superscript" : void 0,
|
|
44
|
+
highlight: toColorInput(node.highlight)
|
|
38
45
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
color: node.color,
|
|
48
|
-
bold: node.bold,
|
|
49
|
-
italic: node.italic,
|
|
50
|
-
underline: convertUnderline(node.underline),
|
|
51
|
-
strike: convertStrike(node.strike),
|
|
52
|
-
subscript: node.subscript,
|
|
53
|
-
superscript: node.superscript,
|
|
54
|
-
highlight: node.highlight,
|
|
46
|
+
}
|
|
47
|
+
function buildShapeParagraphs(node) {
|
|
48
|
+
if (!node.text) return void 0;
|
|
49
|
+
const fontSizePx = node.fontSize ?? 24;
|
|
50
|
+
const lineHeight = node.lineHeight ?? 1.3;
|
|
51
|
+
const properties = buildShapeTextProperties(node);
|
|
52
|
+
return node.text.replace(/\r*\n/g, "\n").split("\n").map((text) => ({
|
|
53
|
+
properties: {
|
|
55
54
|
align: node.textAlign ?? "center",
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
lineSpacing: asHundredthPt(Math.round(pxToPt(fontSizePx * lineHeight) * 100))
|
|
56
|
+
},
|
|
57
|
+
runs: [{
|
|
58
|
+
text,
|
|
59
|
+
properties
|
|
60
|
+
}]
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
function renderShapeNode(node, ctx) {
|
|
64
|
+
const lineSpec = resolveShapeLine(node.line, node.outline);
|
|
65
|
+
const boundsPx = getContentArea(node);
|
|
66
|
+
const fillOpacity = node.fill?.transparency !== void 0 ? 1 - node.fill.transparency / 100 : void 0;
|
|
67
|
+
addGlimpseShape(ctx, {
|
|
68
|
+
preset: node.shapeType,
|
|
69
|
+
...createShapeBoundsInput(boundsPx),
|
|
70
|
+
rotation: createShapeRotationInput(node.rotate),
|
|
71
|
+
fill: node.fill?.color ? solidShapeFill(node.fill.color) : noneShapeFill(),
|
|
72
|
+
outline: shapeOutline(lineSpec),
|
|
73
|
+
effects: node.glow ? { glow: {
|
|
74
|
+
radius: asEmu(Math.round(pxToEmu(node.glow.size ?? 8))),
|
|
75
|
+
color: toColorInput(node.glow.color ?? "FFFFFF")
|
|
76
|
+
} } : void 0,
|
|
77
|
+
body: node.text ? { anchor: "middle" } : void 0,
|
|
78
|
+
paragraphs: buildShapeParagraphs(node)
|
|
79
|
+
}, boundsPx, {
|
|
80
|
+
fillColor: node.fill?.color,
|
|
81
|
+
fillOpacity,
|
|
82
|
+
glow: node.glow,
|
|
83
|
+
shadow: node.shadow,
|
|
84
|
+
dashType: lineSpec?.dashType
|
|
85
|
+
});
|
|
60
86
|
}
|
|
61
87
|
//#endregion
|
|
62
88
|
export { renderShapeNode };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.js","names":[],"sources":["../../../src/renderPptx/nodes/shape.ts"],"sourcesContent":["import type { BorderStyle, PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { pxToPt } from \"../units.ts\";\nimport {
|
|
1
|
+
{"version":3,"file":"shape.js","names":[],"sources":["../../../src/renderPptx/nodes/shape.ts"],"sourcesContent":["import {\n asEmu,\n asHundredthPt,\n asPt,\n type AddShapeParagraphInput,\n type AddShapeRunPropertiesInput,\n} from \"@pptx-glimpse/document\";\nimport type { BorderStyle, PositionedNode, Underline } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { pxToPt } from \"../units.ts\";\nimport { getContentArea } from \"../utils/contentArea.ts\";\nimport { pxToEmu } from \"../units.ts\";\nimport { toColorInput } from \"../glimpseTextBoxes.ts\";\nimport {\n addGlimpseShape,\n createShapeBoundsInput,\n createShapeRotationInput,\n noneShapeFill,\n shapeOutline,\n solidShapeFill,\n} from \"../utils/glimpseShape.ts\";\n\ntype ShapePositionedNode = Extract<PositionedNode, { type: \"shape\" }>;\n\n/**\n * outline (Text と同じ書式の `outline.size` / `outline.color`) と\n * 既存 `line` 属性 (`line.color` / `line.width` / `line.dashType`) を\n * 1 つの BorderStyle にマージする。\n *\n * フィールド単位のマージで、`outline` の指定があるフィールドは `line` を\n * 上書きするが、`outline` 側で省略されたフィールドは `line` の値を引き継ぎ、\n * `line` にも値が無い場合は Text outline と同じ既定値 (`width: 1pt 相当` /\n * `color: FFFFFF`) を採用する。`dashType` は `outline` に対応フィールドが\n * 無いため `line.dashType` をそのまま使う。\n */\nfunction resolveShapeLine(\n line: BorderStyle | undefined,\n outline: { size?: number; color?: string } | undefined,\n): BorderStyle | undefined {\n if (!outline) return line;\n return {\n color: outline.color ?? line?.color ?? \"FFFFFF\",\n width: outline.size ?? line?.width ?? 1,\n dashType: line?.dashType,\n };\n}\n\nfunction toUnderlineInput(underline: Underline | undefined) {\n if (underline === undefined || underline === false) return undefined;\n if (underline === true) return true;\n return {\n style: underline.style,\n color: toColorInput(underline.color),\n };\n}\n\nfunction buildShapeTextProperties(\n node: ShapePositionedNode,\n): AddShapeRunPropertiesInput {\n return {\n fontFace: node.fontFamily ?? \"Noto Sans JP\",\n fontSize: asPt(pxToPt(node.fontSize ?? 24)),\n color: toColorInput(node.color),\n bold: node.bold,\n italic: node.italic,\n underline: toUnderlineInput(node.underline),\n strike: node.strike,\n baseline: node.subscript\n ? \"subscript\"\n : node.superscript\n ? \"superscript\"\n : undefined,\n highlight: toColorInput(node.highlight),\n };\n}\n\nfunction buildShapeParagraphs(\n node: ShapePositionedNode,\n): AddShapeParagraphInput[] | undefined {\n if (!node.text) return undefined;\n const fontSizePx = node.fontSize ?? 24;\n const lineHeight = node.lineHeight ?? 1.3;\n const properties = buildShapeTextProperties(node);\n return node.text\n .replace(/\\r*\\n/g, \"\\n\")\n .split(\"\\n\")\n .map((text) => ({\n properties: {\n align: node.textAlign ?? \"center\",\n lineSpacing: asHundredthPt(\n Math.round(pxToPt(fontSizePx * lineHeight) * 100),\n ),\n },\n runs: [{ text, properties }],\n }));\n}\n\nexport function renderShapeNode(\n node: ShapePositionedNode,\n ctx: RenderContext,\n): void {\n const lineSpec = resolveShapeLine(node.line, node.outline);\n const boundsPx = getContentArea(node);\n const fillOpacity =\n node.fill?.transparency !== undefined\n ? 1 - node.fill.transparency / 100\n : undefined;\n\n addGlimpseShape(\n ctx,\n {\n preset: node.shapeType,\n ...createShapeBoundsInput(boundsPx),\n rotation: createShapeRotationInput(node.rotate),\n fill: node.fill?.color\n ? solidShapeFill(node.fill.color)\n : noneShapeFill(),\n outline: shapeOutline(lineSpec),\n effects: node.glow\n ? {\n glow: {\n radius: asEmu(Math.round(pxToEmu(node.glow.size ?? 8))),\n color: toColorInput(node.glow.color ?? \"FFFFFF\")!,\n },\n }\n : undefined,\n body: node.text\n ? {\n anchor: \"middle\",\n }\n : undefined,\n paragraphs: buildShapeParagraphs(node),\n },\n boundsPx,\n {\n fillColor: node.fill?.color,\n fillOpacity,\n glow: node.glow,\n shadow: node.shadow,\n dashType: lineSpec?.dashType,\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmCA,SAAS,iBACP,MACA,SACyB;CACzB,IAAI,CAAC,SAAS,OAAO;CACrB,OAAO;EACL,OAAO,QAAQ,SAAS,MAAM,SAAS;EACvC,OAAO,QAAQ,QAAQ,MAAM,SAAS;EACtC,UAAU,MAAM;CAClB;AACF;AAEA,SAAS,iBAAiB,WAAkC;CAC1D,IAAI,cAAc,KAAA,KAAa,cAAc,OAAO,OAAO,KAAA;CAC3D,IAAI,cAAc,MAAM,OAAO;CAC/B,OAAO;EACL,OAAO,UAAU;EACjB,OAAO,aAAa,UAAU,KAAK;CACrC;AACF;AAEA,SAAS,yBACP,MAC4B;CAC5B,OAAO;EACL,UAAU,KAAK,cAAc;EAC7B,UAAU,KAAK,OAAO,KAAK,YAAY,EAAE,CAAC;EAC1C,OAAO,aAAa,KAAK,KAAK;EAC9B,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,WAAW,iBAAiB,KAAK,SAAS;EAC1C,QAAQ,KAAK;EACb,UAAU,KAAK,YACX,cACA,KAAK,cACH,gBACA,KAAA;EACN,WAAW,aAAa,KAAK,SAAS;CACxC;AACF;AAEA,SAAS,qBACP,MACsC;CACtC,IAAI,CAAC,KAAK,MAAM,OAAO,KAAA;CACvB,MAAM,aAAa,KAAK,YAAY;CACpC,MAAM,aAAa,KAAK,cAAc;CACtC,MAAM,aAAa,yBAAyB,IAAI;CAChD,OAAO,KAAK,KACT,QAAQ,UAAU,IAAI,CAAC,CACvB,MAAM,IAAI,CAAC,CACX,KAAK,UAAU;EACd,YAAY;GACV,OAAO,KAAK,aAAa;GACzB,aAAa,cACX,KAAK,MAAM,OAAO,aAAa,UAAU,IAAI,GAAG,CAClD;EACF;EACA,MAAM,CAAC;GAAE;GAAM;EAAW,CAAC;CAC7B,EAAE;AACN;AAEA,SAAgB,gBACd,MACA,KACM;CACN,MAAM,WAAW,iBAAiB,KAAK,MAAM,KAAK,OAAO;CACzD,MAAM,WAAW,eAAe,IAAI;CACpC,MAAM,cACJ,KAAK,MAAM,iBAAiB,KAAA,IACxB,IAAI,KAAK,KAAK,eAAe,MAC7B,KAAA;CAEN,gBACE,KACA;EACE,QAAQ,KAAK;EACb,GAAG,uBAAuB,QAAQ;EAClC,UAAU,yBAAyB,KAAK,MAAM;EAC9C,MAAM,KAAK,MAAM,QACb,eAAe,KAAK,KAAK,KAAK,IAC9B,cAAc;EAClB,SAAS,aAAa,QAAQ;EAC9B,SAAS,KAAK,OACV,EACE,MAAM;GACJ,QAAQ,MAAM,KAAK,MAAM,QAAQ,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC;GACtD,OAAO,aAAa,KAAK,KAAK,SAAS,QAAQ;EACjD,EACF,IACA,KAAA;EACJ,MAAM,KAAK,OACP,EACE,QAAQ,SACV,IACA,KAAA;EACJ,YAAY,qBAAqB,IAAI;CACvC,GACA,UACA;EACE,WAAW,KAAK,MAAM;EACtB;EACA,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,UAAU,UAAU;CACtB,CACF;AACF"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { addGlimpsePicture, imageBytesFromSource } from "../utils/glimpsePicture.js";
|
|
2
2
|
//#region src/renderPptx/nodes/svg.ts
|
|
3
3
|
function renderSvgNode(node, ctx) {
|
|
4
|
-
ctx.
|
|
5
|
-
data: node.iconImageData,
|
|
6
|
-
...rectPxToIn(node)
|
|
7
|
-
});
|
|
4
|
+
addGlimpsePicture(ctx, node, imageBytesFromSource("", node.iconImageData));
|
|
8
5
|
}
|
|
9
6
|
//#endregion
|
|
10
7
|
export { renderSvgNode };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svg.js","names":[],"sources":["../../../src/renderPptx/nodes/svg.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport {
|
|
1
|
+
{"version":3,"file":"svg.js","names":[],"sources":["../../../src/renderPptx/nodes/svg.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport {\n addGlimpsePicture,\n imageBytesFromSource,\n} from \"../utils/glimpsePicture.ts\";\n\ntype SvgPositionedNode = Extract<PositionedNode, { type: \"svg\" }>;\n\nexport function renderSvgNode(\n node: SvgPositionedNode,\n ctx: RenderContext,\n): void {\n addGlimpsePicture(ctx, node, imageBytesFromSource(\"\", node.iconImageData));\n}\n"],"mappings":";;AASA,SAAgB,cACd,MACA,KACM;CACN,kBAAkB,KAAK,MAAM,qBAAqB,IAAI,KAAK,aAAa,CAAC;AAC3E"}
|
|
@@ -1,51 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { convertGlow, convertOutline, convertStrike, convertUnderline, createTextOptions, resolveSubSup } from "../textOptions.js";
|
|
3
|
-
import { registerTextGradient } from "../gradientFills.js";
|
|
1
|
+
import { createTextOptions } from "../textOptions.js";
|
|
4
2
|
//#region src/renderPptx/nodes/text.ts
|
|
5
3
|
function renderTextNode(node, ctx) {
|
|
6
4
|
const textOptions = createTextOptions(node);
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
italic: run.italic ?? node.italic,
|
|
23
|
-
underline: convertUnderline(run.underline ?? node.underline),
|
|
24
|
-
strike: convertStrike(run.strike ?? node.strike),
|
|
25
|
-
subscript: subSup.subscript,
|
|
26
|
-
superscript: subSup.superscript,
|
|
27
|
-
highlight: run.highlight ?? node.highlight,
|
|
28
|
-
glow: convertGlow(node.glow),
|
|
29
|
-
outline: convertOutline(node.outline),
|
|
30
|
-
charSpacing: letterSpacingPx !== void 0 ? pxToPt(letterSpacingPx) : void 0,
|
|
31
|
-
...run.href ? { hyperlink: { url: run.href } } : {}
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
ctx.slide.addText(textItems, {
|
|
36
|
-
x: textOptions.x,
|
|
37
|
-
y: textOptions.y,
|
|
38
|
-
w: textOptions.w,
|
|
39
|
-
h: textOptions.h,
|
|
40
|
-
rotate: textOptions.rotate,
|
|
41
|
-
align: textOptions.align,
|
|
42
|
-
valign: textOptions.valign,
|
|
43
|
-
margin: textOptions.margin,
|
|
44
|
-
lineSpacing: textOptions.lineSpacing
|
|
45
|
-
});
|
|
46
|
-
} else ctx.slide.addText(node.text ?? "", {
|
|
47
|
-
...textOptions,
|
|
48
|
-
color: textGradientMarker ?? textOptions.color
|
|
5
|
+
const marker = ctx.buildContext.glimpseTextBoxes.register(node);
|
|
6
|
+
ctx.slide.addShape(ctx.pptx.ShapeType.rect, {
|
|
7
|
+
x: textOptions.x,
|
|
8
|
+
y: textOptions.y,
|
|
9
|
+
w: textOptions.w,
|
|
10
|
+
h: textOptions.h,
|
|
11
|
+
fill: {
|
|
12
|
+
color: "FFFFFF",
|
|
13
|
+
transparency: 100
|
|
14
|
+
},
|
|
15
|
+
line: {
|
|
16
|
+
color: "FFFFFF",
|
|
17
|
+
transparency: 100
|
|
18
|
+
},
|
|
19
|
+
objectName: marker
|
|
49
20
|
});
|
|
50
21
|
}
|
|
51
22
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":[],"sources":["../../../src/renderPptx/nodes/text.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport {
|
|
1
|
+
{"version":3,"file":"text.js","names":[],"sources":["../../../src/renderPptx/nodes/text.ts"],"sourcesContent":["import type { PositionedNode } from \"../../types.ts\";\nimport type { RenderContext } from \"../types.ts\";\nimport { createTextOptions } from \"../textOptions.ts\";\n\ntype TextPositionedNode = Extract<PositionedNode, { type: \"text\" }>;\n\nexport function renderTextNode(\n node: TextPositionedNode,\n ctx: RenderContext,\n): void {\n const textOptions = createTextOptions(node);\n const marker = ctx.buildContext.glimpseTextBoxes.register(node);\n\n ctx.slide.addShape(ctx.pptx.ShapeType.rect, {\n x: textOptions.x,\n y: textOptions.y,\n w: textOptions.w,\n h: textOptions.h,\n fill: { color: \"FFFFFF\", transparency: 100 },\n line: { color: \"FFFFFF\", transparency: 100 },\n objectName: marker,\n });\n}\n"],"mappings":";;AAMA,SAAgB,eACd,MACA,KACM;CACN,MAAM,cAAc,kBAAkB,IAAI;CAC1C,MAAM,SAAS,IAAI,aAAa,iBAAiB,SAAS,IAAI;CAE9D,IAAI,MAAM,SAAS,IAAI,KAAK,UAAU,MAAM;EAC1C,GAAG,YAAY;EACf,GAAG,YAAY;EACf,GAAG,YAAY;EACf,GAAG,YAAY;EACf,MAAM;GAAE,OAAO;GAAU,cAAc;EAAI;EAC3C,MAAM;GAAE,OAAO;GAAU,cAAc;EAAI;EAC3C,YAAY;CACd,CAAC;AACH"}
|