ooxml-ui 1.43.0 → 1.44.0
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/base.d.ts +0 -1
- package/dist/chart/format-pane-3d.d.ts +0 -1
- package/dist/chart/format-pane-advanced-intent.d.ts +0 -1
- package/dist/chart/format-pane-analysis.d.ts +0 -1
- package/dist/chart/format-pane-axis.d.ts +0 -1
- package/dist/chart/format-pane-common.d.ts +0 -1
- package/dist/chart/format-pane-effects.d.ts +0 -1
- package/dist/chart/format-pane-fields.d.ts +0 -1
- package/dist/chart/format-pane-fill-kinds.d.ts +0 -1
- package/dist/chart/format-pane-fill-line.d.ts +0 -1
- package/dist/chart/format-pane-locales/es.d.ts +0 -1
- package/dist/chart/format-pane-model.d.ts +0 -1
- package/dist/chart/format-pane-options.d.ts +0 -1
- package/dist/chart/format-pane-space.d.ts +0 -1
- package/dist/chart/format-pane-text.d.ts +0 -1
- package/dist/chart/format-pane-types.d.ts +0 -1
- package/dist/chart/format-pane-view.d.ts +0 -1
- package/dist/chrome/find-bar.d.ts +1 -2
- package/dist/controls.d.ts +0 -1
- package/dist/embedding/region-host.d.ts +0 -1
- package/dist/files/save-progress-label.d.ts +0 -1
- package/dist/fonts/custom-fonts.d.ts +0 -1
- package/dist/form/color-swatches.d.ts +0 -1
- package/dist/image-native-size.d.ts +0 -1
- package/dist/picture-artistic-filters.d.ts +0 -1
- package/dist/picture-artistic-preview.d.ts +0 -1
- package/dist/picture-paint.d.ts +0 -1
- package/dist/pptx/{chart-3d-view-scene-CGLU6ISD.mjs → chart-3d-view-scene-D6OJTZYC.mjs} +3 -2
- package/dist/pptx/{chart-3d-view-scene-C7QUQTXD.cjs → chart-3d-view-scene-PC2RUBL4.cjs} +38 -37
- package/dist/pptx/{chunk-JP26TA3Q.cjs → chunk-2GDYTHUY.cjs} +12 -12
- package/dist/pptx/{chunk-YZWKNFPU.cjs → chunk-2SO3BL67.cjs} +2706 -160
- package/dist/pptx/{chunk-5BINBXFV.mjs → chunk-BNPTGOEZ.mjs} +3 -3
- package/dist/pptx/{chunk-7FTP7OOA.mjs → chunk-D3DQS2J2.mjs} +6767 -6987
- package/dist/pptx/chunk-EDIAPF6J.mjs +135 -0
- package/dist/pptx/{chunk-DH6EKOVI.mjs → chunk-H6M3FKNG.mjs} +1 -1
- package/dist/pptx/{chunk-CK6RYGB4.cjs → chunk-HB6CH2FF.cjs} +3 -126
- package/dist/pptx/chunk-HWJKBKCW.cjs +147 -0
- package/dist/pptx/{chunk-BA4CJI4U.mjs → chunk-KYTG7WNC.mjs} +3 -115
- package/dist/pptx/{chunk-P4NVINSK.cjs → chunk-LK35P6RE.cjs} +5329 -5606
- package/dist/pptx/{chunk-TW5UQCZS.mjs → chunk-TDALHSYV.mjs} +2605 -168
- package/dist/pptx/{chunk-UGSMMZU6.cjs → chunk-ZH35NTNU.cjs} +49 -49
- package/dist/pptx/dom/elements/connector.d.ts.map +1 -1
- package/dist/pptx/dom/elements/equation.d.ts.map +1 -1
- package/dist/pptx/dom/elements/media.d.ts.map +1 -1
- package/dist/pptx/dom/elements/ole.d.ts.map +1 -1
- package/dist/pptx/dom/elements/reflection-mirror-content.d.ts.map +1 -1
- package/dist/pptx/dom/elements/shape-filter-defs.d.ts +5 -0
- package/dist/pptx/dom/elements/shape-filter-defs.d.ts.map +1 -1
- package/dist/pptx/dom/elements/table.d.ts.map +1 -1
- package/dist/pptx/dom/elements/text-shape.d.ts.map +1 -1
- package/dist/pptx/dom/elements/text-warp.d.ts.map +1 -1
- package/dist/pptx/dom/index.cjs +524 -446
- package/dist/pptx/dom/index.mjs +114 -37
- package/dist/pptx/export/html2canvas-clone.cjs +7 -6
- package/dist/pptx/export/html2canvas-clone.mjs +2 -1
- package/dist/pptx/index.cjs +3828 -3663
- package/dist/pptx/index.mjs +5 -4
- package/dist/pptx/render/chart-combo-stock.cjs +4 -3
- package/dist/pptx/render/chart-combo-stock.mjs +2 -1
- package/dist/pptx/render/chart-overlays.cjs +8 -7
- package/dist/pptx/render/chart-overlays.mjs +2 -1
- package/dist/pptx/render/chart-surface-treemap.cjs +5 -4
- package/dist/pptx/render/chart-surface-treemap.mjs +2 -1
- package/dist/pptx/render/chart-view-model.cjs +45 -44
- package/dist/pptx/render/chart-view-model.mjs +2 -1
- package/dist/pptx/render/chart-waterfall-map.cjs +7 -6
- package/dist/pptx/render/chart-waterfall-map.mjs +2 -1
- package/dist/pptx/render/connector-dash.d.ts +2 -1
- package/dist/pptx/render/connector-dash.d.ts.map +1 -1
- package/dist/pptx/render/connector-path.d.ts +1 -1
- package/dist/pptx/render/connector-path.d.ts.map +1 -1
- package/dist/pptx/render/connector-style.d.ts +4 -2
- package/dist/pptx/render/connector-style.d.ts.map +1 -1
- package/dist/pptx/render/dash-path-start.d.ts +38 -0
- package/dist/pptx/render/dash-path-start.d.ts.map +1 -0
- package/dist/pptx/render/dash-pattern.d.ts +61 -0
- package/dist/pptx/render/dash-pattern.d.ts.map +1 -0
- package/dist/pptx/render/device-pixel-exact.d.ts +34 -0
- package/dist/pptx/render/device-pixel-exact.d.ts.map +1 -0
- package/dist/pptx/render/device-pixel-group.d.ts +42 -0
- package/dist/pptx/render/device-pixel-group.d.ts.map +1 -0
- package/dist/pptx/render/device-pixel-stroke.d.ts +21 -3
- package/dist/pptx/render/device-pixel-stroke.d.ts.map +1 -1
- package/dist/pptx/render/element-style-transform.d.ts +6 -5
- package/dist/pptx/render/element-style-transform.d.ts.map +1 -1
- package/dist/pptx/render/embedded-fonts-sheet.d.ts +6 -0
- package/dist/pptx/render/embedded-fonts-sheet.d.ts.map +1 -1
- package/dist/pptx/render/equation-box-style.d.ts +23 -0
- package/dist/pptx/render/equation-box-style.d.ts.map +1 -0
- package/dist/pptx/render/fill-style.d.ts +16 -1
- package/dist/pptx/render/fill-style.d.ts.map +1 -1
- package/dist/pptx/render/font-line-gap.d.ts +0 -18
- package/dist/pptx/render/font-line-gap.d.ts.map +1 -1
- package/dist/pptx/render/gradient-svg-image.d.ts +20 -0
- package/dist/pptx/render/gradient-svg-image.d.ts.map +1 -0
- package/dist/pptx/render/group-fill.d.ts.map +1 -1
- package/dist/pptx/render/hollow-shape-hit-test.d.ts +23 -1
- package/dist/pptx/render/hollow-shape-hit-test.d.ts.map +1 -1
- package/dist/pptx/render/index.d.ts +11 -0
- package/dist/pptx/render/index.d.ts.map +1 -1
- package/dist/pptx/render/linked-text-box-overflow.d.ts +20 -5
- package/dist/pptx/render/linked-text-box-overflow.d.ts.map +1 -1
- package/dist/pptx/render/media-control-bar.d.ts +41 -0
- package/dist/pptx/render/media-control-bar.d.ts.map +1 -0
- package/dist/pptx/render/media-playback.d.ts +6 -6
- package/dist/pptx/render/media-playback.d.ts.map +1 -1
- package/dist/pptx/render/morph-animation.d.ts.map +1 -1
- package/dist/pptx/render/morph-carry.d.ts.map +1 -1
- package/dist/pptx/render/morph-connector-carry.d.ts +43 -0
- package/dist/pptx/render/morph-connector-carry.d.ts.map +1 -0
- package/dist/pptx/render/morph-effect-carry.d.ts +2 -0
- package/dist/pptx/render/morph-effect-carry.d.ts.map +1 -1
- package/dist/pptx/render/morph-effect-silhouette.d.ts +23 -0
- package/dist/pptx/render/morph-effect-silhouette.d.ts.map +1 -0
- package/dist/pptx/render/morph-geometry-key.d.ts.map +1 -1
- package/dist/pptx/render/morph-line-carry.d.ts +27 -0
- package/dist/pptx/render/morph-line-carry.d.ts.map +1 -1
- package/dist/pptx/render/morph-line-ends.d.ts +27 -0
- package/dist/pptx/render/morph-line-ends.d.ts.map +1 -0
- package/dist/pptx/render/morph-line-reach.d.ts +72 -0
- package/dist/pptx/render/morph-line-reach.d.ts.map +1 -0
- package/dist/pptx/render/morph-overlay-order.d.ts.map +1 -1
- package/dist/pptx/render/morph-plan-css.d.ts +0 -7
- package/dist/pptx/render/morph-plan-css.d.ts.map +1 -1
- package/dist/pptx/render/morph-predicates.d.ts.map +1 -1
- package/dist/pptx/render/morph-shape-carry.d.ts.map +1 -1
- package/dist/pptx/render/paragraph-baseline.d.ts +33 -0
- package/dist/pptx/render/paragraph-baseline.d.ts.map +1 -1
- package/dist/pptx/render/path-gradient-rect.d.ts +1 -1
- package/dist/pptx/render/path-gradient-rect.d.ts.map +1 -1
- package/dist/pptx/render/shape-geometry-base.d.ts +73 -0
- package/dist/pptx/render/shape-geometry-base.d.ts.map +1 -0
- package/dist/pptx/render/shape-geometry-cascade.d.ts +7 -37
- package/dist/pptx/render/shape-geometry-cascade.d.ts.map +1 -1
- package/dist/pptx/render/silhouette-effects.d.ts +118 -0
- package/dist/pptx/render/silhouette-effects.d.ts.map +1 -0
- package/dist/pptx/render/silhouette-fill-layer.d.ts +19 -0
- package/dist/pptx/render/silhouette-fill-layer.d.ts.map +1 -0
- package/dist/pptx/render/silhouette-morph-refresh.d.ts +6 -0
- package/dist/pptx/render/silhouette-morph-refresh.d.ts.map +1 -0
- package/dist/pptx/render/silhouette-morph-registry.d.ts +36 -0
- package/dist/pptx/render/silhouette-morph-registry.d.ts.map +1 -0
- package/dist/pptx/render/stroke-only-preset.d.ts +22 -0
- package/dist/pptx/render/stroke-only-preset.d.ts.map +1 -1
- package/dist/pptx/render/stroke-outline.d.ts.map +1 -1
- package/dist/pptx/render/subpath-fill-overlay.d.ts +11 -5
- package/dist/pptx/render/subpath-fill-overlay.d.ts.map +1 -1
- package/dist/pptx/render/subpath-geometry.d.ts +38 -0
- package/dist/pptx/render/subpath-geometry.d.ts.map +1 -0
- package/dist/pptx/render/svg-gradient-paint.d.ts.map +1 -1
- package/dist/pptx/render/svg-id-scope.d.ts +8 -0
- package/dist/pptx/render/svg-id-scope.d.ts.map +1 -0
- package/dist/pptx/render/table-cell-baseline.d.ts +36 -0
- package/dist/pptx/render/table-cell-baseline.d.ts.map +1 -0
- package/dist/pptx/render/table-cell-border-inset.d.ts +21 -0
- package/dist/pptx/render/table-cell-border-inset.d.ts.map +1 -0
- package/dist/pptx/render/table-cell-css.d.ts.map +1 -1
- package/dist/pptx/render/table-cell-paragraphs.d.ts +13 -1
- package/dist/pptx/render/table-cell-paragraphs.d.ts.map +1 -1
- package/dist/pptx/render/table-style-bg-settle.d.ts +43 -0
- package/dist/pptx/render/table-style-bg-settle.d.ts.map +1 -0
- package/dist/pptx/render/table-style-bg-span.d.ts +26 -0
- package/dist/pptx/render/table-style-bg-span.d.ts.map +1 -0
- package/dist/pptx/render/table-style-borders.d.ts.map +1 -1
- package/dist/pptx/render/table-style-builtins-data.d.ts +1 -1
- package/dist/pptx/render/table-style-builtins-data.d.ts.map +1 -1
- package/dist/pptx/render/table-style-fill.d.ts.map +1 -1
- package/dist/pptx/render/table-style-shadow.d.ts +20 -0
- package/dist/pptx/render/table-style-shadow.d.ts.map +1 -0
- package/dist/pptx/render/table-style-theme-refs.d.ts.map +1 -1
- package/dist/pptx/render/table-style.d.ts +9 -0
- package/dist/pptx/render/table-style.d.ts.map +1 -1
- package/dist/pptx/render/text-block-style.d.ts +5 -0
- package/dist/pptx/render/text-block-style.d.ts.map +1 -1
- package/dist/pptx/render/text-paragraphs.d.ts +11 -1
- package/dist/pptx/render/text-paragraphs.d.ts.map +1 -1
- package/dist/pptx/render/text-warp-arch.d.ts +25 -0
- package/dist/pptx/render/text-warp-arch.d.ts.map +1 -0
- package/dist/pptx/render/text-warp-closed-paths.d.ts +53 -0
- package/dist/pptx/render/text-warp-closed-paths.d.ts.map +1 -0
- package/dist/pptx/render/text-warp-envelope-curves.d.ts.map +1 -1
- package/dist/pptx/render/text-warp-envelope-map.d.ts +12 -0
- package/dist/pptx/render/text-warp-envelope-map.d.ts.map +1 -1
- package/dist/pptx/render/text-warp-glyph-outline.d.ts.map +1 -1
- package/dist/pptx/render/text-warp-polygon-clip.d.ts +21 -0
- package/dist/pptx/render/text-warp-polygon-clip.d.ts.map +1 -0
- package/dist/pptx/render/text-warp-preset-definitions-extra.d.ts +21 -0
- package/dist/pptx/render/text-warp-preset-definitions-extra.d.ts.map +1 -0
- package/dist/pptx/render/text-warp-preset-definitions.d.ts +19 -0
- package/dist/pptx/render/text-warp-preset-definitions.d.ts.map +1 -1
- package/dist/pptx/render/text-warp-preset-sampler.d.ts.map +1 -1
- package/dist/pptx/render/text-warp-run-paint.d.ts +19 -0
- package/dist/pptx/render/text-warp-run-paint.d.ts.map +1 -0
- package/dist/pptx/render/text-warp.d.ts.map +1 -1
- package/dist/pptx/render/visual-effects.d.ts +9 -0
- package/dist/pptx/render/visual-effects.d.ts.map +1 -1
- package/dist/pptx/{smartart-insert-preview-UP6DYY42.cjs → smartart-insert-preview-55QCEISC.cjs} +7 -6
- package/dist/pptx/{smartart-insert-preview-DXFDFDSC.mjs → smartart-insert-preview-GPBTE3HU.mjs} +6 -5
- package/dist/render-cache.d.ts +0 -1
- package/dist/ribbon/ribbon-group.d.ts +1 -2
- package/dist/ribbon/svg-preview.d.ts +0 -1
- package/dist/theme-bridge.d.ts +0 -1
- package/dist/theme.d.ts +0 -1
- package/package.json +2 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { screenBorderWidth, screenStrokeWidth, screenBorder, DEVICE_PX_VAR, snappedStrokeTransform } from './chunk-EDIAPF6J.mjs';
|
|
2
|
+
import { getSubstituteFonts, buildFontFamilyString, evaluateCustomGeometryPathData, getShapeClipPath, getAdjustmentAwareClipPath, getShapeClipPathFromPreset, getCloudPathForRendering, hasShapeProperties, evaluatePresetShape, getShapeType, getRoundRectRadiusPx, isImageLikeElement, ooxmlGradientAngleToCssDegrees, chartDataChangeType, isParetoChartData, resolveDisplayedChartTypeName, evaluateCustomGeometryPaths, customGeometryPathsToSvgSubpaths, parseDataUrlToBytes, sampleFirstPixelColorFromBytes, flattenChartUserShapes } from 'ooxml-core/pptx';
|
|
2
3
|
import { DEFAULT_CHART_PALETTE, computeAxisStackedValueRange, computeAxisValueRange, formatCompactAxisValue, automaticMarkerSymbol, markerOutline, getChartStylePalette, formatChartNumber, clusteredBarGeometry, tint, shade, hasManualLayoutFields, resolveManualLayoutRect, applyLabelManualLayout, resolveDataLabelFlags, composeDataLabelText, generateAxisTicks, generateMinorAxisTicks, computeStackedValueRangeForAxis, computeValueRangeForChart, computeValueRangeForAxis, groupRowsByCategory, boxWhiskerDistribution, computeHistogramBins as computeHistogramBins$1, aggregateByCategory, computeSunburstArcs as computeSunburstArcs$1, computeHierarchicalSunburstArcs as computeHierarchicalSunburstArcs$1, computeFunnelGeometry, resolveManualPlotRect, radarRingPoints, radarAngle, computeRadarPoints, buildWaterfallSteps, computeWaterfallRange, buildMarkerPrimitive as buildMarkerPrimitive$1, chartDataTableMetrics, resolveBlankDisplay, computeStackedSeriesPlots, visibleRuns, smoothLinePath, maxBubbleSize, medianBubbleRadius, computeBubbleRadius, resolveAutoTitleText, STOCK_DEFAULT_WICK_COLOR, stockCandle, STOCK_DEFAULT_UP_FILL, STOCK_DEFAULT_DOWN_FILL, STOCK_TICK_WIDTH, boxMeanMarkerPath, buildHierarchyRoots, layoutTreemap, hierarchyBranchLabels, placeBestFitLabel, nudgeOutsideLabels, impliesAutoTitle, buildChartGradientDef, chartErrorBarAmount, fitChartTrendline, chartLineDashArray, calendarTicks, formatDate, excelSerialToDate, sampleSmoothLine, polylineRunsPath } from 'ooxml-core/chart';
|
|
3
4
|
export { DEFAULT_BAR_GAP_WIDTH, DEFAULT_CHART_PALETTE, applyLabelManualLayout, computeBoxStats, computeBubbleRadius, computeLinearRegression, computeLogValueRange, computeRSquared, computeRadarPoints, computeStackedSeriesPlots, computeStackedValueRangeForAxis, computeValueRangeForAxis, computeValueRangeForChart, findLogAxis, fitPolynomial, generateAxisTicks, generateLogTicks, generateMinorAxisTicks, getChartStylePalette, hasManualLayoutFields, radarAngle, radarRingPoints, resolveManualLayoutRect, shade, tint, valueToYLog } from 'ooxml-core/chart';
|
|
4
|
-
import { colorWithOpacity, clampUnitInterval,
|
|
5
|
-
export { clampUnitInterval, colorWithOpacity, hexToRgbChannels, normalizeHexColor } from 'ooxml-core/color';
|
|
6
|
-
import { buildRectPathGradientImage } from 'ooxml-core/diagram';
|
|
7
|
-
export { buildRectPathGradientImage, buildRectPathGradientSvg } from 'ooxml-core/diagram';
|
|
5
|
+
import { colorWithOpacity, normalizeHexColor, hexToRgbUnit, clampUnitInterval as clampUnitInterval$1, officeGradientStops, officeTwoStopGradientStops, hexToRgbChannels as hexToRgbChannels$1 } from 'ooxml-core/color';
|
|
6
|
+
export { clampUnitInterval, colorWithOpacity, hexToRgbChannels, hexToRgbUnit, normalizeHexColor } from 'ooxml-core/color';
|
|
7
|
+
import { buildRectPathGradientImage, buildRectPathGradientExactSvg } from 'ooxml-core/diagram';
|
|
8
|
+
export { buildRectPathGradientExactSvg, buildRectPathGradientImage, buildRectPathGradientSvg } from 'ooxml-core/diagram';
|
|
8
9
|
import { regionMapGeometry, buildRegionMapEntries, resolveValueColorStops, buildValueColorScale, sequentialColorScale, regionViewBounds, normalizeValue, scalePathD, regionBounds, shouldRenderRegionLabel, resolveRegionCode } from 'ooxml-core/chart/region-map';
|
|
9
10
|
export { buildRegionMapEntries, formatRegionMapValue, normalizeValue, resolveRegionCode, resolveRegionEntityCode, sequentialColorScale, shouldRenderRegionLabel } from 'ooxml-core/chart/region-map';
|
|
10
11
|
|
|
11
|
-
// src/pptx/render/chart-font.ts
|
|
12
12
|
var CHART_PX_PER_PT = 4 / 3;
|
|
13
13
|
function chartFontPx(sizePt) {
|
|
14
14
|
return sizePt * CHART_PX_PER_PT;
|
|
@@ -153,6 +153,57 @@ function upsertDataPoint(dataPoints, point) {
|
|
|
153
153
|
return next;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
// src/pptx/render/dash-pattern.ts
|
|
157
|
+
var PRESET_PATTERNS = {
|
|
158
|
+
dash: [4, 3],
|
|
159
|
+
dot: [1, 3],
|
|
160
|
+
lgDash: [8, 3],
|
|
161
|
+
dashDot: [4, 3, 1, 3],
|
|
162
|
+
lgDashDot: [8, 3, 1, 3],
|
|
163
|
+
lgDashDotDot: [8, 3, 1, 3, 1, 3],
|
|
164
|
+
sysDash: [3, 1],
|
|
165
|
+
sysDot: [1, 1],
|
|
166
|
+
sysDashDot: [3, 1, 1, 1],
|
|
167
|
+
sysDashDotDot: [3, 1, 1, 1, 1, 1]
|
|
168
|
+
};
|
|
169
|
+
var CUSTOM_DASH_UNIT = 1e5;
|
|
170
|
+
var FALLBACK_CUSTOM_PATTERN = [3, 2];
|
|
171
|
+
function dashPenWidth(strokeWidth) {
|
|
172
|
+
if (!Number.isFinite(strokeWidth) || strokeWidth <= 1) return 1;
|
|
173
|
+
return Math.max(1, Math.ceil(strokeWidth - 0.5));
|
|
174
|
+
}
|
|
175
|
+
function dashPatternUnits(dashType, customSegments) {
|
|
176
|
+
if (!dashType || dashType === "solid") return void 0;
|
|
177
|
+
if (dashType === "custom") {
|
|
178
|
+
const pattern = (customSegments ?? []).flatMap((seg) => [
|
|
179
|
+
Math.max(0, seg.dash) / CUSTOM_DASH_UNIT,
|
|
180
|
+
Math.max(0, seg.space) / CUSTOM_DASH_UNIT
|
|
181
|
+
]);
|
|
182
|
+
return pattern.some((n) => n > 0) ? pattern : FALLBACK_CUSTOM_PATTERN;
|
|
183
|
+
}
|
|
184
|
+
return PRESET_PATTERNS[dashType];
|
|
185
|
+
}
|
|
186
|
+
function isDashedStroke(dashType) {
|
|
187
|
+
return dashType !== void 0 && dashType !== "solid" && dashType !== "";
|
|
188
|
+
}
|
|
189
|
+
function capCompensatedDashArray(pattern, strokeWidth, lineCap) {
|
|
190
|
+
const pen = dashPenWidth(strokeWidth);
|
|
191
|
+
const round = lineCap === "rnd";
|
|
192
|
+
const out = [];
|
|
193
|
+
for (let i = 0; i < pattern.length; i += 1) {
|
|
194
|
+
const len = (pattern[i] ?? 0) * pen;
|
|
195
|
+
if (!round) {
|
|
196
|
+
out.push(len);
|
|
197
|
+
} else if (i % 2 === 0) {
|
|
198
|
+
out.push(Math.max(0, len - pen));
|
|
199
|
+
} else {
|
|
200
|
+
const dash = (pattern[i - 1] ?? 0) * pen;
|
|
201
|
+
out.push(len + (dash - Math.max(0, dash - pen)));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return out.map((n) => Number(n.toFixed(4))).join(" ");
|
|
205
|
+
}
|
|
206
|
+
|
|
156
207
|
// src/pptx/constants.ts
|
|
157
208
|
var DEFAULT_CANVAS_WIDTH = 1280;
|
|
158
209
|
var DEFAULT_CANVAS_HEIGHT = 720;
|
|
@@ -165,15 +216,2430 @@ var DEFAULT_TEXT_FONT_SIZE = 24;
|
|
|
165
216
|
var DEFAULT_BODY_INSET_LR_PX = 91440 / 9525;
|
|
166
217
|
var DEFAULT_BODY_INSET_TB_PX = 45720 / 9525;
|
|
167
218
|
|
|
219
|
+
// src/pptx/render/chart-format/chart-area-outer-effects.ts
|
|
220
|
+
var PX_PER_PT = 96 / 72;
|
|
221
|
+
function chartAreaEffectStyle(data) {
|
|
222
|
+
const format = data?.elementFormats?.chartArea;
|
|
223
|
+
const effects = format && !format.reset ? format.effects : void 0;
|
|
224
|
+
if (!effects || !effects.shadow && !(effects.glow && effects.glow.radius > 0)) {
|
|
225
|
+
return void 0;
|
|
226
|
+
}
|
|
227
|
+
const fill = format?.fill?.kind ?? (data?.style?.chartAreaFill === "none" ? "none" : "automatic");
|
|
228
|
+
const line2 = format?.line?.kind ?? (data?.style?.chartAreaBorder ? "solid" : "automatic");
|
|
229
|
+
if (fill === "none" && line2 !== "solid" && line2 !== "gradient") {
|
|
230
|
+
return void 0;
|
|
231
|
+
}
|
|
232
|
+
const style = {};
|
|
233
|
+
if (effects.shadow) {
|
|
234
|
+
const s = effects.shadow;
|
|
235
|
+
style.shadowColor = s.color;
|
|
236
|
+
style.shadowOpacity = 1 - (s.transparency ?? 0) / 100;
|
|
237
|
+
style.shadowBlur = s.blur * PX_PER_PT;
|
|
238
|
+
style.shadowDistance = s.distance * PX_PER_PT;
|
|
239
|
+
style.shadowAngle = s.angle;
|
|
240
|
+
style.outerShadowXml = {};
|
|
241
|
+
}
|
|
242
|
+
if (effects.glow && effects.glow.radius > 0) {
|
|
243
|
+
style.glowColor = effects.glow.color;
|
|
244
|
+
style.glowRadius = effects.glow.radius * PX_PER_PT;
|
|
245
|
+
style.glowOpacity = 1 - (effects.glow.transparency ?? 0) / 100;
|
|
246
|
+
}
|
|
247
|
+
return style;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// src/pptx/render/effect-profile.ts
|
|
251
|
+
var SHADOW_BLUR_TO_CSS = 0.654;
|
|
252
|
+
var GLOW_GROW_FRACTION = 0.417;
|
|
253
|
+
var GLOW_SIGMA_FRACTION = 1 / 6;
|
|
254
|
+
function shadowBlurToCss(blurRadius) {
|
|
255
|
+
return Math.max(0, blurRadius) * SHADOW_BLUR_TO_CSS;
|
|
256
|
+
}
|
|
257
|
+
function glowCssLengths(radius) {
|
|
258
|
+
const r = Math.max(0, radius);
|
|
259
|
+
return { spread: r * GLOW_GROW_FRACTION, blur: r * GLOW_SIGMA_FRACTION * 2 };
|
|
260
|
+
}
|
|
261
|
+
var GLOW_FILTER_LAYERS = 3;
|
|
262
|
+
var GLOW_FILTER_BLUR_FRACTION = 0.38;
|
|
263
|
+
function glowFilterLengths(radius) {
|
|
264
|
+
const blur = Math.max(0, radius) * GLOW_FILTER_BLUR_FRACTION;
|
|
265
|
+
return Array.from({ length: GLOW_FILTER_LAYERS }, () => Math.round(blur * 100) / 100);
|
|
266
|
+
}
|
|
267
|
+
var TEXT_SHADOW_BLUR_TO_CSS = 0.72;
|
|
268
|
+
|
|
269
|
+
// src/pptx/render/reflection.ts
|
|
270
|
+
function clampUnit(value) {
|
|
271
|
+
return value < 0 ? 0 : value > 1 ? 1 : value;
|
|
272
|
+
}
|
|
273
|
+
var ALGN_TRANSFORM_ORIGIN = {
|
|
274
|
+
tl: "left top",
|
|
275
|
+
t: "center top",
|
|
276
|
+
tr: "right top",
|
|
277
|
+
l: "left top",
|
|
278
|
+
ctr: "center top",
|
|
279
|
+
r: "right top",
|
|
280
|
+
bl: "left bottom",
|
|
281
|
+
b: "center bottom",
|
|
282
|
+
br: "right bottom"
|
|
283
|
+
};
|
|
284
|
+
function buildReflectionMaskGradient(cssAngleDeg, startOpacity, endOpacity, fadeLength, blurRadius, holdPx) {
|
|
285
|
+
const effectiveFadeLength = fadeLength + blurRadius * 2;
|
|
286
|
+
const midOpacity = (startOpacity + endOpacity) / 2;
|
|
287
|
+
const midPoint = Math.round(effectiveFadeLength * 0.5);
|
|
288
|
+
const holdStop = holdPx > 0 ? `, rgba(0,0,0,${startOpacity}) ${holdPx}px` : "";
|
|
289
|
+
if (blurRadius > 0) {
|
|
290
|
+
return `linear-gradient(${cssAngleDeg}deg, rgba(0,0,0,${startOpacity}) 0px${holdStop}, rgba(0,0,0,${midOpacity}) ${midPoint}px, rgba(0,0,0,${endOpacity}) ${effectiveFadeLength}px)`;
|
|
291
|
+
}
|
|
292
|
+
return `linear-gradient(${cssAngleDeg}deg, rgba(0,0,0,${startOpacity}) 0px${holdStop}, rgba(0,0,0,${endOpacity}) ${fadeLength}px)`;
|
|
293
|
+
}
|
|
294
|
+
function getReflectionWrapperStyle(style, elementHeight) {
|
|
295
|
+
if (!style) {
|
|
296
|
+
return void 0;
|
|
297
|
+
}
|
|
298
|
+
const hasReflection = typeof style.reflectionStartOpacity === "number" && style.reflectionStartOpacity > 0 || typeof style.reflectionDistance === "number" && style.reflectionDistance > 0 || typeof style.reflectionBlurRadius === "number" && style.reflectionBlurRadius > 0;
|
|
299
|
+
if (!hasReflection) {
|
|
300
|
+
return void 0;
|
|
301
|
+
}
|
|
302
|
+
const distance = style.reflectionDistance ?? 0;
|
|
303
|
+
const startOpacity = clampUnit(
|
|
304
|
+
typeof style.reflectionStartOpacity === "number" ? style.reflectionStartOpacity : 0.5
|
|
305
|
+
);
|
|
306
|
+
const endOpacity = clampUnit(
|
|
307
|
+
typeof style.reflectionEndOpacity === "number" ? style.reflectionEndOpacity : 0
|
|
308
|
+
);
|
|
309
|
+
const fadeLength = typeof style.reflectionEndPosition === "number" ? Math.round(style.reflectionEndPosition * Math.max(elementHeight, 1)) : 100;
|
|
310
|
+
const blurRadius = typeof style.reflectionBlurRadius === "number" ? Math.max(0, style.reflectionBlurRadius) : 0;
|
|
311
|
+
const holdPx = typeof style.reflectionStartPosition === "number" && style.reflectionStartPosition > 0 ? Math.round(Math.min(clampUnit(style.reflectionStartPosition) * fadeLength, fadeLength - 1)) : 0;
|
|
312
|
+
const fadeDirectionDeg = style.reflectionFadeDirection ?? 90;
|
|
313
|
+
const cssAngleDeg = ((fadeDirectionDeg + 90) % 360 + 360) % 360;
|
|
314
|
+
const scaleX = (style.reflectionScaleX ?? 1e5) / 1e5;
|
|
315
|
+
const scaleY = (style.reflectionScaleY ?? -1e5) / 1e5;
|
|
316
|
+
const skewX = (style.reflectionSkewX ?? 0) / 6e4;
|
|
317
|
+
const skewY = (style.reflectionSkewY ?? 0) / 6e4;
|
|
318
|
+
const rotation = (style.reflectionRotation ?? 0) / 6e4;
|
|
319
|
+
const transformParts = [`scale(${scaleX}, ${scaleY})`];
|
|
320
|
+
if (skewX !== 0 || skewY !== 0) {
|
|
321
|
+
transformParts.push(`skew(${skewX}deg, ${skewY}deg)`);
|
|
322
|
+
}
|
|
323
|
+
if (rotation !== 0) {
|
|
324
|
+
transformParts.push(`rotate(${rotation}deg)`);
|
|
325
|
+
}
|
|
326
|
+
const maskImage = buildReflectionMaskGradient(
|
|
327
|
+
cssAngleDeg,
|
|
328
|
+
startOpacity,
|
|
329
|
+
endOpacity,
|
|
330
|
+
fadeLength,
|
|
331
|
+
blurRadius,
|
|
332
|
+
holdPx
|
|
333
|
+
);
|
|
334
|
+
return {
|
|
335
|
+
position: "absolute",
|
|
336
|
+
left: "0",
|
|
337
|
+
top: `calc(100% + ${Math.round(distance)}px)`,
|
|
338
|
+
width: "100%",
|
|
339
|
+
height: "100%",
|
|
340
|
+
transform: transformParts.join(" "),
|
|
341
|
+
transformOrigin: ALGN_TRANSFORM_ORIGIN[style.reflectionAlignment ?? "ctr"] ?? "center top",
|
|
342
|
+
maskImage,
|
|
343
|
+
WebkitMaskImage: maskImage,
|
|
344
|
+
pointerEvents: "none"
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function getTextReflectionWrapperStyle(style, elementHeight) {
|
|
348
|
+
if (!style?.textReflection) {
|
|
349
|
+
return void 0;
|
|
350
|
+
}
|
|
351
|
+
return getReflectionWrapperStyle(
|
|
352
|
+
{
|
|
353
|
+
reflectionStartOpacity: style.textReflectionStartOpacity ?? 0.5,
|
|
354
|
+
reflectionEndOpacity: style.textReflectionEndOpacity ?? 0,
|
|
355
|
+
reflectionDistance: style.textReflectionOffset ?? 0,
|
|
356
|
+
reflectionBlurRadius: style.textReflectionBlur ?? 0,
|
|
357
|
+
reflectionFadeDirection: style.textReflectionFadeDirection,
|
|
358
|
+
reflectionScaleX: style.textReflectionScaleX,
|
|
359
|
+
reflectionScaleY: style.textReflectionScaleY,
|
|
360
|
+
reflectionSkewX: style.textReflectionSkewX,
|
|
361
|
+
reflectionSkewY: style.textReflectionSkewY,
|
|
362
|
+
reflectionRotation: style.textReflectionRotation,
|
|
363
|
+
reflectionAlignment: style.textReflectionAlignment
|
|
364
|
+
},
|
|
365
|
+
elementHeight
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
function resolveLiveCustomGeometryPath(element) {
|
|
369
|
+
const el = element;
|
|
370
|
+
if (!el.pathData || !el.pathWidth || !el.pathHeight) {
|
|
371
|
+
return void 0;
|
|
372
|
+
}
|
|
373
|
+
const overrides = el.shapeAdjustments;
|
|
374
|
+
if (overrides && Object.keys(overrides).length > 0 && el.customGeometryRawData) {
|
|
375
|
+
const live = evaluateCustomGeometryPathData(
|
|
376
|
+
el.customGeometryRawData,
|
|
377
|
+
el.pathWidth,
|
|
378
|
+
el.pathHeight,
|
|
379
|
+
overrides
|
|
380
|
+
);
|
|
381
|
+
if (live) {
|
|
382
|
+
return live;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return { pathData: el.pathData, pathWidth: el.pathWidth, pathHeight: el.pathHeight };
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// src/pptx/render/shape-geometry.ts
|
|
389
|
+
function getResolvedShapeClipPathFor(shapeType, width, height, adjustments) {
|
|
390
|
+
if (!shapeType) {
|
|
391
|
+
return void 0;
|
|
392
|
+
}
|
|
393
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
|
|
394
|
+
return getShapeClipPath(shapeType);
|
|
395
|
+
}
|
|
396
|
+
if (adjustments && Object.keys(adjustments).length > 0) {
|
|
397
|
+
const adjusted = getAdjustmentAwareClipPath(shapeType, width, height, adjustments);
|
|
398
|
+
if (adjusted !== void 0) {
|
|
399
|
+
return adjusted;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
const fromPreset = getShapeClipPathFromPreset(shapeType, width, height, adjustments);
|
|
403
|
+
if (fromPreset !== void 0) {
|
|
404
|
+
return fromPreset;
|
|
405
|
+
}
|
|
406
|
+
const cloud = getCloudPathForRendering(shapeType, width, height);
|
|
407
|
+
if (cloud !== void 0) {
|
|
408
|
+
return cloud;
|
|
409
|
+
}
|
|
410
|
+
return getShapeClipPath(shapeType);
|
|
411
|
+
}
|
|
412
|
+
function buildCustomGeometryClipPath(pathData, pathWidth, pathHeight, elemWidth, elemHeight) {
|
|
413
|
+
if (!pathData || !Number.isFinite(pathWidth) || !Number.isFinite(pathHeight) || pathWidth <= 0 || pathHeight <= 0 || !Number.isFinite(elemWidth) || !Number.isFinite(elemHeight) || elemWidth <= 0 || elemHeight <= 0) {
|
|
414
|
+
return void 0;
|
|
415
|
+
}
|
|
416
|
+
const sx = elemWidth / pathWidth;
|
|
417
|
+
const sy = elemHeight / pathHeight;
|
|
418
|
+
const round = (n) => {
|
|
419
|
+
const r = Math.round(n * 100) / 100;
|
|
420
|
+
return Object.is(r, -0) ? "0" : String(r);
|
|
421
|
+
};
|
|
422
|
+
const tokens = pathData.match(/[MLCQZAHVmlcqzahv][^MLCQZAHVmlcqzahv]*/g) ?? [];
|
|
423
|
+
const out = [];
|
|
424
|
+
for (const token of tokens) {
|
|
425
|
+
const cmd = token[0];
|
|
426
|
+
const upper = cmd.toUpperCase();
|
|
427
|
+
if (upper === "Z") {
|
|
428
|
+
out.push("Z");
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
const nums = (token.slice(1).match(/-?[\d.]+(?:e-?\d+)?/gi) ?? []).map(Number);
|
|
432
|
+
if (upper === "A") {
|
|
433
|
+
const parts = [];
|
|
434
|
+
for (let i = 0; i + 6 < nums.length; i += 7) {
|
|
435
|
+
parts.push(
|
|
436
|
+
round(nums[i] * sx),
|
|
437
|
+
round(nums[i + 1] * sy),
|
|
438
|
+
String(nums[i + 2]),
|
|
439
|
+
String(nums[i + 3]),
|
|
440
|
+
String(nums[i + 4]),
|
|
441
|
+
round(nums[i + 5] * sx),
|
|
442
|
+
round(nums[i + 6] * sy)
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
out.push(`A ${parts.join(" ")}`);
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
const scaled = nums.map((n, i) => round(n * (i % 2 === 0 ? sx : sy)));
|
|
449
|
+
out.push(`${upper} ${scaled.join(" ")}`);
|
|
450
|
+
}
|
|
451
|
+
if (out.length === 0) {
|
|
452
|
+
return void 0;
|
|
453
|
+
}
|
|
454
|
+
return `path('${out.join(" ")}')`;
|
|
455
|
+
}
|
|
456
|
+
function getResolvedShapeClipPath(element, width, height) {
|
|
457
|
+
const w = typeof width === "number" ? width : element.width;
|
|
458
|
+
const h = typeof height === "number" ? height : element.height;
|
|
459
|
+
const live = resolveLiveCustomGeometryPath(element);
|
|
460
|
+
if (live) {
|
|
461
|
+
const customClip = buildCustomGeometryClipPath(
|
|
462
|
+
live.pathData,
|
|
463
|
+
live.pathWidth,
|
|
464
|
+
live.pathHeight,
|
|
465
|
+
w,
|
|
466
|
+
h
|
|
467
|
+
);
|
|
468
|
+
if (customClip) {
|
|
469
|
+
return customClip;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const shapeType = element.shapeType;
|
|
473
|
+
if (!shapeType) {
|
|
474
|
+
return void 0;
|
|
475
|
+
}
|
|
476
|
+
const adjustments = element.shapeAdjustments;
|
|
477
|
+
return getResolvedShapeClipPathFor(shapeType, w, h, adjustments);
|
|
478
|
+
}
|
|
479
|
+
var IDENTITY_RECT_PRESETS = /* @__PURE__ */ new Set(["rect", "flowchartprocess"]);
|
|
480
|
+
function isIdentityRectClip(element) {
|
|
481
|
+
const custom = element;
|
|
482
|
+
if (custom.pathData && custom.pathWidth && custom.pathHeight) {
|
|
483
|
+
return false;
|
|
484
|
+
}
|
|
485
|
+
const shapeType = element.shapeType;
|
|
486
|
+
return shapeType !== void 0 && IDENTITY_RECT_PRESETS.has(shapeType.toLowerCase());
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// src/pptx/render/connector-style.ts
|
|
490
|
+
var COMPOUND_BANDS = {
|
|
491
|
+
dbl: [1 / 3, 1 / 3, 1 / 3],
|
|
492
|
+
thickThin: [0.6, 0.2, 0.2],
|
|
493
|
+
thinThick: [0.2, 0.2, 0.6],
|
|
494
|
+
tri: [1 / 6, 1 / 6, 1 / 3, 1 / 6, 1 / 6]
|
|
495
|
+
};
|
|
496
|
+
function compoundStrands(compoundLine) {
|
|
497
|
+
const bands = compoundLine ? COMPOUND_BANDS[compoundLine] : void 0;
|
|
498
|
+
if (!bands) {
|
|
499
|
+
return void 0;
|
|
500
|
+
}
|
|
501
|
+
const strands = [];
|
|
502
|
+
let edge = -0.5;
|
|
503
|
+
bands.forEach((band2, index) => {
|
|
504
|
+
if (index % 2 === 0) {
|
|
505
|
+
strands.push([edge + band2 / 2, band2]);
|
|
506
|
+
}
|
|
507
|
+
edge += band2;
|
|
508
|
+
});
|
|
509
|
+
return strands;
|
|
510
|
+
}
|
|
511
|
+
function getCompoundLineOffsets(compoundLine, strokeWidth) {
|
|
512
|
+
const base = Math.max(strokeWidth, 1);
|
|
513
|
+
const exact = (value) => Math.round(value * 1e6) / 1e6 + 0;
|
|
514
|
+
return compoundStrands(compoundLine)?.map(([offset]) => exact(offset * base)) ?? [0];
|
|
515
|
+
}
|
|
516
|
+
function getCompoundLineWidths(compoundLine, strokeWidth) {
|
|
517
|
+
const base = Math.max(strokeWidth, 1);
|
|
518
|
+
return compoundStrands(compoundLine)?.map(([, width]) => width * base) ?? [base];
|
|
519
|
+
}
|
|
520
|
+
function connectorStrandScreenWidth(widths, strokeWidth, idx) {
|
|
521
|
+
return widths.length > 1 ? screenBorderWidth(widths[idx] ?? strokeWidth) : screenStrokeWidth(strokeWidth, 1);
|
|
522
|
+
}
|
|
523
|
+
function svgLineCap(lineCap, dashed = false) {
|
|
524
|
+
switch (lineCap) {
|
|
525
|
+
case "flat":
|
|
526
|
+
return "butt";
|
|
527
|
+
case "sq":
|
|
528
|
+
return dashed ? "butt" : "square";
|
|
529
|
+
case "rnd":
|
|
530
|
+
return "round";
|
|
531
|
+
default:
|
|
532
|
+
return "butt";
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
function connectorKind(shapeType) {
|
|
536
|
+
const t = (shapeType ?? "").toLowerCase();
|
|
537
|
+
if (t.includes("bentconnector")) {
|
|
538
|
+
return "bent";
|
|
539
|
+
}
|
|
540
|
+
if (t.includes("curvedconnector")) {
|
|
541
|
+
return "curved";
|
|
542
|
+
}
|
|
543
|
+
return "straight";
|
|
544
|
+
}
|
|
545
|
+
function connectorNeedsPath(shapeType) {
|
|
546
|
+
return connectorKind(shapeType) !== "straight";
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// src/pptx/render/device-pixel-exact.ts
|
|
550
|
+
var EMU_PER_PX = 9525;
|
|
551
|
+
var EMU_PER_MASTER_UNIT = 1587.5;
|
|
552
|
+
var MASTER_UNITS_PER_PX = EMU_PER_PX / EMU_PER_MASTER_UNIT;
|
|
553
|
+
function exactPx(model, emu) {
|
|
554
|
+
if (typeof emu !== "number" || !Number.isFinite(emu)) {
|
|
555
|
+
return model;
|
|
556
|
+
}
|
|
557
|
+
return Math.round(emu / EMU_PER_PX) === Math.round(model) ? Math.round(emu / EMU_PER_MASTER_UNIT) / MASTER_UNITS_PER_PX : model;
|
|
558
|
+
}
|
|
559
|
+
function exactDeviceBox(element) {
|
|
560
|
+
return {
|
|
561
|
+
x: exactPx(element.x, element.xEmu),
|
|
562
|
+
y: exactPx(element.y, element.yEmu),
|
|
563
|
+
width: exactPx(element.width, element.widthEmu),
|
|
564
|
+
height: exactPx(element.height, element.heightEmu)
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// src/pptx/render/device-pixel-group.ts
|
|
569
|
+
var parents = /* @__PURE__ */ new WeakMap();
|
|
570
|
+
function registerGroupChildren(group) {
|
|
571
|
+
if (group.type !== "group") {
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
for (const child of group.children) {
|
|
575
|
+
parents.set(child, group);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
var EMU_PER_PX2 = 9525;
|
|
579
|
+
function exactOrigin(group) {
|
|
580
|
+
const emuX = group.xEmu;
|
|
581
|
+
const emuY = group.yEmu;
|
|
582
|
+
return {
|
|
583
|
+
x: typeof emuX === "number" && Math.round(emuX / EMU_PER_PX2) === Math.round(group.x) ? emuX / EMU_PER_PX2 : group.x,
|
|
584
|
+
y: typeof emuY === "number" && Math.round(emuY / EMU_PER_PX2) === Math.round(group.y) ? emuY / EMU_PER_PX2 : group.y
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
function snapPlacement(element) {
|
|
588
|
+
const own = exactDeviceBox(element);
|
|
589
|
+
let group = parents.get(element);
|
|
590
|
+
if (!group) {
|
|
591
|
+
return { x: element.x, y: element.y, exact: own };
|
|
592
|
+
}
|
|
593
|
+
let shownX = 0;
|
|
594
|
+
let shownY = 0;
|
|
595
|
+
let trueX = 0;
|
|
596
|
+
let trueY = 0;
|
|
597
|
+
for (let depth = 0; group && depth < 64; depth++) {
|
|
598
|
+
if (group.rotation || group.flipHorizontal || group.flipVertical) {
|
|
599
|
+
return void 0;
|
|
600
|
+
}
|
|
601
|
+
const origin = exactOrigin(group);
|
|
602
|
+
shownX += group.x;
|
|
603
|
+
shownY += group.y;
|
|
604
|
+
trueX += origin.x;
|
|
605
|
+
trueY += origin.y;
|
|
606
|
+
group = parents.get(group);
|
|
607
|
+
}
|
|
608
|
+
return {
|
|
609
|
+
// Chromium snaps an inline `<svg>` root (every stroke overlay and connector)
|
|
610
|
+
// to a whole stage pixel, so that is where the painted stroke really starts.
|
|
611
|
+
x: Math.round(shownX + element.x),
|
|
612
|
+
y: Math.round(shownY + element.y),
|
|
613
|
+
exact: {
|
|
614
|
+
x: trueX + element.x,
|
|
615
|
+
y: trueY + element.y,
|
|
616
|
+
width: element.width,
|
|
617
|
+
height: element.height
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// src/pptx/render/connector-markers.ts
|
|
623
|
+
var ARROW_MARKER_SIZE = { sm: 2, med: 3, lg: 5 };
|
|
624
|
+
function markerPath(type, arrowWidth, arrowLength) {
|
|
625
|
+
const markerWidth = ARROW_MARKER_SIZE[arrowLength ?? "med"] ?? 3;
|
|
626
|
+
const markerHeight = ARROW_MARKER_SIZE[arrowWidth ?? "med"] ?? 3;
|
|
627
|
+
const box = { markerWidth, markerHeight, refX: 10 };
|
|
628
|
+
switch (type) {
|
|
629
|
+
case "diamond":
|
|
630
|
+
return { shape: "path", d: "M5 0 L10 5 L5 10 L0 5 Z", ...box, refX: 5 };
|
|
631
|
+
case "oval":
|
|
632
|
+
return { shape: "circle", ...box, refX: 5 };
|
|
633
|
+
case "stealth":
|
|
634
|
+
return { shape: "path", d: "M0 0 L10 5 L0 10 L3 5 Z", ...box };
|
|
635
|
+
case "arrow":
|
|
636
|
+
return { shape: "path", d: "M1 1 L9 5 L1 9", strokeOnly: true, ...box, refX: 9 };
|
|
637
|
+
// triangle / fallback
|
|
638
|
+
default:
|
|
639
|
+
return { shape: "path", d: "M0 0 L10 5 L0 10 Z", ...box };
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
function normalizeArrow(a) {
|
|
643
|
+
return a && a !== "none" ? a : void 0;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// src/pptx/render/stroke-paint.ts
|
|
647
|
+
function hasStrokePaint(style) {
|
|
648
|
+
if (!style || Math.max(0, style.strokeWidth ?? 0) <= 0) {
|
|
649
|
+
return false;
|
|
650
|
+
}
|
|
651
|
+
return style.strokeColor !== void 0 || style.strokeFillMode !== void 0;
|
|
652
|
+
}
|
|
653
|
+
function paintedStrokeWidth(style) {
|
|
654
|
+
return hasStrokePaint(style) ? Math.max(0, style?.strokeWidth ?? 0) : 0;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// src/pptx/render/custom-path-markers.ts
|
|
658
|
+
function isArrowedCustomPath(element) {
|
|
659
|
+
if (element.type !== "shape" || !element.pathData || !element.pathWidth || !element.pathHeight) {
|
|
660
|
+
return false;
|
|
661
|
+
}
|
|
662
|
+
const style = element.shapeStyle;
|
|
663
|
+
if (!hasStrokePaint(style) || (style?.strokeWidth ?? 0) <= 0) return false;
|
|
664
|
+
return !/[zZ]/u.test(element.pathData) && (style?.fillMode === "none" || style?.fillColor === "transparent") && Boolean(normalizeArrow(style?.connectorStartArrow) || normalizeArrow(style?.connectorEndArrow));
|
|
665
|
+
}
|
|
666
|
+
function buildCustomPathMarkers(element, stroke) {
|
|
667
|
+
if (!isArrowedCustomPath(element) || !hasShapeProperties(element)) return void 0;
|
|
668
|
+
const style = element.shapeStyle ?? {};
|
|
669
|
+
const seed = [...element.id].map((char) => char.codePointAt(0).toString(16)).join("-");
|
|
670
|
+
const markup = [];
|
|
671
|
+
const add = (end2) => {
|
|
672
|
+
const arrow = normalizeArrow(style[`connector${end2}Arrow`]);
|
|
673
|
+
if (!arrow) return void 0;
|
|
674
|
+
const shape = markerPath(
|
|
675
|
+
arrow,
|
|
676
|
+
style[`connector${end2}ArrowWidth`],
|
|
677
|
+
style[`connector${end2}ArrowLength`]
|
|
678
|
+
);
|
|
679
|
+
const id = `freeform-${seed}-${end2}`;
|
|
680
|
+
const color = escapeSvgAttr(stroke);
|
|
681
|
+
const body = shape.shape === "circle" ? `<circle cx="5" cy="5" r="4" fill="${color}"/>` : `<path d="${escapeSvgAttr(shape.d ?? "")}" fill="${shape.strokeOnly ? "none" : color}"${shape.strokeOnly ? ` stroke="${color}"` : ""}/>`;
|
|
682
|
+
markup.push(
|
|
683
|
+
`<marker id="${id}" viewBox="0 0 10 10" refX="${shape.refX}" refY="5" markerWidth="${shape.markerWidth}" markerHeight="${shape.markerHeight}" markerUnits="strokeWidth" orient="auto-start-reverse" preserveAspectRatio="none">${body}</marker>`
|
|
684
|
+
);
|
|
685
|
+
return `url(#${id})`;
|
|
686
|
+
};
|
|
687
|
+
const start = add("Start");
|
|
688
|
+
const end = add("End");
|
|
689
|
+
return { markup: markup.join(""), start, end };
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// src/pptx/render/dash-path-start.ts
|
|
693
|
+
var ARGS_PER_COMMAND = { M: 2, L: 2, C: 6, Q: 4, A: 7 };
|
|
694
|
+
var COUNTER_CLOCKWISE_PRESETS = /* @__PURE__ */ new Set(["ellipse", "oval", "flowchartconnector"]);
|
|
695
|
+
function parseFigure(d) {
|
|
696
|
+
const tokens = d.match(/[A-Za-z]|-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/giu);
|
|
697
|
+
if (!tokens) return void 0;
|
|
698
|
+
let start;
|
|
699
|
+
const segments = [];
|
|
700
|
+
let closed = false;
|
|
701
|
+
let cmd = "";
|
|
702
|
+
let i = 0;
|
|
703
|
+
while (i < tokens.length) {
|
|
704
|
+
const token = tokens[i];
|
|
705
|
+
if (/^[A-Za-z]$/u.test(token)) {
|
|
706
|
+
cmd = token;
|
|
707
|
+
i += 1;
|
|
708
|
+
if (cmd === "Z") {
|
|
709
|
+
closed = true;
|
|
710
|
+
if (i < tokens.length) return void 0;
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
const count = ARGS_PER_COMMAND[cmd];
|
|
715
|
+
if (count === void 0 || closed) return void 0;
|
|
716
|
+
const args = tokens.slice(i, i + count).map(Number);
|
|
717
|
+
i += count;
|
|
718
|
+
if (args.length < count || args.some((n) => !Number.isFinite(n))) return void 0;
|
|
719
|
+
const end = [args[count - 2], args[count - 1]];
|
|
720
|
+
if (cmd === "M") {
|
|
721
|
+
if (start) return void 0;
|
|
722
|
+
start = end;
|
|
723
|
+
} else {
|
|
724
|
+
if (!start) return void 0;
|
|
725
|
+
segments.push({ cmd, args, end });
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return start && closed && segments.length > 0 ? { start, segments, closed } : void 0;
|
|
729
|
+
}
|
|
730
|
+
var num = (n) => String(Number(n.toFixed(5)));
|
|
731
|
+
function writeSegment(segment) {
|
|
732
|
+
return `${segment.cmd} ${segment.args.map(num).join(" ")}`;
|
|
733
|
+
}
|
|
734
|
+
function reverseSegments(figure) {
|
|
735
|
+
const points = [figure.start, ...figure.segments.map((s) => s.end)];
|
|
736
|
+
const out = [];
|
|
737
|
+
for (let i = figure.segments.length - 1; i >= 0; i -= 1) {
|
|
738
|
+
const segment = figure.segments[i];
|
|
739
|
+
const to = points[i];
|
|
740
|
+
const a = segment.args;
|
|
741
|
+
if (segment.cmd === "L") {
|
|
742
|
+
out.push(`L ${num(to[0])} ${num(to[1])}`);
|
|
743
|
+
} else if (segment.cmd === "C") {
|
|
744
|
+
const c = a;
|
|
745
|
+
out.push(`C ${[c[2], c[3], c[0], c[1], to[0], to[1]].map(num).join(" ")}`);
|
|
746
|
+
} else if (segment.cmd === "Q") {
|
|
747
|
+
out.push(`Q ${[a[0], a[1], to[0], to[1]].map((n) => num(n)).join(" ")}`);
|
|
748
|
+
} else {
|
|
749
|
+
const sweep = a[4] === 0 ? 1 : 0;
|
|
750
|
+
out.push(
|
|
751
|
+
`A ${[a[0], a[1], a[2], a[3], sweep, to[0], to[1]].map((n) => num(n)).join(" ")}`
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
return out;
|
|
756
|
+
}
|
|
757
|
+
function dashStartPathData(d, shapeType) {
|
|
758
|
+
const figure = parseFigure(d);
|
|
759
|
+
if (!figure) return d;
|
|
760
|
+
const lastEnd = figure.segments[figure.segments.length - 1].end;
|
|
761
|
+
const selfClosing = Math.abs(lastEnd[0] - figure.start[0]) < 1e-3 && Math.abs(lastEnd[1] - figure.start[1]) < 1e-3;
|
|
762
|
+
if (selfClosing) {
|
|
763
|
+
if (!COUNTER_CLOCKWISE_PRESETS.has((shapeType ?? "").toLowerCase())) return d;
|
|
764
|
+
return `M ${num(figure.start[0])} ${num(figure.start[1])} ${reverseSegments(figure).join(" ")} Z`;
|
|
765
|
+
}
|
|
766
|
+
return [
|
|
767
|
+
`M ${num(lastEnd[0])} ${num(lastEnd[1])}`,
|
|
768
|
+
`L ${num(figure.start[0])} ${num(figure.start[1])}`,
|
|
769
|
+
...figure.segments.map(writeSegment),
|
|
770
|
+
"Z"
|
|
771
|
+
].join(" ");
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
// src/pptx/render/stroke-clip-edge.ts
|
|
775
|
+
var ROUND_JOIN_STEPS = 8;
|
|
776
|
+
var fmt = (n) => String(Math.round(n * 1e3) / 1e3);
|
|
777
|
+
function signedArea(pts) {
|
|
778
|
+
let area = 0;
|
|
779
|
+
for (let k = 0; k < pts.length; k++) {
|
|
780
|
+
const a = pts[k];
|
|
781
|
+
const b = pts[(k + 1) % pts.length];
|
|
782
|
+
area += a[0] * b[1] - b[0] * a[1];
|
|
783
|
+
}
|
|
784
|
+
return area;
|
|
785
|
+
}
|
|
786
|
+
function offsetRing(pts, half, join, away) {
|
|
787
|
+
let last = [0, 0];
|
|
788
|
+
const normals = pts.map((a, k) => {
|
|
789
|
+
const b = pts[(k + 1) % pts.length];
|
|
790
|
+
const len = Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
791
|
+
if (len >= 1e-6) {
|
|
792
|
+
last = [away * -(b[1] - a[1]) / len, away * (b[0] - a[0]) / len];
|
|
793
|
+
}
|
|
794
|
+
return last;
|
|
795
|
+
});
|
|
796
|
+
const ring = [];
|
|
797
|
+
for (let k = 0; k < pts.length; k++) {
|
|
798
|
+
const v = pts[k];
|
|
799
|
+
const n1 = normals[(k - 1 + pts.length) % pts.length];
|
|
800
|
+
const n2 = normals[k];
|
|
801
|
+
const p1 = [v[0] + n1[0] * half, v[1] + n1[1] * half];
|
|
802
|
+
const p2 = [v[0] + n2[0] * half, v[1] + n2[1] * half];
|
|
803
|
+
const cosHalf = Math.sqrt(Math.max(0, (1 + n1[0] * n2[0] + n1[1] * n2[1]) / 2));
|
|
804
|
+
const bx = n1[0] + n2[0];
|
|
805
|
+
const by = n1[1] + n2[1];
|
|
806
|
+
const blen = Math.hypot(bx, by);
|
|
807
|
+
const miter = cosHalf > 1e-6 && blen > 1e-9 ? [v[0] + bx / blen * (half / cosHalf), v[1] + by / blen * (half / cosHalf)] : void 0;
|
|
808
|
+
const turn = n1[0] * n2[1] - n1[1] * n2[0];
|
|
809
|
+
const opensOutward = away * turn < 0;
|
|
810
|
+
if (!opensOutward || Math.abs(turn) < 1e-9) {
|
|
811
|
+
ring.push(miter ?? p2);
|
|
812
|
+
} else if (join.join === "miter" && miter && 1 / cosHalf <= join.miterLimit) {
|
|
813
|
+
ring.push(miter);
|
|
814
|
+
} else if (join.join === "round") {
|
|
815
|
+
const a1 = Math.atan2(n1[1], n1[0]);
|
|
816
|
+
let sweep = Math.atan2(n2[1], n2[0]) - a1;
|
|
817
|
+
while (sweep > Math.PI) sweep -= 2 * Math.PI;
|
|
818
|
+
while (sweep < -Math.PI) sweep += 2 * Math.PI;
|
|
819
|
+
for (let i = 0; i <= ROUND_JOIN_STEPS; i++) {
|
|
820
|
+
const t = a1 + sweep * i / ROUND_JOIN_STEPS;
|
|
821
|
+
ring.push([v[0] + Math.cos(t) * half, v[1] + Math.sin(t) * half]);
|
|
822
|
+
}
|
|
823
|
+
} else {
|
|
824
|
+
ring.push(p1, p2);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
return ring;
|
|
828
|
+
}
|
|
829
|
+
function outerStrokeEdgePath(d, strokeWidth, join) {
|
|
830
|
+
if (!(strokeWidth > 0)) {
|
|
831
|
+
return void 0;
|
|
832
|
+
}
|
|
833
|
+
const subpaths = flattenPath(d);
|
|
834
|
+
if (!subpaths || subpaths.length === 0) {
|
|
835
|
+
return void 0;
|
|
836
|
+
}
|
|
837
|
+
const reference = Math.sign(signedArea(subpaths[0])) || 1;
|
|
838
|
+
return subpaths.filter((sub) => sub.length > 2).map((sub) => {
|
|
839
|
+
const sign = Math.sign(signedArea(sub)) || reference;
|
|
840
|
+
const away = sign > 0 ? -1 : 1;
|
|
841
|
+
const ring = offsetRing(
|
|
842
|
+
sub,
|
|
843
|
+
strokeWidth / 2,
|
|
844
|
+
join,
|
|
845
|
+
sign === reference ? away : away === 1 ? -1 : 1
|
|
846
|
+
);
|
|
847
|
+
return `M ${ring.map(([x, y]) => `${fmt(x)} ${fmt(y)}`).join(" L ")} Z`;
|
|
848
|
+
}).join(" ");
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
// src/pptx/render/stroke-compound-strands.ts
|
|
852
|
+
var fmt2 = (n) => String(Math.round(n * 1e3) / 1e3);
|
|
853
|
+
function offsetPolyline(points, distance) {
|
|
854
|
+
const normals = points.slice(1).map((b, k) => {
|
|
855
|
+
const a = points[k] ?? b;
|
|
856
|
+
const len = Math.hypot(b[0] - a[0], b[1] - a[1]) || 1;
|
|
857
|
+
return [-(b[1] - a[1]) / len, (b[0] - a[0]) / len];
|
|
858
|
+
});
|
|
859
|
+
return points.map((p, k) => {
|
|
860
|
+
const n1 = normals[Math.max(0, k - 1)] ?? [0, 0];
|
|
861
|
+
const n2 = normals[Math.min(normals.length - 1, k)] ?? n1;
|
|
862
|
+
const bx = n1[0] + n2[0];
|
|
863
|
+
const by = n1[1] + n2[1];
|
|
864
|
+
const blen = Math.hypot(bx, by);
|
|
865
|
+
const cos = blen / 2;
|
|
866
|
+
const reach = cos > 0.25 ? distance / cos : distance;
|
|
867
|
+
return blen > 1e-9 ? [p[0] + bx / blen * reach, p[1] + by / blen * reach] : p;
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
function compoundStrandPath(d, offset, join) {
|
|
871
|
+
const subpaths = flattenPath(d);
|
|
872
|
+
if (!subpaths || subpaths.length === 0) {
|
|
873
|
+
return void 0;
|
|
874
|
+
}
|
|
875
|
+
const closedCount = (d.match(/[zZ]/gu) ?? []).length;
|
|
876
|
+
return subpaths.map((sub, index) => {
|
|
877
|
+
const closed = index < closedCount;
|
|
878
|
+
const points = closed ? offsetRing(sub, Math.abs(offset), join, offset < 0 ? -1 : 1) : offsetPolyline(sub, offset);
|
|
879
|
+
const body = points.map(([x, y]) => `${fmt2(x)} ${fmt2(y)}`).join(" L ");
|
|
880
|
+
return `M ${body}${closed ? " Z" : ""}`;
|
|
881
|
+
}).join(" ");
|
|
882
|
+
}
|
|
883
|
+
function traceCompoundStrands(strands, d, join) {
|
|
884
|
+
if (strands.length < 2) {
|
|
885
|
+
return [...strands];
|
|
886
|
+
}
|
|
887
|
+
return strands.map((strand) => {
|
|
888
|
+
if (strand.offset === 0 || strand.d !== void 0) {
|
|
889
|
+
return strand;
|
|
890
|
+
}
|
|
891
|
+
const traced = compoundStrandPath(d, strand.offset, join);
|
|
892
|
+
return traced ? { ...strand, d: traced, offset: 0 } : strand;
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
function getStrokeOnlyPresetPaths(element) {
|
|
896
|
+
if (element.type !== "shape" || !hasShapeProperties(element)) {
|
|
897
|
+
return void 0;
|
|
898
|
+
}
|
|
899
|
+
const shapeType = element.shapeType;
|
|
900
|
+
if (!shapeType || shapeType === "custom") {
|
|
901
|
+
return void 0;
|
|
902
|
+
}
|
|
903
|
+
if (element.pathData) {
|
|
904
|
+
return void 0;
|
|
905
|
+
}
|
|
906
|
+
const result = evaluatePresetShape(
|
|
907
|
+
shapeType,
|
|
908
|
+
Math.max(element.width, 0),
|
|
909
|
+
Math.max(element.height, 0),
|
|
910
|
+
element.shapeAdjustments
|
|
911
|
+
);
|
|
912
|
+
if (!result || !result.fillNone) {
|
|
913
|
+
return void 0;
|
|
914
|
+
}
|
|
915
|
+
const drawable = result.paths.filter((path) => path.d !== "");
|
|
916
|
+
return drawable.length > 0 ? drawable : void 0;
|
|
917
|
+
}
|
|
918
|
+
function isStrokeOnlyPresetElement(element) {
|
|
919
|
+
return getStrokeOnlyPresetPaths(element) !== void 0;
|
|
920
|
+
}
|
|
921
|
+
function strokeOnlyPresetPathData(element) {
|
|
922
|
+
const paths = getStrokeOnlyPresetPaths(element);
|
|
923
|
+
if (!paths) {
|
|
924
|
+
return void 0;
|
|
925
|
+
}
|
|
926
|
+
const stroked = paths.filter((path) => path.stroke !== false).map((path) => path.d);
|
|
927
|
+
return stroked.length > 0 ? stroked.join(" ") : void 0;
|
|
928
|
+
}
|
|
929
|
+
function getSplitStrokePresetPaths(element) {
|
|
930
|
+
if (element.type !== "shape" || !hasShapeProperties(element) || element.pathData) {
|
|
931
|
+
return void 0;
|
|
932
|
+
}
|
|
933
|
+
const shapeType = element.shapeType;
|
|
934
|
+
if (!shapeType || shapeType === "custom") {
|
|
935
|
+
return void 0;
|
|
936
|
+
}
|
|
937
|
+
const result = evaluatePresetShape(
|
|
938
|
+
shapeType,
|
|
939
|
+
Math.max(element.width, 0),
|
|
940
|
+
Math.max(element.height, 0),
|
|
941
|
+
element.shapeAdjustments
|
|
942
|
+
);
|
|
943
|
+
if (!result || result.fillNone || !result.paths.some((path) => path.stroke === false)) {
|
|
944
|
+
return void 0;
|
|
945
|
+
}
|
|
946
|
+
return result.paths;
|
|
947
|
+
}
|
|
948
|
+
function splitStrokePresetPathData(element) {
|
|
949
|
+
const stroked = getSplitStrokePresetPaths(element)?.filter(
|
|
950
|
+
(path) => path.stroke !== false && path.d !== ""
|
|
951
|
+
);
|
|
952
|
+
return stroked && stroked.length > 0 ? stroked.map((path) => path.d).join(" ") : void 0;
|
|
953
|
+
}
|
|
954
|
+
var NO_STROKE = {
|
|
955
|
+
borderWidth: 0,
|
|
956
|
+
cssBorderWidth: "0px",
|
|
957
|
+
borderStyle: void 0,
|
|
958
|
+
borderColor: void 0,
|
|
959
|
+
border: void 0,
|
|
960
|
+
strokeLinejoin: void 0,
|
|
961
|
+
strokeLinecap: void 0,
|
|
962
|
+
strokeMiterlimit: void 0
|
|
963
|
+
};
|
|
964
|
+
function svgLineJoin(join) {
|
|
965
|
+
switch (join) {
|
|
966
|
+
case "round":
|
|
967
|
+
return "round";
|
|
968
|
+
case "bevel":
|
|
969
|
+
return "bevel";
|
|
970
|
+
case "miter":
|
|
971
|
+
return "miter";
|
|
972
|
+
default:
|
|
973
|
+
return void 0;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
function svgStrokeLineCap(cap) {
|
|
977
|
+
switch (cap) {
|
|
978
|
+
case "rnd":
|
|
979
|
+
return "round";
|
|
980
|
+
case "sq":
|
|
981
|
+
return "square";
|
|
982
|
+
case "flat":
|
|
983
|
+
return "butt";
|
|
984
|
+
default:
|
|
985
|
+
return void 0;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
function strokeMiterLimit(style) {
|
|
989
|
+
if (style?.lineJoin !== "miter" || typeof style.miterLimit !== "number") {
|
|
990
|
+
return void 0;
|
|
991
|
+
}
|
|
992
|
+
if (!Number.isFinite(style.miterLimit)) {
|
|
993
|
+
return void 0;
|
|
994
|
+
}
|
|
995
|
+
return Math.max(style.miterLimit / 1e5, 1);
|
|
996
|
+
}
|
|
997
|
+
function getComputedStrokeStyle(element) {
|
|
998
|
+
if (!hasShapeProperties(element)) {
|
|
999
|
+
return NO_STROKE;
|
|
1000
|
+
}
|
|
1001
|
+
const style = element.shapeStyle;
|
|
1002
|
+
const width = suppressesCssBorder(element) ? 0 : paintedStrokeWidth(style);
|
|
1003
|
+
const joins = {
|
|
1004
|
+
strokeLinejoin: svgLineJoin(style?.lineJoin),
|
|
1005
|
+
strokeLinecap: svgStrokeLineCap(style?.lineCap),
|
|
1006
|
+
strokeMiterlimit: strokeMiterLimit(style)
|
|
1007
|
+
};
|
|
1008
|
+
if (width <= 0 || !style) {
|
|
1009
|
+
return { ...NO_STROKE, ...joins };
|
|
1010
|
+
}
|
|
1011
|
+
const borderWidth = width;
|
|
1012
|
+
const borderStyle = getCssBorderDashStyle(
|
|
1013
|
+
normalizeStrokeDashType(style.strokeDash),
|
|
1014
|
+
style.compoundLine
|
|
1015
|
+
);
|
|
1016
|
+
const rawColor = style.strokeColor ?? DEFAULT_STROKE_COLOR;
|
|
1017
|
+
const borderColor = style.strokeOpacity === void 0 ? rawColor : colorWithOpacity(normalizeHexColor(rawColor, DEFAULT_STROKE_COLOR), style.strokeOpacity);
|
|
1018
|
+
return {
|
|
1019
|
+
borderWidth,
|
|
1020
|
+
cssBorderWidth: screenBorderWidth(borderWidth),
|
|
1021
|
+
borderStyle,
|
|
1022
|
+
borderColor,
|
|
1023
|
+
border: screenBorder(borderWidth, borderStyle ?? "solid", borderColor),
|
|
1024
|
+
...joins
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// src/pptx/render/svg-gradient-rect-path.ts
|
|
1029
|
+
function buildRectPathGradientDef(stops, id, focalPoint, fillToRect) {
|
|
1030
|
+
const rectStops = stops.map((stop) => ({
|
|
1031
|
+
position: Math.round(stop.offset * 100 * 1e4) / 1e4,
|
|
1032
|
+
color: stop.color,
|
|
1033
|
+
...typeof stop.opacity === "number" ? { opacity: stop.opacity } : {}
|
|
1034
|
+
}));
|
|
1035
|
+
const markup = buildRectPathGradientExactSvg(rectStops, focalPoint, fillToRect);
|
|
1036
|
+
return { kind: "rectPath", id, href: `data:image/svg+xml,${encodeURIComponent(markup)}` };
|
|
1037
|
+
}
|
|
1038
|
+
function rectPathGradientMarkup(def) {
|
|
1039
|
+
const id = escapeSvgAttr(def.id);
|
|
1040
|
+
const href = escapeSvgAttr(def.href);
|
|
1041
|
+
return `<pattern id="${id}" patternUnits="objectBoundingBox" patternContentUnits="objectBoundingBox" width="1" height="1"><image href="${href}" x="0" y="0" width="1" height="1" preserveAspectRatio="none"/></pattern>`;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
// src/pptx/render/svg-stroke-pattern-paint.ts
|
|
1045
|
+
function buildSvgStrokePatternDef(style, elementId) {
|
|
1046
|
+
if (!style || style.strokeFillMode !== "pattern" || !style.strokePatternPreset) {
|
|
1047
|
+
return void 0;
|
|
1048
|
+
}
|
|
1049
|
+
const fg = normalizeHexColor(style.strokeColor, "#000000");
|
|
1050
|
+
const bg = normalizeHexColor(style.strokePatternBackgroundColor, "#ffffff");
|
|
1051
|
+
const tile = getPatternTile(style.strokePatternPreset, fg, bg);
|
|
1052
|
+
if (!tile) {
|
|
1053
|
+
return void 0;
|
|
1054
|
+
}
|
|
1055
|
+
const markup = `<svg xmlns="http://www.w3.org/2000/svg" width="${tile.w}" height="${tile.h}">${tile.inner}</svg>`;
|
|
1056
|
+
return {
|
|
1057
|
+
kind: "pattern",
|
|
1058
|
+
id: svgGradientId(elementId, "strokepat"),
|
|
1059
|
+
width: tile.w,
|
|
1060
|
+
height: tile.h,
|
|
1061
|
+
href: `data:image/svg+xml,${encodeURIComponent(markup)}`
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
// src/pptx/render/svg-gradient-paint.ts
|
|
1066
|
+
function round4(value) {
|
|
1067
|
+
return Math.round(value * 1e4) / 1e4;
|
|
1068
|
+
}
|
|
1069
|
+
function svgGradientId(elementId, suffix = "grad") {
|
|
1070
|
+
const seed = String(elementId).replace(/[^a-zA-Z0-9_-]/gu, "_");
|
|
1071
|
+
return `pptx-${suffix}-${seed}`;
|
|
1072
|
+
}
|
|
1073
|
+
function toSvgStops(stops) {
|
|
1074
|
+
const sanitized = sanitizeGradientStops(stops);
|
|
1075
|
+
return (officeTwoStopGradientStops(sanitized) ?? sanitized).map((stop) => ({
|
|
1076
|
+
offset: round4(stop.position / 100),
|
|
1077
|
+
color: stop.color,
|
|
1078
|
+
...typeof stop.opacity === "number" ? { opacity: round4(stop.opacity) } : {}
|
|
1079
|
+
}));
|
|
1080
|
+
}
|
|
1081
|
+
function linearEndpoints(angleDegrees) {
|
|
1082
|
+
const radians = angleDegrees * Math.PI / 180;
|
|
1083
|
+
const dx = Math.cos(radians);
|
|
1084
|
+
const dy = Math.sin(radians);
|
|
1085
|
+
const span = (Math.abs(dx) + Math.abs(dy)) / 2;
|
|
1086
|
+
return {
|
|
1087
|
+
x1: round4(0.5 - dx * span),
|
|
1088
|
+
y1: round4(0.5 - dy * span),
|
|
1089
|
+
x2: round4(0.5 + dx * span),
|
|
1090
|
+
y2: round4(0.5 + dy * span)
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
function buildFromSource(source, id) {
|
|
1094
|
+
const { stops } = source;
|
|
1095
|
+
if (stops.length === 0) {
|
|
1096
|
+
return void 0;
|
|
1097
|
+
}
|
|
1098
|
+
if ((source.type || "linear") === "radial") {
|
|
1099
|
+
if ((source.pathType || "circle") === "rect") {
|
|
1100
|
+
return buildRectPathGradientDef(stops, id, source.focalPoint, source.fillToRect);
|
|
1101
|
+
}
|
|
1102
|
+
const { cx, cy } = computeGradientCenter(source.fillToRect, source.focalPoint);
|
|
1103
|
+
const fx = cx / 100;
|
|
1104
|
+
const fy = cy / 100;
|
|
1105
|
+
const r = Math.hypot(Math.max(fx, 1 - fx), Math.max(fy, 1 - fy));
|
|
1106
|
+
return { kind: "radial", id, cx: round4(fx), cy: round4(fy), r: round4(r), stops };
|
|
1107
|
+
}
|
|
1108
|
+
const angle = typeof source.angle === "number" && Number.isFinite(source.angle) ? source.angle : 90;
|
|
1109
|
+
return { kind: "linear", id, ...linearEndpoints(angle), stops };
|
|
1110
|
+
}
|
|
1111
|
+
function buildSvgGradientDef(style, elementId) {
|
|
1112
|
+
if (!style || style.fillMode !== "gradient") {
|
|
1113
|
+
return void 0;
|
|
1114
|
+
}
|
|
1115
|
+
return buildFromSource(
|
|
1116
|
+
{
|
|
1117
|
+
stops: toSvgStops(style.fillGradientStops),
|
|
1118
|
+
type: style.fillGradientType,
|
|
1119
|
+
pathType: style.fillGradientPathType,
|
|
1120
|
+
angle: style.fillGradientAngle,
|
|
1121
|
+
fillToRect: style.fillGradientFillToRect,
|
|
1122
|
+
focalPoint: style.fillGradientFocalPoint
|
|
1123
|
+
},
|
|
1124
|
+
svgGradientId(elementId)
|
|
1125
|
+
);
|
|
1126
|
+
}
|
|
1127
|
+
function buildSvgStrokeGradientDef(style, elementId) {
|
|
1128
|
+
if (!style || style.strokeFillMode !== "gradient") {
|
|
1129
|
+
return void 0;
|
|
1130
|
+
}
|
|
1131
|
+
return buildFromSource(
|
|
1132
|
+
{
|
|
1133
|
+
stops: toSvgStops(style.strokeGradientStops),
|
|
1134
|
+
type: style.strokeGradientType,
|
|
1135
|
+
pathType: style.strokeGradientPathType,
|
|
1136
|
+
angle: style.strokeGradientAngle
|
|
1137
|
+
},
|
|
1138
|
+
svgGradientId(elementId, "stroke")
|
|
1139
|
+
);
|
|
1140
|
+
}
|
|
1141
|
+
function svgGradientFillRef(def) {
|
|
1142
|
+
return `url(#${def.id})`;
|
|
1143
|
+
}
|
|
1144
|
+
function numAttr(value) {
|
|
1145
|
+
return escapeSvgAttr(String(Number.isFinite(value) ? value : 0));
|
|
1146
|
+
}
|
|
1147
|
+
function svgGradientMarkup(def) {
|
|
1148
|
+
if (def.kind === "rectPath") {
|
|
1149
|
+
return rectPathGradientMarkup(def);
|
|
1150
|
+
}
|
|
1151
|
+
const id = escapeSvgAttr(def.id);
|
|
1152
|
+
const stops = def.stops.map(
|
|
1153
|
+
(stop) => `<stop offset="${numAttr(stop.offset)}" stop-color="${escapeSvgAttr(stop.color)}"${typeof stop.opacity === "number" ? ` stop-opacity="${numAttr(stop.opacity)}"` : ""}/>`
|
|
1154
|
+
).join("");
|
|
1155
|
+
if (def.kind === "radial") {
|
|
1156
|
+
return `<radialGradient id="${id}" cx="${numAttr(def.cx)}" cy="${numAttr(def.cy)}" r="${numAttr(def.r)}">${stops}</radialGradient>`;
|
|
1157
|
+
}
|
|
1158
|
+
return `<linearGradient id="${id}" x1="${numAttr(def.x1)}" y1="${numAttr(def.y1)}" x2="${numAttr(def.x2)}" y2="${numAttr(def.y2)}">${stops}</linearGradient>`;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
// src/pptx/render/stroke-outline.ts
|
|
1162
|
+
var DEFAULT_OPEN_PRESET_STROKE_WIDTH = 2;
|
|
1163
|
+
function isPatternPaint(paint) {
|
|
1164
|
+
return paint?.kind === "pattern";
|
|
1165
|
+
}
|
|
1166
|
+
function outlinePathData(clipPath, width, height) {
|
|
1167
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
|
|
1168
|
+
return void 0;
|
|
1169
|
+
}
|
|
1170
|
+
const rect = `M 0 0 L ${width} 0 L ${width} ${height} L 0 ${height} Z`;
|
|
1171
|
+
if (!clipPath) {
|
|
1172
|
+
return rect;
|
|
1173
|
+
}
|
|
1174
|
+
const asPath = /^path\('(.*)'\)$/su.exec(clipPath.trim());
|
|
1175
|
+
if (asPath) {
|
|
1176
|
+
return asPath[1];
|
|
1177
|
+
}
|
|
1178
|
+
const asPolygon = /^polygon\((.*)\)$/su.exec(clipPath.trim());
|
|
1179
|
+
if (asPolygon) {
|
|
1180
|
+
const points = asPolygon[1].split(",").map((pair) => pair.trim().split(/\s+/u)).filter((parts) => parts.length === 2).map(([rawX, rawY]) => {
|
|
1181
|
+
const toPx = (token, extent) => token.endsWith("%") ? Number.parseFloat(token) / 100 * extent : Number.parseFloat(token);
|
|
1182
|
+
return [toPx(rawX, width), toPx(rawY, height)];
|
|
1183
|
+
}).filter(([x, y]) => Number.isFinite(x) && Number.isFinite(y));
|
|
1184
|
+
if (points.length < 3) {
|
|
1185
|
+
return rect;
|
|
1186
|
+
}
|
|
1187
|
+
const [first, ...rest] = points;
|
|
1188
|
+
return `M ${first[0]} ${first[1]} ${rest.map(([x, y]) => `L ${x} ${y}`).join(" ")} Z`;
|
|
1189
|
+
}
|
|
1190
|
+
return rect;
|
|
1191
|
+
}
|
|
1192
|
+
var WEDGE_CALLOUT_PRESET_NAMES = /* @__PURE__ */ new Set([
|
|
1193
|
+
"wedgerectcallout",
|
|
1194
|
+
"wedgeroundrectcallout",
|
|
1195
|
+
"wedgeellipsecallout"
|
|
1196
|
+
]);
|
|
1197
|
+
function isWedgeCalloutPresetShape(shapeType) {
|
|
1198
|
+
return typeof shapeType === "string" && WEDGE_CALLOUT_PRESET_NAMES.has(shapeType.toLowerCase());
|
|
1199
|
+
}
|
|
1200
|
+
function clipPathPolygonPoints(clipPath, width, height) {
|
|
1201
|
+
const asPolygon = /^polygon\((.*)\)$/su.exec(clipPath.trim());
|
|
1202
|
+
if (!asPolygon) {
|
|
1203
|
+
return [];
|
|
1204
|
+
}
|
|
1205
|
+
const toPx = (token, extent) => token.endsWith("%") ? Number.parseFloat(token) / 100 * extent : Number.parseFloat(token);
|
|
1206
|
+
return asPolygon[1].split(",").map((pair) => pair.trim().split(/\s+/u)).filter((parts) => parts.length === 2).map(([rawX, rawY]) => [toPx(rawX, width), toPx(rawY, height)]).filter(([x, y]) => Number.isFinite(x) && Number.isFinite(y));
|
|
1207
|
+
}
|
|
1208
|
+
function getPresetShapeVectorGeometry(shapeType, width, height, adjustments) {
|
|
1209
|
+
const normalizedWidth = Math.max(Number.isFinite(width) ? width : 0, 1);
|
|
1210
|
+
const normalizedHeight = Math.max(Number.isFinite(height) ? height : 0, 1);
|
|
1211
|
+
const clipPath = getResolvedShapeClipPathFor(
|
|
1212
|
+
shapeType,
|
|
1213
|
+
normalizedWidth,
|
|
1214
|
+
normalizedHeight,
|
|
1215
|
+
adjustments
|
|
1216
|
+
);
|
|
1217
|
+
const d = outlinePathData(clipPath, normalizedWidth, normalizedHeight);
|
|
1218
|
+
if (!d) {
|
|
1219
|
+
return void 0;
|
|
1220
|
+
}
|
|
1221
|
+
let minX = 0;
|
|
1222
|
+
let minY = 0;
|
|
1223
|
+
let maxX = normalizedWidth;
|
|
1224
|
+
let maxY = normalizedHeight;
|
|
1225
|
+
for (const [x, y] of clipPath ? clipPathPolygonPoints(clipPath, normalizedWidth, normalizedHeight) : []) {
|
|
1226
|
+
minX = Math.min(minX, x);
|
|
1227
|
+
minY = Math.min(minY, y);
|
|
1228
|
+
maxX = Math.max(maxX, x);
|
|
1229
|
+
maxY = Math.max(maxY, y);
|
|
1230
|
+
}
|
|
1231
|
+
return {
|
|
1232
|
+
d,
|
|
1233
|
+
minX,
|
|
1234
|
+
minY,
|
|
1235
|
+
maxX,
|
|
1236
|
+
maxY,
|
|
1237
|
+
viewWidth: Math.max(maxX - minX, 1),
|
|
1238
|
+
viewHeight: Math.max(maxY - minY, 1)
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
function outlineStrands(compoundLine, strokeWidth) {
|
|
1242
|
+
const offsets = getCompoundLineOffsets(compoundLine, strokeWidth);
|
|
1243
|
+
if (offsets.length <= 1) {
|
|
1244
|
+
return [{ strokeWidth, cssStrokeWidth: screenStrokeWidth(strokeWidth), offset: 0 }];
|
|
1245
|
+
}
|
|
1246
|
+
const widths = getCompoundLineWidths(compoundLine, strokeWidth);
|
|
1247
|
+
return offsets.map((offset, idx) => {
|
|
1248
|
+
const width = widths[idx] ?? strokeWidth;
|
|
1249
|
+
return { strokeWidth: width, cssStrokeWidth: screenBorderWidth(width), offset };
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
function needsCenteredStrokeOverlay(element, style, declaredWidth) {
|
|
1253
|
+
if (!style || declaredWidth <= 0 || element.type === "connector" || !hasStrokePaint(style)) {
|
|
1254
|
+
return false;
|
|
1255
|
+
}
|
|
1256
|
+
const shapeType = getShapeType(element.shapeType);
|
|
1257
|
+
if (shapeType === "line") {
|
|
1258
|
+
return false;
|
|
1259
|
+
}
|
|
1260
|
+
return style.lineAlignment !== "in";
|
|
1261
|
+
}
|
|
1262
|
+
function clipEdgeBleed(element, d, style) {
|
|
1263
|
+
if ((style?.strokeOpacity ?? 1) < 1 || element.type === "picture" || element.type === "image" || isArrowedCustomPath(element) || // A silhouette shape keeps no clip on its container (its fill is the SVG
|
|
1264
|
+
// overlay's), so there is no cut to cover; and the filter shadows the painted
|
|
1265
|
+
// alpha, which the hairline would thicken (a hollow triangle's shadow read
|
|
1266
|
+
// 25 % darker than PowerPoint's).
|
|
1267
|
+
usesSilhouetteEffects(element)) {
|
|
1268
|
+
return void 0;
|
|
1269
|
+
}
|
|
1270
|
+
const width = straddlingStrokeWidth(element);
|
|
1271
|
+
const shapeType = getShapeType(element.shapeType);
|
|
1272
|
+
if (width <= 0 || shapeType === "roundRect" || shapeType === "ellipse" || isIdentityRectClip(element) || getResolvedShapeClipPath(element) === void 0) {
|
|
1273
|
+
return void 0;
|
|
1274
|
+
}
|
|
1275
|
+
const edge = outerStrokeEdgePath(d, width, outlineStrokeJoin(element));
|
|
1276
|
+
return edge ? {
|
|
1277
|
+
d: edge,
|
|
1278
|
+
strokeWidth: 1,
|
|
1279
|
+
cssStrokeWidth: `max(1px, calc(2 * var(${DEVICE_PX_VAR}, 0px)))`,
|
|
1280
|
+
offset: 0
|
|
1281
|
+
} : void 0;
|
|
1282
|
+
}
|
|
1283
|
+
function insetLineOnClippedShape(element, style, declaredWidth) {
|
|
1284
|
+
if (!style || style.lineAlignment !== "in" || declaredWidth <= 0 || element.type === "connector" || element.type === "picture" || element.type === "image" || !hasStrokePaint(style)) {
|
|
1285
|
+
return false;
|
|
1286
|
+
}
|
|
1287
|
+
const shapeType = getShapeType(element.shapeType);
|
|
1288
|
+
if (shapeType === "line" || shapeType === "roundRect" || shapeType === "ellipse") {
|
|
1289
|
+
return false;
|
|
1290
|
+
}
|
|
1291
|
+
return !isIdentityRectClip(element) && getResolvedShapeClipPath(element) !== void 0;
|
|
1292
|
+
}
|
|
1293
|
+
function straddlingStrokeWidth(element) {
|
|
1294
|
+
if (!hasShapeProperties(element)) {
|
|
1295
|
+
return 0;
|
|
1296
|
+
}
|
|
1297
|
+
const style = element.shapeStyle;
|
|
1298
|
+
const width = Math.max(0, style?.strokeWidth ?? 0);
|
|
1299
|
+
if (!needsCenteredStrokeOverlay(element, style, width)) {
|
|
1300
|
+
return 0;
|
|
1301
|
+
}
|
|
1302
|
+
const dash = normalizeStrokeDashType(style?.strokeDash);
|
|
1303
|
+
return !dash || dash === "solid" ? width : 0;
|
|
1304
|
+
}
|
|
1305
|
+
function outlineStrokeJoin(element) {
|
|
1306
|
+
const style = hasShapeProperties(element) ? element.shapeStyle : void 0;
|
|
1307
|
+
const join = style?.lineJoin === "bevel" ? "bevel" : style?.lineJoin === "miter" ? "miter" : "round";
|
|
1308
|
+
return { join, miterLimit: strokeMiterLimit(style) ?? 4 };
|
|
1309
|
+
}
|
|
1310
|
+
function snapTransform(element, isOpenPreset, strokeWidth) {
|
|
1311
|
+
if (element.rotation) {
|
|
1312
|
+
return void 0;
|
|
1313
|
+
}
|
|
1314
|
+
const place = snapPlacement(element);
|
|
1315
|
+
if (!place) {
|
|
1316
|
+
return void 0;
|
|
1317
|
+
}
|
|
1318
|
+
const shapeType = getShapeType(element.shapeType);
|
|
1319
|
+
if (isOpenPreset) {
|
|
1320
|
+
if (shapeType !== "line") {
|
|
1321
|
+
return void 0;
|
|
1322
|
+
}
|
|
1323
|
+
const axis = element.height === 0 ? "h" : element.width === 0 ? "v" : void 0;
|
|
1324
|
+
return axis ? snappedStrokeTransform(axis, place.x, place.y, strokeWidth, void 0, place.exact) : void 0;
|
|
1325
|
+
}
|
|
1326
|
+
return shapeType === "rect" ? snappedStrokeTransform(
|
|
1327
|
+
"box",
|
|
1328
|
+
place.x,
|
|
1329
|
+
place.y,
|
|
1330
|
+
strokeWidth,
|
|
1331
|
+
{ width: element.width, height: element.height },
|
|
1332
|
+
place.exact
|
|
1333
|
+
) : void 0;
|
|
1334
|
+
}
|
|
1335
|
+
function buildStrokeOutline(element) {
|
|
1336
|
+
if (!hasShapeProperties(element)) {
|
|
1337
|
+
return void 0;
|
|
1338
|
+
}
|
|
1339
|
+
const style = element.shapeStyle;
|
|
1340
|
+
const declaredWidth = Math.max(0, style?.strokeWidth ?? 0);
|
|
1341
|
+
const openPresetD = strokeOnlyPresetPathData(element);
|
|
1342
|
+
if (!openPresetD && (!style || declaredWidth <= 0)) {
|
|
1343
|
+
return void 0;
|
|
1344
|
+
}
|
|
1345
|
+
const paint = style && declaredWidth > 0 ? buildSvgStrokeGradientDef(style, element.id) ?? buildSvgStrokePatternDef(style, element.id) : void 0;
|
|
1346
|
+
const splitD = !openPresetD && declaredWidth > 0 ? splitStrokePresetPathData(element) : void 0;
|
|
1347
|
+
const ownPathD = openPresetD ?? splitD;
|
|
1348
|
+
const insetOnClip = !ownPathD && insetLineOnClippedShape(element, style, declaredWidth);
|
|
1349
|
+
const centeredFlatStroke = !paint && !ownPathD && (isArrowedCustomPath(element) || needsCenteredStrokeOverlay(element, style, declaredWidth));
|
|
1350
|
+
if (!paint && !ownPathD && !centeredFlatStroke && !insetOnClip) {
|
|
1351
|
+
return void 0;
|
|
1352
|
+
}
|
|
1353
|
+
const d = ownPathD ?? outlinePathData(getResolvedShapeClipPath(element), element.width, element.height);
|
|
1354
|
+
if (!d) {
|
|
1355
|
+
return void 0;
|
|
1356
|
+
}
|
|
1357
|
+
const lineWidth = declaredWidth > 0 ? declaredWidth : DEFAULT_OPEN_PRESET_STROKE_WIDTH;
|
|
1358
|
+
const strokeWidth = insetOnClip ? lineWidth * 2 : lineWidth;
|
|
1359
|
+
const stroke = paint ? svgGradientFillRef(paint) : colorWithOpacity(style?.strokeColor ?? DEFAULT_STROKE_COLOR, style?.strokeOpacity);
|
|
1360
|
+
const strands = traceCompoundStrands(
|
|
1361
|
+
outlineStrands(style?.compoundLine, strokeWidth),
|
|
1362
|
+
d,
|
|
1363
|
+
outlineStrokeJoin(element)
|
|
1364
|
+
);
|
|
1365
|
+
const bleed = !ownPathD ? clipEdgeBleed(element, d, style) : void 0;
|
|
1366
|
+
const snap = paint || strands.length !== 1 ? void 0 : snapTransform(element, !!openPresetD, strokeWidth);
|
|
1367
|
+
const snapped = snap ? strands.map((strand) => ({ ...strand, cssTransform: snap })) : strands;
|
|
1368
|
+
const dashStartD = !ownPathD && isDashedStroke(style?.strokeDash) ? dashStartPathData(d, element.shapeType) : d;
|
|
1369
|
+
return {
|
|
1370
|
+
markers: buildCustomPathMarkers(element, stroke),
|
|
1371
|
+
d: dashStartD,
|
|
1372
|
+
paint,
|
|
1373
|
+
stroke,
|
|
1374
|
+
strokeWidth,
|
|
1375
|
+
strands: bleed ? [...snapped, bleed] : snapped,
|
|
1376
|
+
dashArray: getSvgStrokeDasharray(
|
|
1377
|
+
normalizeStrokeDashType(style?.strokeDash),
|
|
1378
|
+
Math.max(lineWidth, 1),
|
|
1379
|
+
style?.customDashSegments,
|
|
1380
|
+
style?.lineCap
|
|
1381
|
+
),
|
|
1382
|
+
lineCap: svgLineCap(style?.lineCap, isDashedStroke(style?.strokeDash)),
|
|
1383
|
+
lineJoin: outlineStrokeJoin(element).join
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
function strokeOutlineViewBox(element) {
|
|
1387
|
+
const width = Math.max(element.width, 0);
|
|
1388
|
+
const height = Math.max(element.height, 0);
|
|
1389
|
+
if (width < 1 || height < 1) {
|
|
1390
|
+
return void 0;
|
|
1391
|
+
}
|
|
1392
|
+
return `0 0 ${width} ${height}`;
|
|
1393
|
+
}
|
|
1394
|
+
function suppressesCssBorder(element) {
|
|
1395
|
+
return buildStrokeOutline(element) !== void 0;
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
// src/pptx/render/stroke-clip-outset.ts
|
|
1399
|
+
var SVG_DEFAULT_JOIN = { join: "miter", miterLimit: 4 };
|
|
1400
|
+
var ROUND_JOIN_STEPS2 = 16;
|
|
1401
|
+
var CURVE_STEPS = 16;
|
|
1402
|
+
function flattenArc(from, rx, ry, rotationDeg, largeArc, sweep, to) {
|
|
1403
|
+
if (rx === 0 || ry === 0 || from[0] === to[0] && from[1] === to[1]) {
|
|
1404
|
+
return [to];
|
|
1405
|
+
}
|
|
1406
|
+
const phi = rotationDeg * Math.PI / 180;
|
|
1407
|
+
const cosPhi = Math.cos(phi);
|
|
1408
|
+
const sinPhi = Math.sin(phi);
|
|
1409
|
+
const dx = (from[0] - to[0]) / 2;
|
|
1410
|
+
const dy = (from[1] - to[1]) / 2;
|
|
1411
|
+
const x1 = cosPhi * dx + sinPhi * dy;
|
|
1412
|
+
const y1 = -sinPhi * dx + cosPhi * dy;
|
|
1413
|
+
let radiusX = Math.abs(rx);
|
|
1414
|
+
let radiusY = Math.abs(ry);
|
|
1415
|
+
const lambda = x1 * x1 / (radiusX * radiusX) + y1 * y1 / (radiusY * radiusY);
|
|
1416
|
+
if (lambda > 1) {
|
|
1417
|
+
const scale = Math.sqrt(lambda);
|
|
1418
|
+
radiusX *= scale;
|
|
1419
|
+
radiusY *= scale;
|
|
1420
|
+
}
|
|
1421
|
+
const numerator = radiusX * radiusX * radiusY * radiusY - radiusX * radiusX * y1 * y1 - radiusY * radiusY * x1 * x1;
|
|
1422
|
+
const denominator = radiusX * radiusX * y1 * y1 + radiusY * radiusY * x1 * x1;
|
|
1423
|
+
const coefficient = (largeArc === sweep ? -1 : 1) * Math.sqrt(Math.max(0, numerator / denominator));
|
|
1424
|
+
const cxp = coefficient * radiusX * y1 / radiusY;
|
|
1425
|
+
const cyp = -coefficient * radiusY * x1 / radiusX;
|
|
1426
|
+
const cx = cosPhi * cxp - sinPhi * cyp + (from[0] + to[0]) / 2;
|
|
1427
|
+
const cy = sinPhi * cxp + cosPhi * cyp + (from[1] + to[1]) / 2;
|
|
1428
|
+
const angle = (ux, uy, vx, vy) => {
|
|
1429
|
+
const sign = ux * vy - uy * vx < 0 ? -1 : 1;
|
|
1430
|
+
const dot = (ux * vx + uy * vy) / (Math.hypot(ux, uy) * Math.hypot(vx, vy));
|
|
1431
|
+
return sign * Math.acos(Math.max(-1, Math.min(1, dot)));
|
|
1432
|
+
};
|
|
1433
|
+
const theta1 = angle(1, 0, (x1 - cxp) / radiusX, (y1 - cyp) / radiusY);
|
|
1434
|
+
let delta = angle(
|
|
1435
|
+
(x1 - cxp) / radiusX,
|
|
1436
|
+
(y1 - cyp) / radiusY,
|
|
1437
|
+
(-x1 - cxp) / radiusX,
|
|
1438
|
+
(-y1 - cyp) / radiusY
|
|
1439
|
+
);
|
|
1440
|
+
if (!sweep && delta > 0) {
|
|
1441
|
+
delta -= 2 * Math.PI;
|
|
1442
|
+
} else if (sweep && delta < 0) {
|
|
1443
|
+
delta += 2 * Math.PI;
|
|
1444
|
+
}
|
|
1445
|
+
const out = [];
|
|
1446
|
+
for (let step = 1; step <= CURVE_STEPS; step++) {
|
|
1447
|
+
const t = theta1 + delta * step / CURVE_STEPS;
|
|
1448
|
+
const px2 = radiusX * Math.cos(t);
|
|
1449
|
+
const py = radiusY * Math.sin(t);
|
|
1450
|
+
out.push([cosPhi * px2 - sinPhi * py + cx, sinPhi * px2 + cosPhi * py + cy]);
|
|
1451
|
+
}
|
|
1452
|
+
return out;
|
|
1453
|
+
}
|
|
1454
|
+
function flattenPath(d) {
|
|
1455
|
+
const tokens = d.match(/[A-Za-z]|-?\d*\.?\d+(?:e[-+]?\d+)?/giu);
|
|
1456
|
+
if (!tokens) {
|
|
1457
|
+
return void 0;
|
|
1458
|
+
}
|
|
1459
|
+
const subpaths = [];
|
|
1460
|
+
let current = [];
|
|
1461
|
+
let pos = [0, 0];
|
|
1462
|
+
let start = [0, 0];
|
|
1463
|
+
let i = 0;
|
|
1464
|
+
let command = "";
|
|
1465
|
+
const num3 = () => Number.parseFloat(tokens[i++] ?? "NaN");
|
|
1466
|
+
while (i < tokens.length) {
|
|
1467
|
+
const token = tokens[i];
|
|
1468
|
+
if (/^[A-Za-z]$/u.test(token)) {
|
|
1469
|
+
command = token;
|
|
1470
|
+
i++;
|
|
1471
|
+
if (command === "Z" || command === "z") {
|
|
1472
|
+
if (current.length > 1) {
|
|
1473
|
+
subpaths.push(current);
|
|
1474
|
+
}
|
|
1475
|
+
current = [];
|
|
1476
|
+
pos = start;
|
|
1477
|
+
continue;
|
|
1478
|
+
}
|
|
1479
|
+
} else if (command === "M") {
|
|
1480
|
+
command = "L";
|
|
1481
|
+
}
|
|
1482
|
+
switch (command) {
|
|
1483
|
+
case "M":
|
|
1484
|
+
if (current.length > 1) {
|
|
1485
|
+
subpaths.push(current);
|
|
1486
|
+
}
|
|
1487
|
+
pos = [num3(), num3()];
|
|
1488
|
+
start = pos;
|
|
1489
|
+
current = [pos];
|
|
1490
|
+
break;
|
|
1491
|
+
case "L":
|
|
1492
|
+
pos = [num3(), num3()];
|
|
1493
|
+
current.push(pos);
|
|
1494
|
+
break;
|
|
1495
|
+
case "H":
|
|
1496
|
+
pos = [num3(), pos[1]];
|
|
1497
|
+
current.push(pos);
|
|
1498
|
+
break;
|
|
1499
|
+
case "V":
|
|
1500
|
+
pos = [pos[0], num3()];
|
|
1501
|
+
current.push(pos);
|
|
1502
|
+
break;
|
|
1503
|
+
case "C": {
|
|
1504
|
+
const p1 = [num3(), num3()];
|
|
1505
|
+
const p2 = [num3(), num3()];
|
|
1506
|
+
const p3 = [num3(), num3()];
|
|
1507
|
+
for (let step = 1; step <= CURVE_STEPS; step++) {
|
|
1508
|
+
const t = step / CURVE_STEPS;
|
|
1509
|
+
const u = 1 - t;
|
|
1510
|
+
current.push([
|
|
1511
|
+
u * u * u * pos[0] + 3 * u * u * t * p1[0] + 3 * u * t * t * p2[0] + t * t * t * p3[0],
|
|
1512
|
+
u * u * u * pos[1] + 3 * u * u * t * p1[1] + 3 * u * t * t * p2[1] + t * t * t * p3[1]
|
|
1513
|
+
]);
|
|
1514
|
+
}
|
|
1515
|
+
pos = p3;
|
|
1516
|
+
break;
|
|
1517
|
+
}
|
|
1518
|
+
case "Q": {
|
|
1519
|
+
const p1 = [num3(), num3()];
|
|
1520
|
+
const p2 = [num3(), num3()];
|
|
1521
|
+
for (let step = 1; step <= CURVE_STEPS; step++) {
|
|
1522
|
+
const t = step / CURVE_STEPS;
|
|
1523
|
+
const u = 1 - t;
|
|
1524
|
+
current.push([
|
|
1525
|
+
u * u * pos[0] + 2 * u * t * p1[0] + t * t * p2[0],
|
|
1526
|
+
u * u * pos[1] + 2 * u * t * p1[1] + t * t * p2[1]
|
|
1527
|
+
]);
|
|
1528
|
+
}
|
|
1529
|
+
pos = p2;
|
|
1530
|
+
break;
|
|
1531
|
+
}
|
|
1532
|
+
case "A": {
|
|
1533
|
+
const rx = num3();
|
|
1534
|
+
const ry = num3();
|
|
1535
|
+
const rotation = num3();
|
|
1536
|
+
const largeArc = num3() !== 0;
|
|
1537
|
+
const sweep = num3() !== 0;
|
|
1538
|
+
const to = [num3(), num3()];
|
|
1539
|
+
current.push(...flattenArc(pos, rx, ry, rotation, largeArc, sweep, to));
|
|
1540
|
+
pos = to;
|
|
1541
|
+
break;
|
|
1542
|
+
}
|
|
1543
|
+
default:
|
|
1544
|
+
return void 0;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
if (current.length > 1) {
|
|
1548
|
+
subpaths.push(current);
|
|
1549
|
+
}
|
|
1550
|
+
return subpaths.every((sub) => sub.every(([x, y]) => Number.isFinite(x) && Number.isFinite(y))) ? subpaths : void 0;
|
|
1551
|
+
}
|
|
1552
|
+
var fmt3 = (n) => String(Math.round(n * 1e3) / 1e3);
|
|
1553
|
+
function outsetClipPathForStroke(clipPath, strokeWidth, width, height, join = SVG_DEFAULT_JOIN) {
|
|
1554
|
+
if (!(strokeWidth > 0)) {
|
|
1555
|
+
return clipPath;
|
|
1556
|
+
}
|
|
1557
|
+
const d = outlinePathData(clipPath, width, height);
|
|
1558
|
+
const subpaths = d ? flattenPath(d) : void 0;
|
|
1559
|
+
if (!d || !subpaths || subpaths.length === 0) {
|
|
1560
|
+
return clipPath;
|
|
1561
|
+
}
|
|
1562
|
+
const half = strokeWidth / 2;
|
|
1563
|
+
const signedArea2 = (pts) => {
|
|
1564
|
+
let area = 0;
|
|
1565
|
+
for (let k = 0; k < pts.length; k++) {
|
|
1566
|
+
const a = pts[k];
|
|
1567
|
+
const b = pts[(k + 1) % pts.length];
|
|
1568
|
+
area += a[0] * b[1] - b[0] * a[1];
|
|
1569
|
+
}
|
|
1570
|
+
return area;
|
|
1571
|
+
};
|
|
1572
|
+
const reference = Math.sign(signedArea2(subpaths[0])) || 1;
|
|
1573
|
+
const quads = [];
|
|
1574
|
+
const push = (poly) => {
|
|
1575
|
+
const wound = Math.sign(signedArea2(poly)) === reference ? poly : [...poly].reverse();
|
|
1576
|
+
quads.push(`M ${wound.map(([x, y]) => `${fmt3(x)} ${fmt3(y)}`).join(" L ")} Z`);
|
|
1577
|
+
};
|
|
1578
|
+
for (const sub of subpaths) {
|
|
1579
|
+
const pts = sub;
|
|
1580
|
+
let last = [0, 0];
|
|
1581
|
+
const normals = pts.map((a, k) => {
|
|
1582
|
+
const b = pts[(k + 1) % pts.length];
|
|
1583
|
+
const len = Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
1584
|
+
if (len >= 1e-6) {
|
|
1585
|
+
last = [-(b[1] - a[1]) / len, (b[0] - a[0]) / len];
|
|
1586
|
+
}
|
|
1587
|
+
return last;
|
|
1588
|
+
});
|
|
1589
|
+
for (let k = 0; k < pts.length; k++) {
|
|
1590
|
+
const a = pts[k];
|
|
1591
|
+
const b = pts[(k + 1) % pts.length];
|
|
1592
|
+
const [nx, ny] = normals[k];
|
|
1593
|
+
push([
|
|
1594
|
+
[a[0] + nx * half, a[1] + ny * half],
|
|
1595
|
+
[b[0] + nx * half, b[1] + ny * half],
|
|
1596
|
+
[b[0] - nx * half, b[1] - ny * half],
|
|
1597
|
+
[a[0] - nx * half, a[1] - ny * half]
|
|
1598
|
+
]);
|
|
1599
|
+
push(joinPiece(b, normals[k], normals[(k + 1) % pts.length]));
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
function joinPiece(v, n1, n2) {
|
|
1603
|
+
if (join.join === "round") {
|
|
1604
|
+
const r = half / Math.cos(Math.PI / ROUND_JOIN_STEPS2);
|
|
1605
|
+
return Array.from({ length: ROUND_JOIN_STEPS2 }, (_, i) => {
|
|
1606
|
+
const t = 2 * Math.PI * i / ROUND_JOIN_STEPS2;
|
|
1607
|
+
return [v[0] + r * Math.cos(t), v[1] + r * Math.sin(t)];
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
const turn = n1[0] * n2[1] - n1[1] * n2[0];
|
|
1611
|
+
if (Math.abs(turn) < 1e-9) {
|
|
1612
|
+
return [v, v, v, v];
|
|
1613
|
+
}
|
|
1614
|
+
const side = turn > 0 ? -1 : 1;
|
|
1615
|
+
const p1 = [v[0] + side * n1[0] * half, v[1] + side * n1[1] * half];
|
|
1616
|
+
const p2 = [v[0] + side * n2[0] * half, v[1] + side * n2[1] * half];
|
|
1617
|
+
const cosHalf = Math.sqrt(Math.max(0, (1 + n1[0] * n2[0] + n1[1] * n2[1]) / 2));
|
|
1618
|
+
if (join.join === "miter" && cosHalf > 0 && 1 / cosHalf <= join.miterLimit) {
|
|
1619
|
+
const bx = n1[0] + n2[0];
|
|
1620
|
+
const by = n1[1] + n2[1];
|
|
1621
|
+
const blen = Math.hypot(bx, by);
|
|
1622
|
+
const reach = half / cosHalf / blen;
|
|
1623
|
+
return [v, p1, [v[0] + side * bx * reach, v[1] + side * by * reach], p2];
|
|
1624
|
+
}
|
|
1625
|
+
return [v, p1, p2, p2];
|
|
1626
|
+
}
|
|
1627
|
+
return `path('${d} ${quads.join(" ")}')`;
|
|
1628
|
+
}
|
|
1629
|
+
|
|
1630
|
+
// src/pptx/render/shape-geometry-base.ts
|
|
1631
|
+
var CYLINDER_RADIUS = "48% / 12%";
|
|
1632
|
+
var MIN_ROUND_RECT_RADIUS_PX = 0.01;
|
|
1633
|
+
function resolveBaseShapeGeometry(element) {
|
|
1634
|
+
const shapeType = getShapeType(element.shapeType);
|
|
1635
|
+
if (element.type === "connector" || shapeType === "connector") {
|
|
1636
|
+
return { kind: "bare" };
|
|
1637
|
+
}
|
|
1638
|
+
if (isStrokeOnlyPresetElement(element) || isArrowedCustomPath(element)) {
|
|
1639
|
+
return { kind: "strokeOnly" };
|
|
1640
|
+
}
|
|
1641
|
+
if (shapeType === "roundRect" && hasShapeProperties(element)) {
|
|
1642
|
+
const radiusPx = getRoundRectRadiusPx(element);
|
|
1643
|
+
return radiusPx > MIN_ROUND_RECT_RADIUS_PX ? { kind: "borderRadius", radius: `${radiusPx}px` } : { kind: "none" };
|
|
1644
|
+
}
|
|
1645
|
+
if (shapeType === "ellipse") {
|
|
1646
|
+
return { kind: "borderRadius", radius: "50%" };
|
|
1647
|
+
}
|
|
1648
|
+
const clipPath = isIdentityRectClip(element) ? void 0 : getResolvedShapeClipPath(element);
|
|
1649
|
+
if (clipPath) {
|
|
1650
|
+
const stroke = straddlingStrokeWidth(element);
|
|
1651
|
+
return {
|
|
1652
|
+
kind: "clipPath",
|
|
1653
|
+
clipPath: stroke > 0 ? outsetClipPathForStroke(
|
|
1654
|
+
clipPath,
|
|
1655
|
+
stroke,
|
|
1656
|
+
element.width,
|
|
1657
|
+
element.height,
|
|
1658
|
+
outlineStrokeJoin(element)
|
|
1659
|
+
) : clipPath
|
|
1660
|
+
};
|
|
1661
|
+
}
|
|
1662
|
+
if (shapeType === "line") {
|
|
1663
|
+
const authored = element.shapeStyle?.strokeWidth;
|
|
1664
|
+
return { kind: "lineEdge", strokeWidth: Math.max(Math.max(0, authored ?? 0), 2) };
|
|
1665
|
+
}
|
|
1666
|
+
if (shapeType === "cylinder") {
|
|
1667
|
+
return { kind: "borderRadius", radius: CYLINDER_RADIUS };
|
|
1668
|
+
}
|
|
1669
|
+
return { kind: "none" };
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
// src/pptx/render/silhouette-morph-registry.ts
|
|
1673
|
+
var entries = /* @__PURE__ */ new Map();
|
|
1674
|
+
function registerSilhouetteMorph(elementId, own, out, size) {
|
|
1675
|
+
entries.set(elementId, { params: own, ...size, own: JSON.stringify(own), out });
|
|
1676
|
+
}
|
|
1677
|
+
function silhouetteMorphEntry(elementId) {
|
|
1678
|
+
return entries.get(elementId);
|
|
1679
|
+
}
|
|
1680
|
+
function silhouetteMorphFor(elementId, own) {
|
|
1681
|
+
const entry = entries.get(elementId);
|
|
1682
|
+
return entry && entry.own === JSON.stringify(own) ? entry.out : void 0;
|
|
1683
|
+
}
|
|
1684
|
+
function paintedSize(element) {
|
|
1685
|
+
return {
|
|
1686
|
+
width: Math.max(element.width, 0),
|
|
1687
|
+
height: Math.max(element.height, 0)
|
|
1688
|
+
};
|
|
1689
|
+
}
|
|
1690
|
+
function needsPerSubpathPaint(subpaths) {
|
|
1691
|
+
return subpaths.some(
|
|
1692
|
+
(sp) => sp.fillMode !== void 0 && sp.fillMode !== "norm" || sp.stroke === false
|
|
1693
|
+
);
|
|
1694
|
+
}
|
|
1695
|
+
function asSubpathCapable(element) {
|
|
1696
|
+
if (element.type === "shape" || element.type === "image" || element.type === "picture") {
|
|
1697
|
+
return element;
|
|
1698
|
+
}
|
|
1699
|
+
return void 0;
|
|
1700
|
+
}
|
|
1701
|
+
function getSubpathGeometry(element, force = false) {
|
|
1702
|
+
const slots = asSubpathCapable(element);
|
|
1703
|
+
if (!slots) {
|
|
1704
|
+
return void 0;
|
|
1705
|
+
}
|
|
1706
|
+
if (slots.pathData && slots.pathWidth && slots.pathHeight) {
|
|
1707
|
+
const structured = evaluateCustomGeometryPaths(
|
|
1708
|
+
slots.customGeometryRawData,
|
|
1709
|
+
slots.pathWidth,
|
|
1710
|
+
slots.pathHeight,
|
|
1711
|
+
slots.shapeAdjustments
|
|
1712
|
+
) ?? slots.customGeometryPaths;
|
|
1713
|
+
if (!structured || structured.length === 0) {
|
|
1714
|
+
return void 0;
|
|
1715
|
+
}
|
|
1716
|
+
const subpaths2 = customGeometryPathsToSvgSubpaths(
|
|
1717
|
+
structured,
|
|
1718
|
+
slots.pathWidth,
|
|
1719
|
+
slots.pathHeight
|
|
1720
|
+
);
|
|
1721
|
+
return force || needsPerSubpathPaint(subpaths2) ? { subpaths: subpaths2, width: slots.pathWidth, height: slots.pathHeight } : void 0;
|
|
1722
|
+
}
|
|
1723
|
+
if (!slots.shapeType) {
|
|
1724
|
+
return void 0;
|
|
1725
|
+
}
|
|
1726
|
+
const { width, height } = paintedSize(element);
|
|
1727
|
+
const result = evaluatePresetShape(slots.shapeType, width, height, slots.shapeAdjustments);
|
|
1728
|
+
if (!result || result.fillNone || result.paths.length === 0) {
|
|
1729
|
+
return void 0;
|
|
1730
|
+
}
|
|
1731
|
+
const subpaths = result.paths.map((p) => ({
|
|
1732
|
+
d: p.d,
|
|
1733
|
+
fillMode: p.fill,
|
|
1734
|
+
stroke: p.stroke
|
|
1735
|
+
}));
|
|
1736
|
+
return force || needsPerSubpathPaint(subpaths) ? { subpaths, width, height } : void 0;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
// src/pptx/render/silhouette-effects.ts
|
|
1740
|
+
var DEFAULT_SHADOW = "#000000";
|
|
1741
|
+
var DEFAULT_GLOW = "#ffff00";
|
|
1742
|
+
var GLOW_RING_STEPS = 24;
|
|
1743
|
+
var GLOW_INNER_RING_STEPS = 12;
|
|
1744
|
+
function unit(value) {
|
|
1745
|
+
return Math.min(1, Math.max(0, value));
|
|
1746
|
+
}
|
|
1747
|
+
function hex(value, fallback) {
|
|
1748
|
+
if (!value || value === "transparent") {
|
|
1749
|
+
return fallback;
|
|
1750
|
+
}
|
|
1751
|
+
const candidate = value.startsWith("#") ? value : `#${value}`;
|
|
1752
|
+
return /^#[0-9A-Fa-f]{6}$/u.test(candidate) ? candidate : fallback;
|
|
1753
|
+
}
|
|
1754
|
+
function finite(value) {
|
|
1755
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
1756
|
+
}
|
|
1757
|
+
function getSilhouetteFilterId(elementId) {
|
|
1758
|
+
return `shape-fx-${elementId.replace(/[^A-Za-z0-9_.-]/gu, "_")}`;
|
|
1759
|
+
}
|
|
1760
|
+
function resolveOuterShadowLayers(style, rotation) {
|
|
1761
|
+
const layers = [];
|
|
1762
|
+
if (style.shadows && style.shadows.length > 0) {
|
|
1763
|
+
for (const shadow of style.shadows) {
|
|
1764
|
+
if (!shadow.color || shadow.color === "transparent") {
|
|
1765
|
+
continue;
|
|
1766
|
+
}
|
|
1767
|
+
const angle = (shadow.angle ?? 0) * Math.PI / 180;
|
|
1768
|
+
const distance = shadow.distance ?? 0;
|
|
1769
|
+
layers.push({
|
|
1770
|
+
offsetX: Math.cos(angle) * distance,
|
|
1771
|
+
offsetY: Math.sin(angle) * distance,
|
|
1772
|
+
blur: Math.max(0, shadow.blur ?? 6),
|
|
1773
|
+
color: hex(shadow.color, DEFAULT_SHADOW),
|
|
1774
|
+
opacity: unit(shadow.opacity ?? 0.35)
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1777
|
+
return layers;
|
|
1778
|
+
}
|
|
1779
|
+
if (!style.shadowColor || style.shadowColor === "transparent") {
|
|
1780
|
+
return layers;
|
|
1781
|
+
}
|
|
1782
|
+
const ooxml = style.outerShadowXml !== void 0;
|
|
1783
|
+
let offsetX;
|
|
1784
|
+
let offsetY;
|
|
1785
|
+
if (finite(style.shadowAngle) && finite(style.shadowDistance)) {
|
|
1786
|
+
const angle = style.shadowRotateWithShape === false && typeof rotation === "number" ? style.shadowAngle - rotation : style.shadowAngle;
|
|
1787
|
+
offsetX = Math.cos(angle * Math.PI / 180) * style.shadowDistance;
|
|
1788
|
+
offsetY = Math.sin(angle * Math.PI / 180) * style.shadowDistance;
|
|
1789
|
+
} else {
|
|
1790
|
+
offsetX = finite(style.shadowOffsetX) ? style.shadowOffsetX : ooxml ? 0 : 4;
|
|
1791
|
+
offsetY = finite(style.shadowOffsetY) ? style.shadowOffsetY : ooxml ? 0 : 4;
|
|
1792
|
+
}
|
|
1793
|
+
const rawBlur = finite(style.shadowBlur) ? Math.max(0, style.shadowBlur) : ooxml ? 0 : 6;
|
|
1794
|
+
layers.push({
|
|
1795
|
+
offsetX,
|
|
1796
|
+
offsetY,
|
|
1797
|
+
blur: ooxml ? shadowBlurToCss(rawBlur) : rawBlur,
|
|
1798
|
+
color: hex(style.shadowColor, DEFAULT_SHADOW),
|
|
1799
|
+
opacity: finite(style.shadowOpacity) ? unit(style.shadowOpacity) : ooxml ? 1 : 0.35
|
|
1800
|
+
});
|
|
1801
|
+
return layers;
|
|
1802
|
+
}
|
|
1803
|
+
function resolveGlow(style) {
|
|
1804
|
+
if (!style.glowColor || style.glowColor === "transparent" || !style.glowRadius) {
|
|
1805
|
+
return void 0;
|
|
1806
|
+
}
|
|
1807
|
+
if (!(style.glowRadius > 0)) {
|
|
1808
|
+
return void 0;
|
|
1809
|
+
}
|
|
1810
|
+
const { spread, blur } = glowCssLengths(style.glowRadius);
|
|
1811
|
+
return {
|
|
1812
|
+
spread,
|
|
1813
|
+
blur,
|
|
1814
|
+
color: hex(style.glowColor, DEFAULT_GLOW),
|
|
1815
|
+
opacity: finite(style.glowOpacity) ? unit(style.glowOpacity) : 0.75
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
function resolveInnerShadow(style) {
|
|
1819
|
+
if (!style.innerShadowColor || style.innerShadowColor === "transparent") {
|
|
1820
|
+
return void 0;
|
|
1821
|
+
}
|
|
1822
|
+
return {
|
|
1823
|
+
offsetX: finite(style.innerShadowOffsetX) ? style.innerShadowOffsetX : 0,
|
|
1824
|
+
offsetY: finite(style.innerShadowOffsetY) ? style.innerShadowOffsetY : 0,
|
|
1825
|
+
blur: shadowBlurToCss(finite(style.innerShadowBlur) ? Math.max(0, style.innerShadowBlur) : 6),
|
|
1826
|
+
color: hex(style.innerShadowColor, DEFAULT_SHADOW),
|
|
1827
|
+
opacity: finite(style.innerShadowOpacity) ? unit(style.innerShadowOpacity) : 0.5
|
|
1828
|
+
};
|
|
1829
|
+
}
|
|
1830
|
+
function paintsNoFill(style) {
|
|
1831
|
+
return !style || !style.fillColor || style.fillColor === "transparent" || style.fillMode === "none";
|
|
1832
|
+
}
|
|
1833
|
+
function overlayCanPaintFill(style) {
|
|
1834
|
+
const mode = style?.fillMode;
|
|
1835
|
+
return mode === void 0 || mode === "solid" || mode === "none";
|
|
1836
|
+
}
|
|
1837
|
+
function isLayerFillMode(style) {
|
|
1838
|
+
const mode = style?.fillMode;
|
|
1839
|
+
return mode === "gradient" || mode === "pattern" || mode === "image";
|
|
1840
|
+
}
|
|
1841
|
+
function getSilhouetteEffectParams(element) {
|
|
1842
|
+
if (element.type !== "shape" || !hasShapeProperties(element)) {
|
|
1843
|
+
return void 0;
|
|
1844
|
+
}
|
|
1845
|
+
const style = element.shapeStyle;
|
|
1846
|
+
if (!style) {
|
|
1847
|
+
return void 0;
|
|
1848
|
+
}
|
|
1849
|
+
const shadows = resolveOuterShadowLayers(style, element.rotation);
|
|
1850
|
+
const glow = resolveGlow(style);
|
|
1851
|
+
const innerShadow = resolveInnerShadow(style);
|
|
1852
|
+
if (shadows.length === 0 && !glow && !innerShadow) {
|
|
1853
|
+
return void 0;
|
|
1854
|
+
}
|
|
1855
|
+
if (style.lineShadowColor || style.lineGlowColor || style.shape3d || style.scene3d) {
|
|
1856
|
+
return void 0;
|
|
1857
|
+
}
|
|
1858
|
+
const layerFill = isLayerFillMode(style);
|
|
1859
|
+
if (!layerFill && !overlayCanPaintFill(style)) {
|
|
1860
|
+
return void 0;
|
|
1861
|
+
}
|
|
1862
|
+
const geometry = resolveBaseShapeGeometry(element);
|
|
1863
|
+
if (layerFill && geometry.kind !== "clipPath") {
|
|
1864
|
+
return void 0;
|
|
1865
|
+
}
|
|
1866
|
+
if (geometry.kind === "bare" || geometry.kind === "strokeOnly" || geometry.kind === "lineEdge") {
|
|
1867
|
+
return void 0;
|
|
1868
|
+
}
|
|
1869
|
+
const translucent = typeof style.fillOpacity === "number" && style.fillOpacity < 0.999;
|
|
1870
|
+
if (geometry.kind !== "clipPath" && !paintsNoFill(style) && !translucent) {
|
|
1871
|
+
return void 0;
|
|
1872
|
+
}
|
|
1873
|
+
if (geometry.kind === "clipPath" && !layerFill && !paintsNoFill(style) && !getSubpathGeometry(element, true)) {
|
|
1874
|
+
return void 0;
|
|
1875
|
+
}
|
|
1876
|
+
const inner = innerShadow && geometry.kind === "clipPath" && !paintsNoFill(style) ? innerShadow : void 0;
|
|
1877
|
+
if (shadows.length === 0 && !glow && !inner) {
|
|
1878
|
+
return void 0;
|
|
1879
|
+
}
|
|
1880
|
+
return { shadows, ...glow ? { glow } : {}, ...inner ? { inner } : {} };
|
|
1881
|
+
}
|
|
1882
|
+
function px(value) {
|
|
1883
|
+
return String(Math.round(value * 100) / 100);
|
|
1884
|
+
}
|
|
1885
|
+
function scaledAlpha(input, result, opacity) {
|
|
1886
|
+
return `<feComponentTransfer in="${input}" result="${result}"><feFuncA type="linear" slope="${px(opacity)}"/></feComponentTransfer>`;
|
|
1887
|
+
}
|
|
1888
|
+
var MORPH_PROGRESS_VAR = "--pptx-morph-p";
|
|
1889
|
+
function flood(color, result, opacity, side) {
|
|
1890
|
+
if (!side) {
|
|
1891
|
+
return `<feFlood flood-color="${color}" result="${result}"/>`;
|
|
1892
|
+
}
|
|
1893
|
+
const k = side === "out" ? `(1 - var(${MORPH_PROGRESS_VAR}, 1))` : `var(${MORPH_PROGRESS_VAR}, 1)`;
|
|
1894
|
+
return `<feFlood flood-color="${color}" flood-opacity="${side === "out" ? 0 : px(opacity)}" style="flood-opacity:calc(${px(opacity)} * ${k})" result="${result}"/>`;
|
|
1895
|
+
}
|
|
1896
|
+
function alpha(input, result, opacity, side) {
|
|
1897
|
+
return side ? { markup: "", mask: input } : { markup: scaledAlpha(input, result, opacity), mask: result };
|
|
1898
|
+
}
|
|
1899
|
+
function glowMarkup(glow, tag, side) {
|
|
1900
|
+
const parts = [];
|
|
1901
|
+
const names = [];
|
|
1902
|
+
const ring = (radius, steps, ringTag) => {
|
|
1903
|
+
for (let i = 0; i < steps; i++) {
|
|
1904
|
+
const angle = 2 * Math.PI * i / steps;
|
|
1905
|
+
const name = `${tag}${ringTag}${i}`;
|
|
1906
|
+
names.push(name);
|
|
1907
|
+
parts.push(
|
|
1908
|
+
`<feOffset in="SourceAlpha" dx="${px(Math.cos(angle) * radius)}" dy="${px(Math.sin(angle) * radius)}" result="${name}"/>`
|
|
1909
|
+
);
|
|
1910
|
+
}
|
|
1911
|
+
};
|
|
1912
|
+
if (glow.spread > 0.01) {
|
|
1913
|
+
ring(glow.spread, GLOW_RING_STEPS, "gr");
|
|
1914
|
+
ring(glow.spread / 2, GLOW_INNER_RING_STEPS, "gi");
|
|
1915
|
+
}
|
|
1916
|
+
const merge = [
|
|
1917
|
+
...names.map((n) => `<feMergeNode in="${n}"/>`),
|
|
1918
|
+
'<feMergeNode in="SourceAlpha"/>'
|
|
1919
|
+
];
|
|
1920
|
+
parts.push(`<feMerge result="${tag}glowGrown">${merge.join("")}</feMerge>`);
|
|
1921
|
+
parts.push(
|
|
1922
|
+
`<feGaussianBlur in="${tag}glowGrown" stdDeviation="${px(glow.blur / 2)}" result="${tag}glowBlur"/>`
|
|
1923
|
+
);
|
|
1924
|
+
const scaled = alpha(`${tag}glowBlur`, `${tag}glowMask`, glow.opacity, side);
|
|
1925
|
+
parts.push(
|
|
1926
|
+
scaled.markup,
|
|
1927
|
+
flood(glow.color, `${tag}glowColor`, glow.opacity, side),
|
|
1928
|
+
`<feComposite in="${tag}glowColor" in2="${scaled.mask}" operator="in" result="${tag}glowLayer"/>`
|
|
1929
|
+
);
|
|
1930
|
+
return parts.join("");
|
|
1931
|
+
}
|
|
1932
|
+
function effectReach(params) {
|
|
1933
|
+
let reach = 0;
|
|
1934
|
+
for (const s of params.shadows) {
|
|
1935
|
+
reach = Math.max(reach, Math.hypot(s.offsetX, s.offsetY) + 1.5 * s.blur);
|
|
1936
|
+
}
|
|
1937
|
+
if (params.glow) {
|
|
1938
|
+
reach = Math.max(reach, params.glow.spread + 1.5 * params.glow.blur);
|
|
1939
|
+
}
|
|
1940
|
+
if (params.inner) {
|
|
1941
|
+
reach = Math.max(
|
|
1942
|
+
reach,
|
|
1943
|
+
Math.hypot(params.inner.offsetX, params.inner.offsetY) + 1.5 * params.inner.blur
|
|
1944
|
+
);
|
|
1945
|
+
}
|
|
1946
|
+
return reach;
|
|
1947
|
+
}
|
|
1948
|
+
function effectLayers(params, tag, side) {
|
|
1949
|
+
const out = { parts: [], glow: [], shadows: [], inner: [] };
|
|
1950
|
+
if (params.glow) {
|
|
1951
|
+
out.parts.push(glowMarkup(params.glow, tag, side));
|
|
1952
|
+
out.glow.push(`${tag}glowLayer`);
|
|
1953
|
+
}
|
|
1954
|
+
params.shadows.forEach((s, i) => {
|
|
1955
|
+
const name = `${tag}shadow${i}`;
|
|
1956
|
+
const scaled = alpha(`${name}Off`, `${name}Mask`, s.opacity, side);
|
|
1957
|
+
out.parts.push(
|
|
1958
|
+
`<feGaussianBlur in="SourceAlpha" stdDeviation="${px(s.blur / 2)}" result="${name}Blur"/>`,
|
|
1959
|
+
`<feOffset in="${name}Blur" dx="${px(s.offsetX)}" dy="${px(s.offsetY)}" result="${name}Off"/>`,
|
|
1960
|
+
scaled.markup,
|
|
1961
|
+
flood(s.color, `${name}Color`, s.opacity, side),
|
|
1962
|
+
`<feComposite in="${name}Color" in2="${scaled.mask}" operator="in" result="${name}"/>`
|
|
1963
|
+
);
|
|
1964
|
+
out.shadows.push(name);
|
|
1965
|
+
});
|
|
1966
|
+
if (params.inner) {
|
|
1967
|
+
const i = params.inner;
|
|
1968
|
+
const name = `${tag}inner`;
|
|
1969
|
+
const scaled = alpha(`${name}Blur`, `${name}Mask`, i.opacity, side);
|
|
1970
|
+
out.parts.push(
|
|
1971
|
+
`<feComponentTransfer in="SourceAlpha" result="${name}Inv"><feFuncA type="table" tableValues="1 0"/></feComponentTransfer>`,
|
|
1972
|
+
`<feOffset in="${name}Inv" dx="${px(-i.offsetX)}" dy="${px(-i.offsetY)}" result="${name}Off"/>`,
|
|
1973
|
+
`<feGaussianBlur in="${name}Off" stdDeviation="${px(i.blur / 2)}" result="${name}Blur"/>`,
|
|
1974
|
+
scaled.markup,
|
|
1975
|
+
flood(i.color, `${name}Flood`, i.opacity, side),
|
|
1976
|
+
`<feComposite in="${name}Flood" in2="${scaled.mask}" operator="in" result="${name}Color"/>`,
|
|
1977
|
+
`<feComposite in="${name}Color" in2="SourceAlpha" operator="in" result="${name}Layer"/>`
|
|
1978
|
+
);
|
|
1979
|
+
out.inner.push(`${name}Layer`);
|
|
1980
|
+
}
|
|
1981
|
+
return out;
|
|
1982
|
+
}
|
|
1983
|
+
function pairLayers(a, b, tag, parts) {
|
|
1984
|
+
const names = [];
|
|
1985
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
1986
|
+
const x = a[i];
|
|
1987
|
+
const y = b[i];
|
|
1988
|
+
if (x && y) {
|
|
1989
|
+
parts.push(
|
|
1990
|
+
`<feComposite in="${x}" in2="${y}" operator="arithmetic" k1="0" k2="1" k3="1" k4="0" result="${tag}${i}"/>`
|
|
1991
|
+
);
|
|
1992
|
+
names.push(`${tag}${i}`);
|
|
1993
|
+
} else {
|
|
1994
|
+
names.push(x ?? y);
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
return names;
|
|
1998
|
+
}
|
|
1999
|
+
function buildSilhouetteFilterMarkup(filterId, width, height, params, outgoing) {
|
|
2000
|
+
const pad = Math.ceil(Math.max(effectReach(params), outgoing ? effectReach(outgoing) : 0)) + 4;
|
|
2001
|
+
const parts = [
|
|
2002
|
+
`<filter id="${filterId}" filterUnits="userSpaceOnUse" x="${-pad}" y="${-pad}" width="${px(Math.max(width, 1) + 2 * pad)}" height="${px(Math.max(height, 1) + 2 * pad)}" color-interpolation-filters="sRGB">`
|
|
2003
|
+
];
|
|
2004
|
+
const into = effectLayers(params, "", outgoing ? "in" : void 0);
|
|
2005
|
+
parts.push(...into.parts);
|
|
2006
|
+
let { glow, shadows, inner } = into;
|
|
2007
|
+
if (outgoing) {
|
|
2008
|
+
const out = effectLayers(outgoing, "o", "out");
|
|
2009
|
+
parts.push(...out.parts);
|
|
2010
|
+
glow = pairLayers(out.glow, into.glow, "sumglow", parts);
|
|
2011
|
+
shadows = pairLayers(out.shadows, into.shadows, "sumshadow", parts);
|
|
2012
|
+
inner = pairLayers(out.inner, into.inner, "suminner", parts);
|
|
2013
|
+
}
|
|
2014
|
+
const stack = [...glow, ...[...shadows].reverse()];
|
|
2015
|
+
parts.push(
|
|
2016
|
+
`<feMerge>${[...stack, "SourceGraphic", ...inner].map((n) => `<feMergeNode in="${n}"/>`).join("")}</feMerge>`,
|
|
2017
|
+
"</filter>"
|
|
2018
|
+
);
|
|
2019
|
+
return parts.join("");
|
|
2020
|
+
}
|
|
2021
|
+
function getSilhouetteEffects(element) {
|
|
2022
|
+
const params = getSilhouetteEffectParams(element);
|
|
2023
|
+
if (!params) {
|
|
2024
|
+
return void 0;
|
|
2025
|
+
}
|
|
2026
|
+
const filterId = getSilhouetteFilterId(element.id);
|
|
2027
|
+
return {
|
|
2028
|
+
filterId,
|
|
2029
|
+
cssReference: `url(#${filterId})`,
|
|
2030
|
+
filterMarkup: buildSilhouetteFilterMarkup(
|
|
2031
|
+
filterId,
|
|
2032
|
+
element.width,
|
|
2033
|
+
element.height,
|
|
2034
|
+
params,
|
|
2035
|
+
silhouetteMorphFor(element.id, params)
|
|
2036
|
+
),
|
|
2037
|
+
paintsInnerShadow: params.inner !== void 0
|
|
2038
|
+
};
|
|
2039
|
+
}
|
|
2040
|
+
function silhouetteFillsOverlay(element) {
|
|
2041
|
+
if (!usesSilhouetteEffects(element) || !hasShapeProperties(element)) {
|
|
2042
|
+
return false;
|
|
2043
|
+
}
|
|
2044
|
+
return resolveBaseShapeGeometry(element).kind === "clipPath" && !paintsNoFill(element.shapeStyle) && !isLayerFillMode(element.shapeStyle);
|
|
2045
|
+
}
|
|
2046
|
+
function silhouetteFillsLayer(element) {
|
|
2047
|
+
return hasShapeProperties(element) && isLayerFillMode(element.shapeStyle) && usesSilhouetteEffects(element);
|
|
2048
|
+
}
|
|
2049
|
+
function usesSilhouetteEffects(element) {
|
|
2050
|
+
return getSilhouetteEffectParams(element) !== void 0;
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
// src/pptx/render/visual-effects.ts
|
|
2054
|
+
var DEFAULT_SHADOW_COLOR = "#000000";
|
|
2055
|
+
var DEFAULT_GLOW_COLOR = "#ffff00";
|
|
2056
|
+
function escapeSvgAttr(value) {
|
|
2057
|
+
return String(value).replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
2058
|
+
}
|
|
2059
|
+
function clampUnitInterval(value) {
|
|
2060
|
+
return Math.min(1, Math.max(0, value));
|
|
2061
|
+
}
|
|
2062
|
+
function normalizeHexColor2(value, fallback) {
|
|
2063
|
+
if (!value || value === "transparent") {
|
|
2064
|
+
return fallback;
|
|
2065
|
+
}
|
|
2066
|
+
const candidate = value.startsWith("#") ? value : `#${value}`;
|
|
2067
|
+
return /^#[0-9A-Fa-f]{6}$/u.test(candidate) ? candidate : fallback;
|
|
2068
|
+
}
|
|
2069
|
+
function hexToRgbChannels(color) {
|
|
2070
|
+
const normalized = color.replace("#", "");
|
|
2071
|
+
if (!/^[0-9a-fA-F]{6}$/u.test(normalized)) {
|
|
2072
|
+
return null;
|
|
2073
|
+
}
|
|
2074
|
+
return {
|
|
2075
|
+
r: Number.parseInt(normalized.slice(0, 2), 16),
|
|
2076
|
+
g: Number.parseInt(normalized.slice(2, 4), 16),
|
|
2077
|
+
b: Number.parseInt(normalized.slice(4, 6), 16)
|
|
2078
|
+
};
|
|
2079
|
+
}
|
|
2080
|
+
function colorWithOpacity2(color, opacity) {
|
|
2081
|
+
if (opacity === void 0) {
|
|
2082
|
+
return color;
|
|
2083
|
+
}
|
|
2084
|
+
const rgb = hexToRgbChannels(color);
|
|
2085
|
+
if (!rgb) {
|
|
2086
|
+
return color;
|
|
2087
|
+
}
|
|
2088
|
+
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${clampUnitInterval(opacity)})`;
|
|
2089
|
+
}
|
|
2090
|
+
function getOuterShadowCss(style, context) {
|
|
2091
|
+
if (!style?.shadowColor || style.shadowColor === "transparent") {
|
|
2092
|
+
return void 0;
|
|
2093
|
+
}
|
|
2094
|
+
const usesOoxmlDefaults = style.outerShadowXml !== void 0;
|
|
2095
|
+
let offsetX;
|
|
2096
|
+
let offsetY;
|
|
2097
|
+
if (typeof style.shadowAngle === "number" && typeof style.shadowDistance === "number") {
|
|
2098
|
+
const angle = style.shadowRotateWithShape === false && typeof context?.rotation === "number" ? style.shadowAngle - context.rotation : style.shadowAngle;
|
|
2099
|
+
const angleRad = angle * Math.PI / 180;
|
|
2100
|
+
offsetX = Math.cos(angleRad) * style.shadowDistance;
|
|
2101
|
+
offsetY = Math.sin(angleRad) * style.shadowDistance;
|
|
2102
|
+
} else {
|
|
2103
|
+
offsetX = typeof style.shadowOffsetX === "number" && Number.isFinite(style.shadowOffsetX) ? style.shadowOffsetX : usesOoxmlDefaults ? 0 : 4;
|
|
2104
|
+
offsetY = typeof style.shadowOffsetY === "number" && Number.isFinite(style.shadowOffsetY) ? style.shadowOffsetY : usesOoxmlDefaults ? 0 : 4;
|
|
2105
|
+
}
|
|
2106
|
+
const rawBlur = typeof style.shadowBlur === "number" && Number.isFinite(style.shadowBlur) ? Math.max(0, style.shadowBlur) : usesOoxmlDefaults ? 0 : 6;
|
|
2107
|
+
const blur = usesOoxmlDefaults ? shadowBlurToCss(rawBlur) : rawBlur;
|
|
2108
|
+
const opacity = typeof style.shadowOpacity === "number" && Number.isFinite(style.shadowOpacity) ? clampUnitInterval(style.shadowOpacity) : usesOoxmlDefaults ? 1 : 0.35;
|
|
2109
|
+
const spread = getShadowScaleSpread(style.shadowScaleX, style.shadowScaleY, blur);
|
|
2110
|
+
const color = colorWithOpacity2(
|
|
2111
|
+
normalizeHexColor2(style.shadowColor, DEFAULT_SHADOW_COLOR),
|
|
2112
|
+
opacity
|
|
2113
|
+
);
|
|
2114
|
+
const geometry = `${Math.round(offsetX)}px ${Math.round(offsetY)}px ${Math.round(blur)}px`;
|
|
2115
|
+
return spread === 0 ? `${geometry} ${color}` : `${geometry} ${spread}px ${color}`;
|
|
2116
|
+
}
|
|
2117
|
+
function getCompositeOuterShadowFilterCss(style, context) {
|
|
2118
|
+
if (!style) {
|
|
2119
|
+
return void 0;
|
|
2120
|
+
}
|
|
2121
|
+
const usesOoxmlDefaults = style.outerShadowXml !== void 0;
|
|
2122
|
+
const shadows = style.shadows && style.shadows.length > 0 ? style.shadows : style.shadowColor && style.shadowColor !== "transparent" ? [
|
|
2123
|
+
{
|
|
2124
|
+
angle: style.shadowAngle,
|
|
2125
|
+
distance: style.shadowDistance,
|
|
2126
|
+
offsetX: style.shadowOffsetX,
|
|
2127
|
+
offsetY: style.shadowOffsetY,
|
|
2128
|
+
blur: style.shadowBlur,
|
|
2129
|
+
color: style.shadowColor,
|
|
2130
|
+
opacity: style.shadowOpacity
|
|
2131
|
+
}
|
|
2132
|
+
] : [];
|
|
2133
|
+
const parts = [];
|
|
2134
|
+
for (const shadow of shadows) {
|
|
2135
|
+
if (!shadow.color || shadow.color === "transparent") {
|
|
2136
|
+
continue;
|
|
2137
|
+
}
|
|
2138
|
+
let offsetX;
|
|
2139
|
+
let offsetY;
|
|
2140
|
+
if (typeof shadow.angle === "number" && typeof shadow.distance === "number") {
|
|
2141
|
+
const angle = style.shadowRotateWithShape === false && typeof context?.rotation === "number" ? shadow.angle - context.rotation : shadow.angle;
|
|
2142
|
+
const angleRad = angle * Math.PI / 180;
|
|
2143
|
+
offsetX = Math.cos(angleRad) * shadow.distance;
|
|
2144
|
+
offsetY = Math.sin(angleRad) * shadow.distance;
|
|
2145
|
+
} else {
|
|
2146
|
+
offsetX = typeof shadow.offsetX === "number" && Number.isFinite(shadow.offsetX) ? shadow.offsetX : usesOoxmlDefaults ? 0 : 4;
|
|
2147
|
+
offsetY = typeof shadow.offsetY === "number" && Number.isFinite(shadow.offsetY) ? shadow.offsetY : usesOoxmlDefaults ? 0 : 4;
|
|
2148
|
+
}
|
|
2149
|
+
const rawBlur = typeof shadow.blur === "number" && Number.isFinite(shadow.blur) ? Math.max(0, shadow.blur) : usesOoxmlDefaults ? 0 : 6;
|
|
2150
|
+
const blur = usesOoxmlDefaults ? shadowBlurToCss(rawBlur) : rawBlur;
|
|
2151
|
+
const opacity = typeof shadow.opacity === "number" && Number.isFinite(shadow.opacity) ? clampUnitInterval(shadow.opacity) : usesOoxmlDefaults ? 1 : 0.35;
|
|
2152
|
+
const color = colorWithOpacity2(normalizeHexColor2(shadow.color, DEFAULT_SHADOW_COLOR), opacity);
|
|
2153
|
+
parts.push(
|
|
2154
|
+
`drop-shadow(${Math.round(offsetX)}px ${Math.round(offsetY)}px ${Math.round(blur)}px ${color})`
|
|
2155
|
+
);
|
|
2156
|
+
}
|
|
2157
|
+
return parts.length > 0 ? parts.join(" ") : void 0;
|
|
2158
|
+
}
|
|
2159
|
+
function getShadowScaleSpread(scaleX, scaleY, blur) {
|
|
2160
|
+
const sx = typeof scaleX === "number" && Number.isFinite(scaleX) ? scaleX / 1e5 : 1;
|
|
2161
|
+
const sy = typeof scaleY === "number" && Number.isFinite(scaleY) ? scaleY / 1e5 : 1;
|
|
2162
|
+
const avgScale = (sx + sy) / 2;
|
|
2163
|
+
if (avgScale === 1) {
|
|
2164
|
+
return 0;
|
|
2165
|
+
}
|
|
2166
|
+
const base = Math.max(blur, 4);
|
|
2167
|
+
return Math.round(base * (avgScale - 1));
|
|
2168
|
+
}
|
|
2169
|
+
function getInnerShadowCss(style) {
|
|
2170
|
+
if (!style?.innerShadowColor || style.innerShadowColor === "transparent") {
|
|
2171
|
+
return void 0;
|
|
2172
|
+
}
|
|
2173
|
+
const offsetX = typeof style.innerShadowOffsetX === "number" && Number.isFinite(style.innerShadowOffsetX) ? style.innerShadowOffsetX : 0;
|
|
2174
|
+
const offsetY = typeof style.innerShadowOffsetY === "number" && Number.isFinite(style.innerShadowOffsetY) ? style.innerShadowOffsetY : 0;
|
|
2175
|
+
const blur = typeof style.innerShadowBlur === "number" && Number.isFinite(style.innerShadowBlur) ? Math.max(0, style.innerShadowBlur) : 6;
|
|
2176
|
+
const opacity = typeof style.innerShadowOpacity === "number" && Number.isFinite(style.innerShadowOpacity) ? clampUnitInterval(style.innerShadowOpacity) : 0.5;
|
|
2177
|
+
return `inset ${Math.round(-offsetX) + 0}px ${Math.round(-offsetY) + 0}px ${Math.round(shadowBlurToCss(blur))}px ${colorWithOpacity2(
|
|
2178
|
+
normalizeHexColor2(style.innerShadowColor, DEFAULT_SHADOW_COLOR),
|
|
2179
|
+
opacity
|
|
2180
|
+
)}`;
|
|
2181
|
+
}
|
|
2182
|
+
function getMultiLayerShadowCss(style) {
|
|
2183
|
+
if (!style?.shadows || style.shadows.length === 0) {
|
|
2184
|
+
return void 0;
|
|
2185
|
+
}
|
|
2186
|
+
const parts = [];
|
|
2187
|
+
for (const shadow of style.shadows) {
|
|
2188
|
+
if (!shadow.color || shadow.color === "transparent") {
|
|
2189
|
+
continue;
|
|
2190
|
+
}
|
|
2191
|
+
const angleRad = (shadow.angle ?? 0) * Math.PI / 180;
|
|
2192
|
+
const dist = shadow.distance ?? 0;
|
|
2193
|
+
const offsetX = Math.round(Math.cos(angleRad) * dist);
|
|
2194
|
+
const offsetY = Math.round(Math.sin(angleRad) * dist);
|
|
2195
|
+
const blur = Math.round(Math.max(0, shadow.blur ?? 6));
|
|
2196
|
+
const opacity = clampUnitInterval(shadow.opacity ?? 0.35);
|
|
2197
|
+
const color = colorWithOpacity2(normalizeHexColor2(shadow.color, DEFAULT_SHADOW_COLOR), opacity);
|
|
2198
|
+
parts.push(`${offsetX}px ${offsetY}px ${blur}px ${color}`);
|
|
2199
|
+
}
|
|
2200
|
+
return parts.length > 0 ? parts.join(", ") : void 0;
|
|
2201
|
+
}
|
|
2202
|
+
function getGlowBoxShadowCss(color, radius, opacity) {
|
|
2203
|
+
if (!color || color === "transparent" || !radius || radius <= 0) {
|
|
2204
|
+
return void 0;
|
|
2205
|
+
}
|
|
2206
|
+
const baseOpacity = typeof opacity === "number" ? clampUnitInterval(opacity) : 0.75;
|
|
2207
|
+
const normalizedColor = normalizeHexColor2(color, DEFAULT_GLOW_COLOR);
|
|
2208
|
+
const { spread, blur } = glowCssLengths(radius);
|
|
2209
|
+
const glowColor = colorWithOpacity2(normalizedColor, baseOpacity);
|
|
2210
|
+
return `0 0 ${Math.round(blur * 10) / 10}px ${Math.round(spread * 10) / 10}px ${glowColor}`;
|
|
2211
|
+
}
|
|
2212
|
+
function getBoxShadowCss(style, options = {}, context) {
|
|
2213
|
+
if (!style) {
|
|
2214
|
+
return void 0;
|
|
2215
|
+
}
|
|
2216
|
+
const parts = [];
|
|
2217
|
+
const multiLayer = options.includeOuter === false ? void 0 : getMultiLayerShadowCss(style);
|
|
2218
|
+
if (multiLayer) {
|
|
2219
|
+
parts.push(multiLayer);
|
|
2220
|
+
} else if (options.includeOuter !== false) {
|
|
2221
|
+
const outer = getOuterShadowCss(style, context);
|
|
2222
|
+
if (outer) {
|
|
2223
|
+
parts.push(outer);
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
const inner = options.includeInner === false ? void 0 : getInnerShadowCss(style);
|
|
2227
|
+
if (inner) {
|
|
2228
|
+
parts.push(inner);
|
|
2229
|
+
}
|
|
2230
|
+
if (options.includeGlow !== false) {
|
|
2231
|
+
const glow = getGlowBoxShadowCss(style.glowColor, style.glowRadius, style.glowOpacity);
|
|
2232
|
+
if (glow) {
|
|
2233
|
+
parts.push(glow);
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
return parts.length > 0 ? parts.join(", ") : void 0;
|
|
2237
|
+
}
|
|
2238
|
+
var buildShadowCssFromShapeStyle = getOuterShadowCss;
|
|
2239
|
+
var buildInnerShadowCssFromShapeStyle = getInnerShadowCss;
|
|
2240
|
+
var buildMultiLayerShadowCss = getMultiLayerShadowCss;
|
|
2241
|
+
var buildGlowBoxShadow = getGlowBoxShadowCss;
|
|
2242
|
+
function getLineShadowParams(style) {
|
|
2243
|
+
if (!style?.lineShadowColor || style.lineShadowColor === "transparent") {
|
|
2244
|
+
return void 0;
|
|
2245
|
+
}
|
|
2246
|
+
return {
|
|
2247
|
+
offsetX: typeof style.lineShadowOffsetX === "number" ? style.lineShadowOffsetX : 2,
|
|
2248
|
+
offsetY: typeof style.lineShadowOffsetY === "number" ? style.lineShadowOffsetY : 2,
|
|
2249
|
+
blur: typeof style.lineShadowBlur === "number" ? Math.max(0, style.lineShadowBlur) : 4,
|
|
2250
|
+
color: normalizeHexColor2(style.lineShadowColor, DEFAULT_SHADOW_COLOR),
|
|
2251
|
+
opacity: typeof style.lineShadowOpacity === "number" ? clampUnitInterval(style.lineShadowOpacity) : 0.35
|
|
2252
|
+
};
|
|
2253
|
+
}
|
|
2254
|
+
function getLineShadowCss(style) {
|
|
2255
|
+
const p = getLineShadowParams(style);
|
|
2256
|
+
if (!p) {
|
|
2257
|
+
return void 0;
|
|
2258
|
+
}
|
|
2259
|
+
return `${Math.round(p.offsetX)}px ${Math.round(p.offsetY)}px ${Math.round(
|
|
2260
|
+
p.blur
|
|
2261
|
+
)}px ${colorWithOpacity2(p.color, p.opacity)}`;
|
|
2262
|
+
}
|
|
2263
|
+
function getLineGlowFilterCss(style) {
|
|
2264
|
+
if (!style?.lineGlowColor || style.lineGlowColor === "transparent" || !style.lineGlowRadius) {
|
|
2265
|
+
return void 0;
|
|
2266
|
+
}
|
|
2267
|
+
const glowOpacity = typeof style.lineGlowOpacity === "number" ? style.lineGlowOpacity : 0.75;
|
|
2268
|
+
const glowRad = Math.round(Math.max(0, style.lineGlowRadius));
|
|
2269
|
+
const glowCol = colorWithOpacity2(
|
|
2270
|
+
normalizeHexColor2(style.lineGlowColor, DEFAULT_GLOW_COLOR),
|
|
2271
|
+
glowOpacity
|
|
2272
|
+
);
|
|
2273
|
+
return `drop-shadow(0 0 ${glowRad}px ${glowCol})`;
|
|
2274
|
+
}
|
|
2275
|
+
var buildLineShadowCss = getLineShadowCss;
|
|
2276
|
+
var buildLineGlowFilter = getLineGlowFilterCss;
|
|
2277
|
+
function getEffectDagCssFilter(style, elementId) {
|
|
2278
|
+
if (!style) {
|
|
2279
|
+
return void 0;
|
|
2280
|
+
}
|
|
2281
|
+
const filters = [];
|
|
2282
|
+
if (style.dagGrayscale) {
|
|
2283
|
+
filters.push("grayscale(1)");
|
|
2284
|
+
}
|
|
2285
|
+
if (typeof style.dagBiLevel === "number") {
|
|
2286
|
+
const thresh = Math.max(0, Math.min(100, style.dagBiLevel));
|
|
2287
|
+
filters.push(thresh > 50 ? "contrast(1000)" : "contrast(0.01)");
|
|
2288
|
+
}
|
|
2289
|
+
if (typeof style.dagLumBrightness === "number" || typeof style.dagLumContrast === "number") {
|
|
2290
|
+
const bright = style.dagLumBrightness ?? 0;
|
|
2291
|
+
const contrast = style.dagLumContrast ?? 0;
|
|
2292
|
+
if (bright !== 0) {
|
|
2293
|
+
filters.push(`brightness(${1 + bright / 100})`);
|
|
2294
|
+
}
|
|
2295
|
+
if (contrast !== 0) {
|
|
2296
|
+
filters.push(`contrast(${1 + contrast / 100})`);
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
if (typeof style.dagHslHue === "number" && style.dagHslHue !== 0) {
|
|
2300
|
+
filters.push(`hue-rotate(${style.dagHslHue}deg)`);
|
|
2301
|
+
}
|
|
2302
|
+
if (typeof style.dagHslSaturation === "number" && style.dagHslSaturation !== 100) {
|
|
2303
|
+
filters.push(`saturate(${style.dagHslSaturation / 100})`);
|
|
2304
|
+
}
|
|
2305
|
+
if (typeof style.dagHslLuminance === "number" && style.dagHslLuminance !== 0) {
|
|
2306
|
+
filters.push(`brightness(${1 + style.dagHslLuminance / 100})`);
|
|
2307
|
+
}
|
|
2308
|
+
if (typeof style.dagAlphaModFix === "number") {
|
|
2309
|
+
const alpha2 = clampUnitInterval(style.dagAlphaModFix / 100);
|
|
2310
|
+
filters.push(`opacity(${alpha2})`);
|
|
2311
|
+
}
|
|
2312
|
+
if (typeof style.dagTintHue === "number" || typeof style.dagTintAmount === "number") {
|
|
2313
|
+
const hue = style.dagTintHue ?? 0;
|
|
2314
|
+
const amt = Math.max(0, Math.min(100, style.dagTintAmount ?? 50));
|
|
2315
|
+
filters.push(`sepia(${amt / 100}) hue-rotate(${hue}deg)`);
|
|
2316
|
+
}
|
|
2317
|
+
if (style.dagDuotone && elementId) {
|
|
2318
|
+
filters.push(`url(#${getDuotoneFilterId(elementId)})`);
|
|
2319
|
+
}
|
|
2320
|
+
return filters.length > 0 ? filters.join(" ") : void 0;
|
|
2321
|
+
}
|
|
2322
|
+
var getEffectDagFilter = getEffectDagCssFilter;
|
|
2323
|
+
function hasEffectDagProperties(style) {
|
|
2324
|
+
if (!style) {
|
|
2325
|
+
return false;
|
|
2326
|
+
}
|
|
2327
|
+
return Boolean(
|
|
2328
|
+
style.dagGrayscale || typeof style.dagBiLevel === "number" || typeof style.dagLumBrightness === "number" || typeof style.dagLumContrast === "number" || typeof style.dagHslHue === "number" || typeof style.dagHslSaturation === "number" || typeof style.dagHslLuminance === "number" || typeof style.dagAlphaModFix === "number" || typeof style.dagTintHue === "number" || typeof style.dagTintAmount === "number" || style.dagDuotone || style.dagFillOverlayBlend || style.dagFillOverlayColor
|
|
2329
|
+
);
|
|
2330
|
+
}
|
|
2331
|
+
function getEffectFilterCss(style, elementId, options = {}) {
|
|
2332
|
+
if (!style) {
|
|
2333
|
+
return void 0;
|
|
2334
|
+
}
|
|
2335
|
+
const parts = [];
|
|
2336
|
+
if (options.glow !== false && style.glowColor && style.glowColor !== "transparent" && style.glowRadius) {
|
|
2337
|
+
const glowOpacity = typeof style.glowOpacity === "number" ? style.glowOpacity : 0.75;
|
|
2338
|
+
const glowCol = colorWithOpacity2(
|
|
2339
|
+
normalizeHexColor2(style.glowColor, DEFAULT_GLOW_COLOR),
|
|
2340
|
+
glowOpacity
|
|
2341
|
+
);
|
|
2342
|
+
for (const blur of glowFilterLengths(style.glowRadius)) {
|
|
2343
|
+
parts.push(`drop-shadow(0 0 ${blur}px ${glowCol})`);
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
if (typeof style.softEdgeRadius === "number" && style.softEdgeRadius > 0) {
|
|
2347
|
+
if (elementId) {
|
|
2348
|
+
parts.push(`url(#${getSoftEdgeFilterId(elementId)})`);
|
|
2349
|
+
} else {
|
|
2350
|
+
parts.push(`blur(${Math.min(2, Math.round(style.softEdgeRadius))}px)`);
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
if (typeof style.blurRadius === "number" && style.blurRadius > 0) {
|
|
2354
|
+
parts.push(`blur(${Math.round(style.blurRadius)}px)`);
|
|
2355
|
+
}
|
|
2356
|
+
const dagFilter = getEffectDagCssFilter(style, elementId);
|
|
2357
|
+
if (dagFilter) {
|
|
2358
|
+
parts.push(dagFilter);
|
|
2359
|
+
}
|
|
2360
|
+
return parts.length > 0 ? parts.join(" ") : void 0;
|
|
2361
|
+
}
|
|
2362
|
+
function getEffectDagOpacity(style) {
|
|
2363
|
+
if (!style || typeof style.dagAlphaModFix !== "number") {
|
|
2364
|
+
return void 0;
|
|
2365
|
+
}
|
|
2366
|
+
return clampUnitInterval(style.dagAlphaModFix / 100);
|
|
2367
|
+
}
|
|
2368
|
+
function getEffectDagBlendMode(blend) {
|
|
2369
|
+
switch (blend) {
|
|
2370
|
+
case "mult":
|
|
2371
|
+
return "multiply";
|
|
2372
|
+
case "screen":
|
|
2373
|
+
return "screen";
|
|
2374
|
+
case "darken":
|
|
2375
|
+
return "darken";
|
|
2376
|
+
case "lighten":
|
|
2377
|
+
return "lighten";
|
|
2378
|
+
default:
|
|
2379
|
+
return void 0;
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
function getEffectDagFillOverlay(style) {
|
|
2383
|
+
if (!style?.dagFillOverlayColor || style.dagFillOverlayColor === "transparent") {
|
|
2384
|
+
return void 0;
|
|
2385
|
+
}
|
|
2386
|
+
const blendMode = getEffectDagBlendMode(style.dagFillOverlayBlend) ?? "normal";
|
|
2387
|
+
const color = colorWithOpacity2(
|
|
2388
|
+
normalizeHexColor2(style.dagFillOverlayColor, DEFAULT_SHADOW_COLOR),
|
|
2389
|
+
style.dagFillOverlayOpacity
|
|
2390
|
+
);
|
|
2391
|
+
return { color, blendMode };
|
|
2392
|
+
}
|
|
2393
|
+
function getShapeFillOverlay(style) {
|
|
2394
|
+
if (!style?.shapeFillOverlayColor || style.shapeFillOverlayColor === "transparent") {
|
|
2395
|
+
return void 0;
|
|
2396
|
+
}
|
|
2397
|
+
const blendMode = getEffectDagBlendMode(style.shapeFillOverlayBlend) ?? "normal";
|
|
2398
|
+
const color = colorWithOpacity2(
|
|
2399
|
+
normalizeHexColor2(style.shapeFillOverlayColor, DEFAULT_SHADOW_COLOR),
|
|
2400
|
+
style.shapeFillOverlayOpacity
|
|
2401
|
+
);
|
|
2402
|
+
return { color, blendMode };
|
|
2403
|
+
}
|
|
2404
|
+
function getDuotoneFilterId(elementId) {
|
|
2405
|
+
return `dag-duotone-${elementId}`;
|
|
2406
|
+
}
|
|
2407
|
+
function getDuotoneSvgFilter(style, elementId) {
|
|
2408
|
+
if (!style?.dagDuotone) {
|
|
2409
|
+
return void 0;
|
|
2410
|
+
}
|
|
2411
|
+
const id = getDuotoneFilterId(elementId);
|
|
2412
|
+
const c1 = hexToRgbUnit(style.dagDuotone.color1);
|
|
2413
|
+
const c2 = hexToRgbUnit(style.dagDuotone.color2);
|
|
2414
|
+
const grayscaleMatrix = [
|
|
2415
|
+
0.2126,
|
|
2416
|
+
0.7152,
|
|
2417
|
+
0.0722,
|
|
2418
|
+
0,
|
|
2419
|
+
0,
|
|
2420
|
+
0.2126,
|
|
2421
|
+
0.7152,
|
|
2422
|
+
0.0722,
|
|
2423
|
+
0,
|
|
2424
|
+
0,
|
|
2425
|
+
0.2126,
|
|
2426
|
+
0.7152,
|
|
2427
|
+
0.0722,
|
|
2428
|
+
0,
|
|
2429
|
+
0,
|
|
2430
|
+
0,
|
|
2431
|
+
0,
|
|
2432
|
+
0,
|
|
2433
|
+
1,
|
|
2434
|
+
0
|
|
2435
|
+
].join(" ");
|
|
2436
|
+
const slopeR = c2.r - c1.r;
|
|
2437
|
+
const slopeG = c2.g - c1.g;
|
|
2438
|
+
const slopeB = c2.b - c1.b;
|
|
2439
|
+
const filterMarkup = [
|
|
2440
|
+
`<filter id="${escapeSvgAttr(id)}" color-interpolation-filters="sRGB">`,
|
|
2441
|
+
`<feColorMatrix type="matrix" values="${grayscaleMatrix}"/>`,
|
|
2442
|
+
`<feComponentTransfer>`,
|
|
2443
|
+
`<feFuncR type="linear" slope="${slopeR}" intercept="${c1.r}"/>`,
|
|
2444
|
+
`<feFuncG type="linear" slope="${slopeG}" intercept="${c1.g}"/>`,
|
|
2445
|
+
`<feFuncB type="linear" slope="${slopeB}" intercept="${c1.b}"/>`,
|
|
2446
|
+
`</feComponentTransfer>`,
|
|
2447
|
+
`</filter>`
|
|
2448
|
+
].join("");
|
|
2449
|
+
return { id, cssReference: `url(#${id})`, filterMarkup };
|
|
2450
|
+
}
|
|
2451
|
+
function getSoftEdgeFilterId(elementId) {
|
|
2452
|
+
return `soft-edge-${elementId}`;
|
|
2453
|
+
}
|
|
2454
|
+
var SOFT_EDGE_ERODE_FACTOR = 0.9;
|
|
2455
|
+
var SOFT_EDGE_BLUR_FACTOR = 0.3;
|
|
2456
|
+
function getSoftEdgeSvgFilter(style, elementId) {
|
|
2457
|
+
if (!style || typeof style.softEdgeRadius !== "number" || style.softEdgeRadius <= 0) {
|
|
2458
|
+
return void 0;
|
|
2459
|
+
}
|
|
2460
|
+
const id = getSoftEdgeFilterId(elementId);
|
|
2461
|
+
const radius = style.softEdgeRadius;
|
|
2462
|
+
const erode = (radius * SOFT_EDGE_ERODE_FACTOR).toFixed(2);
|
|
2463
|
+
const blur = (radius * SOFT_EDGE_BLUR_FACTOR).toFixed(2);
|
|
2464
|
+
const filterMarkup = [
|
|
2465
|
+
`<filter id="${escapeSvgAttr(id)}" x="-20%" y="-20%" width="140%" height="140%" color-interpolation-filters="sRGB">`,
|
|
2466
|
+
`<feMorphology in="SourceAlpha" operator="erode" radius="${erode}" result="softEdgeEroded"/>`,
|
|
2467
|
+
`<feGaussianBlur in="softEdgeEroded" stdDeviation="${blur}" result="softEdgeAlpha"/>`,
|
|
2468
|
+
`<feComposite in="SourceGraphic" in2="softEdgeAlpha" operator="in"/>`,
|
|
2469
|
+
`</filter>`
|
|
2470
|
+
].join("");
|
|
2471
|
+
return { id, cssReference: `url(#${id})`, filterMarkup };
|
|
2472
|
+
}
|
|
2473
|
+
function getShapeEffectFilterDefs(element) {
|
|
2474
|
+
const softEdge = getSoftEdgeSvgFilter(getEffectStyleSource(element), element.id);
|
|
2475
|
+
const silhouette = getSilhouetteEffects(element);
|
|
2476
|
+
if (!softEdge && !silhouette) {
|
|
2477
|
+
return void 0;
|
|
2478
|
+
}
|
|
2479
|
+
const base = softEdge ?? {
|
|
2480
|
+
id: silhouette?.filterId ?? "",
|
|
2481
|
+
cssReference: silhouette?.cssReference ?? "",
|
|
2482
|
+
filterMarkup: ""
|
|
2483
|
+
};
|
|
2484
|
+
return {
|
|
2485
|
+
...base,
|
|
2486
|
+
filterMarkup: `${softEdge?.filterMarkup ?? ""}${silhouette?.filterMarkup ?? ""}`
|
|
2487
|
+
};
|
|
2488
|
+
}
|
|
2489
|
+
function getDuotoneSvgFilterMarkup(filterId, color1, color2) {
|
|
2490
|
+
const c1 = hexToRgbUnit(color1);
|
|
2491
|
+
const c2 = hexToRgbUnit(color2);
|
|
2492
|
+
const grayscaleMatrix = [
|
|
2493
|
+
0.2126,
|
|
2494
|
+
0.7152,
|
|
2495
|
+
0.0722,
|
|
2496
|
+
0,
|
|
2497
|
+
0,
|
|
2498
|
+
0.2126,
|
|
2499
|
+
0.7152,
|
|
2500
|
+
0.0722,
|
|
2501
|
+
0,
|
|
2502
|
+
0,
|
|
2503
|
+
0.2126,
|
|
2504
|
+
0.7152,
|
|
2505
|
+
0.0722,
|
|
2506
|
+
0,
|
|
2507
|
+
0,
|
|
2508
|
+
0,
|
|
2509
|
+
0,
|
|
2510
|
+
0,
|
|
2511
|
+
1,
|
|
2512
|
+
0
|
|
2513
|
+
].join(" ");
|
|
2514
|
+
const slopeR = c2.r - c1.r;
|
|
2515
|
+
const slopeG = c2.g - c1.g;
|
|
2516
|
+
const slopeB = c2.b - c1.b;
|
|
2517
|
+
return [
|
|
2518
|
+
`<svg width="0" height="0" style="position:absolute;overflow:hidden" aria-hidden="true">`,
|
|
2519
|
+
`<defs>`,
|
|
2520
|
+
`<filter id="${escapeSvgAttr(filterId)}" color-interpolation-filters="sRGB">`,
|
|
2521
|
+
`<feColorMatrix type="matrix" values="${grayscaleMatrix}"/>`,
|
|
2522
|
+
`<feComponentTransfer>`,
|
|
2523
|
+
`<feFuncR type="linear" slope="${slopeR}" intercept="${c1.r}"/>`,
|
|
2524
|
+
`<feFuncG type="linear" slope="${slopeG}" intercept="${c1.g}"/>`,
|
|
2525
|
+
`<feFuncB type="linear" slope="${slopeB}" intercept="${c1.b}"/>`,
|
|
2526
|
+
`</feComponentTransfer>`,
|
|
2527
|
+
`</filter>`,
|
|
2528
|
+
`</defs>`,
|
|
2529
|
+
`</svg>`
|
|
2530
|
+
].join("");
|
|
2531
|
+
}
|
|
2532
|
+
function getEffectStyleSource(element) {
|
|
2533
|
+
if ("shapeStyle" in element) {
|
|
2534
|
+
return element.shapeStyle;
|
|
2535
|
+
}
|
|
2536
|
+
if (element.type === "chart") {
|
|
2537
|
+
return chartAreaEffectStyle(element.chartData);
|
|
2538
|
+
}
|
|
2539
|
+
return element.type === "group" ? element.groupEffectStyle : void 0;
|
|
2540
|
+
}
|
|
2541
|
+
function getComputedEffectStyle(element, options = {}) {
|
|
2542
|
+
const style = getEffectStyleSource(element);
|
|
2543
|
+
const result = {};
|
|
2544
|
+
if (!style) {
|
|
2545
|
+
return result;
|
|
2546
|
+
}
|
|
2547
|
+
const paintsLineEffectsItself = element.type === "connector" || getShapeType("shapeType" in element ? element.shapeType : void 0) === "connector";
|
|
2548
|
+
const shadowsCompositePixels = element.type === "group" || element.type === "text" || element.type === "image" || element.type === "picture";
|
|
2549
|
+
const compositeShadow = shadowsCompositePixels ? getCompositeOuterShadowFilterCss(style, { rotation: element.rotation }) : void 0;
|
|
2550
|
+
const silhouette = shadowsCompositePixels ? void 0 : getSilhouetteEffects(element);
|
|
2551
|
+
const boxShadow = shadowsCompositePixels ? void 0 : getBoxShadowCss(
|
|
2552
|
+
style,
|
|
2553
|
+
{
|
|
2554
|
+
includeGlow: silhouette ? false : options.includeGlowBoxShadow,
|
|
2555
|
+
includeOuter: !silhouette,
|
|
2556
|
+
includeInner: !silhouette?.paintsInnerShadow
|
|
2557
|
+
},
|
|
2558
|
+
{ rotation: element.rotation }
|
|
2559
|
+
);
|
|
2560
|
+
const lineShadow = paintsLineEffectsItself ? void 0 : getLineShadowCss(style);
|
|
2561
|
+
const shadowParts = [boxShadow, lineShadow].filter(
|
|
2562
|
+
(part) => part !== void 0 && part !== ""
|
|
2563
|
+
);
|
|
2564
|
+
if (shadowParts.length > 0) {
|
|
2565
|
+
result.boxShadow = shadowParts.join(", ");
|
|
2566
|
+
}
|
|
2567
|
+
const glowInBoxShadow = !shadowsCompositePixels && (options.includeGlowBoxShadow !== false || silhouette !== void 0);
|
|
2568
|
+
const filter = getEffectFilterCss(style, element.id, { glow: !glowInBoxShadow });
|
|
2569
|
+
const lineGlow = paintsLineEffectsItself ? void 0 : getLineGlowFilterCss(style);
|
|
2570
|
+
const filterParts = [silhouette?.cssReference, compositeShadow, filter, lineGlow].filter(
|
|
2571
|
+
(part) => part !== void 0 && part !== ""
|
|
2572
|
+
);
|
|
2573
|
+
if (filterParts.length > 0) {
|
|
2574
|
+
result.filter = filterParts.join(" ");
|
|
2575
|
+
}
|
|
2576
|
+
const reflection = getReflectionWrapperStyle(style, element.height);
|
|
2577
|
+
if (reflection) {
|
|
2578
|
+
result.reflection = reflection;
|
|
2579
|
+
}
|
|
2580
|
+
const opacity = getEffectDagOpacity(style);
|
|
2581
|
+
if (opacity !== void 0) {
|
|
2582
|
+
result.opacity = opacity;
|
|
2583
|
+
}
|
|
2584
|
+
const overlay = getEffectDagFillOverlay(style) ?? getShapeFillOverlay(style);
|
|
2585
|
+
if (overlay) {
|
|
2586
|
+
result.fillOverlay = overlay;
|
|
2587
|
+
} else {
|
|
2588
|
+
const blend = getEffectDagBlendMode(style.dagFillOverlayBlend);
|
|
2589
|
+
if (blend) {
|
|
2590
|
+
result.mixBlendMode = blend;
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
if (style.blurGrow && typeof style.blurRadius === "number" && style.blurRadius > 0) {
|
|
2594
|
+
result.overflowVisible = true;
|
|
2595
|
+
}
|
|
2596
|
+
return result;
|
|
2597
|
+
}
|
|
2598
|
+
function hasImageEffects(element) {
|
|
2599
|
+
return isImageLikeElement(element) && Boolean(element.imageEffects);
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
// src/pptx/render/gradient-svg-image.ts
|
|
2603
|
+
function num2(value) {
|
|
2604
|
+
return String(Math.round(value * 1e4) / 1e4);
|
|
2605
|
+
}
|
|
2606
|
+
function stopMarkup(stops) {
|
|
2607
|
+
return stops.map(
|
|
2608
|
+
(stop) => `<stop offset="${num2(Math.min(Math.max(stop.position, 0), 100) / 100)}" stop-color="${escapeSvgAttr(
|
|
2609
|
+
stop.color
|
|
2610
|
+
)}"${typeof stop.opacity === "number" ? ` stop-opacity="${num2(stop.opacity)}"` : ""}/>`
|
|
2611
|
+
).join("");
|
|
2612
|
+
}
|
|
2613
|
+
function toCssUrl(svg) {
|
|
2614
|
+
return `url("data:image/svg+xml,${encodeURIComponent(svg).replace(/[()]/gu, (c) => c === "(" ? "%28" : "%29")}")`;
|
|
2615
|
+
}
|
|
2616
|
+
function buildScaledLinearGradientImage(stops, ooxmlAngleDegrees) {
|
|
2617
|
+
const radians = ooxmlAngleDegrees * Math.PI / 180;
|
|
2618
|
+
const dx = Math.cos(radians);
|
|
2619
|
+
const dy = Math.sin(radians);
|
|
2620
|
+
const span = (Math.abs(dx) + Math.abs(dy)) / 2;
|
|
2621
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1" preserveAspectRatio="none"><defs><linearGradient id="g" x1="${num2(0.5 - dx * span)}" y1="${num2(0.5 - dy * span)}" x2="${num2(
|
|
2622
|
+
0.5 + dx * span
|
|
2623
|
+
)}" y2="${num2(0.5 + dy * span)}">${stopMarkup(stops)}</linearGradient></defs><rect width="1" height="1" fill="url(#g)"/></svg>`;
|
|
2624
|
+
return toCssUrl(svg);
|
|
2625
|
+
}
|
|
2626
|
+
function buildFocalCircleGradientImage(stops, fx, fy, width, height) {
|
|
2627
|
+
const radius = Math.hypot(width, height) / 2;
|
|
2628
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${num2(width)} ${num2(height)}" preserveAspectRatio="none"><defs><radialGradient id="g" gradientUnits="userSpaceOnUse" cx="${num2(width / 2)}" cy="${num2(
|
|
2629
|
+
height / 2
|
|
2630
|
+
)}" r="${num2(radius)}" fx="${num2(fx * width)}" fy="${num2(fy * height)}">${stopMarkup(stops)}</radialGradient></defs><rect width="${num2(width)}" height="${num2(height)}" fill="url(#g)"/></svg>`;
|
|
2631
|
+
return toCssUrl(svg);
|
|
2632
|
+
}
|
|
2633
|
+
|
|
168
2634
|
// src/pptx/render/vector-subpath-paint.ts
|
|
169
2635
|
function toHexByte(value) {
|
|
170
2636
|
const clamped = Math.max(0, Math.min(255, Math.round(value)));
|
|
171
2637
|
return clamped.toString(16).padStart(2, "0");
|
|
172
2638
|
}
|
|
173
|
-
function shiftHex(
|
|
174
|
-
const channels = hexToRgbChannels(
|
|
2639
|
+
function shiftHex(hex2, factor, towardsWhite) {
|
|
2640
|
+
const channels = hexToRgbChannels$1(hex2);
|
|
175
2641
|
if (!channels) {
|
|
176
|
-
return
|
|
2642
|
+
return hex2;
|
|
177
2643
|
}
|
|
178
2644
|
const shift = (c) => towardsWhite ? c + (255 - c) * factor : c * (1 - factor);
|
|
179
2645
|
return `#${toHexByte(shift(channels.r))}${toHexByte(shift(channels.g))}${toHexByte(shift(channels.b))}`;
|
|
@@ -204,75 +2670,53 @@ function buildSubpathPaints(subpaths, hasFill, fillColor, fillOpacity) {
|
|
|
204
2670
|
}
|
|
205
2671
|
|
|
206
2672
|
// src/pptx/render/subpath-fill-overlay.ts
|
|
207
|
-
function
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
2673
|
+
function hasReproducibleFillMode(element) {
|
|
2674
|
+
if (!hasShapeProperties(element)) {
|
|
2675
|
+
return false;
|
|
2676
|
+
}
|
|
2677
|
+
const mode = element.shapeStyle?.fillMode;
|
|
2678
|
+
return mode === void 0 || mode === "solid" || mode === "none";
|
|
212
2679
|
}
|
|
213
|
-
function
|
|
214
|
-
return
|
|
215
|
-
(sp) => sp.fillMode !== void 0 && sp.fillMode !== "norm" || sp.stroke === false
|
|
216
|
-
);
|
|
2680
|
+
function suppressesCssFill(element) {
|
|
2681
|
+
return hasReproducibleFillMode(element) && getSubpathGeometry(element, silhouetteFillsOverlay(element)) !== void 0;
|
|
217
2682
|
}
|
|
218
|
-
function
|
|
219
|
-
|
|
220
|
-
|
|
2683
|
+
function shadeVeil(mode, opacity) {
|
|
2684
|
+
const strength = mode === "lighten" || mode === "darken" ? 0.4 : mode === "lightenLess" || mode === "darkenLess" ? 0.2 : 0;
|
|
2685
|
+
if (strength === 0) {
|
|
2686
|
+
return void 0;
|
|
221
2687
|
}
|
|
222
|
-
|
|
2688
|
+
const channel = mode?.startsWith("lighten") ? 255 : 0;
|
|
2689
|
+
return `rgba(${channel},${channel},${channel},${Math.round(strength * opacity * 1e3) / 1e3})`;
|
|
223
2690
|
}
|
|
224
|
-
function
|
|
225
|
-
|
|
226
|
-
if (!slots) {
|
|
2691
|
+
function buildShadingOverlay(element) {
|
|
2692
|
+
if (!hasShapeProperties(element)) {
|
|
227
2693
|
return void 0;
|
|
228
2694
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
slots.customGeometryRawData,
|
|
232
|
-
slots.pathWidth,
|
|
233
|
-
slots.pathHeight,
|
|
234
|
-
slots.shapeAdjustments
|
|
235
|
-
) ?? slots.customGeometryPaths;
|
|
236
|
-
if (!structured || structured.length === 0) {
|
|
237
|
-
return void 0;
|
|
238
|
-
}
|
|
239
|
-
const subpaths2 = customGeometryPathsToSvgSubpaths(
|
|
240
|
-
structured,
|
|
241
|
-
slots.pathWidth,
|
|
242
|
-
slots.pathHeight
|
|
243
|
-
);
|
|
244
|
-
return needsPerSubpathPaint(subpaths2) ? { subpaths: subpaths2, width: slots.pathWidth, height: slots.pathHeight } : void 0;
|
|
245
|
-
}
|
|
246
|
-
if (!slots.shapeType) {
|
|
2695
|
+
const ss = element.shapeStyle;
|
|
2696
|
+
if (ss?.fillMode !== "gradient" && ss?.fillMode !== "pattern" && ss?.fillMode !== "image") {
|
|
247
2697
|
return void 0;
|
|
248
2698
|
}
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
if (!result || result.fillNone || result.paths.length === 0) {
|
|
2699
|
+
const geometry = getSubpathGeometry(element);
|
|
2700
|
+
if (!geometry) {
|
|
252
2701
|
return void 0;
|
|
253
2702
|
}
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
2703
|
+
const opacity = ss.fillOpacity ?? 1;
|
|
2704
|
+
const paints2 = geometry.subpaths.map((subpath) => ({
|
|
2705
|
+
d: subpath.d,
|
|
2706
|
+
fill: shadeVeil(subpath.fillMode, opacity) ?? "none",
|
|
2707
|
+
stroked: subpath.stroke !== false
|
|
258
2708
|
}));
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
function hasReproducibleFillMode(element) {
|
|
262
|
-
if (!hasShapeProperties(element)) {
|
|
263
|
-
return false;
|
|
2709
|
+
if (paints2.every((paint) => paint.fill === "none")) {
|
|
2710
|
+
return void 0;
|
|
264
2711
|
}
|
|
265
|
-
|
|
266
|
-
return mode === void 0 || mode === "solid" || mode === "none";
|
|
267
|
-
}
|
|
268
|
-
function suppressesCssFill(element) {
|
|
269
|
-
return hasReproducibleFillMode(element) && getSubpathGeometry(element) !== void 0;
|
|
2712
|
+
return { paints: paints2, viewBoxWidth: geometry.width, viewBoxHeight: geometry.height };
|
|
270
2713
|
}
|
|
271
2714
|
function buildSubpathFillOverlay(element) {
|
|
272
2715
|
if (!hasReproducibleFillMode(element)) {
|
|
273
|
-
return
|
|
2716
|
+
return buildShadingOverlay(element);
|
|
274
2717
|
}
|
|
275
|
-
const
|
|
2718
|
+
const silhouette = silhouetteFillsOverlay(element);
|
|
2719
|
+
const geometry = getSubpathGeometry(element, silhouette);
|
|
276
2720
|
if (!geometry) {
|
|
277
2721
|
return void 0;
|
|
278
2722
|
}
|
|
@@ -282,7 +2726,8 @@ function buildSubpathFillOverlay(element) {
|
|
|
282
2726
|
return {
|
|
283
2727
|
paints: buildSubpathPaints(geometry.subpaths, hasFill, fillColor, ss?.fillOpacity),
|
|
284
2728
|
viewBoxWidth: geometry.width,
|
|
285
|
-
viewBoxHeight: geometry.height
|
|
2729
|
+
viewBoxHeight: geometry.height,
|
|
2730
|
+
...silhouette ? { silhouette: true } : {}
|
|
286
2731
|
};
|
|
287
2732
|
}
|
|
288
2733
|
function clampCropValue(value) {
|
|
@@ -306,7 +2751,7 @@ function sanitizeGradientStops(stops) {
|
|
|
306
2751
|
).map((stop) => ({
|
|
307
2752
|
color: normalizeHexColor(String(stop.color), DEFAULT_FILL_COLOR),
|
|
308
2753
|
position: Math.max(0, Math.min(100, stop.position)),
|
|
309
|
-
opacity: typeof stop.opacity === "number" && Number.isFinite(stop.opacity) ? clampUnitInterval(stop.opacity) : void 0,
|
|
2754
|
+
opacity: typeof stop.opacity === "number" && Number.isFinite(stop.opacity) ? clampUnitInterval$1(stop.opacity) : void 0,
|
|
310
2755
|
colorRef: stop.colorRef
|
|
311
2756
|
})).sort((left, right) => left.position - right.position);
|
|
312
2757
|
}
|
|
@@ -338,16 +2783,20 @@ function computeGradientCenter(fillToRect, focalPoint) {
|
|
|
338
2783
|
}
|
|
339
2784
|
return { cx: 50, cy: 50 };
|
|
340
2785
|
}
|
|
341
|
-
function buildCirclePathGradient(stops, focalPoint, fillToRect) {
|
|
2786
|
+
function buildCirclePathGradient(stops, focalPoint, fillToRect, bounds) {
|
|
342
2787
|
const stopStr = stops.map(toCssGradientStop).join(", ");
|
|
343
2788
|
const { cx, cy } = computeGradientCenter(fillToRect, focalPoint);
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
2789
|
+
if (Math.abs(cx - 50) < 0.5 && Math.abs(cy - 50) < 0.5) {
|
|
2790
|
+
return `radial-gradient(circle farthest-corner at 50% 50%, ${stopStr})`;
|
|
2791
|
+
}
|
|
2792
|
+
const { width, height } = bounds ?? {};
|
|
2793
|
+
if (typeof width === "number" && typeof height === "number" && width > 0 && height > 0) {
|
|
2794
|
+
return buildFocalCircleGradientImage(stops, cx / 100, cy / 100, width, height);
|
|
349
2795
|
}
|
|
350
|
-
|
|
2796
|
+
const posX = `${Math.round(cx)}%`;
|
|
2797
|
+
const posY = `${Math.round(cy)}%`;
|
|
2798
|
+
const radius = Math.round(Math.max(cx, 100 - cx, cy, 100 - cy));
|
|
2799
|
+
return `radial-gradient(ellipse ${radius}% ${radius}% at ${posX} ${posY}, ${stopStr})`;
|
|
351
2800
|
}
|
|
352
2801
|
function buildRectPathGradient(stops, focalPoint, fillToRect) {
|
|
353
2802
|
return buildRectPathGradientImage(stops, focalPoint, fillToRect);
|
|
@@ -449,6 +2898,16 @@ function adjustLinearGradientAngle(angle, gradient, context) {
|
|
|
449
2898
|
}
|
|
450
2899
|
return result;
|
|
451
2900
|
}
|
|
2901
|
+
function isStretchedLinear(gradient, angle, context) {
|
|
2902
|
+
const { width, height } = context ?? {};
|
|
2903
|
+
if (gradient.fillGradientScaled === false || !width || !height) {
|
|
2904
|
+
return false;
|
|
2905
|
+
}
|
|
2906
|
+
if (Math.abs(width - height) < 0.5) {
|
|
2907
|
+
return false;
|
|
2908
|
+
}
|
|
2909
|
+
return Math.abs(angle % 90) > 0.01 && Math.abs(angle % 90 - 90) > 0.01;
|
|
2910
|
+
}
|
|
452
2911
|
function buildGradientCss(gradient, context) {
|
|
453
2912
|
if (!gradient || gradient.fillMode !== "gradient") {
|
|
454
2913
|
return void 0;
|
|
@@ -457,21 +2916,25 @@ function buildGradientCss(gradient, context) {
|
|
|
457
2916
|
if (sanitized.length === 0) {
|
|
458
2917
|
return gradient.fillGradient;
|
|
459
2918
|
}
|
|
460
|
-
const stops =
|
|
2919
|
+
const stops = officeGradientStops(sanitized);
|
|
461
2920
|
const gradientType = gradient.fillGradientType || "linear";
|
|
462
2921
|
if (gradientType === "radial") {
|
|
463
2922
|
const pathType = gradient.fillGradientPathType || "circle";
|
|
464
2923
|
const fp = gradient.fillGradientFocalPoint;
|
|
465
2924
|
const ftr = gradient.fillGradientFillToRect;
|
|
466
|
-
if (pathType === "rect") {
|
|
2925
|
+
if (pathType === "rect" || pathType === "shape" && context?.rectangular) {
|
|
467
2926
|
return buildRectPathGradient(stops, fp, ftr);
|
|
468
2927
|
}
|
|
469
2928
|
if (pathType === "shape") {
|
|
470
2929
|
return buildShapePathGradient(stops, fp, ftr);
|
|
471
2930
|
}
|
|
472
|
-
return buildCirclePathGradient(stops, fp, ftr);
|
|
2931
|
+
return buildCirclePathGradient(stops, fp, ftr, context);
|
|
473
2932
|
}
|
|
474
2933
|
const normalizedAngle = typeof gradient.fillGradientAngle === "number" && Number.isFinite(gradient.fillGradientAngle) ? gradient.fillGradientAngle : 90;
|
|
2934
|
+
const flipped = gradient.fillGradientFlip && gradient.fillGradientFlip !== "none";
|
|
2935
|
+
if (isStretchedLinear(gradient, normalizedAngle, context) && !flipped && gradient.fillGradientRotWithShape !== false) {
|
|
2936
|
+
return buildScaledLinearGradientImage(stops, normalizedAngle);
|
|
2937
|
+
}
|
|
475
2938
|
const effectiveAngle = convertOoxmlAngleToCss(
|
|
476
2939
|
adjustLinearGradientAngle(normalizedAngle, gradient, context)
|
|
477
2940
|
);
|
|
@@ -841,7 +3304,7 @@ function getComputedFillStyle(element, parentGroupFill) {
|
|
|
841
3304
|
if (!ss) {
|
|
842
3305
|
return {};
|
|
843
3306
|
}
|
|
844
|
-
if (suppressesCssFill(element)) {
|
|
3307
|
+
if (suppressesCssFill(element) || silhouetteFillsLayer(element)) {
|
|
845
3308
|
return { backgroundColor: "transparent" };
|
|
846
3309
|
}
|
|
847
3310
|
if (ss.fillMode === "group") {
|
|
@@ -863,7 +3326,8 @@ function resolveComputedFill(ss, element) {
|
|
|
863
3326
|
const geometry = {
|
|
864
3327
|
rotation: element.rotation,
|
|
865
3328
|
width: element.width,
|
|
866
|
-
height: element.height
|
|
3329
|
+
height: element.height,
|
|
3330
|
+
rectangular: element.type === "shape" && getShapeType(element.shapeType) === "rect"
|
|
867
3331
|
};
|
|
868
3332
|
const gradient = buildGradientCss(ss, geometry) ?? (ss.fillMode === "gradient" ? ss.fillGradient : void 0);
|
|
869
3333
|
if (gradient) {
|
|
@@ -885,8 +3349,8 @@ function resolveComputedFill(ss, element) {
|
|
|
885
3349
|
backgroundRepeat: tileRect.backgroundRepeat
|
|
886
3350
|
};
|
|
887
3351
|
}
|
|
888
|
-
const
|
|
889
|
-
if (
|
|
3352
|
+
const isSvgImage = gradient.startsWith("url(");
|
|
3353
|
+
if (isSvgImage) {
|
|
890
3354
|
return {
|
|
891
3355
|
backgroundImage: gradient,
|
|
892
3356
|
backgroundSize: "100% 100%",
|
|
@@ -989,36 +3453,9 @@ function getCompoundLineStyle(compoundLine, strokeColor, strokeWidth) {
|
|
|
989
3453
|
borderStyle: "double"
|
|
990
3454
|
};
|
|
991
3455
|
}
|
|
992
|
-
function getSvgStrokeDasharray(dashType, strokeWidth, customDashSegments) {
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
}
|
|
996
|
-
const stroke = Math.max(strokeWidth, 1);
|
|
997
|
-
if (dashType === "custom" && customDashSegments && customDashSegments.length > 0) {
|
|
998
|
-
return customDashSegments.flatMap((seg) => [seg.dash / 1e3 * stroke, seg.space / 1e3 * stroke]).join(" ");
|
|
999
|
-
}
|
|
1000
|
-
switch (dashType) {
|
|
1001
|
-
case "dot":
|
|
1002
|
-
case "sysDot":
|
|
1003
|
-
return `${stroke} ${stroke * 2}`;
|
|
1004
|
-
case "dash":
|
|
1005
|
-
case "sysDash":
|
|
1006
|
-
return `${stroke * 4} ${stroke * 2}`;
|
|
1007
|
-
case "lgDash":
|
|
1008
|
-
return `${stroke * 7} ${stroke * 2.5}`;
|
|
1009
|
-
case "dashDot":
|
|
1010
|
-
case "sysDashDot":
|
|
1011
|
-
return `${stroke * 4} ${stroke * 2} ${stroke} ${stroke * 2}`;
|
|
1012
|
-
case "lgDashDot":
|
|
1013
|
-
return `${stroke * 7} ${stroke * 2.5} ${stroke} ${stroke * 2.5}`;
|
|
1014
|
-
case "lgDashDotDot":
|
|
1015
|
-
case "sysDashDotDot":
|
|
1016
|
-
return `${stroke * 7} ${stroke * 2.5} ${stroke} ${stroke * 2} ${stroke} ${stroke * 2}`;
|
|
1017
|
-
case "custom":
|
|
1018
|
-
return `${stroke * 3} ${stroke * 2}`;
|
|
1019
|
-
default:
|
|
1020
|
-
return void 0;
|
|
1021
|
-
}
|
|
3456
|
+
function getSvgStrokeDasharray(dashType, strokeWidth, customDashSegments, lineCap) {
|
|
3457
|
+
const pattern = dashPatternUnits(dashType, customDashSegments);
|
|
3458
|
+
return pattern ? capCompensatedDashArray(pattern, strokeWidth, lineCap) : void 0;
|
|
1022
3459
|
}
|
|
1023
3460
|
function getElementTransform(element) {
|
|
1024
3461
|
const transforms = [];
|
|
@@ -1084,14 +3521,14 @@ function parseDrawingPercent(value) {
|
|
|
1084
3521
|
if (!Number.isFinite(parsed)) {
|
|
1085
3522
|
return void 0;
|
|
1086
3523
|
}
|
|
1087
|
-
return clampUnitInterval(parsed / 1e5);
|
|
3524
|
+
return clampUnitInterval$1(parsed / 1e5);
|
|
1088
3525
|
}
|
|
1089
3526
|
|
|
1090
3527
|
// src/pptx/render/connector-dash.ts
|
|
1091
|
-
function buildDashArray(dash, strokeWidth, customDashSegments) {
|
|
3528
|
+
function buildDashArray(dash, strokeWidth, customDashSegments, lineCap) {
|
|
1092
3529
|
const segments = customDashSegments && customDashSegments.length > 0 ? customDashSegments.map((seg) => ({ dash: seg.dash, space: seg.space })) : void 0;
|
|
1093
3530
|
const dashType = segments ? "custom" : normalizeStrokeDashType(dash);
|
|
1094
|
-
return getSvgStrokeDasharray(dashType, strokeWidth, segments);
|
|
3531
|
+
return getSvgStrokeDasharray(dashType, strokeWidth, segments, lineCap);
|
|
1095
3532
|
}
|
|
1096
3533
|
|
|
1097
3534
|
// src/pptx/render/chart-legend-swatch.ts
|
|
@@ -1756,7 +4193,7 @@ function shadowMarkup(shapes, shadow) {
|
|
|
1756
4193
|
).join("");
|
|
1757
4194
|
return `<filter id="${id}" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="${r2(blur)}"/></filter><g filter="url(#${id})" opacity="${r2(opacityOf(shadow.transparency))}" transform="translate(${r2(dist * Math.cos(rad))} ${r2(dist * Math.sin(rad))})">${body}</g>`;
|
|
1758
4195
|
}
|
|
1759
|
-
function
|
|
4196
|
+
function glowMarkup2(shapes, glow) {
|
|
1760
4197
|
const id = uid("g");
|
|
1761
4198
|
const radius = ptToPx(glow.radius);
|
|
1762
4199
|
const color = safeColor(glow.color, "#FFFFFF");
|
|
@@ -1780,7 +4217,7 @@ function effectsBehind(shapes, effects) {
|
|
|
1780
4217
|
if (!effects || shapes.length === 0) {
|
|
1781
4218
|
return "";
|
|
1782
4219
|
}
|
|
1783
|
-
return (effects.shadow ? shadowMarkup(shapes, effects.shadow) : "") + (effects.glow && effects.glow.radius > 0 ?
|
|
4220
|
+
return (effects.shadow ? shadowMarkup(shapes, effects.shadow) : "") + (effects.glow && effects.glow.radius > 0 ? glowMarkup2(shapes, effects.glow) : "");
|
|
1784
4221
|
}
|
|
1785
4222
|
function paintedShapes(shapes, paint, softEdge) {
|
|
1786
4223
|
const inner = shapes.map(paint).join("");
|
|
@@ -2011,9 +4448,9 @@ function needsLineDecoration(line2) {
|
|
|
2011
4448
|
function arrowHead(type, tip, ux, uy, width, paint) {
|
|
2012
4449
|
const length = Math.max(6, width * 3);
|
|
2013
4450
|
const half = Math.max(3, width * 1.5);
|
|
2014
|
-
const
|
|
4451
|
+
const px2 = -uy;
|
|
2015
4452
|
const py = ux;
|
|
2016
|
-
const at = (along, across) => `${r23(tip.x + ux * along +
|
|
4453
|
+
const at = (along, across) => `${r23(tip.x + ux * along + px2 * across)},${r23(tip.y + uy * along + py * across)}`;
|
|
2017
4454
|
switch (type) {
|
|
2018
4455
|
case "triangle":
|
|
2019
4456
|
return `<polygon points="${at(0, 0)} ${at(-length, half)} ${at(-length, -half)}" fill="${paint}"/>`;
|
|
@@ -3219,8 +5656,8 @@ function ribbonExtrusion(prims, depth) {
|
|
|
3219
5656
|
}
|
|
3220
5657
|
function shiftPoints(points, dx, dy) {
|
|
3221
5658
|
return points.trim().split(/\s+/u).map((pair) => {
|
|
3222
|
-
const [
|
|
3223
|
-
return `${
|
|
5659
|
+
const [px2, py] = pair.split(",").map(Number);
|
|
5660
|
+
return `${px2 + dx},${py + dy}`;
|
|
3224
5661
|
}).join(" ");
|
|
3225
5662
|
}
|
|
3226
5663
|
function applyChart3DDepth(vm, chartType, view3D, surfaces, grouping, pieCenter, picture) {
|
|
@@ -3328,16 +5765,16 @@ var DISPLAY_UNIT_LABELS = {
|
|
|
3328
5765
|
billions: "Billions",
|
|
3329
5766
|
trillions: "Trillions"
|
|
3330
5767
|
};
|
|
3331
|
-
function getDisplayUnitDivisor(
|
|
3332
|
-
if (!
|
|
5768
|
+
function getDisplayUnitDivisor(unit2, customValue) {
|
|
5769
|
+
if (!unit2) {
|
|
3333
5770
|
return 1;
|
|
3334
5771
|
}
|
|
3335
|
-
if (
|
|
5772
|
+
if (unit2 === "custom" && customValue) {
|
|
3336
5773
|
return customValue;
|
|
3337
5774
|
}
|
|
3338
|
-
return DISPLAY_UNIT_DIVISORS[
|
|
5775
|
+
return DISPLAY_UNIT_DIVISORS[unit2] ?? 1;
|
|
3339
5776
|
}
|
|
3340
|
-
function getDisplayUnitLabel(
|
|
5777
|
+
function getDisplayUnitLabel(unit2, customLabel) {
|
|
3341
5778
|
if (typeof customLabel === "string") {
|
|
3342
5779
|
return customLabel;
|
|
3343
5780
|
}
|
|
@@ -3347,10 +5784,10 @@ function getDisplayUnitLabel(unit, customLabel) {
|
|
|
3347
5784
|
if (customLabel?.text) {
|
|
3348
5785
|
return customLabel.text;
|
|
3349
5786
|
}
|
|
3350
|
-
if (!
|
|
5787
|
+
if (!unit2 || unit2 === "custom") {
|
|
3351
5788
|
return "";
|
|
3352
5789
|
}
|
|
3353
|
-
return DISPLAY_UNIT_LABELS[
|
|
5790
|
+
return DISPLAY_UNIT_LABELS[unit2] ?? "";
|
|
3354
5791
|
}
|
|
3355
5792
|
function formatAxisValueWithUnits(value, axis) {
|
|
3356
5793
|
if (!axis?.displayUnits) {
|
|
@@ -3596,9 +6033,9 @@ function resolveMarkerLabelPlacement(chartData, series, pointIndex, point, frame
|
|
|
3596
6033
|
}
|
|
3597
6034
|
|
|
3598
6035
|
// src/pptx/render/chart-label-measure.ts
|
|
3599
|
-
var
|
|
3600
|
-
var DATA_LABEL_PAD_X = 3 *
|
|
3601
|
-
var DATA_LABEL_PAD_Y = 1.5 *
|
|
6036
|
+
var PX_PER_PT2 = 4 / 3;
|
|
6037
|
+
var DATA_LABEL_PAD_X = 3 * PX_PER_PT2;
|
|
6038
|
+
var DATA_LABEL_PAD_Y = 1.5 * PX_PER_PT2;
|
|
3602
6039
|
var DATA_LABEL_LINE_HEIGHT = 1.2207;
|
|
3603
6040
|
var ASCENT = 0.952;
|
|
3604
6041
|
var injected;
|
|
@@ -3672,7 +6109,7 @@ function calloutPoints(box, target) {
|
|
|
3672
6109
|
[x, y + h]
|
|
3673
6110
|
];
|
|
3674
6111
|
if (!target) {
|
|
3675
|
-
return corners.map(([
|
|
6112
|
+
return corners.map(([px2, py]) => `${r25(px2)},${r25(py)}`).join(" ");
|
|
3676
6113
|
}
|
|
3677
6114
|
const below = target.y > y + h;
|
|
3678
6115
|
const above = target.y < y;
|
|
@@ -3721,7 +6158,7 @@ function calloutPoints(box, target) {
|
|
|
3721
6158
|
[x, cy - base / 4]
|
|
3722
6159
|
);
|
|
3723
6160
|
}
|
|
3724
|
-
return pts.map(([
|
|
6161
|
+
return pts.map(([px2, py]) => `${r25(px2)},${r25(py)}`).join(" ");
|
|
3725
6162
|
}
|
|
3726
6163
|
function calloutLabelLift(chartData, series, fontSize, moved) {
|
|
3727
6164
|
const opts = series.dataLabelOptions ?? chartData.style?.dataLabels;
|
|
@@ -5617,12 +8054,12 @@ function buildDateAxisPlan(chartData, layout, selectedAxis, axisY) {
|
|
|
5617
8054
|
const x = serialToX(value, min, max, layout);
|
|
5618
8055
|
return axis.orientation === "maxMin" ? layout.plotLeft + layout.plotWidth - (x - layout.plotLeft) : x;
|
|
5619
8056
|
});
|
|
5620
|
-
const
|
|
8057
|
+
const unit2 = axis.majorTimeUnit ?? axis.baseTimeUnit ?? "days";
|
|
5621
8058
|
const ticks = calendarTicks(
|
|
5622
8059
|
min,
|
|
5623
8060
|
max,
|
|
5624
8061
|
dates.date1904 ?? false,
|
|
5625
|
-
|
|
8062
|
+
unit2,
|
|
5626
8063
|
Math.max(1, axis.majorUnit ?? 1)
|
|
5627
8064
|
);
|
|
5628
8065
|
const y = axisY ?? (axis.axPos === "t" ? layout.plotTop : layout.plotBottom);
|
|
@@ -5645,7 +8082,7 @@ function buildDateAxisPlan(chartData, layout, selectedAxis, axisY) {
|
|
|
5645
8082
|
y: labelsAbove ? labelY - offset : labelY + offset,
|
|
5646
8083
|
text: formatDate(
|
|
5647
8084
|
excelSerialToDate(serial5, dates.date1904),
|
|
5648
|
-
|
|
8085
|
+
unit2,
|
|
5649
8086
|
axis.numFmt?.formatCode ?? dates.formatCode
|
|
5650
8087
|
),
|
|
5651
8088
|
...chartAxisTextStyle(axis),
|
|
@@ -5676,7 +8113,7 @@ function buildDateAxisPlan(chartData, layout, selectedAxis, axisY) {
|
|
|
5676
8113
|
});
|
|
5677
8114
|
}
|
|
5678
8115
|
if (!axis.deleted && axis.minorTickMark && axis.minorTickMark !== "none") {
|
|
5679
|
-
const minorUnit = axis.minorTimeUnit ?? axis.baseTimeUnit ??
|
|
8116
|
+
const minorUnit = axis.minorTimeUnit ?? axis.baseTimeUnit ?? unit2;
|
|
5680
8117
|
for (const serial5 of calendarTicks(
|
|
5681
8118
|
min,
|
|
5682
8119
|
max,
|
|
@@ -5827,25 +8264,25 @@ function wrapTextByEstimatedWidth(text, maxWidth, fontSize, options = {}) {
|
|
|
5827
8264
|
}
|
|
5828
8265
|
let current = "";
|
|
5829
8266
|
let pendingWhitespace = false;
|
|
5830
|
-
for (const
|
|
5831
|
-
if (/^\s+$/u.test(
|
|
8267
|
+
for (const unit2 of estimatedWrapUnits(paragraph)) {
|
|
8268
|
+
if (/^\s+$/u.test(unit2)) {
|
|
5832
8269
|
pendingWhitespace = current.length > 0;
|
|
5833
8270
|
continue;
|
|
5834
8271
|
}
|
|
5835
8272
|
const separator = pendingWhitespace && current.length > 0 ? " " : "";
|
|
5836
|
-
const candidate = `${current}${separator}${
|
|
8273
|
+
const candidate = `${current}${separator}${unit2}`;
|
|
5837
8274
|
if (current.length === 0 || estimatedTextWidth(Array.from(candidate), fontSize) <= maxWidth) {
|
|
5838
8275
|
current = candidate;
|
|
5839
8276
|
pendingWhitespace = false;
|
|
5840
8277
|
continue;
|
|
5841
8278
|
}
|
|
5842
|
-
if (HANGING_PUNCTUATION_RE.test(
|
|
5843
|
-
current +=
|
|
8279
|
+
if (HANGING_PUNCTUATION_RE.test(unit2)) {
|
|
8280
|
+
current += unit2;
|
|
5844
8281
|
pendingWhitespace = false;
|
|
5845
8282
|
continue;
|
|
5846
8283
|
}
|
|
5847
8284
|
lines.push(current);
|
|
5848
|
-
current =
|
|
8285
|
+
current = unit2;
|
|
5849
8286
|
pendingWhitespace = false;
|
|
5850
8287
|
}
|
|
5851
8288
|
const completed = current.trimEnd();
|
|
@@ -7320,22 +9757,22 @@ function applyParetoConversion(data) {
|
|
|
7320
9757
|
]
|
|
7321
9758
|
};
|
|
7322
9759
|
}
|
|
7323
|
-
function orderParetoEntries(
|
|
7324
|
-
return [...
|
|
9760
|
+
function orderParetoEntries(entries2) {
|
|
9761
|
+
return [...entries2].sort(
|
|
7325
9762
|
(left, right) => Math.max(right.value, 0) - Math.max(left.value, 0) || left.sourcePointIndex - right.sourcePointIndex
|
|
7326
9763
|
);
|
|
7327
9764
|
}
|
|
7328
|
-
function buildParetoPrimitives(
|
|
7329
|
-
const total =
|
|
9765
|
+
function buildParetoPrimitives(entries2, layout, series, seriesIndex) {
|
|
9766
|
+
const total = entries2.reduce((sum, entry) => sum + Math.max(entry.value, 0), 0);
|
|
7330
9767
|
if (total <= 0) {
|
|
7331
9768
|
return [];
|
|
7332
9769
|
}
|
|
7333
9770
|
let cumulative = 0;
|
|
7334
|
-
const points =
|
|
9771
|
+
const points = entries2.map((entry, displayIndex) => {
|
|
7335
9772
|
cumulative += Math.max(entry.value, 0);
|
|
7336
|
-
const percentage = displayIndex ===
|
|
9773
|
+
const percentage = displayIndex === entries2.length - 1 ? 100 : cumulative / total * 100;
|
|
7337
9774
|
return {
|
|
7338
|
-
x: layout.plotLeft + layout.plotWidth * (displayIndex + 0.5) /
|
|
9775
|
+
x: layout.plotLeft + layout.plotWidth * (displayIndex + 0.5) / entries2.length,
|
|
7339
9776
|
y: layout.plotBottom - layout.plotHeight * percentage / 100,
|
|
7340
9777
|
pointIndex: entry.sourcePointIndex
|
|
7341
9778
|
};
|
|
@@ -7421,9 +9858,9 @@ function buildHistogramViewModel(element, chartData, categoryLabels) {
|
|
|
7421
9858
|
value,
|
|
7422
9859
|
label: categoryLabels[index] ?? ""
|
|
7423
9860
|
}))).map((entry, sourcePointIndex) => ({ ...entry, sourcePointIndex }));
|
|
7424
|
-
const
|
|
7425
|
-
const values =
|
|
7426
|
-
const labels =
|
|
9861
|
+
const entries2 = paretoIndex >= 0 ? orderParetoEntries(baseEntries) : baseEntries;
|
|
9862
|
+
const values = entries2.map((entry) => entry.value);
|
|
9863
|
+
const labels = entries2.map((entry) => entry.label);
|
|
7427
9864
|
const range = distributionRange([{ name: series?.name ?? "", values }]);
|
|
7428
9865
|
const bars = computeHistogramBars(
|
|
7429
9866
|
values,
|
|
@@ -7446,14 +9883,14 @@ function buildHistogramViewModel(element, chartData, categoryLabels) {
|
|
|
7446
9883
|
part: {
|
|
7447
9884
|
role: "dataPoint",
|
|
7448
9885
|
seriesIndex: histogramIndex,
|
|
7449
|
-
pointIndex:
|
|
9886
|
+
pointIndex: entries2[displayIndex]?.sourcePointIndex ?? displayIndex
|
|
7450
9887
|
}
|
|
7451
9888
|
}
|
|
7452
9889
|
})
|
|
7453
9890
|
);
|
|
7454
9891
|
if (paretoIndex >= 0) {
|
|
7455
9892
|
primitives.push(
|
|
7456
|
-
...buildParetoPrimitives(
|
|
9893
|
+
...buildParetoPrimitives(entries2, layout, chartData.series[paretoIndex], paretoIndex)
|
|
7457
9894
|
);
|
|
7458
9895
|
}
|
|
7459
9896
|
const dataLabels = chartData.style?.hasDataLabels ? bars.map((bar, index) => ({
|
|
@@ -7468,7 +9905,7 @@ function buildHistogramViewModel(element, chartData, categoryLabels) {
|
|
|
7468
9905
|
resolveDataLabelTextStyle(
|
|
7469
9906
|
chartData,
|
|
7470
9907
|
series,
|
|
7471
|
-
|
|
9908
|
+
entries2[index]?.sourcePointIndex ?? index
|
|
7472
9909
|
)
|
|
7473
9910
|
) : {}
|
|
7474
9911
|
})) : [];
|
|
@@ -7828,11 +10265,11 @@ function splitLabelLines(label) {
|
|
|
7828
10265
|
}
|
|
7829
10266
|
|
|
7830
10267
|
// src/pptx/render/chart-legend-entries.ts
|
|
7831
|
-
function applyLegendEntryOverrides(legend,
|
|
7832
|
-
if ((!
|
|
10268
|
+
function applyLegendEntryOverrides(legend, entries2, defaultTextStyle) {
|
|
10269
|
+
if ((!entries2 || entries2.length === 0) && !defaultTextStyle) {
|
|
7833
10270
|
return legend;
|
|
7834
10271
|
}
|
|
7835
|
-
const byIndex = new Map((
|
|
10272
|
+
const byIndex = new Map((entries2 ?? []).map((entry) => [entry.index, entry]));
|
|
7836
10273
|
const result = [];
|
|
7837
10274
|
legend.forEach((item, index) => {
|
|
7838
10275
|
const override = byIndex.get(index);
|
|
@@ -8084,11 +10521,11 @@ var AXIS_LABEL_COLOR = "#64748b";
|
|
|
8084
10521
|
var ZERO_LINE_COLOR = "#94a3b8";
|
|
8085
10522
|
var TICK_COUNT3 = 5;
|
|
8086
10523
|
function axisTickValues(range) {
|
|
8087
|
-
const
|
|
8088
|
-
if (
|
|
8089
|
-
const steps = Math.round((range.max - range.min) /
|
|
10524
|
+
const unit2 = range.majorUnit;
|
|
10525
|
+
if (unit2 !== void 0 && Number.isFinite(unit2) && unit2 > 0 && !range.logScale) {
|
|
10526
|
+
const steps = Math.round((range.max - range.min) / unit2);
|
|
8090
10527
|
if (steps >= 1 && steps <= 100) {
|
|
8091
|
-
return Array.from({ length: steps + 1 }, (_unused, index) => range.min +
|
|
10528
|
+
return Array.from({ length: steps + 1 }, (_unused, index) => range.min + unit2 * index);
|
|
8092
10529
|
}
|
|
8093
10530
|
}
|
|
8094
10531
|
return Array.from(
|
|
@@ -9099,19 +11536,19 @@ function seriesXValues(chartData, series) {
|
|
|
9099
11536
|
return fromCategories.length > 0 ? fromCategories : void 0;
|
|
9100
11537
|
}
|
|
9101
11538
|
function computeScatterXDomain(perSeriesXValues) {
|
|
9102
|
-
const
|
|
11539
|
+
const finite2 = [];
|
|
9103
11540
|
for (const values of perSeriesXValues) {
|
|
9104
11541
|
for (const value of values ?? []) {
|
|
9105
11542
|
if (Number.isFinite(value)) {
|
|
9106
|
-
|
|
11543
|
+
finite2.push(value);
|
|
9107
11544
|
}
|
|
9108
11545
|
}
|
|
9109
11546
|
}
|
|
9110
|
-
if (
|
|
11547
|
+
if (finite2.length === 0) {
|
|
9111
11548
|
return void 0;
|
|
9112
11549
|
}
|
|
9113
|
-
const min = Math.min(...
|
|
9114
|
-
return { min, span: Math.max(Math.max(...
|
|
11550
|
+
const min = Math.min(...finite2);
|
|
11551
|
+
return { min, span: Math.max(Math.max(...finite2) - min, 1) };
|
|
9115
11552
|
}
|
|
9116
11553
|
function computeScatterDots(values, maxXIndex, layout, range, xValues, xDomain) {
|
|
9117
11554
|
const finiteX = xValues?.slice(0, values.length).filter(Number.isFinite), minX = xDomain ? xDomain.min : finiteX?.length ? Math.min(...finiteX) : 0, spanX = xDomain ? xDomain.span : finiteX?.length ? Math.max(Math.max(...finiteX) - minX, 1) : maxXIndex;
|
|
@@ -9646,8 +12083,8 @@ function buildRegionMapViewModel(element, chartData, categoryLabels) {
|
|
|
9646
12083
|
const resolve2 = (label) => regions.find(
|
|
9647
12084
|
(r) => r.entityId === label || r.code === label || r.name.toLowerCase() === label.toLowerCase()
|
|
9648
12085
|
)?.code ?? resolveRegionCode(label);
|
|
9649
|
-
const
|
|
9650
|
-
const values =
|
|
12086
|
+
const entries2 = buildRegionMapEntries(categories, series?.values ?? [], options, resolve2);
|
|
12087
|
+
const values = entries2.map((entry) => entry.value);
|
|
9651
12088
|
const finiteVals = values.filter((v) => Number.isFinite(v));
|
|
9652
12089
|
const minVal = finiteVals.length > 0 ? Math.min(...finiteVals) : 0;
|
|
9653
12090
|
const maxVal = finiteVals.length > 0 ? Math.max(...finiteVals) : 1;
|
|
@@ -9660,7 +12097,7 @@ function buildRegionMapViewModel(element, chartData, categoryLabels) {
|
|
|
9660
12097
|
const colorScale = valueColorStops ? buildValueColorScale(valueColorStops) : (t) => sequentialColorScale(t, series?.color ?? "#4472C4");
|
|
9661
12098
|
const regionValueMap = /* @__PURE__ */ new Map();
|
|
9662
12099
|
const unmatchedRows = [];
|
|
9663
|
-
for (const entry of
|
|
12100
|
+
for (const entry of entries2) {
|
|
9664
12101
|
if (entry.code !== void 0) {
|
|
9665
12102
|
regionValueMap.set(entry.code, {
|
|
9666
12103
|
value: entry.value,
|
|
@@ -10318,4 +12755,4 @@ function computeTrendlinePrimitives(chartData, catCount, layout, range, mode = "
|
|
|
10318
12755
|
return out;
|
|
10319
12756
|
}
|
|
10320
12757
|
|
|
10321
|
-
export { AXIS_LABEL_COLOR, CHART_PX_PER_PT, CHART_TITLE_FONT_PX, CHART_TITLE_TOP_INSET_PX, DATA_LABEL_LINE_HEIGHT, DATA_LABEL_PAD_X, DATA_LABEL_PAD_Y, DATA_TABLE_HEADER_H, DATA_TABLE_KEY_W, DATA_TABLE_PADDING, DATA_TABLE_ROW_H, DEFAULT_BODY_INSET_LR_PX, DEFAULT_BODY_INSET_TB_PX, DEFAULT_CANVAS_HEIGHT, DEFAULT_CANVAS_WIDTH, DEFAULT_CHART_AREA_FILL, DEFAULT_CHART_DATA_LABEL_PX, DEFAULT_CHART_TEXT_PX, DEFAULT_FILL_COLOR, DEFAULT_FONT_FAMILY, DEFAULT_PALETTE, DEFAULT_STROKE_COLOR, DEFAULT_TEXT_COLOR, DEFAULT_TEXT_FONT_SIZE, GRIDLINE_COLOR3 as GRIDLINE_COLOR, HYPERLINK_COLOR, LEGACY_CHART_TITLE_BAND_PX, LEGEND_LINE_SWATCH_WIDTH, LEGEND_MARKER_RADIUS, OOXML_PATTERN_PRESETS, PIE_AUTO_INSET_PX, TEXT_ORIENTATION_IDENTITY, ZERO_LINE_COLOR, adjustFillForMode, applyDataPointPictureFills, applyLegendEntryOverrides, applyParetoConversion, axisShowsMajorGridlines, axisTickValues, buildBoxWhiskerViewModel, buildCartesianViewModel, buildCategoryLabels, buildChartViewModel, buildCirclePathGradient, buildComboViewModel, buildCssGradientFromShapeStyle, buildDashArray, buildDataLabelText, buildFallbackViewModel, buildFunnelViewModel, buildGradientCss, buildGridlinesAndLabels, buildHistogramViewModel, buildLegend, buildLineLegendSwatch, buildMarkTooltip, buildPatternFill, buildPatternFillCss, buildPieViewModel, buildPrimaryAxis, buildRadarViewModel, buildRectPathGradient, buildReflectedGradientStops, buildRegionMapViewModel, buildSecondaryAxis, buildShapePathGradient, buildStockCloseLabel, buildStockViewModel, buildSubpathFillOverlay, buildSubpathPaints, buildSunburstViewModel, buildSurfaceViewModel, buildTreemapViewModel, buildTrendlineLegendSwatch, buildValueAxisGridlinesAndLabels, buildWaterfallViewModel, buildZeroLine, canvasFontFamily, chartAreaCornerRadius, chartAreaFill, chartAxisIndex, chartFontPx, chartFrameToViewOffset, chartGridlinesPatch, chartGridlinesState, chartPlotBounds, chartPreserveAspectRatio, chartTextBox, chartTextFontFamily, chartTitleBand, chartTitleBandFor, chartTitleFontPx, chartTitleReservePx, clampCropValue, clearBarFacePicturePixelCache, clipStackedSegment, collapseChartTitleRunsForEdit, computeAxisTitlePrimitives, computeBarRects, computeBoxWhiskerGeometry, computeChartLegendLayout, computeDataTableHeight, computeDataTablePrimitives, computeErrorBarPrimitives, computeFunnelSegments, computeGradientCenter, computeHierarchicalSunburstArcs, computeHistogramBars, computeHistogramBins, computeLayout, computeLayoutOptions, computeLinePoints, computePieLayout, computePieSlicePath, computePieSlices, computePlotLayout, computeScatterDots, computeScatterXDomain, computeStackedBarRects, computeStackedValueRange, computeSunburstArcs, computeTrendlinePrimitives, computeValueRange, computeValueRange2, convertOoxmlAngleToCss, createArrayBufferCopy, cumulativePercentOfTotal, dataLabelBox, dataLabelBoxSize, dataLabelFontOverride, decodeFirstPixelColor, ensureBarFacePicturePixelSampled, estimateChartTextWidth, estimateTextWidth, findDataPoint, findPointLabel, findValueAxis, fitTitleBand, formatAxisValue, formatAxisValue2, formatAxisValueWithUnits, getBarFacePicturePixelSampleVersion, getCachedBarFacePicturePixelColor, getCompoundLineBorderWidth, getCompoundLineBoxShadow, getCompoundLineStyle, getComputedFillStyle, getCssBorderDashStyle, getDisplayUnitDivisor, getDisplayUnitLabel, getElementOrientationMatrix, getElementTransform, getElementTransformWithoutRotation, getGradientTileFlipCss, getGradientTileRectCss, getPatternSvg, getPatternTile, getPptxRenderCacheEpoch, getPrimaryValueAxis, getPrimaryValueAxisId, getSecondaryCategoryAxis, getSecondaryValueAxis, getSecondaryValueAxisId, getSvgStrokeDasharray, getTextCompensationTransform, hasSecondaryCategoryAxis, hasSecondaryValueAxis, invalidatePptxRenderCacheEpoch, isParetoChart, isPrimaryCategoryAxisAtTop, isSeriesOnSecondaryAxis, isTextOrientationMatrix, linePointsToSvgString, manualLayoutOf, manualLegendAnchor, manualTitleAnchor, measureChartTextWidth, multiplyTextOrientationMatrices, normalizeStrokeDashType, orderParetoEntries, paletteColor, paletteColor2, parseDrawingPercent, plotAreaFill, primaryValueAxis, reserveLegendSpace, resetBarFacePicturePixelCacheForTests, resolveActiveDataPointPicture, resolveBarFacePicturePixelColor, resolveBarFaceTargets, resolveBarLabelAnchor, resolveBarLabelPlacement, resolveCategoryLabels, resolveChartKind, resolveChartPalette, resolveChartStyleDefaults, resolveChartTitleRunSpans, resolveChartTitleTextStyle, resolveDataLabelContent, resolveDataLabelTextStyle, resolveDataPointExplosion, resolveDataPointFill, resolveDataPointMarker, resolveDataPointPictureFill, resolveDisplayedChartType, resolveExtrusionFaceFill, resolveLabelPosition, resolveLegendAnchorPosition, resolveLegendPlacement, resolveLegendSwatchKind, resolveMarkerLabelAnchor, resolveMarkerLabelPlacement, resolveUntargetedBarFaceFill, resolveVaryColorFill, sanitizeGradientStops, seriesColor, seriesColor2, seriesXValues, setBoundedRenderCache, setChartTextMeasurer, shouldRenderMajorGridlines, splitLabelLines, splitSeriesByAxis, stackedBarWidth, stackedSegmentExtent, subscribeBarFacePicturePixelSamples, suppressesCssFill, surfaceColor, titleBaselineFor, toCssGradientStop, unitsCaptionOffset, upsertDataPoint, valueToY, valueToY2, withChartTitleBand, withManualLayouts, withResolvedPalette, wrapTextByEstimatedWidth };
|
|
12758
|
+
export { AXIS_LABEL_COLOR, CHART_PX_PER_PT, CHART_TITLE_FONT_PX, CHART_TITLE_TOP_INSET_PX, DATA_LABEL_LINE_HEIGHT, DATA_LABEL_PAD_X, DATA_LABEL_PAD_Y, DATA_TABLE_HEADER_H, DATA_TABLE_KEY_W, DATA_TABLE_PADDING, DATA_TABLE_ROW_H, DEFAULT_BODY_INSET_LR_PX, DEFAULT_BODY_INSET_TB_PX, DEFAULT_CANVAS_HEIGHT, DEFAULT_CANVAS_WIDTH, DEFAULT_CHART_AREA_FILL, DEFAULT_CHART_DATA_LABEL_PX, DEFAULT_CHART_TEXT_PX, DEFAULT_FILL_COLOR, DEFAULT_FONT_FAMILY, DEFAULT_PALETTE, DEFAULT_STROKE_COLOR, DEFAULT_TEXT_COLOR, DEFAULT_TEXT_FONT_SIZE, GRIDLINE_COLOR3 as GRIDLINE_COLOR, HYPERLINK_COLOR, LEGACY_CHART_TITLE_BAND_PX, LEGEND_LINE_SWATCH_WIDTH, LEGEND_MARKER_RADIUS, MORPH_PROGRESS_VAR, OOXML_PATTERN_PRESETS, PIE_AUTO_INSET_PX, TEXT_ORIENTATION_IDENTITY, TEXT_SHADOW_BLUR_TO_CSS, ZERO_LINE_COLOR, adjustFillForMode, applyDataPointPictureFills, applyLegendEntryOverrides, applyParetoConversion, axisShowsMajorGridlines, axisTickValues, buildBoxWhiskerViewModel, buildCartesianViewModel, buildCategoryLabels, buildChartViewModel, buildCirclePathGradient, buildComboViewModel, buildCssGradientFromShapeStyle, buildCustomGeometryClipPath, buildCustomPathMarkers, buildDashArray, buildDataLabelText, buildFallbackViewModel, buildFunnelViewModel, buildGlowBoxShadow, buildGradientCss, buildGridlinesAndLabels, buildHistogramViewModel, buildInnerShadowCssFromShapeStyle, buildLegend, buildLineGlowFilter, buildLineLegendSwatch, buildLineShadowCss, buildMarkTooltip, buildMultiLayerShadowCss, buildPatternFill, buildPatternFillCss, buildPieViewModel, buildPrimaryAxis, buildRadarViewModel, buildRectPathGradient, buildReflectedGradientStops, buildRegionMapViewModel, buildSecondaryAxis, buildShadowCssFromShapeStyle, buildShapePathGradient, buildSilhouetteFilterMarkup, buildStockCloseLabel, buildStockViewModel, buildStrokeOutline, buildSubpathFillOverlay, buildSubpathPaints, buildSunburstViewModel, buildSurfaceViewModel, buildSvgGradientDef, buildSvgStrokeGradientDef, buildSvgStrokePatternDef, buildTreemapViewModel, buildTrendlineLegendSwatch, buildValueAxisGridlinesAndLabels, buildWaterfallViewModel, buildZeroLine, canvasFontFamily, capCompensatedDashArray, chartAreaCornerRadius, chartAreaFill, chartAxisIndex, chartFontPx, chartFrameToViewOffset, chartGridlinesPatch, chartGridlinesState, chartPlotBounds, chartPreserveAspectRatio, chartTextBox, chartTextFontFamily, chartTitleBand, chartTitleBandFor, chartTitleFontPx, chartTitleReservePx, clampCropValue, clearBarFacePicturePixelCache, clipStackedSegment, collapseChartTitleRunsForEdit, compoundStrandPath, computeAxisTitlePrimitives, computeBarRects, computeBoxWhiskerGeometry, computeChartLegendLayout, computeDataTableHeight, computeDataTablePrimitives, computeErrorBarPrimitives, computeFunnelSegments, computeGradientCenter, computeHierarchicalSunburstArcs, computeHistogramBars, computeHistogramBins, computeLayout, computeLayoutOptions, computeLinePoints, computePieLayout, computePieSlicePath, computePieSlices, computePlotLayout, computeScatterDots, computeScatterXDomain, computeStackedBarRects, computeStackedValueRange, computeSunburstArcs, computeTrendlinePrimitives, computeValueRange, computeValueRange2, connectorKind, connectorNeedsPath, connectorStrandScreenWidth, convertOoxmlAngleToCss, createArrayBufferCopy, cumulativePercentOfTotal, dashPatternUnits, dashPenWidth, dashStartPathData, dataLabelBox, dataLabelBoxSize, dataLabelFontOverride, decodeFirstPixelColor, ensureBarFacePicturePixelSampled, escapeSvgAttr, estimateChartTextWidth, estimateTextWidth, findDataPoint, findPointLabel, findValueAxis, fitTitleBand, flattenPath, formatAxisValue, formatAxisValue2, formatAxisValueWithUnits, getBarFacePicturePixelSampleVersion, getBoxShadowCss, getCachedBarFacePicturePixelColor, getCompositeOuterShadowFilterCss, getCompoundLineBorderWidth, getCompoundLineBoxShadow, getCompoundLineOffsets, getCompoundLineStyle, getCompoundLineWidths, getComputedEffectStyle, getComputedFillStyle, getComputedStrokeStyle, getCssBorderDashStyle, getDisplayUnitDivisor, getDisplayUnitLabel, getDuotoneFilterId, getDuotoneSvgFilter, getDuotoneSvgFilterMarkup, getEffectDagBlendMode, getEffectDagCssFilter, getEffectDagFillOverlay, getEffectDagFilter, getEffectDagOpacity, getEffectFilterCss, getEffectStyleSource, getElementOrientationMatrix, getElementTransform, getElementTransformWithoutRotation, getGlowBoxShadowCss, getGradientTileFlipCss, getGradientTileRectCss, getInnerShadowCss, getLineGlowFilterCss, getLineShadowCss, getLineShadowParams, getMultiLayerShadowCss, getOuterShadowCss, getPatternSvg, getPatternTile, getPptxRenderCacheEpoch, getPresetShapeVectorGeometry, getPrimaryValueAxis, getPrimaryValueAxisId, getReflectionWrapperStyle, getResolvedShapeClipPath, getResolvedShapeClipPathFor, getSecondaryCategoryAxis, getSecondaryValueAxis, getSecondaryValueAxisId, getShapeEffectFilterDefs, getShapeFillOverlay, getSilhouetteEffectParams, getSilhouetteEffects, getSilhouetteFilterId, getSoftEdgeFilterId, getSoftEdgeSvgFilter, getSplitStrokePresetPaths, getStrokeOnlyPresetPaths, getSvgStrokeDasharray, getTextCompensationTransform, getTextReflectionWrapperStyle, glowFilterLengths, hasEffectDagProperties, hasImageEffects, hasSecondaryCategoryAxis, hasSecondaryValueAxis, hasStrokePaint, invalidatePptxRenderCacheEpoch, isArrowedCustomPath, isDashedStroke, isIdentityRectClip, isParetoChart, isPatternPaint, isPrimaryCategoryAxisAtTop, isSeriesOnSecondaryAxis, isStrokeOnlyPresetElement, isTextOrientationMatrix, isWedgeCalloutPresetShape, linePointsToSvgString, manualLayoutOf, manualLegendAnchor, manualTitleAnchor, markerPath, measureChartTextWidth, multiplyTextOrientationMatrices, normalizeArrow, normalizeStrokeDashType, orderParetoEntries, outlinePathData, outlineStrokeJoin, outsetClipPathForStroke, paintedStrokeWidth, paletteColor, paletteColor2, parseDrawingPercent, plotAreaFill, primaryValueAxis, registerGroupChildren, registerSilhouetteMorph, reserveLegendSpace, resetBarFacePicturePixelCacheForTests, resolveActiveDataPointPicture, resolveBarFacePicturePixelColor, resolveBarFaceTargets, resolveBarLabelAnchor, resolveBarLabelPlacement, resolveBaseShapeGeometry, resolveCategoryLabels, resolveChartKind, resolveChartPalette, resolveChartStyleDefaults, resolveChartTitleRunSpans, resolveChartTitleTextStyle, resolveComputedFill, resolveDataLabelContent, resolveDataLabelTextStyle, resolveDataPointExplosion, resolveDataPointFill, resolveDataPointMarker, resolveDataPointPictureFill, resolveDisplayedChartType, resolveExtrusionFaceFill, resolveGlow, resolveInnerShadow, resolveLabelPosition, resolveLegendAnchorPosition, resolveLegendPlacement, resolveLegendSwatchKind, resolveLiveCustomGeometryPath, resolveMarkerLabelAnchor, resolveMarkerLabelPlacement, resolveOuterShadowLayers, resolveUntargetedBarFaceFill, resolveVaryColorFill, sanitizeGradientStops, seriesColor, seriesColor2, seriesXValues, setBoundedRenderCache, setChartTextMeasurer, shouldRenderMajorGridlines, silhouetteFillsLayer, silhouetteFillsOverlay, silhouetteMorphEntry, snapPlacement, splitLabelLines, splitSeriesByAxis, splitStrokePresetPathData, stackedBarWidth, stackedSegmentExtent, straddlingStrokeWidth, strokeMiterLimit, strokeOnlyPresetPathData, strokeOutlineViewBox, subscribeBarFacePicturePixelSamples, suppressesCssBorder, suppressesCssFill, surfaceColor, svgGradientFillRef, svgGradientId, svgGradientMarkup, svgLineCap, titleBaselineFor, toCssGradientStop, unitsCaptionOffset, upsertDataPoint, usesSilhouetteEffects, valueToY, valueToY2, withChartTitleBand, withManualLayouts, withResolvedPalette, wrapTextByEstimatedWidth };
|