@office-open/core 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/archive.mjs +135 -1
- package/dist/chart/index.d.mts +1 -1
- package/dist/chart/index.mjs +611 -1
- package/dist/drawingml/index.mjs +3918 -1
- package/dist/id-generators-CM3u923a.mjs +72 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +424 -1
- package/dist/smartart/index.mjs +2 -1
- package/dist/smartart-CdBk8E0n.mjs +336 -0
- package/dist/values.mjs +371 -1
- package/dist/xml-components-CJKrtCSG.mjs +381 -0
- package/package.json +2 -2
- package/dist/id-generators-Dd0w7vti.mjs +0 -1
- package/dist/smartart-C-ZIRmWU.mjs +0 -1
- package/dist/xml-components-Csq7gWPd.mjs +0 -1
package/dist/drawingml/index.mjs
CHANGED
|
@@ -1 +1,3918 @@
|
|
|
1
|
-
import{S as e,T as t,a as n}from"../xml-components-Csq7gWPd.mjs";import{d as r,t as i}from"../id-generators-Dd0w7vti.mjs";const a=e=>{let t=[];return e.tint!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.tint}},name:`a:tint`})),e.shade!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.shade}},name:`a:shade`})),e.comp&&t.push(new n({name:`a:comp`})),e.inv&&t.push(new n({name:`a:inv`})),e.gray&&t.push(new n({name:`a:gray`})),e.alpha!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.alpha}},name:`a:alpha`})),e.alphaOff!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.alphaOff}},name:`a:alphaOff`})),e.alphaMod!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.alphaMod}},name:`a:alphaMod`})),e.hue!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.hue}},name:`a:hue`})),e.hueOff!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.hueOff}},name:`a:hueOff`})),e.hueMod!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.hueMod}},name:`a:hueMod`})),e.sat!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.sat}},name:`a:sat`})),e.satOff!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.satOff}},name:`a:satOff`})),e.satMod!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.satMod}},name:`a:satMod`})),e.lum!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.lum}},name:`a:lum`})),e.lumOff!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.lumOff}},name:`a:lumOff`})),e.lumMod!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.lumMod}},name:`a:lumMod`})),e.red!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.red}},name:`a:red`})),e.redOff!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.redOff}},name:`a:redOff`})),e.redMod!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.redMod}},name:`a:redMod`})),e.green!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.green}},name:`a:green`})),e.greenOff!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.greenOff}},name:`a:greenOff`})),e.greenMod!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.greenMod}},name:`a:greenMod`})),e.blue!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.blue}},name:`a:blue`})),e.blueOff!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.blueOff}},name:`a:blueOff`})),e.blueMod!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:e.blueMod}},name:`a:blueMod`})),e.gamma&&t.push(new n({name:`a:gamma`})),e.invGamma&&t.push(new n({name:`a:invGamma`})),t},o=e=>{let t=e.transforms?a(e.transforms):[];return new n({attributes:{hue:{key:`hue`,value:e.hue},lum:{key:`lum`,value:e.luminance},sat:{key:`sat`,value:e.saturation}},children:[...t],name:`a:hslClr`})},s={ALICE_BLUE:`aliceBlue`,ANTIQUE_WHITE:`antiqueWhite`,AQUA:`aqua`,AQUAMARINE:`aquamarine`,AZURE:`azure`,BEIGE:`beige`,BISQUE:`bisque`,BLACK:`black`,BLANCHED_ALMOND:`blanchedAlmond`,BLUE:`blue`,BLUE_VIOLET:`blueViolet`,BROWN:`brown`,BURLY_WOOD:`burlyWood`,CADET_BLUE:`cadetBlue`,CHARTREUSE:`chartreuse`,CHOCOLATE:`chocolate`,CORAL:`coral`,CORNFLOWER_BLUE:`cornflowerBlue`,CORNSILK:`cornsilk`,CRIMSON:`crimson`,CYAN:`cyan`,DARK_BLUE:`darkBlue`,DARK_CYAN:`darkCyan`,DARK_GOLDENROD:`darkGoldenrod`,DARK_GRAY:`darkGray`,DARK_GREY:`darkGrey`,DARK_GREEN:`darkGreen`,DARK_KHAKI:`darkKhaki`,DARK_MAGENTA:`darkMagenta`,DARK_OLIVE_GREEN:`darkOliveGreen`,DARK_ORANGE:`darkOrange`,DARK_ORCHID:`darkOrchid`,DARK_RED:`darkRed`,DARK_SALMON:`darkSalmon`,DARK_SEA_GREEN:`darkSeaGreen`,DARK_SLATE_BLUE:`darkSlateBlue`,DARK_SLATE_GRAY:`darkSlateGray`,DARK_SLATE_GREY:`darkSlateGrey`,DARK_TURQUOISE:`darkTurquoise`,DARK_VIOLET:`darkViolet`,DEEP_PINK:`deepPink`,DEEP_SKY_BLUE:`deepSkyBlue`,DIM_GRAY:`dimGray`,DIM_GREY:`dimGrey`,DODGER_BLUE:`dodgerBlue`,FIREBRICK:`firebrick`,FLORAL_WHITE:`floralWhite`,FOREST_GREEN:`forestGreen`,FUCHSIA:`fuchsia`,GAINSBORO:`gainsboro`,GHOST_WHITE:`ghostWhite`,GOLD:`gold`,GOLDENROD:`goldenrod`,GRAY:`gray`,GREY:`grey`,GREEN:`green`,GREEN_YELLOW:`greenYellow`,HONEYDEW:`honeydew`,HOT_PINK:`hotPink`,INDIAN_RED:`indianRed`,INDIGO:`indigo`,IVORY:`ivory`,KHAKI:`khaki`,LAVENDER:`lavender`,LAVENDER_BLUSH:`lavenderBlush`,LAWN_GREEN:`lawnGreen`,LEMON_CHIFFON:`lemonChiffon`,LIGHT_BLUE:`lightBlue`,LIGHT_CORAL:`lightCoral`,LIGHT_CYAN:`lightCyan`,LIGHT_GOLDENROD_YELLOW:`lightGoldenrodYellow`,LIGHT_GRAY:`lightGray`,LIGHT_GREY:`lightGrey`,LIGHT_GREEN:`lightGreen`,LIGHT_PINK:`lightPink`,LIGHT_SALMON:`lightSalmon`,LIGHT_SEA_GREEN:`lightSeaGreen`,LIGHT_SKY_BLUE:`lightSkyBlue`,LIGHT_SLATE_GRAY:`lightSlateGray`,LIGHT_SLATE_GREY:`lightSlateGrey`,LIGHT_STEEL_BLUE:`lightSteelBlue`,LIGHT_YELLOW:`lightYellow`,LIME:`lime`,LIME_GREEN:`limeGreen`,LINEN:`linen`,MAGENTA:`magenta`,MAROON:`maroon`,MEDIUM_AQUAMARINE:`mediumAquamarine`,MEDIUM_BLUE:`mediumBlue`,MEDIUM_ORCHID:`mediumOrchid`,MEDIUM_PURPLE:`mediumPurple`,MEDIUM_SEA_GREEN:`mediumSeaGreen`,MEDIUM_SLATE_BLUE:`mediumSlateBlue`,MEDIUM_SPRING_GREEN:`mediumSpringGreen`,MEDIUM_TURQUOISE:`mediumTurquoise`,MEDIUM_VIOLET_RED:`mediumVioletRed`,MIDNIGHT_BLUE:`midnightBlue`,MINT_CREAM:`mintCream`,MISTY_ROSE:`mistyRose`,MOCCASIN:`moccasin`,NAVAJO_WHITE:`navajoWhite`,NAVY:`navy`,OLD_LACE:`oldLace`,OLIVE:`olive`,OLIVE_DRAB:`oliveDrab`,ORANGE:`orange`,ORANGE_RED:`orangeRed`,ORCHID:`orchid`,PALE_GOLDENROD:`paleGoldenrod`,PALE_GREEN:`paleGreen`,PALE_TURQUOISE:`paleTurquoise`,PALE_VIOLET_RED:`paleVioletRed`,PAPAYA_WHIP:`papayaWhip`,PEACH_PUFF:`peachPuff`,PERU:`peru`,PINK:`pink`,PLUM:`plum`,POWDER_BLUE:`powderBlue`,PURPLE:`purple`,RED:`red`,ROSY_BROWN:`rosyBrown`,ROYAL_BLUE:`royalBlue`,SADDLE_BROWN:`saddleBrown`,SALMON:`salmon`,SANDY_BROWN:`sandyBrown`,SEA_GREEN:`seaGreen`,SEA_SHELL:`seaShell`,SIENNA:`sienna`,SILVER:`silver`,SKY_BLUE:`skyBlue`,SLATE_BLUE:`slateBlue`,SLATE_GRAY:`slateGray`,SLATE_GREY:`slateGrey`,SNOW:`snow`,SPRING_GREEN:`springGreen`,STEEL_BLUE:`steelBlue`,TAN:`tan`,TEAL:`teal`,THISTLE:`thistle`,TOMATO:`tomato`,TURQUOISE:`turquoise`,VIOLET:`violet`,WHEAT:`wheat`,WHITE:`white`,WHITE_SMOKE:`whiteSmoke`,YELLOW:`yellow`,YELLOW_GREEN:`yellowGreen`},ee=e=>{let t=e.transforms?a(e.transforms):[];return new n({attributes:{value:{key:`val`,value:e.value}},children:[...t],name:`a:prstClr`})},te=e=>{let t=e.transforms?a(e.transforms):[];return new n({attributes:{value:{key:`val`,value:e.value}},children:[...t],name:`a:srgbClr`})},c=e=>{let t=e.transforms?a(e.transforms):[];return new n({attributes:{r:{key:`r`,value:e.r},g:{key:`g`,value:e.g},b:{key:`b`,value:e.b}},children:[...t],name:`a:scrgbClr`})},l={BG1:`bg1`,TX1:`tx1`,BG2:`bg2`,TX2:`tx2`,ACCENT1:`accent1`,ACCENT2:`accent2`,ACCENT3:`accent3`,ACCENT4:`accent4`,ACCENT5:`accent5`,ACCENT6:`accent6`,HLINK:`hlink`,FOLHLINK:`folHlink`,DK1:`dk1`,LT1:`lt1`,DK2:`dk2`,LT2:`lt2`,PHCLR:`phClr`},u=e=>{let t=e.transforms?a(e.transforms):[];return new n({attributes:{value:{key:`val`,value:e.value}},children:[...t],name:`a:schemeClr`})},d={SCROLL_BAR:`scrollBar`,BACKGROUND:`background`,ACTIVE_CAPTION:`activeCaption`,INACTIVE_CAPTION:`inactiveCaption`,MENU:`menu`,WINDOW:`window`,WINDOW_FRAME:`windowFrame`,MENU_TEXT:`menuText`,WINDOW_TEXT:`windowText`,CAPTION_TEXT:`captionText`,ACTIVE_BORDER:`activeBorder`,INACTIVE_BORDER:`inactiveBorder`,APP_WORKSPACE:`appWorkspace`,HIGHLIGHT:`highlight`,HIGHLIGHT_TEXT:`highlightText`,BTN_FACE:`btnFace`,BTN_SHADOW:`btnShadow`,GRAY_TEXT:`grayText`,BTN_TEXT:`btnText`,INACTIVE_CAPTION_TEXT:`inactiveCaptionText`,BTN_HIGHLIGHT:`btnHighlight`,THREE_D_DK_SHADOW:`3dDkShadow`,THREE_D_LIGHT:`3dLight`,INFO_TEXT:`infoText`,INFO_BK:`infoBk`,HOT_LIGHT:`hotLight`,GRADIENT_ACTIVE_CAPTION:`gradientActiveCaption`,GRADIENT_INACTIVE_CAPTION:`gradientInactiveCaption`,MENU_HIGHLIGHT:`menuHighlight`,MENU_BAR:`menuBar`},f=e=>{let t=e.transforms?a(e.transforms):[];return new n({attributes:{lastClr:{key:`lastClr`,value:e.lastClr},value:{key:`val`,value:e.value}},children:[...t],name:`a:sysClr`})},ne=new Set(Object.values(d)),re=new Set(Object.values(s)),ie=new Set(Object.values(l)),p=e=>{if(`hue`in e&&`saturation`in e&&`luminance`in e)return o(e);if(`r`in e&&`g`in e&&`b`in e)return c(e);let t=e.value;return ne.has(t)?f(e):re.has(t)?ee(e):ie.has(t)?u(e):te(e)},m=e=>new n({children:[p(e)],name:`a:solidFill`}),h=e=>{let t=[];if(e.grayscale&&t.push(new n({name:`a:grayscl`})),e.luminance){let r={};e.luminance.bright!==void 0&&(r.bright={key:`bright`,value:`${e.luminance.bright}%`}),e.luminance.contrast!==void 0&&(r.contrast={key:`contrast`,value:`${e.luminance.contrast}%`}),t.push(new n({attributes:r,name:`a:lum`}))}if(e.hsl){let r={};e.hsl.hue!==void 0&&(r.hue={key:`hue`,value:String(e.hsl.hue)}),e.hsl.saturation!==void 0&&(r.sat={key:`sat`,value:`${e.hsl.saturation}%`}),e.hsl.luminance!==void 0&&(r.lum={key:`lum`,value:`${e.hsl.luminance}%`}),t.push(new n({attributes:r,name:`a:hsl`}))}if(e.tint){let r={};e.tint.hue!==void 0&&(r.hue={key:`hue`,value:String(e.tint.hue)}),e.tint.amount!==void 0&&(r.amt={key:`amt`,value:`${e.tint.amount}%`}),t.push(new n({attributes:r,name:`a:tint`}))}if(e.duotone&&t.push(new n({children:[p(e.duotone.color1),p(e.duotone.color2)],name:`a:duotone`})),e.biLevel&&t.push(new n({attributes:{thresh:{key:`thresh`,value:`${e.biLevel.threshold}%`}},name:`a:biLevel`})),e.alphaCeiling&&t.push(new n({name:`a:alphaCeiling`})),e.alphaFloor&&t.push(new n({name:`a:alphaFloor`})),e.alphaInverse!==void 0&&(typeof e.alphaInverse==`boolean`?t.push(new n({name:`a:alphaInv`})):t.push(new n({children:[p(e.alphaInverse)],name:`a:alphaInv`}))),e.alphaModFix){let r=e.alphaModFix.amount??100;t.push(new n({attributes:{amt:{key:`amt`,value:`${r}%`}},name:`a:alphaModFix`}))}if(e.alphaRepl&&t.push(new n({attributes:{a:{key:`a`,value:`${e.alphaRepl.amount}%`}},name:`a:alphaRepl`})),e.alphaBiLevel&&t.push(new n({attributes:{thresh:{key:`thresh`,value:`${e.alphaBiLevel.threshold}%`}},name:`a:alphaBiLevel`})),e.colorChange){let r={};e.colorChange.useAlpha===!1&&(r.useA={key:`useA`,value:`0`}),t.push(new n({attributes:r,children:[new n({children:[p(e.colorChange.from)],name:`a:clrFrom`}),new n({children:[p(e.colorChange.to)],name:`a:clrTo`})],name:`a:clrChange`}))}if(e.colorRepl&&t.push(new n({children:[p(e.colorRepl.color)],name:`a:clrRepl`})),e.blur){let r={};e.blur.radius!==void 0&&(r.rad={key:`rad`,value:e.blur.radius}),e.blur.grow===!1&&(r.grow={key:`grow`,value:0}),t.push(new n({attributes:r,name:`a:blur`}))}return t},g=e=>{if(!e)return new n({name:`a:srcRect`});let t={};return e.left!==void 0&&(t.l={key:`l`,value:e.left}),e.top!==void 0&&(t.t={key:`t`,value:e.top}),e.right!==void 0&&(t.r={key:`r`,value:e.right}),e.bottom!==void 0&&(t.b={key:`b`,value:e.bottom}),new n({attributes:t,name:`a:srcRect`})};var ae=class extends t{constructor(){super(`a:fillRect`)}},_=class extends t{constructor(){super(`a:stretch`),this.root.push(new ae)}};const oe={NONE:`none`,X:`x`,Y:`y`,XY:`xy`},v={TOP_LEFT:`tl`,TOP:`t`,TOP_RIGHT:`tr`,LEFT:`l`,CENTER:`ctr`,RIGHT:`r`,BOTTOM_LEFT:`bl`,BOTTOM:`b`,BOTTOM_RIGHT:`br`},y=e=>{if(!e)return new n({name:`a:tile`});let t={};return e.tx!==void 0&&(t.tx={key:`tx`,value:e.tx}),e.ty!==void 0&&(t.ty={key:`ty`,value:e.ty}),e.sx!==void 0&&(t.sx={key:`sx`,value:e.sx}),e.sy!==void 0&&(t.sy={key:`sy`,value:e.sy}),e.flip!==void 0&&(t.flip={key:`flip`,value:oe[e.flip]}),e.align!==void 0&&(t.algn={key:`algn`,value:v[e.align]}),new n({attributes:Object.keys(t).length>0?t:void 0,name:`a:tile`})},b={SHAPE:`shape`,CIRCLE:`circle`,RECT:`rect`},se={NONE:`none`,X:`x`,Y:`y`,XY:`xy`},x=e=>new n({attributes:{pos:{key:`pos`,value:e.position}},children:[p(e.color)],name:`a:gs`}),S=(e,t)=>new n({attributes:{l:{key:`l`,value:t?.left},t:{key:`t`,value:t?.top},r:{key:`r`,value:t?.right},b:{key:`b`,value:t?.bottom}},name:e}),ce=e=>{if(`angle`in e)return new n({attributes:{ang:{key:`ang`,value:e.angle},scaled:{key:`scaled`,value:e.scaled}},name:`a:lin`});let t=e,r=[];return t.fillToRect&&r.push(S(`a:fillToRect`,t.fillToRect)),new n({attributes:{path:{key:`path`,value:t.path?b[t.path]:void 0}},children:r,name:`a:path`})},C=e=>{let t=[];return t.push(new n({children:e.stops.map(x),name:`a:gsLst`})),e.shade&&t.push(ce(e.shade)),e.tileRect&&t.push(S(`a:tileRect`,e.tileRect)),new n({attributes:{flip:{key:`flip`,value:e.flip?se[e.flip]:void 0},rotWithShape:{key:`rotWithShape`,value:e.rotateWithShape}},children:t,name:`a:gradFill`})},le={PCT5:`pct5`,PCT10:`pct10`,PCT20:`pct20`,PCT25:`pct25`,PCT30:`pct30`,PCT40:`pct40`,PCT50:`pct50`,PCT60:`pct60`,PCT70:`pct70`,PCT75:`pct75`,PCT80:`pct80`,PCT90:`pct90`,HORZ:`horz`,VERT:`vert`,LT_HORZ:`ltHorz`,LT_VERT:`ltVert`,DK_HORZ:`dkHorz`,DK_VERT:`dkVert`,NAR_HORZ:`narHorz`,NAR_VERT:`narVert`,DASH_HORZ:`dashHorz`,DASH_VERT:`dashVert`,CROSS:`cross`,DN_DIAG:`dnDiag`,UP_DIAG:`upDiag`,LT_DN_DIAG:`ltDnDiag`,LT_UP_DIAG:`ltUpDiag`,DK_DN_DIAG:`dkDnDiag`,DK_UP_DIAG:`dkUpDiag`,WD_DN_DIAG:`wdDnDiag`,WD_UP_DIAG:`wdUpDiag`,DASH_DN_DIAG:`dashDnDiag`,DASH_UP_DIAG:`dashUpDiag`,DIAG_CROSS:`diagCross`,SM_CHECK:`smCheck`,LG_CHECK:`lgCheck`,SM_GRID:`smGrid`,LG_GRID:`lgGrid`,DOT_GRID:`dotGrid`,SM_CONFETTI:`smConfetti`,LG_CONFETTI:`lgConfetti`,HORZ_BRICK:`horzBrick`,DIAG_BRICK:`diagBrick`,SOLID_DMND:`solidDmnd`,OPEN_DMND:`openDmnd`,DOT_DMND:`dotDmnd`,PLAID:`plaid`,SPHERE:`sphere`,WEAVE:`weave`,DIVOT:`divot`,SHINGLE:`shingle`,WAVE:`wave`,TRELLIS:`trellis`,ZIG_ZAG:`zigZag`},w=e=>{let t=[];return e.foregroundColor&&t.push(new n({children:[p(e.foregroundColor)],name:`a:fgClr`})),e.backgroundColor&&t.push(new n({children:[p(e.backgroundColor)],name:`a:bgClr`})),new n({attributes:{prst:{key:`prst`,value:e.pattern}},children:t,name:`a:pattFill`})};function T(e){return typeof e==`string`?{value:e.replace(`#`,``)}:e}function ue(e){return e instanceof Uint8Array?e:new Uint8Array(e)}const de=e=>{if(typeof e==`string`||e.type!==`blip`)return;let t=ue(e.data);return{data:t,fileName:`${i(t)}.${e.imageType}`,type:e.imageType}},fe=e=>{if(typeof e==`string`)return m({value:e.replace(`#`,``)});switch(e.type){case`solid`:return m(T(e.color));case`none`:return new n({name:`a:noFill`});case`gradient`:return`options`in e?C(e.options):C({stops:e.stops.map(e=>({position:e.position*1e3,color:T(e.color)})),...!e.path&&e.angle!==void 0&&{shade:{angle:e.angle*6e4,scaled:e.scaled??!0}},...e.path&&{shade:{path:e.path.toUpperCase()}}});case`blip`:{let t=`${i(ue(e.data))}.${e.imageType}`,r=[];e.blipEffects&&r.push(...h(e.blipEffects));let a=[new n({attributes:{cstate:{key:`cstate`,value:`none`},embed:{key:`r:embed`,value:`{${t}}`}},children:r,name:`a:blip`}),g(e.srcRect)];e.tile?a.push(y(e.tile)):a.push(new _);let o={};return e.dpi!==void 0&&(o.dpi={key:`dpi`,value:e.dpi}),e.rotWithShape!==void 0&&(o.rotWithShape={key:`rotWithShape`,value:+!!e.rotWithShape}),new n({attributes:Object.keys(o).length>0?o:void 0,children:a,name:`a:blipFill`})}case`pattern`:return w({pattern:e.pattern,...e.foregroundColor&&{foregroundColor:T(e.foregroundColor)},...e.backgroundColor&&{backgroundColor:T(e.backgroundColor)}});case`group`:return new n({name:`a:grpFill`})}},E=()=>new n({name:`a:noFill`}),D=()=>new n({name:`a:grpFill`}),O=e=>{let t=[];for(let r of e)t.push(new n({attributes:{d:{key:`d`,value:r.d},sp:{key:`sp`,value:r.sp}},name:`a:ds`}));return new n({children:t,name:`a:custDash`})},k={NONE:`none`,TRIANGLE:`triangle`,STEALTH:`stealth`,DIAMOND:`diamond`,OVAL:`oval`,ARROW:`arrow`},A={SMALL:`sm`,MEDIUM:`med`,LARGE:`lg`},j={SMALL:`sm`,MEDIUM:`med`,LARGE:`lg`},M=(e,t)=>new n({attributes:{type:{key:`type`,value:k[t.type]},w:{key:`w`,value:t.width?A[t.width]:void 0},len:{key:`len`,value:t.length?j[t.length]:void 0}},name:e}),N={ROUND:`rnd`,SQUARE:`sq`,FLAT:`flat`},P={SINGLE:`sng`,DOUBLE:`dbl`,THICK_THIN:`thickThin`,THIN_THICK:`thinThick`,TRI:`tri`},F={CENTER:`ctr`,INSET:`in`},I={SOLID:`solid`,DOT:`dot`,DASH:`dash`,LG_DASH:`lgDash`,DASH_DOT:`dashDot`,LG_DASH_DOT:`lgDashDot`,LG_DASH_DOT_DOT:`lgDashDotDot`,SYS_DASH:`sysDash`,SYS_DOT:`sysDot`,SYS_DASH_DOT:`sysDashDot`,SYS_DASH_DOT_DOT:`sysDashDotDot`},L={ROUND:`round`,BEVEL:`bevel`,MITER:`miter`},pe=e=>e.type===`noFill`?E():e.type===`solidFill`&&e.color?m(e.color):e.type===`gradFill`&&e.gradientFill?C(e.gradientFill):e.type===`pattFill`&&e.patternFill?w(e.patternFill):null,me=e=>{let t=[],r=pe(e);return r&&t.push(r),e.customDash===void 0?e.dash!==void 0&&t.push(new n({attributes:{val:{key:`val`,value:I[e.dash]}},name:`a:prstDash`})):t.push(O(e.customDash)),e.join!==void 0&&(e.join===`MITER`&&e.miterLimit!==void 0?t.push(new n({attributes:{lim:{key:`lim`,value:e.miterLimit}},name:`a:miter`})):t.push(new n({name:`a:${L[e.join]}`}))),e.headEnd&&t.push(M(`a:headEnd`,e.headEnd)),e.tailEnd&&t.push(M(`a:tailEnd`,e.tailEnd)),new n({attributes:{align:{key:`algn`,value:e.align?F[e.align]:void 0},cap:{key:`cap`,value:e.cap?N[e.cap]:void 0},compoundLine:{key:`cmpd`,value:e.compoundLine?P[e.compoundLine]:void 0},width:{key:`w`,value:e.width}},children:t,name:`a:ln`})},he={OVER:`over`,MULTIPLY:`mult`,SCREEN:`screen`,DARKEN:`darken`,LIGHTEN:`lighten`},R=e=>{let t;return t=e.noFill?E():e.solidFill?m(e.solidFill):e.gradientFill?C(e.gradientFill):e.patternFill?w(e.patternFill):e.groupFill?D():m({value:`000000`}),new n({attributes:{blend:{key:`blend`,value:e.blend}},children:[t],name:`a:fillOverlay`})},z=e=>e.radius===void 0?new n({children:[p(e.color)],name:`a:glow`}):new n({attributes:{rad:{key:`rad`,value:e.radius}},children:[p(e.color)],name:`a:glow`}),B=e=>e.blurRadius!==void 0||e.distance!==void 0||e.direction!==void 0?new n({attributes:{...e.blurRadius!==void 0&&{blurRad:{key:`blurRad`,value:e.blurRadius}},...e.distance!==void 0&&{dist:{key:`dist`,value:e.distance}},...e.direction!==void 0&&{dir:{key:`dir`,value:e.direction}}},children:[p(e.color)],name:`a:innerShdw`}):new n({children:[p(e.color)],name:`a:innerShdw`}),V={TOP_LEFT:`tl`,TOP:`t`,TOP_RIGHT:`tr`,LEFT:`l`,CENTER:`ctr`,RIGHT:`r`,BOTTOM_LEFT:`bl`,BOTTOM:`b`,BOTTOM_RIGHT:`br`},H=e=>{let t={};return e.blurRadius!==void 0&&(t.blurRad={key:`blurRad`,value:e.blurRadius}),e.distance!==void 0&&(t.dist={key:`dist`,value:e.distance}),e.direction!==void 0&&(t.dir={key:`dir`,value:e.direction}),e.scaleX!==void 0&&(t.sx={key:`sx`,value:e.scaleX}),e.scaleY!==void 0&&(t.sy={key:`sy`,value:e.scaleY}),e.skewX!==void 0&&(t.kx={key:`kx`,value:e.skewX}),e.skewY!==void 0&&(t.ky={key:`ky`,value:e.skewY}),e.alignment!==void 0&&(t.algn={key:`algn`,value:V[e.alignment]}),e.rotWithShape===!1&&(t.rotWithShape={key:`rotWithShape`,value:0}),new n({attributes:t,children:[p(e.color)],name:`a:outerShdw`})},U={SHDW1:`shdw1`,SHDW2:`shdw2`,SHDW3:`shdw3`,SHDW4:`shdw4`,SHDW5:`shdw5`,SHDW6:`shdw6`,SHDW7:`shdw7`,SHDW8:`shdw8`,SHDW9:`shdw9`,SHDW10:`shdw10`,SHDW11:`shdw11`,SHDW12:`shdw12`,SHDW13:`shdw13`,SHDW14:`shdw14`,SHDW15:`shdw15`,SHDW16:`shdw16`,SHDW17:`shdw17`,SHDW18:`shdw18`,SHDW19:`shdw19`,SHDW20:`shdw20`},W=e=>{let t={prst:{key:`prst`,value:U[e.preset]}};return e.distance!==void 0&&(t.dist={key:`dist`,value:e.distance}),e.direction!==void 0&&(t.dir={key:`dir`,value:e.direction}),new n({attributes:t,children:[p(e.color)],name:`a:prstShdw`})},G=e=>{if(!e)return new n({name:`a:reflection`});let t={};return e.blurRadius!==void 0&&(t.blurRad={key:`blurRad`,value:e.blurRadius}),e.startAlpha!==void 0&&(t.stA={key:`stA`,value:e.startAlpha}),e.startPosition!==void 0&&(t.stPos={key:`stPos`,value:e.startPosition}),e.endAlpha!==void 0&&(t.endA={key:`endA`,value:e.endAlpha}),e.endPosition!==void 0&&(t.endPos={key:`endPos`,value:e.endPosition}),e.distance!==void 0&&(t.dist={key:`dist`,value:e.distance}),e.direction!==void 0&&(t.dir={key:`dir`,value:e.direction}),e.fadeDirection!==void 0&&(t.fadeDir={key:`fadeDir`,value:e.fadeDirection}),e.scaleX!==void 0&&(t.sx={key:`sx`,value:e.scaleX}),e.scaleY!==void 0&&(t.sy={key:`sy`,value:e.scaleY}),e.skewX!==void 0&&(t.kx={key:`kx`,value:e.skewX}),e.skewY!==void 0&&(t.ky={key:`ky`,value:e.skewY}),e.alignment!==void 0&&(t.algn={key:`algn`,value:e.alignment}),e.rotWithShape===!1&&(t.rotWithShape={key:`rotWithShape`,value:0}),new n({attributes:t,name:`a:reflection`})},K=e=>new n({attributes:{rad:{key:`rad`,value:e}},name:`a:softEdge`}),ge=e=>e.radius!==void 0||e.grow===!1?new n({attributes:{...e.radius!==void 0&&{rad:{key:`rad`,value:e.radius}},...e.grow===!1&&{grow:{key:`grow`,value:0}}},name:`a:blur`}):new n({name:`a:blur`}),_e=e=>{let t=[];return e.blur&&t.push(ge(e.blur)),e.fillOverlay&&t.push(R(e.fillOverlay)),e.glow&&t.push(z(e.glow)),e.innerShadow&&t.push(B(e.innerShadow)),e.outerShadow&&t.push(H(e.outerShadow)),e.presetShadow&&t.push(W(e.presetShadow)),e.reflection&&t.push(G(e.reflection===!0?void 0:e.reflection)),e.softEdge!==void 0&&t.push(K(e.softEdge)),new n({children:t,name:`a:effectLst`})},q=e=>{let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]={key:n,value:r});return Object.keys(t).length>0?t:void 0},ve=e=>new n({name:`a:alphaBiLevel`,attributes:{thresh:{key:`thresh`,value:e.threshold}}}),ye=()=>new n({name:`a:alphaCeiling`}),be=()=>new n({name:`a:alphaFloor`}),xe=e=>new n({name:`a:alphaInv`,children:e?.color?[p(e.color)]:void 0}),Se=e=>e?.amount===void 0?new n({name:`a:alphaModFix`}):new n({name:`a:alphaModFix`,attributes:{amt:{key:`amt`,value:e.amount}}}),Ce=e=>e?.radius===void 0?new n({name:`a:alphaOutset`}):new n({name:`a:alphaOutset`,attributes:{rad:{key:`rad`,value:e.radius}}}),we=e=>new n({name:`a:alphaRepl`,attributes:{a:{key:`a`,value:e.alpha}}}),Te=e=>new n({name:`a:biLevel`,attributes:{thresh:{key:`thresh`,value:e}}}),Ee=e=>new n({name:`a:blend`,attributes:{blend:{key:`blend`,value:e.blend}},children:[J(e.container)]}),De=e=>{let t=[new n({name:`a:clrFrom`,children:[p(e.from)]}),new n({name:`a:clrTo`,children:[p(e.to)]})];return e.useA===!1?new n({name:`a:clrChange`,attributes:{useA:{key:`useA`,value:0}},children:t}):new n({name:`a:clrChange`,children:t})},Oe=e=>new n({name:`a:clrRepl`,children:[p(e)]}),ke=e=>new n({name:`a:duotone`,children:[p(e.color1),p(e.color2)]}),Ae=e=>{let t;return t=e.noFill?E():e.solidFill?m(e.solidFill):e.gradientFill?C(e.gradientFill):e.patternFill?w(e.patternFill):e.groupFill?D():E(),new n({name:`a:fill`,children:[t]})},je=()=>new n({name:`a:grayscl`}),Me=e=>new n({name:`a:hsl`,attributes:q({hue:e?.hue,sat:e?.saturation,lum:e?.luminance})}),Ne=e=>new n({name:`a:lum`,attributes:q({bright:e?.bright,contrast:e?.contrast})}),Pe=e=>new n({name:`a:tint`,attributes:q({hue:e?.hue,amt:e?.amount})}),Fe=e=>new n({name:`a:relOff`,attributes:q({tx:e?.translateX,ty:e?.translateY})}),Ie=e=>new n({name:`a:xfrm`,attributes:q({sx:e?.scaleX,sy:e?.scaleY,kx:e?.skewX,ky:e?.skewY,tx:e?.translateX,ty:e?.translateY})}),Le=e=>new n({name:`a:effect`,attributes:{ref:{key:`ref`,value:e.ref}}}),Re=e=>e.radius!==void 0||e.grow===!1?new n({attributes:{...e.radius!==void 0&&{rad:{key:`rad`,value:e.radius}},...e.grow===!1&&{grow:{key:`grow`,value:0}}},name:`a:blur`}):new n({name:`a:blur`}),J=(e,t=`a:cont`)=>{let r=q({type:e.type,name:e.name}),i=[];if(e.blur&&i.push(Re(e.blur)),e.fillOverlay&&i.push(R(e.fillOverlay)),e.glow&&i.push(z(e.glow)),e.innerShadow&&i.push(B(e.innerShadow)),e.outerShadow&&i.push(H(e.outerShadow)),e.presetShadow&&i.push(W(e.presetShadow)),e.reflection&&i.push(G(e.reflection===!0?void 0:e.reflection)),e.softEdge!==void 0&&i.push(K(e.softEdge)),e.containers)for(let t of e.containers)i.push(J(t));if(e.effectRefs)for(let t of e.effectRefs)i.push(Le(t));return e.alphaBiLevel&&i.push(ve(e.alphaBiLevel)),e.alphaCeiling&&i.push(ye()),e.alphaFloor&&i.push(be()),e.alphaInverse&&i.push(xe(e.alphaInverse)),e.alphaModulate&&i.push(new n({name:`a:alphaMod`,children:[J(e.alphaModulate)]})),e.alphaModulateFixed&&i.push(Se(e.alphaModulateFixed)),e.alphaOutset&&i.push(Ce(e.alphaOutset)),e.alphaReplace&&i.push(we(e.alphaReplace)),e.biLevel&&i.push(Te(e.biLevel.threshold)),e.blend&&i.push(Ee(e.blend)),e.colorChange&&i.push(De(e.colorChange)),e.colorReplace&&i.push(Oe(e.colorReplace)),e.duotone&&i.push(ke(e.duotone)),e.fill&&i.push(Ae(e.fill)),e.grayscale&&i.push(je()),e.hsl&&i.push(Me(e.hsl)),e.luminance&&i.push(Ne(e.luminance)),e.tint&&i.push(Pe(e.tint)),e.relativeOffset&&i.push(Fe(e.relativeOffset)),e.transform&&i.push(Ie(e.transform)),new n({name:t,attributes:r,children:i.length>0?i:void 0})},ze=e=>J(e,`a:effectDag`),Y=e=>new n({name:`a:rot`,attributes:{lat:{key:`lat`,value:e.lat},lon:{key:`lon`,value:e.lon},rev:{key:`rev`,value:e.rev}}}),Be=e=>{let t=[];e.rotation&&t.push(Y(e.rotation));let r={prst:{key:`prst`,value:e.preset}};return e.fov!==void 0&&(r.fov={key:`fov`,value:e.fov}),e.zoom!==void 0&&(r.zoom={key:`zoom`,value:e.zoom}),new n({name:`a:camera`,attributes:r,children:t.length>0?t:void 0})},Ve=e=>{let t=[];return e.rotation&&t.push(Y(e.rotation)),new n({name:`a:lightRig`,attributes:{rig:{key:`rig`,value:e.rig},dir:{key:`dir`,value:e.direction}},children:t.length>0?t:void 0})},He=(e,t)=>new n({name:e,attributes:{x:{key:`x`,value:t.x},y:{key:`y`,value:t.y},z:{key:`z`,value:t.z}}}),X=(e,t)=>new n({name:e,attributes:{dx:{key:`dx`,value:t.dx},dy:{key:`dy`,value:t.dy},dz:{key:`dz`,value:t.dz}}}),Ue=e=>new n({name:`a:backdrop`,children:[He(`a:anchor`,e.anchor),X(`a:norm`,e.normal),X(`a:up`,e.up)]}),We=e=>{let t=[Be(e.camera),Ve(e.lightRig)];return e.backdrop&&t.push(Ue(e.backdrop)),new n({name:`a:scene3d`,children:t})},Z={RELAXED_INSET:`relaxedInset`,CIRCLE:`circle`,SLOPE:`slope`,CROSS:`cross`,ANGLE:`angle`,SOFT_ROUND:`softRound`,CONVEX:`convex`,COOL_SLANT:`coolSlant`,DIVOT:`divot`,RIBLET:`riblet`,HARD_EDGE:`hardEdge`,ART_DECO:`artDeco`},Ge=e=>{if(!e)return new n({name:`a:bevelT`});let t={};return e.w!==void 0&&(t.w={key:`w`,value:e.w}),e.h!==void 0&&(t.h={key:`h`,value:e.h}),e.prst!==void 0&&(t.prst={key:`prst`,value:Z[e.prst]}),new n({attributes:t,name:`a:bevelT`})},Ke=e=>{if(!e)return new n({name:`a:bevelB`});let t={};return e.w!==void 0&&(t.w={key:`w`,value:e.w}),e.h!==void 0&&(t.h={key:`h`,value:e.h}),e.prst!==void 0&&(t.prst={key:`prst`,value:Z[e.prst]}),new n({attributes:t,name:`a:bevelB`})},qe={LEGACY_MATTE:`legacyMatte`,LEGACY_PLASTIC:`legacyPlastic`,LEGACY_METAL:`legacyMetal`,LEGACY_WIREFRAME:`legacyWireframe`,MATTE:`matte`,PLASTIC:`plastic`,METAL:`metal`,WARM_MATTE:`warmMatte`,TRANSLUCENT_POWDER:`translucentPowder`,POWDER:`powder`,DK_EDGE:`dkEdge`,SOFT_EDGE:`softEdge`,CLEAR:`clear`,FLAT:`flat`,SOFT_METAL:`softmetal`},Je=e=>{let t=[];return e.bevelT&&t.push(Ge(e.bevelT)),e.bevelB&&t.push(Ke(e.bevelB)),e.extrusionColor&&t.push(new n({children:[p(e.extrusionColor)],name:`a:extrusionClr`})),e.contourColor&&t.push(new n({children:[p(e.contourColor)],name:`a:contourClr`})),new n({attributes:e.z!==void 0||e.extrusionH!==void 0||e.contourW!==void 0||e.prstMaterial!==void 0?{...e.z!==void 0&&{z:{key:`z`,value:e.z}},...e.extrusionH!==void 0&&{extrusionH:{key:`extrusionH`,value:e.extrusionH}},...e.contourW!==void 0&&{contourW:{key:`contourW`,value:e.contourW}},...e.prstMaterial!==void 0&&{prstMaterial:{key:`prstMaterial`,value:qe[e.prstMaterial]}}}:void 0,children:t,name:`a:sp3d`})},Ye=e=>{let t=[];if(e)for(let r of e)t.push(new n({attributes:{name:{key:`name`,value:r.name},fmla:{key:`fmla`,value:r.formula}},name:`a:gd`}));return new n({children:t,name:`a:avLst`})};var Xe=class extends e{xmlKeys={prst:`prst`}},Ze=class extends t{constructor(e){super(`a:prstGeom`),this.root.push(new Xe({prst:e?.preset??`rect`})),this.root.push(Ye(e?.adjustmentValues))}};const Q=(e,t)=>new n({name:e,children:t.map(e=>new n({attributes:{name:{key:`name`,value:e.name},fmla:{key:`fmla`,value:e.formula}},name:`a:gd`}))}),Qe=(e,t)=>new n({name:e,children:[new n({name:`a:pt`,attributes:{x:{key:`x`,value:t.x},y:{key:`y`,value:t.y}}})]}),$e=e=>{switch(e.command){case`moveTo`:return Qe(`a:moveTo`,e.point);case`lineTo`:return Qe(`a:lnTo`,e.point);case`arcTo`:return new n({name:`a:arcTo`,attributes:{wR:{key:`wR`,value:e.widthRadius},hR:{key:`hR`,value:e.heightRadius},stAng:{key:`stAng`,value:e.startAngle},swAng:{key:`swAng`,value:e.sweepAngle}}});case`quadBezTo`:return new n({name:`a:quadBezTo`,children:e.points.map(e=>new n({name:`a:pt`,attributes:{x:{key:`x`,value:e.x},y:{key:`y`,value:e.y}}}))});case`cubicBezTo`:return new n({name:`a:cubicBezTo`,children:e.points.map(e=>new n({name:`a:pt`,attributes:{x:{key:`x`,value:e.x},y:{key:`y`,value:e.y}}}))});case`close`:return new n({name:`a:close`})}},et=e=>{let t={};return e.w!==void 0&&(t.w={key:`w`,value:e.w}),e.h!==void 0&&(t.h={key:`h`,value:e.h}),e.fill!==void 0&&(t.fill={key:`fill`,value:e.fill}),e.stroke!==void 0&&(t.stroke={key:`stroke`,value:e.stroke}),e.extrusionOk!==void 0&&(t.extrusionOk={key:`extrusionOk`,value:e.extrusionOk}),new n({name:`a:path`,attributes:Object.keys(t).length>0?t:void 0,children:e.commands.map($e)})},$=e=>new n({name:`a:pos`,attributes:{x:{key:`x`,value:e.x},y:{key:`y`,value:e.y}}}),tt=e=>{let t={};return e.guideRefX!==void 0&&(t.gdRefX={key:`gdRefX`,value:e.guideRefX}),e.minX!==void 0&&(t.minX={key:`minX`,value:e.minX}),e.maxX!==void 0&&(t.maxX={key:`maxX`,value:e.maxX}),e.guideRefY!==void 0&&(t.gdRefY={key:`gdRefY`,value:e.guideRefY}),e.minY!==void 0&&(t.minY={key:`minY`,value:e.minY}),e.maxY!==void 0&&(t.maxY={key:`maxY`,value:e.maxY}),new n({name:`a:ahXY`,attributes:Object.keys(t).length>0?t:void 0,children:[$(e.position)]})},nt=e=>{let t={};return e.guideRefRadius!==void 0&&(t.gdRefR={key:`gdRefR`,value:e.guideRefRadius}),e.minRadius!==void 0&&(t.minR={key:`minR`,value:e.minRadius}),e.maxRadius!==void 0&&(t.maxR={key:`maxR`,value:e.maxRadius}),e.guideRefAngle!==void 0&&(t.gdRefAng={key:`gdRefAng`,value:e.guideRefAngle}),e.minAngle!==void 0&&(t.minAng={key:`minAng`,value:e.minAngle}),e.maxAngle!==void 0&&(t.maxAng={key:`maxAng`,value:e.maxAngle}),new n({name:`a:ahPolar`,attributes:Object.keys(t).length>0?t:void 0,children:[$(e.position)]})},rt=e=>new n({name:`a:cxn`,attributes:{ang:{key:`ang`,value:e.angle}},children:[$(e.position)]}),it=e=>new n({name:`a:rect`,attributes:{l:{key:`l`,value:e.left},t:{key:`t`,value:e.top},r:{key:`r`,value:e.right},b:{key:`b`,value:e.bottom}}}),at=e=>{let t=[];return e.adjustmentValues&&t.push(Q(`a:avLst`,e.adjustmentValues)),e.guides&&t.push(Q(`a:gdLst`,e.guides)),e.adjustHandles&&e.adjustHandles.length>0&&t.push(new n({name:`a:ahLst`,children:e.adjustHandles.map(e=>e.type===`xy`?tt(e):nt(e))})),e.connectionSites&&e.connectionSites.length>0&&t.push(new n({name:`a:cxnLst`,children:e.connectionSites.map(rt)})),e.textRect&&t.push(it(e.textRect)),t.push(new n({name:`a:pathLst`,children:e.pathList.map(et)})),new n({name:`a:custGeom`,children:t})},ot=e=>new n({attributes:{asvg:{key:`xmlns:asvg`,value:`http://schemas.microsoft.com/office/drawing/2016/SVG/main`},embed:{key:`r:embed`,value:`{${e}}`}},name:`asvg:svgBlip`}),st=e=>new n({attributes:{uri:{key:`uri`,value:`{96DAC541-7B7A-43D3-8B79-37D633B846F1}`}},children:[ot(e)],name:`a:ext`}),ct=e=>new n({children:[st(e)],name:`a:extLst`}),lt=(e,t)=>{let r=[];return t&&r.push(...h(t)),e.type===`svg`&&e.fallbackFileName&&r.push(ct(e.referenceId)),new n({attributes:{cstate:{key:`cstate`,value:`none`},embed:{key:`r:embed`,value:`{${e.type===`svg`&&e.fallbackFileName?e.fallbackFileName:e.referenceId}}`}},children:r,name:`a:blip`})},ut=(e,t)=>{let r=[];r.push(lt(e,t?.blipEffects)),r.push(g(t?.srcRect)),t?.tile?r.push(y(t.tile)):r.push(new _);let i={};return t?.dpi!==void 0&&(i.dpi={key:`dpi`,value:t.dpi}),t?.rotWithShape!==void 0&&(i.rotWithShape={key:`rotWithShape`,value:+!!t.rotWithShape}),new n({attributes:Object.keys(i).length>0?i:void 0,children:r,name:`pic:blipFill`})};function dt(e){let t={};return e.flipHorizontal!==void 0&&(t.flipH={key:`flipH`,value:e.flipHorizontal}),e.flipVertical!==void 0&&(t.flipV={key:`flipV`,value:e.flipVertical}),e.rotation!==void 0&&(t.rot={key:`rot`,value:e.rotation}),Object.keys(t).length>0?t:void 0}const ft=(e,t=`a:xfrm`)=>{let r=[];return(e.x!==void 0||e.y!==void 0)&&r.push(new n({name:`a:off`,attributes:{x:{key:`x`,value:e.x??0},y:{key:`y`,value:e.y??0}}})),(e.width!==void 0||e.height!==void 0)&&r.push(new n({name:`a:ext`,attributes:{cx:{key:`cx`,value:e.width??0},cy:{key:`cy`,value:e.height??0}}})),new n({name:t,attributes:dt(e),children:r.length>0?r:void 0})},pt=(e,t=`a:xfrm`)=>{let r=ft(e,t);return r.root.push(new n({name:`a:chOff`,attributes:{x:{key:`x`,value:e.childOffsetX??0},y:{key:`y`,value:e.childOffsetY??0}}})),r.root.push(new n({name:`a:chExt`,attributes:{cx:{key:`cx`,value:e.childExtentWidth??0},cy:{key:`cy`,value:e.childExtentHeight??0}}})),r},mt=e=>({emus:{x:r(e.width),y:r(e.height)},flip:e.flip,offset:{emus:{x:r(e.offset?.left??0),y:r(e.offset?.top??0)},pixels:{x:Math.round(e.offset?.left??0),y:Math.round(e.offset?.top??0)}},pixels:{x:Math.round(e.width),y:Math.round(e.height)},rotation:e.rotation?e.rotation*6e4:void 0});export{Z as BevelPresetType,he as BlendMode,P as CompoundLine,N as LineCap,j as LineEndLength,k as LineEndType,A as LineEndWidth,L as LineJoin,b as PathShadeType,F as PenAlignment,s as PresetColor,I as PresetDash,Ze as PresetGeometry,Xe as PresetGeometryAttributes,qe as PresetMaterialType,le as PresetPattern,U as PresetShadowVal,V as RectAlignment,l as SchemeColor,_ as Stretch,d as SystemColor,v as TileAlignment,se as TileFlipMode,fe as buildFill,Ye as createAdjustmentValues,Ge as createBevel,lt as createBlip,h as createBlipEffects,ut as createBlipFill,Ke as createBottomBevel,p as createColorElement,a as createColorTransforms,O as createCustomDash,at as createCustomGeometry,ze as createEffectDag,_e as createEffectList,ct as createExtentionList,R as createFillOverlayEffect,z as createGlowEffect,C as createGradientFill,x as createGradientStop,D as createGroupFill,pt as createGroupTransform2D,o as createHslColor,B as createInnerShadowEffect,M as createLineEnd,E as createNoFill,H as createOuterShadowEffect,me as createOutline,w as createPatternFill,ee as createPresetColor,W as createPresetShadowEffect,G as createReflectionEffect,te as createRgbColor,c as createScRgbColor,We as createScene3D,u as createSchemeColor,Je as createShape3D,K as createSoftEdgeEffect,m as createSolidFill,g as createSourceRectangle,f as createSystemColor,y as createTileInfo,ft as createTransform2D,mt as createTransformation,de as extractBlipFillMedia};
|
|
1
|
+
import { S as XmlAttributeComponent, T as XmlComponent, a as BuilderElement } from "../xml-components-CJKrtCSG.mjs";
|
|
2
|
+
import { d as convertPixelsToEmu, t as hashedId } from "../id-generators-CM3u923a.mjs";
|
|
3
|
+
//#region src/drawingml/color/color-transform.ts
|
|
4
|
+
/**
|
|
5
|
+
* Color transform elements for DrawingML colors.
|
|
6
|
+
*
|
|
7
|
+
* This module provides color transformation elements defined in EG_ColorTransform,
|
|
8
|
+
* which can be applied as child elements to any color type (srgbClr, schemeClr, etc.).
|
|
9
|
+
*
|
|
10
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, EG_ColorTransform
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Creates color transform child elements.
|
|
16
|
+
*
|
|
17
|
+
* These elements modify the parent color according to OOXML color transform rules.
|
|
18
|
+
* Multiple transforms can be applied in sequence.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Lighten accent1 by 40%
|
|
23
|
+
* createColorTransforms({ tint: 40000 });
|
|
24
|
+
* // Semi-transparent red with 50% alpha
|
|
25
|
+
* createColorTransforms({ alpha: 50000 });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
const createColorTransforms = (options) => {
|
|
29
|
+
const transforms = [];
|
|
30
|
+
if (options.tint !== void 0) transforms.push(new BuilderElement({
|
|
31
|
+
attributes: { val: {
|
|
32
|
+
key: "val",
|
|
33
|
+
value: options.tint
|
|
34
|
+
} },
|
|
35
|
+
name: "a:tint"
|
|
36
|
+
}));
|
|
37
|
+
if (options.shade !== void 0) transforms.push(new BuilderElement({
|
|
38
|
+
attributes: { val: {
|
|
39
|
+
key: "val",
|
|
40
|
+
value: options.shade
|
|
41
|
+
} },
|
|
42
|
+
name: "a:shade"
|
|
43
|
+
}));
|
|
44
|
+
if (options.comp) transforms.push(new BuilderElement({ name: "a:comp" }));
|
|
45
|
+
if (options.inv) transforms.push(new BuilderElement({ name: "a:inv" }));
|
|
46
|
+
if (options.gray) transforms.push(new BuilderElement({ name: "a:gray" }));
|
|
47
|
+
if (options.alpha !== void 0) transforms.push(new BuilderElement({
|
|
48
|
+
attributes: { val: {
|
|
49
|
+
key: "val",
|
|
50
|
+
value: options.alpha
|
|
51
|
+
} },
|
|
52
|
+
name: "a:alpha"
|
|
53
|
+
}));
|
|
54
|
+
if (options.alphaOff !== void 0) transforms.push(new BuilderElement({
|
|
55
|
+
attributes: { val: {
|
|
56
|
+
key: "val",
|
|
57
|
+
value: options.alphaOff
|
|
58
|
+
} },
|
|
59
|
+
name: "a:alphaOff"
|
|
60
|
+
}));
|
|
61
|
+
if (options.alphaMod !== void 0) transforms.push(new BuilderElement({
|
|
62
|
+
attributes: { val: {
|
|
63
|
+
key: "val",
|
|
64
|
+
value: options.alphaMod
|
|
65
|
+
} },
|
|
66
|
+
name: "a:alphaMod"
|
|
67
|
+
}));
|
|
68
|
+
if (options.hue !== void 0) transforms.push(new BuilderElement({
|
|
69
|
+
attributes: { val: {
|
|
70
|
+
key: "val",
|
|
71
|
+
value: options.hue
|
|
72
|
+
} },
|
|
73
|
+
name: "a:hue"
|
|
74
|
+
}));
|
|
75
|
+
if (options.hueOff !== void 0) transforms.push(new BuilderElement({
|
|
76
|
+
attributes: { val: {
|
|
77
|
+
key: "val",
|
|
78
|
+
value: options.hueOff
|
|
79
|
+
} },
|
|
80
|
+
name: "a:hueOff"
|
|
81
|
+
}));
|
|
82
|
+
if (options.hueMod !== void 0) transforms.push(new BuilderElement({
|
|
83
|
+
attributes: { val: {
|
|
84
|
+
key: "val",
|
|
85
|
+
value: options.hueMod
|
|
86
|
+
} },
|
|
87
|
+
name: "a:hueMod"
|
|
88
|
+
}));
|
|
89
|
+
if (options.sat !== void 0) transforms.push(new BuilderElement({
|
|
90
|
+
attributes: { val: {
|
|
91
|
+
key: "val",
|
|
92
|
+
value: options.sat
|
|
93
|
+
} },
|
|
94
|
+
name: "a:sat"
|
|
95
|
+
}));
|
|
96
|
+
if (options.satOff !== void 0) transforms.push(new BuilderElement({
|
|
97
|
+
attributes: { val: {
|
|
98
|
+
key: "val",
|
|
99
|
+
value: options.satOff
|
|
100
|
+
} },
|
|
101
|
+
name: "a:satOff"
|
|
102
|
+
}));
|
|
103
|
+
if (options.satMod !== void 0) transforms.push(new BuilderElement({
|
|
104
|
+
attributes: { val: {
|
|
105
|
+
key: "val",
|
|
106
|
+
value: options.satMod
|
|
107
|
+
} },
|
|
108
|
+
name: "a:satMod"
|
|
109
|
+
}));
|
|
110
|
+
if (options.lum !== void 0) transforms.push(new BuilderElement({
|
|
111
|
+
attributes: { val: {
|
|
112
|
+
key: "val",
|
|
113
|
+
value: options.lum
|
|
114
|
+
} },
|
|
115
|
+
name: "a:lum"
|
|
116
|
+
}));
|
|
117
|
+
if (options.lumOff !== void 0) transforms.push(new BuilderElement({
|
|
118
|
+
attributes: { val: {
|
|
119
|
+
key: "val",
|
|
120
|
+
value: options.lumOff
|
|
121
|
+
} },
|
|
122
|
+
name: "a:lumOff"
|
|
123
|
+
}));
|
|
124
|
+
if (options.lumMod !== void 0) transforms.push(new BuilderElement({
|
|
125
|
+
attributes: { val: {
|
|
126
|
+
key: "val",
|
|
127
|
+
value: options.lumMod
|
|
128
|
+
} },
|
|
129
|
+
name: "a:lumMod"
|
|
130
|
+
}));
|
|
131
|
+
if (options.red !== void 0) transforms.push(new BuilderElement({
|
|
132
|
+
attributes: { val: {
|
|
133
|
+
key: "val",
|
|
134
|
+
value: options.red
|
|
135
|
+
} },
|
|
136
|
+
name: "a:red"
|
|
137
|
+
}));
|
|
138
|
+
if (options.redOff !== void 0) transforms.push(new BuilderElement({
|
|
139
|
+
attributes: { val: {
|
|
140
|
+
key: "val",
|
|
141
|
+
value: options.redOff
|
|
142
|
+
} },
|
|
143
|
+
name: "a:redOff"
|
|
144
|
+
}));
|
|
145
|
+
if (options.redMod !== void 0) transforms.push(new BuilderElement({
|
|
146
|
+
attributes: { val: {
|
|
147
|
+
key: "val",
|
|
148
|
+
value: options.redMod
|
|
149
|
+
} },
|
|
150
|
+
name: "a:redMod"
|
|
151
|
+
}));
|
|
152
|
+
if (options.green !== void 0) transforms.push(new BuilderElement({
|
|
153
|
+
attributes: { val: {
|
|
154
|
+
key: "val",
|
|
155
|
+
value: options.green
|
|
156
|
+
} },
|
|
157
|
+
name: "a:green"
|
|
158
|
+
}));
|
|
159
|
+
if (options.greenOff !== void 0) transforms.push(new BuilderElement({
|
|
160
|
+
attributes: { val: {
|
|
161
|
+
key: "val",
|
|
162
|
+
value: options.greenOff
|
|
163
|
+
} },
|
|
164
|
+
name: "a:greenOff"
|
|
165
|
+
}));
|
|
166
|
+
if (options.greenMod !== void 0) transforms.push(new BuilderElement({
|
|
167
|
+
attributes: { val: {
|
|
168
|
+
key: "val",
|
|
169
|
+
value: options.greenMod
|
|
170
|
+
} },
|
|
171
|
+
name: "a:greenMod"
|
|
172
|
+
}));
|
|
173
|
+
if (options.blue !== void 0) transforms.push(new BuilderElement({
|
|
174
|
+
attributes: { val: {
|
|
175
|
+
key: "val",
|
|
176
|
+
value: options.blue
|
|
177
|
+
} },
|
|
178
|
+
name: "a:blue"
|
|
179
|
+
}));
|
|
180
|
+
if (options.blueOff !== void 0) transforms.push(new BuilderElement({
|
|
181
|
+
attributes: { val: {
|
|
182
|
+
key: "val",
|
|
183
|
+
value: options.blueOff
|
|
184
|
+
} },
|
|
185
|
+
name: "a:blueOff"
|
|
186
|
+
}));
|
|
187
|
+
if (options.blueMod !== void 0) transforms.push(new BuilderElement({
|
|
188
|
+
attributes: { val: {
|
|
189
|
+
key: "val",
|
|
190
|
+
value: options.blueMod
|
|
191
|
+
} },
|
|
192
|
+
name: "a:blueMod"
|
|
193
|
+
}));
|
|
194
|
+
if (options.gamma) transforms.push(new BuilderElement({ name: "a:gamma" }));
|
|
195
|
+
if (options.invGamma) transforms.push(new BuilderElement({ name: "a:invGamma" }));
|
|
196
|
+
return transforms;
|
|
197
|
+
};
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/drawingml/color/hsl-color.ts
|
|
200
|
+
/**
|
|
201
|
+
* HSL color element for DrawingML.
|
|
202
|
+
*
|
|
203
|
+
* This module provides HSL (Hue, Saturation, Luminance) color support.
|
|
204
|
+
*
|
|
205
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_HslColor
|
|
206
|
+
*
|
|
207
|
+
* @module
|
|
208
|
+
*/
|
|
209
|
+
/**
|
|
210
|
+
* Creates an HSL color element.
|
|
211
|
+
*
|
|
212
|
+
* Specifies a color using Hue, Saturation, and Luminance values.
|
|
213
|
+
*
|
|
214
|
+
* ## XSD Schema
|
|
215
|
+
* ```xml
|
|
216
|
+
* <xsd:complexType name="CT_HslColor">
|
|
217
|
+
* <xsd:sequence>
|
|
218
|
+
* <xsd:group ref="EG_ColorTransform" minOccurs="0" maxOccurs="unbounded"/>
|
|
219
|
+
* </xsd:sequence>
|
|
220
|
+
* <xsd:attribute name="hue" type="ST_PositiveFixedAngle" use="required"/>
|
|
221
|
+
* <xsd:attribute name="sat" type="ST_Percentage" use="required"/>
|
|
222
|
+
* <xsd:attribute name="lum" type="ST_Percentage" use="required"/>
|
|
223
|
+
* </xsd:complexType>
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
const createHslColor = (options) => {
|
|
227
|
+
const transforms = options.transforms ? createColorTransforms(options.transforms) : [];
|
|
228
|
+
return new BuilderElement({
|
|
229
|
+
attributes: {
|
|
230
|
+
hue: {
|
|
231
|
+
key: "hue",
|
|
232
|
+
value: options.hue
|
|
233
|
+
},
|
|
234
|
+
lum: {
|
|
235
|
+
key: "lum",
|
|
236
|
+
value: options.luminance
|
|
237
|
+
},
|
|
238
|
+
sat: {
|
|
239
|
+
key: "sat",
|
|
240
|
+
value: options.saturation
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
children: [...transforms],
|
|
244
|
+
name: "a:hslClr"
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
//#endregion
|
|
248
|
+
//#region src/drawingml/color/preset-color.ts
|
|
249
|
+
/**
|
|
250
|
+
* Preset color element for DrawingML.
|
|
251
|
+
*
|
|
252
|
+
* This module provides named preset colors (CSS named colors).
|
|
253
|
+
*
|
|
254
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_PresetColor / ST_PresetColorVal
|
|
255
|
+
*
|
|
256
|
+
* @module
|
|
257
|
+
*/
|
|
258
|
+
/**
|
|
259
|
+
* Preset color values (CSS named colors).
|
|
260
|
+
*
|
|
261
|
+
* ## XSD Schema
|
|
262
|
+
* ```xml
|
|
263
|
+
* <xsd:simpleType name="ST_PresetColorVal">
|
|
264
|
+
* <xsd:restriction base="xsd:token">
|
|
265
|
+
* <xsd:enumeration value="aliceBlue"/>
|
|
266
|
+
* ...
|
|
267
|
+
* <xsd:enumeration value="yellowGreen"/>
|
|
268
|
+
* </xsd:restriction>
|
|
269
|
+
* </xsd:simpleType>
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
const PresetColor = {
|
|
273
|
+
ALICE_BLUE: "aliceBlue",
|
|
274
|
+
ANTIQUE_WHITE: "antiqueWhite",
|
|
275
|
+
AQUA: "aqua",
|
|
276
|
+
AQUAMARINE: "aquamarine",
|
|
277
|
+
AZURE: "azure",
|
|
278
|
+
BEIGE: "beige",
|
|
279
|
+
BISQUE: "bisque",
|
|
280
|
+
BLACK: "black",
|
|
281
|
+
BLANCHED_ALMOND: "blanchedAlmond",
|
|
282
|
+
BLUE: "blue",
|
|
283
|
+
BLUE_VIOLET: "blueViolet",
|
|
284
|
+
BROWN: "brown",
|
|
285
|
+
BURLY_WOOD: "burlyWood",
|
|
286
|
+
CADET_BLUE: "cadetBlue",
|
|
287
|
+
CHARTREUSE: "chartreuse",
|
|
288
|
+
CHOCOLATE: "chocolate",
|
|
289
|
+
CORAL: "coral",
|
|
290
|
+
CORNFLOWER_BLUE: "cornflowerBlue",
|
|
291
|
+
CORNSILK: "cornsilk",
|
|
292
|
+
CRIMSON: "crimson",
|
|
293
|
+
CYAN: "cyan",
|
|
294
|
+
DARK_BLUE: "darkBlue",
|
|
295
|
+
DARK_CYAN: "darkCyan",
|
|
296
|
+
DARK_GOLDENROD: "darkGoldenrod",
|
|
297
|
+
DARK_GRAY: "darkGray",
|
|
298
|
+
DARK_GREY: "darkGrey",
|
|
299
|
+
DARK_GREEN: "darkGreen",
|
|
300
|
+
DARK_KHAKI: "darkKhaki",
|
|
301
|
+
DARK_MAGENTA: "darkMagenta",
|
|
302
|
+
DARK_OLIVE_GREEN: "darkOliveGreen",
|
|
303
|
+
DARK_ORANGE: "darkOrange",
|
|
304
|
+
DARK_ORCHID: "darkOrchid",
|
|
305
|
+
DARK_RED: "darkRed",
|
|
306
|
+
DARK_SALMON: "darkSalmon",
|
|
307
|
+
DARK_SEA_GREEN: "darkSeaGreen",
|
|
308
|
+
DARK_SLATE_BLUE: "darkSlateBlue",
|
|
309
|
+
DARK_SLATE_GRAY: "darkSlateGray",
|
|
310
|
+
DARK_SLATE_GREY: "darkSlateGrey",
|
|
311
|
+
DARK_TURQUOISE: "darkTurquoise",
|
|
312
|
+
DARK_VIOLET: "darkViolet",
|
|
313
|
+
DEEP_PINK: "deepPink",
|
|
314
|
+
DEEP_SKY_BLUE: "deepSkyBlue",
|
|
315
|
+
DIM_GRAY: "dimGray",
|
|
316
|
+
DIM_GREY: "dimGrey",
|
|
317
|
+
DODGER_BLUE: "dodgerBlue",
|
|
318
|
+
FIREBRICK: "firebrick",
|
|
319
|
+
FLORAL_WHITE: "floralWhite",
|
|
320
|
+
FOREST_GREEN: "forestGreen",
|
|
321
|
+
FUCHSIA: "fuchsia",
|
|
322
|
+
GAINSBORO: "gainsboro",
|
|
323
|
+
GHOST_WHITE: "ghostWhite",
|
|
324
|
+
GOLD: "gold",
|
|
325
|
+
GOLDENROD: "goldenrod",
|
|
326
|
+
GRAY: "gray",
|
|
327
|
+
GREY: "grey",
|
|
328
|
+
GREEN: "green",
|
|
329
|
+
GREEN_YELLOW: "greenYellow",
|
|
330
|
+
HONEYDEW: "honeydew",
|
|
331
|
+
HOT_PINK: "hotPink",
|
|
332
|
+
INDIAN_RED: "indianRed",
|
|
333
|
+
INDIGO: "indigo",
|
|
334
|
+
IVORY: "ivory",
|
|
335
|
+
KHAKI: "khaki",
|
|
336
|
+
LAVENDER: "lavender",
|
|
337
|
+
LAVENDER_BLUSH: "lavenderBlush",
|
|
338
|
+
LAWN_GREEN: "lawnGreen",
|
|
339
|
+
LEMON_CHIFFON: "lemonChiffon",
|
|
340
|
+
LIGHT_BLUE: "lightBlue",
|
|
341
|
+
LIGHT_CORAL: "lightCoral",
|
|
342
|
+
LIGHT_CYAN: "lightCyan",
|
|
343
|
+
LIGHT_GOLDENROD_YELLOW: "lightGoldenrodYellow",
|
|
344
|
+
LIGHT_GRAY: "lightGray",
|
|
345
|
+
LIGHT_GREY: "lightGrey",
|
|
346
|
+
LIGHT_GREEN: "lightGreen",
|
|
347
|
+
LIGHT_PINK: "lightPink",
|
|
348
|
+
LIGHT_SALMON: "lightSalmon",
|
|
349
|
+
LIGHT_SEA_GREEN: "lightSeaGreen",
|
|
350
|
+
LIGHT_SKY_BLUE: "lightSkyBlue",
|
|
351
|
+
LIGHT_SLATE_GRAY: "lightSlateGray",
|
|
352
|
+
LIGHT_SLATE_GREY: "lightSlateGrey",
|
|
353
|
+
LIGHT_STEEL_BLUE: "lightSteelBlue",
|
|
354
|
+
LIGHT_YELLOW: "lightYellow",
|
|
355
|
+
LIME: "lime",
|
|
356
|
+
LIME_GREEN: "limeGreen",
|
|
357
|
+
LINEN: "linen",
|
|
358
|
+
MAGENTA: "magenta",
|
|
359
|
+
MAROON: "maroon",
|
|
360
|
+
MEDIUM_AQUAMARINE: "mediumAquamarine",
|
|
361
|
+
MEDIUM_BLUE: "mediumBlue",
|
|
362
|
+
MEDIUM_ORCHID: "mediumOrchid",
|
|
363
|
+
MEDIUM_PURPLE: "mediumPurple",
|
|
364
|
+
MEDIUM_SEA_GREEN: "mediumSeaGreen",
|
|
365
|
+
MEDIUM_SLATE_BLUE: "mediumSlateBlue",
|
|
366
|
+
MEDIUM_SPRING_GREEN: "mediumSpringGreen",
|
|
367
|
+
MEDIUM_TURQUOISE: "mediumTurquoise",
|
|
368
|
+
MEDIUM_VIOLET_RED: "mediumVioletRed",
|
|
369
|
+
MIDNIGHT_BLUE: "midnightBlue",
|
|
370
|
+
MINT_CREAM: "mintCream",
|
|
371
|
+
MISTY_ROSE: "mistyRose",
|
|
372
|
+
MOCCASIN: "moccasin",
|
|
373
|
+
NAVAJO_WHITE: "navajoWhite",
|
|
374
|
+
NAVY: "navy",
|
|
375
|
+
OLD_LACE: "oldLace",
|
|
376
|
+
OLIVE: "olive",
|
|
377
|
+
OLIVE_DRAB: "oliveDrab",
|
|
378
|
+
ORANGE: "orange",
|
|
379
|
+
ORANGE_RED: "orangeRed",
|
|
380
|
+
ORCHID: "orchid",
|
|
381
|
+
PALE_GOLDENROD: "paleGoldenrod",
|
|
382
|
+
PALE_GREEN: "paleGreen",
|
|
383
|
+
PALE_TURQUOISE: "paleTurquoise",
|
|
384
|
+
PALE_VIOLET_RED: "paleVioletRed",
|
|
385
|
+
PAPAYA_WHIP: "papayaWhip",
|
|
386
|
+
PEACH_PUFF: "peachPuff",
|
|
387
|
+
PERU: "peru",
|
|
388
|
+
PINK: "pink",
|
|
389
|
+
PLUM: "plum",
|
|
390
|
+
POWDER_BLUE: "powderBlue",
|
|
391
|
+
PURPLE: "purple",
|
|
392
|
+
RED: "red",
|
|
393
|
+
ROSY_BROWN: "rosyBrown",
|
|
394
|
+
ROYAL_BLUE: "royalBlue",
|
|
395
|
+
SADDLE_BROWN: "saddleBrown",
|
|
396
|
+
SALMON: "salmon",
|
|
397
|
+
SANDY_BROWN: "sandyBrown",
|
|
398
|
+
SEA_GREEN: "seaGreen",
|
|
399
|
+
SEA_SHELL: "seaShell",
|
|
400
|
+
SIENNA: "sienna",
|
|
401
|
+
SILVER: "silver",
|
|
402
|
+
SKY_BLUE: "skyBlue",
|
|
403
|
+
SLATE_BLUE: "slateBlue",
|
|
404
|
+
SLATE_GRAY: "slateGray",
|
|
405
|
+
SLATE_GREY: "slateGrey",
|
|
406
|
+
SNOW: "snow",
|
|
407
|
+
SPRING_GREEN: "springGreen",
|
|
408
|
+
STEEL_BLUE: "steelBlue",
|
|
409
|
+
TAN: "tan",
|
|
410
|
+
TEAL: "teal",
|
|
411
|
+
THISTLE: "thistle",
|
|
412
|
+
TOMATO: "tomato",
|
|
413
|
+
TURQUOISE: "turquoise",
|
|
414
|
+
VIOLET: "violet",
|
|
415
|
+
WHEAT: "wheat",
|
|
416
|
+
WHITE: "white",
|
|
417
|
+
WHITE_SMOKE: "whiteSmoke",
|
|
418
|
+
YELLOW: "yellow",
|
|
419
|
+
YELLOW_GREEN: "yellowGreen"
|
|
420
|
+
};
|
|
421
|
+
/**
|
|
422
|
+
* Creates a preset color element.
|
|
423
|
+
*
|
|
424
|
+
* Specifies a color using a named preset (CSS named color).
|
|
425
|
+
*
|
|
426
|
+
* ## XSD Schema
|
|
427
|
+
* ```xml
|
|
428
|
+
* <xsd:complexType name="CT_PresetColor">
|
|
429
|
+
* <xsd:sequence>
|
|
430
|
+
* <xsd:group ref="EG_ColorTransform" minOccurs="0" maxOccurs="unbounded"/>
|
|
431
|
+
* </xsd:sequence>
|
|
432
|
+
* <xsd:attribute name="val" type="ST_PresetColorVal" use="required"/>
|
|
433
|
+
* </xsd:complexType>
|
|
434
|
+
* ```
|
|
435
|
+
*/
|
|
436
|
+
const createPresetColor = (options) => {
|
|
437
|
+
const transforms = options.transforms ? createColorTransforms(options.transforms) : [];
|
|
438
|
+
return new BuilderElement({
|
|
439
|
+
attributes: { value: {
|
|
440
|
+
key: "val",
|
|
441
|
+
value: options.value
|
|
442
|
+
} },
|
|
443
|
+
children: [...transforms],
|
|
444
|
+
name: "a:prstClr"
|
|
445
|
+
});
|
|
446
|
+
};
|
|
447
|
+
//#endregion
|
|
448
|
+
//#region src/drawingml/color/rgb-color.ts
|
|
449
|
+
/**
|
|
450
|
+
* RGB color element for DrawingML shapes.
|
|
451
|
+
*
|
|
452
|
+
* This module provides RGB color support for solid fills.
|
|
453
|
+
*
|
|
454
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SRgbColor
|
|
455
|
+
*
|
|
456
|
+
* @module
|
|
457
|
+
*/
|
|
458
|
+
/**
|
|
459
|
+
* Creates an sRGB color element.
|
|
460
|
+
*
|
|
461
|
+
* Specifies a color using RGB hex values.
|
|
462
|
+
*
|
|
463
|
+
* ## XSD Schema
|
|
464
|
+
* ```xml
|
|
465
|
+
* <xsd:complexType name="CT_SRgbColor">
|
|
466
|
+
* <xsd:sequence>
|
|
467
|
+
* <xsd:group ref="EG_ColorTransform" minOccurs="0" maxOccurs="unbounded"/>
|
|
468
|
+
* </xsd:sequence>
|
|
469
|
+
* <xsd:attribute name="val" type="s:ST_HexColorRGB" use="required"/>
|
|
470
|
+
* </xsd:complexType>
|
|
471
|
+
* ```
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* ```typescript
|
|
475
|
+
* const redColor = createRgbColor({ value: "FF0000" });
|
|
476
|
+
* // With alpha transform
|
|
477
|
+
* const semiRed = createRgbColor({ value: "FF0000", transforms: { alpha: 50000 } });
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
const createRgbColor = (options) => {
|
|
481
|
+
const transforms = options.transforms ? createColorTransforms(options.transforms) : [];
|
|
482
|
+
return new BuilderElement({
|
|
483
|
+
attributes: { value: {
|
|
484
|
+
key: "val",
|
|
485
|
+
value: options.value
|
|
486
|
+
} },
|
|
487
|
+
children: [...transforms],
|
|
488
|
+
name: "a:srgbClr"
|
|
489
|
+
});
|
|
490
|
+
};
|
|
491
|
+
//#endregion
|
|
492
|
+
//#region src/drawingml/color/sc-rgb-color.ts
|
|
493
|
+
/**
|
|
494
|
+
* ScRGB color element for DrawingML shapes.
|
|
495
|
+
*
|
|
496
|
+
* This module provides scRGB color support using percentage-based RGB values.
|
|
497
|
+
*
|
|
498
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_ScRgbColor
|
|
499
|
+
*
|
|
500
|
+
* @module
|
|
501
|
+
*/
|
|
502
|
+
/**
|
|
503
|
+
* Creates an scRGB color element.
|
|
504
|
+
*
|
|
505
|
+
* Specifies a color using percentage-based RGB values.
|
|
506
|
+
*
|
|
507
|
+
* ## XSD Schema
|
|
508
|
+
* ```xml
|
|
509
|
+
* <xsd:complexType name="CT_ScRgbColor">
|
|
510
|
+
* <xsd:sequence>
|
|
511
|
+
* <xsd:group ref="EG_ColorTransform" minOccurs="0" maxOccurs="unbounded"/>
|
|
512
|
+
* </xsd:sequence>
|
|
513
|
+
* <xsd:attribute name="r" type="ST_Percentage" use="required"/>
|
|
514
|
+
* <xsd:attribute name="g" type="ST_Percentage" use="required"/>
|
|
515
|
+
* <xsd:attribute name="b" type="ST_Percentage" use="required"/>
|
|
516
|
+
* </xsd:complexType>
|
|
517
|
+
* ```
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* ```typescript
|
|
521
|
+
* const redColor = createScRgbColor({ r: "100%", g: "0%", b: "0%" });
|
|
522
|
+
* // With alpha transform
|
|
523
|
+
* const semiRed = createScRgbColor({ r: "100%", g: "0%", b: "0%", transforms: { alpha: 50000 } });
|
|
524
|
+
* ```
|
|
525
|
+
*/
|
|
526
|
+
const createScRgbColor = (options) => {
|
|
527
|
+
const transforms = options.transforms ? createColorTransforms(options.transforms) : [];
|
|
528
|
+
return new BuilderElement({
|
|
529
|
+
attributes: {
|
|
530
|
+
r: {
|
|
531
|
+
key: "r",
|
|
532
|
+
value: options.r
|
|
533
|
+
},
|
|
534
|
+
g: {
|
|
535
|
+
key: "g",
|
|
536
|
+
value: options.g
|
|
537
|
+
},
|
|
538
|
+
b: {
|
|
539
|
+
key: "b",
|
|
540
|
+
value: options.b
|
|
541
|
+
}
|
|
542
|
+
},
|
|
543
|
+
children: [...transforms],
|
|
544
|
+
name: "a:scrgbClr"
|
|
545
|
+
});
|
|
546
|
+
};
|
|
547
|
+
//#endregion
|
|
548
|
+
//#region src/drawingml/color/scheme-color.ts
|
|
549
|
+
/**
|
|
550
|
+
* Scheme color element for DrawingML shapes.
|
|
551
|
+
*
|
|
552
|
+
* This module provides scheme-based color support for solid fills,
|
|
553
|
+
* allowing colors to be defined using theme color schemes.
|
|
554
|
+
*
|
|
555
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SchemeColor / ST_SchemeColorVal
|
|
556
|
+
*
|
|
557
|
+
* @module
|
|
558
|
+
*/
|
|
559
|
+
/**
|
|
560
|
+
* Scheme color values for theme-based colors.
|
|
561
|
+
*
|
|
562
|
+
* These values reference colors defined in the document's color scheme/theme.
|
|
563
|
+
*/
|
|
564
|
+
const SchemeColor = {
|
|
565
|
+
/** Background color 1 */
|
|
566
|
+
BG1: "bg1",
|
|
567
|
+
/** Text color 1 */
|
|
568
|
+
TX1: "tx1",
|
|
569
|
+
/** Background color 2 */
|
|
570
|
+
BG2: "bg2",
|
|
571
|
+
/** Text color 2 */
|
|
572
|
+
TX2: "tx2",
|
|
573
|
+
/** Accent color 1 */
|
|
574
|
+
ACCENT1: "accent1",
|
|
575
|
+
/** Accent color 2 */
|
|
576
|
+
ACCENT2: "accent2",
|
|
577
|
+
/** Accent color 3 */
|
|
578
|
+
ACCENT3: "accent3",
|
|
579
|
+
/** Accent color 4 */
|
|
580
|
+
ACCENT4: "accent4",
|
|
581
|
+
/** Accent color 5 */
|
|
582
|
+
ACCENT5: "accent5",
|
|
583
|
+
/** Accent color 6 */
|
|
584
|
+
ACCENT6: "accent6",
|
|
585
|
+
/** Hyperlink color */
|
|
586
|
+
HLINK: "hlink",
|
|
587
|
+
/** Followed hyperlink color */
|
|
588
|
+
FOLHLINK: "folHlink",
|
|
589
|
+
/** Dark color 1 */
|
|
590
|
+
DK1: "dk1",
|
|
591
|
+
/** Light color 1 */
|
|
592
|
+
LT1: "lt1",
|
|
593
|
+
/** Dark color 2 */
|
|
594
|
+
DK2: "dk2",
|
|
595
|
+
/** Light color 2 */
|
|
596
|
+
LT2: "lt2",
|
|
597
|
+
/** Placeholder color */
|
|
598
|
+
PHCLR: "phClr"
|
|
599
|
+
};
|
|
600
|
+
/**
|
|
601
|
+
* Creates a scheme color element.
|
|
602
|
+
*
|
|
603
|
+
* Specifies a color using a theme color scheme reference.
|
|
604
|
+
*
|
|
605
|
+
* ## XSD Schema
|
|
606
|
+
* ```xml
|
|
607
|
+
* <xsd:complexType name="CT_SchemeColor">
|
|
608
|
+
* <xsd:sequence>
|
|
609
|
+
* <xsd:group ref="EG_ColorTransform" minOccurs="0" maxOccurs="unbounded"/>
|
|
610
|
+
* </xsd:sequence>
|
|
611
|
+
* <xsd:attribute name="val" type="ST_SchemeColorVal" use="required"/>
|
|
612
|
+
* </xsd:complexType>
|
|
613
|
+
* ```
|
|
614
|
+
*
|
|
615
|
+
* @example
|
|
616
|
+
* ```typescript
|
|
617
|
+
* const accentColor = createSchemeColor({ value: SchemeColor.ACCENT1 });
|
|
618
|
+
* // With tint transform
|
|
619
|
+
* const lightAccent = createSchemeColor({
|
|
620
|
+
* value: SchemeColor.ACCENT1,
|
|
621
|
+
* transforms: { tint: 40000 },
|
|
622
|
+
* });
|
|
623
|
+
* ```
|
|
624
|
+
*/
|
|
625
|
+
const createSchemeColor = (options) => {
|
|
626
|
+
const transforms = options.transforms ? createColorTransforms(options.transforms) : [];
|
|
627
|
+
return new BuilderElement({
|
|
628
|
+
attributes: { value: {
|
|
629
|
+
key: "val",
|
|
630
|
+
value: options.value
|
|
631
|
+
} },
|
|
632
|
+
children: [...transforms],
|
|
633
|
+
name: "a:schemeClr"
|
|
634
|
+
});
|
|
635
|
+
};
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region src/drawingml/color/system-color.ts
|
|
638
|
+
/**
|
|
639
|
+
* System color element for DrawingML.
|
|
640
|
+
*
|
|
641
|
+
* This module provides system color support, referencing OS-level UI colors.
|
|
642
|
+
*
|
|
643
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SystemColor / ST_SystemColorVal
|
|
644
|
+
*
|
|
645
|
+
* @module
|
|
646
|
+
*/
|
|
647
|
+
/**
|
|
648
|
+
* System color values referencing OS UI colors.
|
|
649
|
+
*
|
|
650
|
+
* ## XSD Schema
|
|
651
|
+
* ```xml
|
|
652
|
+
* <xsd:simpleType name="ST_SystemColorVal">
|
|
653
|
+
* <xsd:restriction base="xsd:token">
|
|
654
|
+
* <xsd:enumeration value="scrollBar"/>
|
|
655
|
+
* <xsd:enumeration value="background"/>
|
|
656
|
+
* ...
|
|
657
|
+
* <xsd:enumeration value="menuBar"/>
|
|
658
|
+
* </xsd:restriction>
|
|
659
|
+
* </xsd:simpleType>
|
|
660
|
+
* ```
|
|
661
|
+
*/
|
|
662
|
+
const SystemColor = {
|
|
663
|
+
SCROLL_BAR: "scrollBar",
|
|
664
|
+
BACKGROUND: "background",
|
|
665
|
+
ACTIVE_CAPTION: "activeCaption",
|
|
666
|
+
INACTIVE_CAPTION: "inactiveCaption",
|
|
667
|
+
MENU: "menu",
|
|
668
|
+
WINDOW: "window",
|
|
669
|
+
WINDOW_FRAME: "windowFrame",
|
|
670
|
+
MENU_TEXT: "menuText",
|
|
671
|
+
WINDOW_TEXT: "windowText",
|
|
672
|
+
CAPTION_TEXT: "captionText",
|
|
673
|
+
ACTIVE_BORDER: "activeBorder",
|
|
674
|
+
INACTIVE_BORDER: "inactiveBorder",
|
|
675
|
+
APP_WORKSPACE: "appWorkspace",
|
|
676
|
+
HIGHLIGHT: "highlight",
|
|
677
|
+
HIGHLIGHT_TEXT: "highlightText",
|
|
678
|
+
BTN_FACE: "btnFace",
|
|
679
|
+
BTN_SHADOW: "btnShadow",
|
|
680
|
+
GRAY_TEXT: "grayText",
|
|
681
|
+
BTN_TEXT: "btnText",
|
|
682
|
+
INACTIVE_CAPTION_TEXT: "inactiveCaptionText",
|
|
683
|
+
BTN_HIGHLIGHT: "btnHighlight",
|
|
684
|
+
THREE_D_DK_SHADOW: "3dDkShadow",
|
|
685
|
+
THREE_D_LIGHT: "3dLight",
|
|
686
|
+
INFO_TEXT: "infoText",
|
|
687
|
+
INFO_BK: "infoBk",
|
|
688
|
+
HOT_LIGHT: "hotLight",
|
|
689
|
+
GRADIENT_ACTIVE_CAPTION: "gradientActiveCaption",
|
|
690
|
+
GRADIENT_INACTIVE_CAPTION: "gradientInactiveCaption",
|
|
691
|
+
MENU_HIGHLIGHT: "menuHighlight",
|
|
692
|
+
MENU_BAR: "menuBar"
|
|
693
|
+
};
|
|
694
|
+
/**
|
|
695
|
+
* Creates a system color element.
|
|
696
|
+
*
|
|
697
|
+
* References a system-defined UI color (e.g., window background, button face).
|
|
698
|
+
*
|
|
699
|
+
* ## XSD Schema
|
|
700
|
+
* ```xml
|
|
701
|
+
* <xsd:complexType name="CT_SystemColor">
|
|
702
|
+
* <xsd:sequence>
|
|
703
|
+
* <xsd:group ref="EG_ColorTransform" minOccurs="0" maxOccurs="unbounded"/>
|
|
704
|
+
* </xsd:sequence>
|
|
705
|
+
* <xsd:attribute name="val" type="ST_SystemColorVal" use="required"/>
|
|
706
|
+
* <xsd:attribute name="lastClr" type="s:ST_HexColorRGB" use="optional"/>
|
|
707
|
+
* </xsd:complexType>
|
|
708
|
+
* ```
|
|
709
|
+
*/
|
|
710
|
+
const createSystemColor = (options) => {
|
|
711
|
+
const transforms = options.transforms ? createColorTransforms(options.transforms) : [];
|
|
712
|
+
return new BuilderElement({
|
|
713
|
+
attributes: {
|
|
714
|
+
lastClr: {
|
|
715
|
+
key: "lastClr",
|
|
716
|
+
value: options.lastClr
|
|
717
|
+
},
|
|
718
|
+
value: {
|
|
719
|
+
key: "val",
|
|
720
|
+
value: options.value
|
|
721
|
+
}
|
|
722
|
+
},
|
|
723
|
+
children: [...transforms],
|
|
724
|
+
name: "a:sysClr"
|
|
725
|
+
});
|
|
726
|
+
};
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region src/drawingml/color/solid-fill.ts
|
|
729
|
+
/**
|
|
730
|
+
* Solid fill element for DrawingML shapes.
|
|
731
|
+
*
|
|
732
|
+
* This module provides solid fill support for outlines and shapes,
|
|
733
|
+
* supporting RGB, scheme, HSL, system, and preset colors.
|
|
734
|
+
*
|
|
735
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SolidColorFillProperties
|
|
736
|
+
*
|
|
737
|
+
* @module
|
|
738
|
+
*/
|
|
739
|
+
/**
|
|
740
|
+
* Creates the color child element for a solid fill based on the color type.
|
|
741
|
+
*/
|
|
742
|
+
const SYSTEM_COLOR_VALUES = new Set(Object.values(SystemColor));
|
|
743
|
+
const PRESET_COLOR_VALUES = new Set(Object.values(PresetColor));
|
|
744
|
+
const SCHEME_COLOR_VALUES = new Set(Object.values(SchemeColor));
|
|
745
|
+
const createColorElement = (color) => {
|
|
746
|
+
if ("hue" in color && "saturation" in color && "luminance" in color) return createHslColor(color);
|
|
747
|
+
if ("r" in color && "g" in color && "b" in color) return createScRgbColor(color);
|
|
748
|
+
const colorValue = color.value;
|
|
749
|
+
if (SYSTEM_COLOR_VALUES.has(colorValue)) return createSystemColor(color);
|
|
750
|
+
if (PRESET_COLOR_VALUES.has(colorValue)) return createPresetColor(color);
|
|
751
|
+
if (SCHEME_COLOR_VALUES.has(colorValue)) return createSchemeColor(color);
|
|
752
|
+
return createRgbColor(color);
|
|
753
|
+
};
|
|
754
|
+
/**
|
|
755
|
+
* Creates a solid fill element.
|
|
756
|
+
*
|
|
757
|
+
* Specifies a solid color fill using any supported color type.
|
|
758
|
+
*
|
|
759
|
+
* ## XSD Schema
|
|
760
|
+
* ```xml
|
|
761
|
+
* <xsd:complexType name="CT_SolidColorFillProperties">
|
|
762
|
+
* <xsd:sequence>
|
|
763
|
+
* <xsd:group ref="EG_ColorChoice" minOccurs="0"/>
|
|
764
|
+
* <xsd:group ref="EG_EffectProperties" minOccurs="0"/>
|
|
765
|
+
* </xsd:sequence>
|
|
766
|
+
* </xsd:complexType>
|
|
767
|
+
* ```
|
|
768
|
+
*
|
|
769
|
+
* @example
|
|
770
|
+
* ```typescript
|
|
771
|
+
* // RGB solid fill
|
|
772
|
+
* const fill = createSolidFill({ value: "FF0000" });
|
|
773
|
+
* // Scheme solid fill with tint
|
|
774
|
+
* const schemeFill = createSolidFill({
|
|
775
|
+
* value: SchemeColor.ACCENT1, transforms: { tint: 40000 },
|
|
776
|
+
* });
|
|
777
|
+
* // HSL solid fill
|
|
778
|
+
* const hslFill = createSolidFill({ hue: 120000, saturation: 100000, luminance: 50000 });
|
|
779
|
+
* ```
|
|
780
|
+
*/
|
|
781
|
+
const createSolidFill = (options) => new BuilderElement({
|
|
782
|
+
children: [createColorElement(options)],
|
|
783
|
+
name: "a:solidFill"
|
|
784
|
+
});
|
|
785
|
+
//#endregion
|
|
786
|
+
//#region src/drawingml/blip/blip-effects.ts
|
|
787
|
+
/**
|
|
788
|
+
* Blip image adjustment effects for DrawingML.
|
|
789
|
+
*
|
|
790
|
+
* These effects are applied directly to the image data within the `<a:blip>` element,
|
|
791
|
+
* corresponding to Word's "Picture Format > Adjust" features (brightness, contrast,
|
|
792
|
+
* grayscale, tint, duotone, etc.).
|
|
793
|
+
*
|
|
794
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Blip children
|
|
795
|
+
*
|
|
796
|
+
* @module
|
|
797
|
+
*/
|
|
798
|
+
/**
|
|
799
|
+
* Creates blip effect elements from BlipEffectsOptions.
|
|
800
|
+
*
|
|
801
|
+
* @returns Array of XML components representing blip effects
|
|
802
|
+
*/
|
|
803
|
+
const createBlipEffects = (options) => {
|
|
804
|
+
const children = [];
|
|
805
|
+
if (options.grayscale) children.push(new BuilderElement({ name: "a:grayscl" }));
|
|
806
|
+
if (options.luminance) {
|
|
807
|
+
const attrs = {};
|
|
808
|
+
if (options.luminance.bright !== void 0) attrs.bright = {
|
|
809
|
+
key: "bright",
|
|
810
|
+
value: `${options.luminance.bright}%`
|
|
811
|
+
};
|
|
812
|
+
if (options.luminance.contrast !== void 0) attrs.contrast = {
|
|
813
|
+
key: "contrast",
|
|
814
|
+
value: `${options.luminance.contrast}%`
|
|
815
|
+
};
|
|
816
|
+
children.push(new BuilderElement({
|
|
817
|
+
attributes: attrs,
|
|
818
|
+
name: "a:lum"
|
|
819
|
+
}));
|
|
820
|
+
}
|
|
821
|
+
if (options.hsl) {
|
|
822
|
+
const attrs = {};
|
|
823
|
+
if (options.hsl.hue !== void 0) attrs.hue = {
|
|
824
|
+
key: "hue",
|
|
825
|
+
value: String(options.hsl.hue)
|
|
826
|
+
};
|
|
827
|
+
if (options.hsl.saturation !== void 0) attrs.sat = {
|
|
828
|
+
key: "sat",
|
|
829
|
+
value: `${options.hsl.saturation}%`
|
|
830
|
+
};
|
|
831
|
+
if (options.hsl.luminance !== void 0) attrs.lum = {
|
|
832
|
+
key: "lum",
|
|
833
|
+
value: `${options.hsl.luminance}%`
|
|
834
|
+
};
|
|
835
|
+
children.push(new BuilderElement({
|
|
836
|
+
attributes: attrs,
|
|
837
|
+
name: "a:hsl"
|
|
838
|
+
}));
|
|
839
|
+
}
|
|
840
|
+
if (options.tint) {
|
|
841
|
+
const attrs = {};
|
|
842
|
+
if (options.tint.hue !== void 0) attrs.hue = {
|
|
843
|
+
key: "hue",
|
|
844
|
+
value: String(options.tint.hue)
|
|
845
|
+
};
|
|
846
|
+
if (options.tint.amount !== void 0) attrs.amt = {
|
|
847
|
+
key: "amt",
|
|
848
|
+
value: `${options.tint.amount}%`
|
|
849
|
+
};
|
|
850
|
+
children.push(new BuilderElement({
|
|
851
|
+
attributes: attrs,
|
|
852
|
+
name: "a:tint"
|
|
853
|
+
}));
|
|
854
|
+
}
|
|
855
|
+
if (options.duotone) children.push(new BuilderElement({
|
|
856
|
+
children: [createColorElement(options.duotone.color1), createColorElement(options.duotone.color2)],
|
|
857
|
+
name: "a:duotone"
|
|
858
|
+
}));
|
|
859
|
+
if (options.biLevel) children.push(new BuilderElement({
|
|
860
|
+
attributes: { thresh: {
|
|
861
|
+
key: "thresh",
|
|
862
|
+
value: `${options.biLevel.threshold}%`
|
|
863
|
+
} },
|
|
864
|
+
name: "a:biLevel"
|
|
865
|
+
}));
|
|
866
|
+
if (options.alphaCeiling) children.push(new BuilderElement({ name: "a:alphaCeiling" }));
|
|
867
|
+
if (options.alphaFloor) children.push(new BuilderElement({ name: "a:alphaFloor" }));
|
|
868
|
+
if (options.alphaInverse !== void 0) if (typeof options.alphaInverse === "boolean") children.push(new BuilderElement({ name: "a:alphaInv" }));
|
|
869
|
+
else children.push(new BuilderElement({
|
|
870
|
+
children: [createColorElement(options.alphaInverse)],
|
|
871
|
+
name: "a:alphaInv"
|
|
872
|
+
}));
|
|
873
|
+
if (options.alphaModFix) {
|
|
874
|
+
const amt = options.alphaModFix.amount ?? 100;
|
|
875
|
+
children.push(new BuilderElement({
|
|
876
|
+
attributes: { amt: {
|
|
877
|
+
key: "amt",
|
|
878
|
+
value: `${amt}%`
|
|
879
|
+
} },
|
|
880
|
+
name: "a:alphaModFix"
|
|
881
|
+
}));
|
|
882
|
+
}
|
|
883
|
+
if (options.alphaRepl) children.push(new BuilderElement({
|
|
884
|
+
attributes: { a: {
|
|
885
|
+
key: "a",
|
|
886
|
+
value: `${options.alphaRepl.amount}%`
|
|
887
|
+
} },
|
|
888
|
+
name: "a:alphaRepl"
|
|
889
|
+
}));
|
|
890
|
+
if (options.alphaBiLevel) children.push(new BuilderElement({
|
|
891
|
+
attributes: { thresh: {
|
|
892
|
+
key: "thresh",
|
|
893
|
+
value: `${options.alphaBiLevel.threshold}%`
|
|
894
|
+
} },
|
|
895
|
+
name: "a:alphaBiLevel"
|
|
896
|
+
}));
|
|
897
|
+
if (options.colorChange) {
|
|
898
|
+
const attrs = {};
|
|
899
|
+
if (options.colorChange.useAlpha === false) attrs.useA = {
|
|
900
|
+
key: "useA",
|
|
901
|
+
value: "0"
|
|
902
|
+
};
|
|
903
|
+
children.push(new BuilderElement({
|
|
904
|
+
attributes: attrs,
|
|
905
|
+
children: [new BuilderElement({
|
|
906
|
+
children: [createColorElement(options.colorChange.from)],
|
|
907
|
+
name: "a:clrFrom"
|
|
908
|
+
}), new BuilderElement({
|
|
909
|
+
children: [createColorElement(options.colorChange.to)],
|
|
910
|
+
name: "a:clrTo"
|
|
911
|
+
})],
|
|
912
|
+
name: "a:clrChange"
|
|
913
|
+
}));
|
|
914
|
+
}
|
|
915
|
+
if (options.colorRepl) children.push(new BuilderElement({
|
|
916
|
+
children: [createColorElement(options.colorRepl.color)],
|
|
917
|
+
name: "a:clrRepl"
|
|
918
|
+
}));
|
|
919
|
+
if (options.blur) {
|
|
920
|
+
const attrs = {};
|
|
921
|
+
if (options.blur.radius !== void 0) attrs.rad = {
|
|
922
|
+
key: "rad",
|
|
923
|
+
value: options.blur.radius
|
|
924
|
+
};
|
|
925
|
+
if (options.blur.grow === false) attrs.grow = {
|
|
926
|
+
key: "grow",
|
|
927
|
+
value: 0
|
|
928
|
+
};
|
|
929
|
+
children.push(new BuilderElement({
|
|
930
|
+
attributes: attrs,
|
|
931
|
+
name: "a:blur"
|
|
932
|
+
}));
|
|
933
|
+
}
|
|
934
|
+
return children;
|
|
935
|
+
};
|
|
936
|
+
//#endregion
|
|
937
|
+
//#region src/drawingml/blip/source-rectangle.ts
|
|
938
|
+
/**
|
|
939
|
+
* Source rectangle module for blip fills.
|
|
940
|
+
*
|
|
941
|
+
* This module defines the portion of an image to use when filling a shape.
|
|
942
|
+
*
|
|
943
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_RelativeRect
|
|
944
|
+
*
|
|
945
|
+
* @module
|
|
946
|
+
*/
|
|
947
|
+
/**
|
|
948
|
+
* Creates a source rectangle element for blip fill cropping.
|
|
949
|
+
*
|
|
950
|
+
* This element specifies a portion of the blip (image) to use as the fill.
|
|
951
|
+
* When no options are provided, the entire blip is used.
|
|
952
|
+
*
|
|
953
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_RelativeRect
|
|
954
|
+
*
|
|
955
|
+
* ## XSD Schema
|
|
956
|
+
* ```xml
|
|
957
|
+
* <xsd:complexType name="CT_RelativeRect">
|
|
958
|
+
* <xsd:attribute name="l" type="ST_Percentage" use="optional" default="0"/>
|
|
959
|
+
* <xsd:attribute name="t" type="ST_Percentage" use="optional" default="0"/>
|
|
960
|
+
* <xsd:attribute name="r" type="ST_Percentage" use="optional" default="0"/>
|
|
961
|
+
* <xsd:attribute name="b" type="ST_Percentage" use="optional" default="0"/>
|
|
962
|
+
* </xsd:complexType>
|
|
963
|
+
* ```
|
|
964
|
+
*
|
|
965
|
+
* @example
|
|
966
|
+
* ```typescript
|
|
967
|
+
* // Crop 10% from left and right
|
|
968
|
+
* createSourceRectangle({ left: 10000, right: 10000 });
|
|
969
|
+
* ```
|
|
970
|
+
*/
|
|
971
|
+
const createSourceRectangle = (options) => {
|
|
972
|
+
if (!options) return new BuilderElement({ name: "a:srcRect" });
|
|
973
|
+
const attributes = {};
|
|
974
|
+
if (options.left !== void 0) attributes.l = {
|
|
975
|
+
key: "l",
|
|
976
|
+
value: options.left
|
|
977
|
+
};
|
|
978
|
+
if (options.top !== void 0) attributes.t = {
|
|
979
|
+
key: "t",
|
|
980
|
+
value: options.top
|
|
981
|
+
};
|
|
982
|
+
if (options.right !== void 0) attributes.r = {
|
|
983
|
+
key: "r",
|
|
984
|
+
value: options.right
|
|
985
|
+
};
|
|
986
|
+
if (options.bottom !== void 0) attributes.b = {
|
|
987
|
+
key: "b",
|
|
988
|
+
value: options.bottom
|
|
989
|
+
};
|
|
990
|
+
return new BuilderElement({
|
|
991
|
+
attributes,
|
|
992
|
+
name: "a:srcRect"
|
|
993
|
+
});
|
|
994
|
+
};
|
|
995
|
+
//#endregion
|
|
996
|
+
//#region src/drawingml/blip/stretch.ts
|
|
997
|
+
/**
|
|
998
|
+
* Stretch fill module for blip fills.
|
|
999
|
+
*
|
|
1000
|
+
* This module defines how images are stretched to fill shapes.
|
|
1001
|
+
*
|
|
1002
|
+
* Reference: http://officeopenxml.com/drwPic.php
|
|
1003
|
+
*
|
|
1004
|
+
* @module
|
|
1005
|
+
*/
|
|
1006
|
+
/**
|
|
1007
|
+
* Represents a fill rectangle for stretch fill mode.
|
|
1008
|
+
*
|
|
1009
|
+
* This element specifies the rectangular area of the shape to which
|
|
1010
|
+
* the blip fill should be stretched.
|
|
1011
|
+
*
|
|
1012
|
+
* Reference: http://officeopenxml.com/drwPic.php
|
|
1013
|
+
*
|
|
1014
|
+
* ## XSD Schema
|
|
1015
|
+
* ```xml
|
|
1016
|
+
* <xsd:complexType name="CT_RelativeRect">
|
|
1017
|
+
* <xsd:attribute name="l" type="ST_Percentage" use="optional" default="0"/>
|
|
1018
|
+
* <xsd:attribute name="t" type="ST_Percentage" use="optional" default="0"/>
|
|
1019
|
+
* <xsd:attribute name="r" type="ST_Percentage" use="optional" default="0"/>
|
|
1020
|
+
* <xsd:attribute name="b" type="ST_Percentage" use="optional" default="0"/>
|
|
1021
|
+
* </xsd:complexType>
|
|
1022
|
+
* ```
|
|
1023
|
+
*/
|
|
1024
|
+
var FillRectangle = class extends XmlComponent {
|
|
1025
|
+
constructor() {
|
|
1026
|
+
super("a:fillRect");
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
/**
|
|
1030
|
+
* Represents a stretch fill mode for blip fills.
|
|
1031
|
+
*
|
|
1032
|
+
* This element specifies that the blip (image) should be stretched to fill
|
|
1033
|
+
* the entire shape. The stretch fill is one of the fill mode properties
|
|
1034
|
+
* that determines how an image is applied to a shape.
|
|
1035
|
+
*
|
|
1036
|
+
* Reference: http://officeopenxml.com/drwPic.php
|
|
1037
|
+
*
|
|
1038
|
+
* ## XSD Schema
|
|
1039
|
+
* ```xml
|
|
1040
|
+
* <xsd:complexType name="CT_StretchInfoProperties">
|
|
1041
|
+
* <xsd:sequence>
|
|
1042
|
+
* <xsd:element name="fillRect" type="CT_RelativeRect" minOccurs="0" maxOccurs="1"/>
|
|
1043
|
+
* </xsd:sequence>
|
|
1044
|
+
* </xsd:complexType>
|
|
1045
|
+
* ```
|
|
1046
|
+
*
|
|
1047
|
+
* @example
|
|
1048
|
+
* ```typescript
|
|
1049
|
+
* const stretch = new Stretch();
|
|
1050
|
+
* ```
|
|
1051
|
+
*/
|
|
1052
|
+
var Stretch = class extends XmlComponent {
|
|
1053
|
+
constructor() {
|
|
1054
|
+
super("a:stretch");
|
|
1055
|
+
this.root.push(new FillRectangle());
|
|
1056
|
+
}
|
|
1057
|
+
};
|
|
1058
|
+
//#endregion
|
|
1059
|
+
//#region src/drawingml/blip/tile.ts
|
|
1060
|
+
/**
|
|
1061
|
+
* Tile fill module for blip fills.
|
|
1062
|
+
*
|
|
1063
|
+
* This module defines how images are tiled (repeated) to fill shapes.
|
|
1064
|
+
*
|
|
1065
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TileInfoProperties
|
|
1066
|
+
*
|
|
1067
|
+
* @module
|
|
1068
|
+
*/
|
|
1069
|
+
/**
|
|
1070
|
+
* Tile flip mode for tiling images.
|
|
1071
|
+
*
|
|
1072
|
+
* Specifies whether the image is flipped along the x-axis, y-axis,
|
|
1073
|
+
* both axes, or not at all when tiling.
|
|
1074
|
+
*/
|
|
1075
|
+
const TileFlipMode$1 = {
|
|
1076
|
+
/** No flipping */
|
|
1077
|
+
NONE: "none",
|
|
1078
|
+
/** Flip along x-axis */
|
|
1079
|
+
X: "x",
|
|
1080
|
+
/** Flip along y-axis */
|
|
1081
|
+
Y: "y",
|
|
1082
|
+
/** Flip along both axes */
|
|
1083
|
+
XY: "xy"
|
|
1084
|
+
};
|
|
1085
|
+
/**
|
|
1086
|
+
* Tile alignment within the shape.
|
|
1087
|
+
*
|
|
1088
|
+
* Specifies the anchor position of the first tile relative to the shape.
|
|
1089
|
+
*/
|
|
1090
|
+
const TileAlignment = {
|
|
1091
|
+
/** Top-left corner */
|
|
1092
|
+
TOP_LEFT: "tl",
|
|
1093
|
+
/** Top center */
|
|
1094
|
+
TOP: "t",
|
|
1095
|
+
/** Top-right corner */
|
|
1096
|
+
TOP_RIGHT: "tr",
|
|
1097
|
+
/** Middle-left */
|
|
1098
|
+
LEFT: "l",
|
|
1099
|
+
/** Center */
|
|
1100
|
+
CENTER: "ctr",
|
|
1101
|
+
/** Middle-right */
|
|
1102
|
+
RIGHT: "r",
|
|
1103
|
+
/** Bottom-left corner */
|
|
1104
|
+
BOTTOM_LEFT: "bl",
|
|
1105
|
+
/** Bottom center */
|
|
1106
|
+
BOTTOM: "b",
|
|
1107
|
+
/** Bottom-right corner */
|
|
1108
|
+
BOTTOM_RIGHT: "br"
|
|
1109
|
+
};
|
|
1110
|
+
/**
|
|
1111
|
+
* Creates a tile fill mode element for blip fills.
|
|
1112
|
+
*
|
|
1113
|
+
* When a blip fill uses tile mode, the image is repeated (tiled) to fill
|
|
1114
|
+
* the shape instead of being stretched. This element controls the tiling
|
|
1115
|
+
* parameters such as offset, scale, flip, and alignment.
|
|
1116
|
+
*
|
|
1117
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_TileInfoProperties
|
|
1118
|
+
*
|
|
1119
|
+
* ## XSD Schema
|
|
1120
|
+
* ```xml
|
|
1121
|
+
* <xsd:complexType name="CT_TileInfoProperties">
|
|
1122
|
+
* <xsd:attribute name="tx" type="ST_Coordinate" use="optional"/>
|
|
1123
|
+
* <xsd:attribute name="ty" type="ST_Coordinate" use="optional"/>
|
|
1124
|
+
* <xsd:attribute name="sx" type="ST_Percentage" use="optional"/>
|
|
1125
|
+
* <xsd:attribute name="sy" type="ST_Percentage" use="optional"/>
|
|
1126
|
+
* <xsd:attribute name="flip" type="ST_TileFlipMode" default="none"/>
|
|
1127
|
+
* <xsd:attribute name="algn" type="ST_RectAlignment" use="optional"/>
|
|
1128
|
+
* </xsd:complexType>
|
|
1129
|
+
* ```
|
|
1130
|
+
*
|
|
1131
|
+
* @example
|
|
1132
|
+
* ```typescript
|
|
1133
|
+
* // Tile with 50% scale
|
|
1134
|
+
* createTileInfo({ sx: 50, sy: 50 });
|
|
1135
|
+
* // Tile with flip and alignment
|
|
1136
|
+
* createTileInfo({ flip: "XY", align: "CENTER" });
|
|
1137
|
+
* ```
|
|
1138
|
+
*/
|
|
1139
|
+
const createTileInfo = (options) => {
|
|
1140
|
+
if (!options) return new BuilderElement({ name: "a:tile" });
|
|
1141
|
+
const attributes = {};
|
|
1142
|
+
if (options.tx !== void 0) attributes.tx = {
|
|
1143
|
+
key: "tx",
|
|
1144
|
+
value: options.tx
|
|
1145
|
+
};
|
|
1146
|
+
if (options.ty !== void 0) attributes.ty = {
|
|
1147
|
+
key: "ty",
|
|
1148
|
+
value: options.ty
|
|
1149
|
+
};
|
|
1150
|
+
if (options.sx !== void 0) attributes.sx = {
|
|
1151
|
+
key: "sx",
|
|
1152
|
+
value: options.sx
|
|
1153
|
+
};
|
|
1154
|
+
if (options.sy !== void 0) attributes.sy = {
|
|
1155
|
+
key: "sy",
|
|
1156
|
+
value: options.sy
|
|
1157
|
+
};
|
|
1158
|
+
if (options.flip !== void 0) attributes.flip = {
|
|
1159
|
+
key: "flip",
|
|
1160
|
+
value: TileFlipMode$1[options.flip]
|
|
1161
|
+
};
|
|
1162
|
+
if (options.align !== void 0) attributes.algn = {
|
|
1163
|
+
key: "algn",
|
|
1164
|
+
value: TileAlignment[options.align]
|
|
1165
|
+
};
|
|
1166
|
+
return new BuilderElement({
|
|
1167
|
+
attributes: Object.keys(attributes).length > 0 ? attributes : void 0,
|
|
1168
|
+
name: "a:tile"
|
|
1169
|
+
});
|
|
1170
|
+
};
|
|
1171
|
+
//#endregion
|
|
1172
|
+
//#region src/drawingml/fill/gradient-fill.ts
|
|
1173
|
+
/**
|
|
1174
|
+
* Gradient fill element for DrawingML shapes.
|
|
1175
|
+
*
|
|
1176
|
+
* This module provides gradient fill support with linear and path shading.
|
|
1177
|
+
*
|
|
1178
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_GradientFillProperties
|
|
1179
|
+
*
|
|
1180
|
+
* @module
|
|
1181
|
+
*/
|
|
1182
|
+
/**
|
|
1183
|
+
* Path shade type for radial gradients.
|
|
1184
|
+
*/
|
|
1185
|
+
const PathShadeType = {
|
|
1186
|
+
/** Follow shape path */
|
|
1187
|
+
SHAPE: "shape",
|
|
1188
|
+
/** Circular gradient */
|
|
1189
|
+
CIRCLE: "circle",
|
|
1190
|
+
/** Rectangular gradient */
|
|
1191
|
+
RECT: "rect"
|
|
1192
|
+
};
|
|
1193
|
+
/**
|
|
1194
|
+
* Tile flip mode for gradient fill.
|
|
1195
|
+
*
|
|
1196
|
+
* ## XSD Schema
|
|
1197
|
+
* ```xml
|
|
1198
|
+
* <xsd:simpleType name="ST_TileFlipMode">
|
|
1199
|
+
* <xsd:restriction base="xsd:string">
|
|
1200
|
+
* <xsd:enumeration value="none"/>
|
|
1201
|
+
* <xsd:enumeration value="x"/>
|
|
1202
|
+
* <xsd:enumeration value="y"/>
|
|
1203
|
+
* <xsd:enumeration value="xy"/>
|
|
1204
|
+
* </xsd:restriction>
|
|
1205
|
+
* </xsd:simpleType>
|
|
1206
|
+
* ```
|
|
1207
|
+
*/
|
|
1208
|
+
const TileFlipMode = {
|
|
1209
|
+
/** No flip */
|
|
1210
|
+
NONE: "none",
|
|
1211
|
+
/** Flip horizontally */
|
|
1212
|
+
X: "x",
|
|
1213
|
+
/** Flip vertically */
|
|
1214
|
+
Y: "y",
|
|
1215
|
+
/** Flip both horizontally and vertically */
|
|
1216
|
+
XY: "xy"
|
|
1217
|
+
};
|
|
1218
|
+
/**
|
|
1219
|
+
* Creates a gradient stop element (a:gs).
|
|
1220
|
+
*
|
|
1221
|
+
* @example
|
|
1222
|
+
* ```typescript
|
|
1223
|
+
* createGradientStop({ position: 0, color: { value: "FF0000" } });
|
|
1224
|
+
* createGradientStop({ position: 100000, color: { value: "0000FF" } });
|
|
1225
|
+
* ```
|
|
1226
|
+
*/
|
|
1227
|
+
const createGradientStop = (stop) => new BuilderElement({
|
|
1228
|
+
attributes: { pos: {
|
|
1229
|
+
key: "pos",
|
|
1230
|
+
value: stop.position
|
|
1231
|
+
} },
|
|
1232
|
+
children: [createColorElement(stop.color)],
|
|
1233
|
+
name: "a:gs"
|
|
1234
|
+
});
|
|
1235
|
+
/**
|
|
1236
|
+
* Creates a relative rect element.
|
|
1237
|
+
*/
|
|
1238
|
+
const createRelativeRect = (name, rect) => new BuilderElement({
|
|
1239
|
+
attributes: {
|
|
1240
|
+
l: {
|
|
1241
|
+
key: "l",
|
|
1242
|
+
value: rect?.left
|
|
1243
|
+
},
|
|
1244
|
+
t: {
|
|
1245
|
+
key: "t",
|
|
1246
|
+
value: rect?.top
|
|
1247
|
+
},
|
|
1248
|
+
r: {
|
|
1249
|
+
key: "r",
|
|
1250
|
+
value: rect?.right
|
|
1251
|
+
},
|
|
1252
|
+
b: {
|
|
1253
|
+
key: "b",
|
|
1254
|
+
value: rect?.bottom
|
|
1255
|
+
}
|
|
1256
|
+
},
|
|
1257
|
+
name
|
|
1258
|
+
});
|
|
1259
|
+
/**
|
|
1260
|
+
* Creates the shade element (a:lin or a:path).
|
|
1261
|
+
*/
|
|
1262
|
+
const createShadeElement = (shade) => {
|
|
1263
|
+
if ("angle" in shade) return new BuilderElement({
|
|
1264
|
+
attributes: {
|
|
1265
|
+
ang: {
|
|
1266
|
+
key: "ang",
|
|
1267
|
+
value: shade.angle
|
|
1268
|
+
},
|
|
1269
|
+
scaled: {
|
|
1270
|
+
key: "scaled",
|
|
1271
|
+
value: shade.scaled
|
|
1272
|
+
}
|
|
1273
|
+
},
|
|
1274
|
+
name: "a:lin"
|
|
1275
|
+
});
|
|
1276
|
+
const pathShade = shade;
|
|
1277
|
+
const children = [];
|
|
1278
|
+
if (pathShade.fillToRect) children.push(createRelativeRect("a:fillToRect", pathShade.fillToRect));
|
|
1279
|
+
return new BuilderElement({
|
|
1280
|
+
attributes: { path: {
|
|
1281
|
+
key: "path",
|
|
1282
|
+
value: pathShade.path ? PathShadeType[pathShade.path] : void 0
|
|
1283
|
+
} },
|
|
1284
|
+
children,
|
|
1285
|
+
name: "a:path"
|
|
1286
|
+
});
|
|
1287
|
+
};
|
|
1288
|
+
/**
|
|
1289
|
+
* Creates a gradient fill element.
|
|
1290
|
+
*
|
|
1291
|
+
* ## XSD Schema
|
|
1292
|
+
* ```xml
|
|
1293
|
+
* <xsd:complexType name="CT_GradientFillProperties">
|
|
1294
|
+
* <xsd:sequence>
|
|
1295
|
+
* <xsd:element name="gsLst" type="CT_GradientStopList" minOccurs="0"/>
|
|
1296
|
+
* <xsd:group ref="EG_ShadeProperties" minOccurs="0"/>
|
|
1297
|
+
* </xsd:sequence>
|
|
1298
|
+
* <xsd:attribute name="rotWithShape" type="xsd:boolean" use="optional"/>
|
|
1299
|
+
* </xsd:complexType>
|
|
1300
|
+
* ```
|
|
1301
|
+
*
|
|
1302
|
+
* @example
|
|
1303
|
+
* ```typescript
|
|
1304
|
+
* // Linear gradient from red to blue
|
|
1305
|
+
* createGradientFill({
|
|
1306
|
+
* stops: [
|
|
1307
|
+
* { position: 0, color: { value: "FF0000" } },
|
|
1308
|
+
* { position: 100000, color: { value: "0000FF" } },
|
|
1309
|
+
* ],
|
|
1310
|
+
* shade: { angle: 5400000 },
|
|
1311
|
+
* });
|
|
1312
|
+
* ```
|
|
1313
|
+
*/
|
|
1314
|
+
const createGradientFill = (options) => {
|
|
1315
|
+
const children = [];
|
|
1316
|
+
children.push(new BuilderElement({
|
|
1317
|
+
children: options.stops.map(createGradientStop),
|
|
1318
|
+
name: "a:gsLst"
|
|
1319
|
+
}));
|
|
1320
|
+
if (options.shade) children.push(createShadeElement(options.shade));
|
|
1321
|
+
if (options.tileRect) children.push(createRelativeRect("a:tileRect", options.tileRect));
|
|
1322
|
+
return new BuilderElement({
|
|
1323
|
+
attributes: {
|
|
1324
|
+
flip: {
|
|
1325
|
+
key: "flip",
|
|
1326
|
+
value: options.flip ? TileFlipMode[options.flip] : void 0
|
|
1327
|
+
},
|
|
1328
|
+
rotWithShape: {
|
|
1329
|
+
key: "rotWithShape",
|
|
1330
|
+
value: options.rotateWithShape
|
|
1331
|
+
}
|
|
1332
|
+
},
|
|
1333
|
+
children,
|
|
1334
|
+
name: "a:gradFill"
|
|
1335
|
+
});
|
|
1336
|
+
};
|
|
1337
|
+
//#endregion
|
|
1338
|
+
//#region src/drawingml/fill/pattern-fill.ts
|
|
1339
|
+
/**
|
|
1340
|
+
* Pattern fill element for DrawingML shapes.
|
|
1341
|
+
*
|
|
1342
|
+
* This module provides pattern fill support with preset patterns and
|
|
1343
|
+
* optional foreground/background colors.
|
|
1344
|
+
*
|
|
1345
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_PatternFillProperties
|
|
1346
|
+
*
|
|
1347
|
+
* @module
|
|
1348
|
+
*/
|
|
1349
|
+
/**
|
|
1350
|
+
* Preset pattern values for pattern fill.
|
|
1351
|
+
*
|
|
1352
|
+
* ## XSD Schema
|
|
1353
|
+
* ```xml
|
|
1354
|
+
* <xsd:simpleType name="ST_PresetPatternVal">
|
|
1355
|
+
* <xsd:restriction base="xsd:token">
|
|
1356
|
+
* <xsd:enumeration value="pct5"/> ... <xsd:enumeration value="zigZag"/>
|
|
1357
|
+
* </xsd:restriction>
|
|
1358
|
+
* </xsd:simpleType>
|
|
1359
|
+
* ```
|
|
1360
|
+
*
|
|
1361
|
+
* @publicApi
|
|
1362
|
+
*/
|
|
1363
|
+
const PresetPattern = {
|
|
1364
|
+
/** 5% pattern */
|
|
1365
|
+
PCT5: "pct5",
|
|
1366
|
+
/** 10% pattern */
|
|
1367
|
+
PCT10: "pct10",
|
|
1368
|
+
/** 20% pattern */
|
|
1369
|
+
PCT20: "pct20",
|
|
1370
|
+
/** 25% pattern */
|
|
1371
|
+
PCT25: "pct25",
|
|
1372
|
+
/** 30% pattern */
|
|
1373
|
+
PCT30: "pct30",
|
|
1374
|
+
/** 40% pattern */
|
|
1375
|
+
PCT40: "pct40",
|
|
1376
|
+
/** 50% pattern */
|
|
1377
|
+
PCT50: "pct50",
|
|
1378
|
+
/** 60% pattern */
|
|
1379
|
+
PCT60: "pct60",
|
|
1380
|
+
/** 70% pattern */
|
|
1381
|
+
PCT70: "pct70",
|
|
1382
|
+
/** 75% pattern */
|
|
1383
|
+
PCT75: "pct75",
|
|
1384
|
+
/** 80% pattern */
|
|
1385
|
+
PCT80: "pct80",
|
|
1386
|
+
/** 90% pattern */
|
|
1387
|
+
PCT90: "pct90",
|
|
1388
|
+
/** Horizontal lines */
|
|
1389
|
+
HORZ: "horz",
|
|
1390
|
+
/** Vertical lines */
|
|
1391
|
+
VERT: "vert",
|
|
1392
|
+
/** Light horizontal lines */
|
|
1393
|
+
LT_HORZ: "ltHorz",
|
|
1394
|
+
/** Light vertical lines */
|
|
1395
|
+
LT_VERT: "ltVert",
|
|
1396
|
+
/** Dark horizontal lines */
|
|
1397
|
+
DK_HORZ: "dkHorz",
|
|
1398
|
+
/** Dark vertical lines */
|
|
1399
|
+
DK_VERT: "dkVert",
|
|
1400
|
+
/** Narrow horizontal lines */
|
|
1401
|
+
NAR_HORZ: "narHorz",
|
|
1402
|
+
/** Narrow vertical lines */
|
|
1403
|
+
NAR_VERT: "narVert",
|
|
1404
|
+
/** Dashed horizontal lines */
|
|
1405
|
+
DASH_HORZ: "dashHorz",
|
|
1406
|
+
/** Dashed vertical lines */
|
|
1407
|
+
DASH_VERT: "dashVert",
|
|
1408
|
+
/** Cross pattern (+) */
|
|
1409
|
+
CROSS: "cross",
|
|
1410
|
+
/** Downward diagonal lines (\) */
|
|
1411
|
+
DN_DIAG: "dnDiag",
|
|
1412
|
+
/** Upward diagonal lines (/) */
|
|
1413
|
+
UP_DIAG: "upDiag",
|
|
1414
|
+
/** Light downward diagonal lines */
|
|
1415
|
+
LT_DN_DIAG: "ltDnDiag",
|
|
1416
|
+
/** Light upward diagonal lines */
|
|
1417
|
+
LT_UP_DIAG: "ltUpDiag",
|
|
1418
|
+
/** Dark downward diagonal lines */
|
|
1419
|
+
DK_DN_DIAG: "dkDnDiag",
|
|
1420
|
+
/** Dark upward diagonal lines */
|
|
1421
|
+
DK_UP_DIAG: "dkUpDiag",
|
|
1422
|
+
/** Wide downward diagonal lines */
|
|
1423
|
+
WD_DN_DIAG: "wdDnDiag",
|
|
1424
|
+
/** Wide upward diagonal lines */
|
|
1425
|
+
WD_UP_DIAG: "wdUpDiag",
|
|
1426
|
+
/** Dashed downward diagonal lines */
|
|
1427
|
+
DASH_DN_DIAG: "dashDnDiag",
|
|
1428
|
+
/** Dashed upward diagonal lines */
|
|
1429
|
+
DASH_UP_DIAG: "dashUpDiag",
|
|
1430
|
+
/** Diagonal cross pattern (X) */
|
|
1431
|
+
DIAG_CROSS: "diagCross",
|
|
1432
|
+
/** Small checkerboard */
|
|
1433
|
+
SM_CHECK: "smCheck",
|
|
1434
|
+
/** Large checkerboard */
|
|
1435
|
+
LG_CHECK: "lgCheck",
|
|
1436
|
+
/** Small grid */
|
|
1437
|
+
SM_GRID: "smGrid",
|
|
1438
|
+
/** Large grid */
|
|
1439
|
+
LG_GRID: "lgGrid",
|
|
1440
|
+
/** Dot grid */
|
|
1441
|
+
DOT_GRID: "dotGrid",
|
|
1442
|
+
/** Small confetti */
|
|
1443
|
+
SM_CONFETTI: "smConfetti",
|
|
1444
|
+
/** Large confetti */
|
|
1445
|
+
LG_CONFETTI: "lgConfetti",
|
|
1446
|
+
/** Horizontal brick pattern */
|
|
1447
|
+
HORZ_BRICK: "horzBrick",
|
|
1448
|
+
/** Diagonal brick pattern */
|
|
1449
|
+
DIAG_BRICK: "diagBrick",
|
|
1450
|
+
/** Solid diamond */
|
|
1451
|
+
SOLID_DMND: "solidDmnd",
|
|
1452
|
+
/** Open diamond */
|
|
1453
|
+
OPEN_DMND: "openDmnd",
|
|
1454
|
+
/** Dotted diamond */
|
|
1455
|
+
DOT_DMND: "dotDmnd",
|
|
1456
|
+
/** Plaid pattern */
|
|
1457
|
+
PLAID: "plaid",
|
|
1458
|
+
/** Sphere pattern */
|
|
1459
|
+
SPHERE: "sphere",
|
|
1460
|
+
/** Weave pattern */
|
|
1461
|
+
WEAVE: "weave",
|
|
1462
|
+
/** Divot pattern */
|
|
1463
|
+
DIVOT: "divot",
|
|
1464
|
+
/** Shingle pattern */
|
|
1465
|
+
SHINGLE: "shingle",
|
|
1466
|
+
/** Wave pattern */
|
|
1467
|
+
WAVE: "wave",
|
|
1468
|
+
/** Trellis pattern */
|
|
1469
|
+
TRELLIS: "trellis",
|
|
1470
|
+
/** Zigzag pattern */
|
|
1471
|
+
ZIG_ZAG: "zigZag"
|
|
1472
|
+
};
|
|
1473
|
+
/**
|
|
1474
|
+
* Creates a pattern fill element (a:pattFill).
|
|
1475
|
+
*
|
|
1476
|
+
* Specifies a pattern fill using preset patterns with optional
|
|
1477
|
+
* foreground and background colors.
|
|
1478
|
+
*
|
|
1479
|
+
* ## XSD Schema
|
|
1480
|
+
* ```xml
|
|
1481
|
+
* <xsd:complexType name="CT_PatternFillProperties">
|
|
1482
|
+
* <xsd:sequence>
|
|
1483
|
+
* <xsd:element name="fgClr" type="CT_Color" minOccurs="0"/>
|
|
1484
|
+
* <xsd:element name="bgClr" type="CT_Color" minOccurs="0"/>
|
|
1485
|
+
* </xsd:sequence>
|
|
1486
|
+
* <xsd:attribute name="prst" type="ST_PresetPatternVal" use="optional"/>
|
|
1487
|
+
* </xsd:complexType>
|
|
1488
|
+
* ```
|
|
1489
|
+
*
|
|
1490
|
+
* @example
|
|
1491
|
+
* ```typescript
|
|
1492
|
+
* // Simple crosshatch pattern
|
|
1493
|
+
* createPatternFill({ pattern: PresetPattern.CROSS });
|
|
1494
|
+
* // Pattern with foreground color
|
|
1495
|
+
* createPatternFill({
|
|
1496
|
+
* pattern: PresetPattern.DIAG_CROSS,
|
|
1497
|
+
* foregroundColor: { value: "FF0000" },
|
|
1498
|
+
* });
|
|
1499
|
+
* // Pattern with foreground and background colors
|
|
1500
|
+
* createPatternFill({
|
|
1501
|
+
* pattern: PresetPattern.HORZ,
|
|
1502
|
+
* foregroundColor: { value: "0000FF" },
|
|
1503
|
+
* backgroundColor: { value: "FFFF00" },
|
|
1504
|
+
* });
|
|
1505
|
+
* ```
|
|
1506
|
+
*/
|
|
1507
|
+
const createPatternFill = (options) => {
|
|
1508
|
+
const children = [];
|
|
1509
|
+
if (options.foregroundColor) children.push(new BuilderElement({
|
|
1510
|
+
children: [createColorElement(options.foregroundColor)],
|
|
1511
|
+
name: "a:fgClr"
|
|
1512
|
+
}));
|
|
1513
|
+
if (options.backgroundColor) children.push(new BuilderElement({
|
|
1514
|
+
children: [createColorElement(options.backgroundColor)],
|
|
1515
|
+
name: "a:bgClr"
|
|
1516
|
+
}));
|
|
1517
|
+
return new BuilderElement({
|
|
1518
|
+
attributes: { prst: {
|
|
1519
|
+
key: "prst",
|
|
1520
|
+
value: options.pattern
|
|
1521
|
+
} },
|
|
1522
|
+
children,
|
|
1523
|
+
name: "a:pattFill"
|
|
1524
|
+
});
|
|
1525
|
+
};
|
|
1526
|
+
//#endregion
|
|
1527
|
+
//#region src/drawingml/fill/fill-options.ts
|
|
1528
|
+
function normalizeColor(color) {
|
|
1529
|
+
return typeof color === "string" ? { value: color.replace("#", "") } : color;
|
|
1530
|
+
}
|
|
1531
|
+
function toUint8Array(data) {
|
|
1532
|
+
return data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
1533
|
+
}
|
|
1534
|
+
/**
|
|
1535
|
+
* Extracts media data from a blip fill option, if present.
|
|
1536
|
+
* Returns undefined for non-blip fills.
|
|
1537
|
+
*
|
|
1538
|
+
* The returned data should be registered with the document's media store
|
|
1539
|
+
* during `prepForXml` so the packer can resolve the `{fileName}` placeholder.
|
|
1540
|
+
*/
|
|
1541
|
+
const extractBlipFillMedia = (fill) => {
|
|
1542
|
+
if (typeof fill === "string" || fill.type !== "blip") return void 0;
|
|
1543
|
+
const raw = toUint8Array(fill.data);
|
|
1544
|
+
return {
|
|
1545
|
+
data: raw,
|
|
1546
|
+
fileName: `${hashedId(raw)}.${fill.imageType}`,
|
|
1547
|
+
type: fill.imageType
|
|
1548
|
+
};
|
|
1549
|
+
};
|
|
1550
|
+
/**
|
|
1551
|
+
* Builds a DrawingML fill XmlComponent from a FillOptions config.
|
|
1552
|
+
*/
|
|
1553
|
+
const buildFill = (options) => {
|
|
1554
|
+
if (typeof options === "string") return createSolidFill({ value: options.replace("#", "") });
|
|
1555
|
+
switch (options.type) {
|
|
1556
|
+
case "solid": return createSolidFill(normalizeColor(options.color));
|
|
1557
|
+
case "none": return new BuilderElement({ name: "a:noFill" });
|
|
1558
|
+
case "gradient":
|
|
1559
|
+
if ("options" in options) return createGradientFill(options.options);
|
|
1560
|
+
return createGradientFill({
|
|
1561
|
+
stops: options.stops.map((stop) => ({
|
|
1562
|
+
position: stop.position * 1e3,
|
|
1563
|
+
color: normalizeColor(stop.color)
|
|
1564
|
+
})),
|
|
1565
|
+
...!options.path && options.angle !== void 0 && { shade: {
|
|
1566
|
+
angle: options.angle * 6e4,
|
|
1567
|
+
scaled: options.scaled ?? true
|
|
1568
|
+
} },
|
|
1569
|
+
...options.path && { shade: { path: options.path.toUpperCase() } }
|
|
1570
|
+
});
|
|
1571
|
+
case "blip": {
|
|
1572
|
+
const fileName = `${hashedId(toUint8Array(options.data))}.${options.imageType}`;
|
|
1573
|
+
const blipChildren = [];
|
|
1574
|
+
if (options.blipEffects) blipChildren.push(...createBlipEffects(options.blipEffects));
|
|
1575
|
+
const children = [new BuilderElement({
|
|
1576
|
+
attributes: {
|
|
1577
|
+
cstate: {
|
|
1578
|
+
key: "cstate",
|
|
1579
|
+
value: "none"
|
|
1580
|
+
},
|
|
1581
|
+
embed: {
|
|
1582
|
+
key: "r:embed",
|
|
1583
|
+
value: `{${fileName}}`
|
|
1584
|
+
}
|
|
1585
|
+
},
|
|
1586
|
+
children: blipChildren,
|
|
1587
|
+
name: "a:blip"
|
|
1588
|
+
}), createSourceRectangle(options.srcRect)];
|
|
1589
|
+
if (options.tile) children.push(createTileInfo(options.tile));
|
|
1590
|
+
else children.push(new Stretch());
|
|
1591
|
+
const attributes = {};
|
|
1592
|
+
if (options.dpi !== void 0) attributes.dpi = {
|
|
1593
|
+
key: "dpi",
|
|
1594
|
+
value: options.dpi
|
|
1595
|
+
};
|
|
1596
|
+
if (options.rotWithShape !== void 0) attributes.rotWithShape = {
|
|
1597
|
+
key: "rotWithShape",
|
|
1598
|
+
value: options.rotWithShape ? 1 : 0
|
|
1599
|
+
};
|
|
1600
|
+
return new BuilderElement({
|
|
1601
|
+
attributes: Object.keys(attributes).length > 0 ? attributes : void 0,
|
|
1602
|
+
children,
|
|
1603
|
+
name: "a:blipFill"
|
|
1604
|
+
});
|
|
1605
|
+
}
|
|
1606
|
+
case "pattern": return createPatternFill({
|
|
1607
|
+
pattern: options.pattern,
|
|
1608
|
+
...options.foregroundColor && { foregroundColor: normalizeColor(options.foregroundColor) },
|
|
1609
|
+
...options.backgroundColor && { backgroundColor: normalizeColor(options.backgroundColor) }
|
|
1610
|
+
});
|
|
1611
|
+
case "group": return new BuilderElement({ name: "a:grpFill" });
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
//#endregion
|
|
1615
|
+
//#region src/drawingml/fill/no-fill.ts
|
|
1616
|
+
/**
|
|
1617
|
+
* No fill element for DrawingML shapes.
|
|
1618
|
+
*
|
|
1619
|
+
* This module provides the no-fill option for outline and shape fills.
|
|
1620
|
+
*
|
|
1621
|
+
* @module
|
|
1622
|
+
*/
|
|
1623
|
+
/**
|
|
1624
|
+
* Creates a no-fill element.
|
|
1625
|
+
*
|
|
1626
|
+
* Specifies that the outline or shape should have no fill applied.
|
|
1627
|
+
*
|
|
1628
|
+
* ## XSD Schema
|
|
1629
|
+
* ```xml
|
|
1630
|
+
* <xsd:element name="noFill" type="CT_Empty"/>
|
|
1631
|
+
* ```
|
|
1632
|
+
*
|
|
1633
|
+
* @example
|
|
1634
|
+
* ```typescript
|
|
1635
|
+
* const noFill = createNoFill();
|
|
1636
|
+
* ```
|
|
1637
|
+
*/
|
|
1638
|
+
const createNoFill = () => new BuilderElement({ name: "a:noFill" });
|
|
1639
|
+
//#endregion
|
|
1640
|
+
//#region src/drawingml/fill/group-fill.ts
|
|
1641
|
+
/**
|
|
1642
|
+
* Group fill element for DrawingML shapes.
|
|
1643
|
+
*
|
|
1644
|
+
* This module provides group fill support which inherits the fill
|
|
1645
|
+
* from the parent group shape.
|
|
1646
|
+
*
|
|
1647
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_GroupFillProperties
|
|
1648
|
+
*
|
|
1649
|
+
* @module
|
|
1650
|
+
*/
|
|
1651
|
+
/**
|
|
1652
|
+
* Creates a group fill element (a:grpFill).
|
|
1653
|
+
*
|
|
1654
|
+
* This element specifies that the shape should inherit its fill
|
|
1655
|
+
* from the parent group shape. This is useful when shapes are
|
|
1656
|
+
* grouped together and should share the same fill.
|
|
1657
|
+
*
|
|
1658
|
+
* ## XSD Schema
|
|
1659
|
+
* ```xml
|
|
1660
|
+
* <xsd:complexType name="CT_GroupFillProperties"/>
|
|
1661
|
+
* ```
|
|
1662
|
+
*
|
|
1663
|
+
* @example
|
|
1664
|
+
* ```typescript
|
|
1665
|
+
* // Shape inherits fill from parent group
|
|
1666
|
+
* createGroupFill();
|
|
1667
|
+
* ```
|
|
1668
|
+
*/
|
|
1669
|
+
const createGroupFill = () => new BuilderElement({ name: "a:grpFill" });
|
|
1670
|
+
//#endregion
|
|
1671
|
+
//#region src/drawingml/outline/custom-dash.ts
|
|
1672
|
+
/**
|
|
1673
|
+
* Custom dash pattern for DrawingML outlines.
|
|
1674
|
+
*
|
|
1675
|
+
* This module provides support for custom dash patterns defined by
|
|
1676
|
+
* a list of dash stops, each specifying dash and space lengths as
|
|
1677
|
+
* percentages relative to line width.
|
|
1678
|
+
*
|
|
1679
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_DashStopList, CT_DashStop
|
|
1680
|
+
*
|
|
1681
|
+
* @module
|
|
1682
|
+
*/
|
|
1683
|
+
/**
|
|
1684
|
+
* Creates a custom dash element (a:custDash) for outlines.
|
|
1685
|
+
*
|
|
1686
|
+
* The custom dash element specifies a repeating pattern of dash and space
|
|
1687
|
+
* segments. Each segment is defined by a `DashStop` with dash (`d`) and
|
|
1688
|
+
* space (`sp`) lengths as positive percentages of the line width.
|
|
1689
|
+
*
|
|
1690
|
+
* ## XSD Schema
|
|
1691
|
+
* ```xml
|
|
1692
|
+
* <xsd:complexType name="CT_DashStopList">
|
|
1693
|
+
* <xsd:sequence>
|
|
1694
|
+
* <xsd:element name="ds" type="CT_DashStop" minOccurs="0" maxOccurs="unbounded"/>
|
|
1695
|
+
* </xsd:sequence>
|
|
1696
|
+
* </xsd:complexType>
|
|
1697
|
+
* ```
|
|
1698
|
+
*
|
|
1699
|
+
* @example
|
|
1700
|
+
* ```typescript
|
|
1701
|
+
* // Simple dash pattern
|
|
1702
|
+
* createCustomDash([
|
|
1703
|
+
* { d: "500%", sp: "200%" },
|
|
1704
|
+
* ]);
|
|
1705
|
+
*
|
|
1706
|
+
* // Complex alternating pattern
|
|
1707
|
+
* createCustomDash([
|
|
1708
|
+
* { d: "500%", sp: "200%" },
|
|
1709
|
+
* { d: "100%", sp: "200%" },
|
|
1710
|
+
* ]);
|
|
1711
|
+
* ```
|
|
1712
|
+
*/
|
|
1713
|
+
const createCustomDash = (stops) => {
|
|
1714
|
+
const children = [];
|
|
1715
|
+
for (const stop of stops) children.push(new BuilderElement({
|
|
1716
|
+
attributes: {
|
|
1717
|
+
d: {
|
|
1718
|
+
key: "d",
|
|
1719
|
+
value: stop.d
|
|
1720
|
+
},
|
|
1721
|
+
sp: {
|
|
1722
|
+
key: "sp",
|
|
1723
|
+
value: stop.sp
|
|
1724
|
+
}
|
|
1725
|
+
},
|
|
1726
|
+
name: "a:ds"
|
|
1727
|
+
}));
|
|
1728
|
+
return new BuilderElement({
|
|
1729
|
+
children,
|
|
1730
|
+
name: "a:custDash"
|
|
1731
|
+
});
|
|
1732
|
+
};
|
|
1733
|
+
//#endregion
|
|
1734
|
+
//#region src/drawingml/outline/line-end.ts
|
|
1735
|
+
/**
|
|
1736
|
+
* Line end (arrow) properties for DrawingML outlines.
|
|
1737
|
+
*
|
|
1738
|
+
* This module provides support for line end markers (arrows) on shape outlines.
|
|
1739
|
+
*
|
|
1740
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_LineEndProperties
|
|
1741
|
+
*
|
|
1742
|
+
* @module
|
|
1743
|
+
*/
|
|
1744
|
+
/**
|
|
1745
|
+
* Line end types (arrow head styles).
|
|
1746
|
+
*
|
|
1747
|
+
* ## XSD Schema
|
|
1748
|
+
* ```xml
|
|
1749
|
+
* <xsd:simpleType name="ST_LineEndType">
|
|
1750
|
+
* <xsd:restriction base="xsd:token">
|
|
1751
|
+
* <xsd:enumeration value="none"/>
|
|
1752
|
+
* <xsd:enumeration value="triangle"/>
|
|
1753
|
+
* <xsd:enumeration value="stealth"/>
|
|
1754
|
+
* <xsd:enumeration value="diamond"/>
|
|
1755
|
+
* <xsd:enumeration value="oval"/>
|
|
1756
|
+
* <xsd:enumeration value="arrow"/>
|
|
1757
|
+
* </xsd:restriction>
|
|
1758
|
+
* </xsd:simpleType>
|
|
1759
|
+
* ```
|
|
1760
|
+
*
|
|
1761
|
+
* @publicApi
|
|
1762
|
+
*/
|
|
1763
|
+
const LineEndType = {
|
|
1764
|
+
/** No line end */
|
|
1765
|
+
NONE: "none",
|
|
1766
|
+
/** Triangle arrow */
|
|
1767
|
+
TRIANGLE: "triangle",
|
|
1768
|
+
/** Stealth arrow (filled triangle) */
|
|
1769
|
+
STEALTH: "stealth",
|
|
1770
|
+
/** Diamond shape */
|
|
1771
|
+
DIAMOND: "diamond",
|
|
1772
|
+
/** Oval shape */
|
|
1773
|
+
OVAL: "oval",
|
|
1774
|
+
/** Simple arrow */
|
|
1775
|
+
ARROW: "arrow"
|
|
1776
|
+
};
|
|
1777
|
+
/**
|
|
1778
|
+
* Line end width options.
|
|
1779
|
+
*
|
|
1780
|
+
* ## XSD Schema
|
|
1781
|
+
* ```xml
|
|
1782
|
+
* <xsd:simpleType name="ST_LineEndWidth">
|
|
1783
|
+
* <xsd:restriction base="xsd:token">
|
|
1784
|
+
* <xsd:enumeration value="sm"/>
|
|
1785
|
+
* <xsd:enumeration value="med"/>
|
|
1786
|
+
* <xsd:enumeration value="lg"/>
|
|
1787
|
+
* </xsd:restriction>
|
|
1788
|
+
* </xsd:simpleType>
|
|
1789
|
+
* ```
|
|
1790
|
+
*
|
|
1791
|
+
* @publicApi
|
|
1792
|
+
*/
|
|
1793
|
+
const LineEndWidth = {
|
|
1794
|
+
/** Small width */
|
|
1795
|
+
SMALL: "sm",
|
|
1796
|
+
/** Medium width */
|
|
1797
|
+
MEDIUM: "med",
|
|
1798
|
+
/** Large width */
|
|
1799
|
+
LARGE: "lg"
|
|
1800
|
+
};
|
|
1801
|
+
/**
|
|
1802
|
+
* Line end length options.
|
|
1803
|
+
*
|
|
1804
|
+
* ## XSD Schema
|
|
1805
|
+
* ```xml
|
|
1806
|
+
* <xsd:simpleType name="ST_LineEndLength">
|
|
1807
|
+
* <xsd:restriction base="xsd:token">
|
|
1808
|
+
* <xsd:enumeration value="sm"/>
|
|
1809
|
+
* <xsd:enumeration value="med"/>
|
|
1810
|
+
* <xsd:enumeration value="lg"/>
|
|
1811
|
+
* </xsd:restriction>
|
|
1812
|
+
* </xsd:simpleType>
|
|
1813
|
+
* ```
|
|
1814
|
+
*
|
|
1815
|
+
* @publicApi
|
|
1816
|
+
*/
|
|
1817
|
+
const LineEndLength = {
|
|
1818
|
+
/** Small length */
|
|
1819
|
+
SMALL: "sm",
|
|
1820
|
+
/** Medium length */
|
|
1821
|
+
MEDIUM: "med",
|
|
1822
|
+
/** Large length */
|
|
1823
|
+
LARGE: "lg"
|
|
1824
|
+
};
|
|
1825
|
+
/**
|
|
1826
|
+
* Creates a line end element (a:headEnd or a:tailEnd).
|
|
1827
|
+
*
|
|
1828
|
+
* @example
|
|
1829
|
+
* ```typescript
|
|
1830
|
+
* // Stealth arrow at start, medium size
|
|
1831
|
+
* createLineEnd("a:headEnd", { type: "STEALTH", width: "MEDIUM", length: "MEDIUM" });
|
|
1832
|
+
* // Triangle arrow at end
|
|
1833
|
+
* createLineEnd("a:tailEnd", { type: "TRIANGLE" });
|
|
1834
|
+
* ```
|
|
1835
|
+
*/
|
|
1836
|
+
const createLineEnd = (name, options) => new BuilderElement({
|
|
1837
|
+
attributes: {
|
|
1838
|
+
type: {
|
|
1839
|
+
key: "type",
|
|
1840
|
+
value: LineEndType[options.type]
|
|
1841
|
+
},
|
|
1842
|
+
w: {
|
|
1843
|
+
key: "w",
|
|
1844
|
+
value: options.width ? LineEndWidth[options.width] : void 0
|
|
1845
|
+
},
|
|
1846
|
+
len: {
|
|
1847
|
+
key: "len",
|
|
1848
|
+
value: options.length ? LineEndLength[options.length] : void 0
|
|
1849
|
+
}
|
|
1850
|
+
},
|
|
1851
|
+
name
|
|
1852
|
+
});
|
|
1853
|
+
//#endregion
|
|
1854
|
+
//#region src/drawingml/outline/outline.ts
|
|
1855
|
+
/**
|
|
1856
|
+
* Outline (line) properties for DrawingML shapes.
|
|
1857
|
+
*
|
|
1858
|
+
* This module provides support for configuring outline properties including
|
|
1859
|
+
* width, cap style, compound line types, fill properties, dash, and join.
|
|
1860
|
+
*
|
|
1861
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_LineProperties
|
|
1862
|
+
*
|
|
1863
|
+
* @module
|
|
1864
|
+
*/
|
|
1865
|
+
/**
|
|
1866
|
+
* Line cap styles for outline endpoints.
|
|
1867
|
+
*
|
|
1868
|
+
* Defines how the ends of a line are rendered.
|
|
1869
|
+
*/
|
|
1870
|
+
const LineCap = {
|
|
1871
|
+
/** Round cap style */
|
|
1872
|
+
ROUND: "rnd",
|
|
1873
|
+
/** Square cap style */
|
|
1874
|
+
SQUARE: "sq",
|
|
1875
|
+
/** Flat cap style */
|
|
1876
|
+
FLAT: "flat"
|
|
1877
|
+
};
|
|
1878
|
+
/**
|
|
1879
|
+
* Compound line types for outlines.
|
|
1880
|
+
*
|
|
1881
|
+
* Defines the structure of compound lines (single, double, etc.).
|
|
1882
|
+
*/
|
|
1883
|
+
const CompoundLine = {
|
|
1884
|
+
/** Single line */
|
|
1885
|
+
SINGLE: "sng",
|
|
1886
|
+
/** Double line */
|
|
1887
|
+
DOUBLE: "dbl",
|
|
1888
|
+
/** Thick-thin double line */
|
|
1889
|
+
THICK_THIN: "thickThin",
|
|
1890
|
+
/** Thin-thick double line */
|
|
1891
|
+
THIN_THICK: "thinThick",
|
|
1892
|
+
/** Triple line */
|
|
1893
|
+
TRI: "tri"
|
|
1894
|
+
};
|
|
1895
|
+
/**
|
|
1896
|
+
* Pen alignment options for outline positioning.
|
|
1897
|
+
*
|
|
1898
|
+
* Defines how the outline is aligned relative to the shape edge.
|
|
1899
|
+
*/
|
|
1900
|
+
const PenAlignment = {
|
|
1901
|
+
/** Center alignment */
|
|
1902
|
+
CENTER: "ctr",
|
|
1903
|
+
/** Inset alignment */
|
|
1904
|
+
INSET: "in"
|
|
1905
|
+
};
|
|
1906
|
+
/**
|
|
1907
|
+
* Preset dash styles for outlines.
|
|
1908
|
+
*
|
|
1909
|
+
* ## XSD Schema
|
|
1910
|
+
* ```xml
|
|
1911
|
+
* <xsd:simpleType name="ST_PresetLineDashVal">
|
|
1912
|
+
* <xsd:restriction base="xsd:token">
|
|
1913
|
+
* <xsd:enumeration value="solid"/>
|
|
1914
|
+
* <xsd:enumeration value="dot"/>
|
|
1915
|
+
* <xsd:enumeration value="dash"/>
|
|
1916
|
+
* <xsd:enumeration value="lgDash"/>
|
|
1917
|
+
* <xsd:enumeration value="dashDot"/>
|
|
1918
|
+
* <xsd:enumeration value="lgDashDot"/>
|
|
1919
|
+
* <xsd:enumeration value="lgDashDotDot"/>
|
|
1920
|
+
* <xsd:enumeration value="sysDash"/>
|
|
1921
|
+
* <xsd:enumeration value="sysDot"/>
|
|
1922
|
+
* <xsd:enumeration value="sysDashDot"/>
|
|
1923
|
+
* <xsd:enumeration value="sysDashDotDot"/>
|
|
1924
|
+
* </xsd:restriction>
|
|
1925
|
+
* </xsd:simpleType>
|
|
1926
|
+
* ```
|
|
1927
|
+
*/
|
|
1928
|
+
const PresetDash = {
|
|
1929
|
+
SOLID: "solid",
|
|
1930
|
+
DOT: "dot",
|
|
1931
|
+
DASH: "dash",
|
|
1932
|
+
LG_DASH: "lgDash",
|
|
1933
|
+
DASH_DOT: "dashDot",
|
|
1934
|
+
LG_DASH_DOT: "lgDashDot",
|
|
1935
|
+
LG_DASH_DOT_DOT: "lgDashDotDot",
|
|
1936
|
+
SYS_DASH: "sysDash",
|
|
1937
|
+
SYS_DOT: "sysDot",
|
|
1938
|
+
SYS_DASH_DOT: "sysDashDot",
|
|
1939
|
+
SYS_DASH_DOT_DOT: "sysDashDotDot"
|
|
1940
|
+
};
|
|
1941
|
+
/**
|
|
1942
|
+
* Line join styles.
|
|
1943
|
+
*/
|
|
1944
|
+
const LineJoin = {
|
|
1945
|
+
ROUND: "round",
|
|
1946
|
+
BEVEL: "bevel",
|
|
1947
|
+
MITER: "miter"
|
|
1948
|
+
};
|
|
1949
|
+
/**
|
|
1950
|
+
* Creates the fill child element for an outline.
|
|
1951
|
+
*
|
|
1952
|
+
* Returns null when no fill type is specified (OOXML allows outline without fill).
|
|
1953
|
+
*/
|
|
1954
|
+
const createOutlineFill = (options) => {
|
|
1955
|
+
if (options.type === "noFill") return createNoFill();
|
|
1956
|
+
if (options.type === "solidFill" && options.color) return createSolidFill(options.color);
|
|
1957
|
+
if (options.type === "gradFill" && options.gradientFill) return createGradientFill(options.gradientFill);
|
|
1958
|
+
if (options.type === "pattFill" && options.patternFill) return createPatternFill(options.patternFill);
|
|
1959
|
+
return null;
|
|
1960
|
+
};
|
|
1961
|
+
/**
|
|
1962
|
+
* Creates an outline element for DrawingML shapes.
|
|
1963
|
+
*
|
|
1964
|
+
* The outline element specifies the line properties for the shape border,
|
|
1965
|
+
* including width, cap style, compound line type, alignment, dash, join, and fill.
|
|
1966
|
+
*
|
|
1967
|
+
* ## XSD Schema
|
|
1968
|
+
* ```xml
|
|
1969
|
+
* <xsd:complexType name="CT_LineProperties">
|
|
1970
|
+
* <xsd:sequence>
|
|
1971
|
+
* <xsd:group ref="EG_FillProperties" minOccurs="0"/>
|
|
1972
|
+
* <xsd:group ref="EG_LineDashProperties" minOccurs="0"/>
|
|
1973
|
+
* <xsd:group ref="EG_LineJoinProperties" minOccurs="0"/>
|
|
1974
|
+
* </xsd:sequence>
|
|
1975
|
+
* <xsd:attribute name="w" use="optional" type="a:ST_LineWidth"/>
|
|
1976
|
+
* <xsd:attribute name="cap" use="optional" type="ST_LineCap"/>
|
|
1977
|
+
* <xsd:attribute name="cmpd" use="optional" type="ST_CompoundLine"/>
|
|
1978
|
+
* <xsd:attribute name="algn" use="optional" type="ST_PenAlignment"/>
|
|
1979
|
+
* </xsd:complexType>
|
|
1980
|
+
* ```
|
|
1981
|
+
*
|
|
1982
|
+
* @example
|
|
1983
|
+
* ```typescript
|
|
1984
|
+
* // Outline with RGB color and dash
|
|
1985
|
+
* const outline = createOutline({
|
|
1986
|
+
* width: 9525,
|
|
1987
|
+
* type: "solidFill",
|
|
1988
|
+
* color: { value: "FF0000" },
|
|
1989
|
+
* dash: "DASH",
|
|
1990
|
+
* });
|
|
1991
|
+
* ```
|
|
1992
|
+
*/
|
|
1993
|
+
const createOutline = (options) => {
|
|
1994
|
+
const children = [];
|
|
1995
|
+
const fill = createOutlineFill(options);
|
|
1996
|
+
if (fill) children.push(fill);
|
|
1997
|
+
if (options.customDash !== void 0) children.push(createCustomDash(options.customDash));
|
|
1998
|
+
else if (options.dash !== void 0) children.push(new BuilderElement({
|
|
1999
|
+
attributes: { val: {
|
|
2000
|
+
key: "val",
|
|
2001
|
+
value: PresetDash[options.dash]
|
|
2002
|
+
} },
|
|
2003
|
+
name: "a:prstDash"
|
|
2004
|
+
}));
|
|
2005
|
+
if (options.join !== void 0) if (options.join === "MITER" && options.miterLimit !== void 0) children.push(new BuilderElement({
|
|
2006
|
+
attributes: { lim: {
|
|
2007
|
+
key: "lim",
|
|
2008
|
+
value: options.miterLimit
|
|
2009
|
+
} },
|
|
2010
|
+
name: "a:miter"
|
|
2011
|
+
}));
|
|
2012
|
+
else children.push(new BuilderElement({ name: `a:${LineJoin[options.join]}` }));
|
|
2013
|
+
if (options.headEnd) children.push(createLineEnd("a:headEnd", options.headEnd));
|
|
2014
|
+
if (options.tailEnd) children.push(createLineEnd("a:tailEnd", options.tailEnd));
|
|
2015
|
+
return new BuilderElement({
|
|
2016
|
+
attributes: {
|
|
2017
|
+
align: {
|
|
2018
|
+
key: "algn",
|
|
2019
|
+
value: options.align ? PenAlignment[options.align] : void 0
|
|
2020
|
+
},
|
|
2021
|
+
cap: {
|
|
2022
|
+
key: "cap",
|
|
2023
|
+
value: options.cap ? LineCap[options.cap] : void 0
|
|
2024
|
+
},
|
|
2025
|
+
compoundLine: {
|
|
2026
|
+
key: "cmpd",
|
|
2027
|
+
value: options.compoundLine ? CompoundLine[options.compoundLine] : void 0
|
|
2028
|
+
},
|
|
2029
|
+
width: {
|
|
2030
|
+
key: "w",
|
|
2031
|
+
value: options.width
|
|
2032
|
+
}
|
|
2033
|
+
},
|
|
2034
|
+
children,
|
|
2035
|
+
name: "a:ln"
|
|
2036
|
+
});
|
|
2037
|
+
};
|
|
2038
|
+
//#endregion
|
|
2039
|
+
//#region src/drawingml/effects/fill-overlay.ts
|
|
2040
|
+
/**
|
|
2041
|
+
* Fill overlay effect for DrawingML shapes.
|
|
2042
|
+
*
|
|
2043
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_FillOverlayEffect
|
|
2044
|
+
*
|
|
2045
|
+
* @module
|
|
2046
|
+
*/
|
|
2047
|
+
/**
|
|
2048
|
+
* Blend modes for fill overlay effect.
|
|
2049
|
+
*
|
|
2050
|
+
* ## XSD Schema
|
|
2051
|
+
* ```xml
|
|
2052
|
+
* <xsd:simpleType name="ST_BlendMode">
|
|
2053
|
+
* <xsd:restriction base="xsd:token">
|
|
2054
|
+
* <xsd:enumeration value="over"/>
|
|
2055
|
+
* <xsd:enumeration value="mult"/>
|
|
2056
|
+
* <xsd:enumeration value="screen"/>
|
|
2057
|
+
* <xsd:enumeration value="darken"/>
|
|
2058
|
+
* <xsd:enumeration value="lighten"/>
|
|
2059
|
+
* </xsd:restriction>
|
|
2060
|
+
* </xsd:simpleType>
|
|
2061
|
+
* ```
|
|
2062
|
+
*/
|
|
2063
|
+
const BlendMode = {
|
|
2064
|
+
/** Over blend mode */
|
|
2065
|
+
OVER: "over",
|
|
2066
|
+
/** Multiply blend mode */
|
|
2067
|
+
MULTIPLY: "mult",
|
|
2068
|
+
/** Screen blend mode */
|
|
2069
|
+
SCREEN: "screen",
|
|
2070
|
+
/** Darken blend mode */
|
|
2071
|
+
DARKEN: "darken",
|
|
2072
|
+
/** Lighten blend mode */
|
|
2073
|
+
LIGHTEN: "lighten"
|
|
2074
|
+
};
|
|
2075
|
+
/**
|
|
2076
|
+
* Creates a fill overlay effect element.
|
|
2077
|
+
*
|
|
2078
|
+
* ## XSD Schema
|
|
2079
|
+
* ```xml
|
|
2080
|
+
* <xsd:complexType name="CT_FillOverlayEffect">
|
|
2081
|
+
* <xsd:sequence>
|
|
2082
|
+
* <xsd:group ref="EG_FillProperties" minOccurs="1" maxOccurs="1"/>
|
|
2083
|
+
* </xsd:sequence>
|
|
2084
|
+
* <xsd:attribute name="blend" type="ST_BlendMode" use="required"/>
|
|
2085
|
+
* </xsd:complexType>
|
|
2086
|
+
* ```
|
|
2087
|
+
*
|
|
2088
|
+
* @example
|
|
2089
|
+
* ```typescript
|
|
2090
|
+
* // Solid fill overlay
|
|
2091
|
+
* const fillOverlay = createFillOverlayEffect({
|
|
2092
|
+
* blend: BlendMode.MULTIPLY,
|
|
2093
|
+
* solidFill: { value: "FF0000" },
|
|
2094
|
+
* });
|
|
2095
|
+
*
|
|
2096
|
+
* // Gradient fill overlay
|
|
2097
|
+
* const fillOverlay = createFillOverlayEffect({
|
|
2098
|
+
* blend: BlendMode.SCREEN,
|
|
2099
|
+
* gradientFill: { type: "linear", stops: [...] },
|
|
2100
|
+
* });
|
|
2101
|
+
* ```
|
|
2102
|
+
*/
|
|
2103
|
+
const createFillOverlayEffect = (options) => {
|
|
2104
|
+
let fillElement;
|
|
2105
|
+
if (options.noFill) fillElement = createNoFill();
|
|
2106
|
+
else if (options.solidFill) fillElement = createSolidFill(options.solidFill);
|
|
2107
|
+
else if (options.gradientFill) fillElement = createGradientFill(options.gradientFill);
|
|
2108
|
+
else if (options.patternFill) fillElement = createPatternFill(options.patternFill);
|
|
2109
|
+
else if (options.groupFill) fillElement = createGroupFill();
|
|
2110
|
+
else fillElement = createSolidFill({ value: "000000" });
|
|
2111
|
+
return new BuilderElement({
|
|
2112
|
+
attributes: { blend: {
|
|
2113
|
+
key: "blend",
|
|
2114
|
+
value: options.blend
|
|
2115
|
+
} },
|
|
2116
|
+
children: [fillElement],
|
|
2117
|
+
name: "a:fillOverlay"
|
|
2118
|
+
});
|
|
2119
|
+
};
|
|
2120
|
+
//#endregion
|
|
2121
|
+
//#region src/drawingml/effects/glow.ts
|
|
2122
|
+
/**
|
|
2123
|
+
* Glow effect for DrawingML shapes.
|
|
2124
|
+
*
|
|
2125
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_GlowEffect
|
|
2126
|
+
*
|
|
2127
|
+
* @module
|
|
2128
|
+
*/
|
|
2129
|
+
/**
|
|
2130
|
+
* Creates a glow effect element.
|
|
2131
|
+
*
|
|
2132
|
+
* ## XSD Schema
|
|
2133
|
+
* ```xml
|
|
2134
|
+
* <xsd:complexType name="CT_GlowEffect">
|
|
2135
|
+
* <xsd:sequence>
|
|
2136
|
+
* <xsd:group ref="EG_ColorChoice" minOccurs="1" maxOccurs="1"/>
|
|
2137
|
+
* </xsd:sequence>
|
|
2138
|
+
* <xsd:attribute name="rad" type="ST_PositiveCoordinate" use="optional" default="0"/>
|
|
2139
|
+
* </xsd:complexType>
|
|
2140
|
+
* ```
|
|
2141
|
+
*/
|
|
2142
|
+
const createGlowEffect = (options) => {
|
|
2143
|
+
if (options.radius === void 0) return new BuilderElement({
|
|
2144
|
+
children: [createColorElement(options.color)],
|
|
2145
|
+
name: "a:glow"
|
|
2146
|
+
});
|
|
2147
|
+
return new BuilderElement({
|
|
2148
|
+
attributes: { rad: {
|
|
2149
|
+
key: "rad",
|
|
2150
|
+
value: options.radius
|
|
2151
|
+
} },
|
|
2152
|
+
children: [createColorElement(options.color)],
|
|
2153
|
+
name: "a:glow"
|
|
2154
|
+
});
|
|
2155
|
+
};
|
|
2156
|
+
//#endregion
|
|
2157
|
+
//#region src/drawingml/effects/inner-shadow.ts
|
|
2158
|
+
/**
|
|
2159
|
+
* Inner shadow effect for DrawingML shapes.
|
|
2160
|
+
*
|
|
2161
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_InnerShadowEffect
|
|
2162
|
+
*
|
|
2163
|
+
* @module
|
|
2164
|
+
*/
|
|
2165
|
+
/**
|
|
2166
|
+
* Creates an inner shadow effect element.
|
|
2167
|
+
*
|
|
2168
|
+
* ## XSD Schema
|
|
2169
|
+
* ```xml
|
|
2170
|
+
* <xsd:complexType name="CT_InnerShadowEffect">
|
|
2171
|
+
* <xsd:sequence>
|
|
2172
|
+
* <xsd:group ref="EG_ColorChoice" minOccurs="1" maxOccurs="1"/>
|
|
2173
|
+
* </xsd:sequence>
|
|
2174
|
+
* <xsd:attribute name="blurRad" type="ST_PositiveCoordinate" default="0"/>
|
|
2175
|
+
* <xsd:attribute name="dist" type="ST_PositiveCoordinate" default="0"/>
|
|
2176
|
+
* <xsd:attribute name="dir" type="ST_PositiveFixedAngle" default="0"/>
|
|
2177
|
+
* </xsd:complexType>
|
|
2178
|
+
* ```
|
|
2179
|
+
*/
|
|
2180
|
+
const createInnerShadowEffect = (options) => {
|
|
2181
|
+
if (!(options.blurRadius !== void 0 || options.distance !== void 0 || options.direction !== void 0)) return new BuilderElement({
|
|
2182
|
+
children: [createColorElement(options.color)],
|
|
2183
|
+
name: "a:innerShdw"
|
|
2184
|
+
});
|
|
2185
|
+
return new BuilderElement({
|
|
2186
|
+
attributes: {
|
|
2187
|
+
...options.blurRadius !== void 0 && { blurRad: {
|
|
2188
|
+
key: "blurRad",
|
|
2189
|
+
value: options.blurRadius
|
|
2190
|
+
} },
|
|
2191
|
+
...options.distance !== void 0 && { dist: {
|
|
2192
|
+
key: "dist",
|
|
2193
|
+
value: options.distance
|
|
2194
|
+
} },
|
|
2195
|
+
...options.direction !== void 0 && { dir: {
|
|
2196
|
+
key: "dir",
|
|
2197
|
+
value: options.direction
|
|
2198
|
+
} }
|
|
2199
|
+
},
|
|
2200
|
+
children: [createColorElement(options.color)],
|
|
2201
|
+
name: "a:innerShdw"
|
|
2202
|
+
});
|
|
2203
|
+
};
|
|
2204
|
+
//#endregion
|
|
2205
|
+
//#region src/drawingml/effects/outer-shadow.ts
|
|
2206
|
+
/**
|
|
2207
|
+
* Outer shadow effect for DrawingML shapes.
|
|
2208
|
+
*
|
|
2209
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_OuterShadowEffect
|
|
2210
|
+
*
|
|
2211
|
+
* @module
|
|
2212
|
+
*/
|
|
2213
|
+
/**
|
|
2214
|
+
* Rectangle alignment for shadow positioning.
|
|
2215
|
+
*/
|
|
2216
|
+
const RectAlignment = {
|
|
2217
|
+
TOP_LEFT: "tl",
|
|
2218
|
+
TOP: "t",
|
|
2219
|
+
TOP_RIGHT: "tr",
|
|
2220
|
+
LEFT: "l",
|
|
2221
|
+
CENTER: "ctr",
|
|
2222
|
+
RIGHT: "r",
|
|
2223
|
+
BOTTOM_LEFT: "bl",
|
|
2224
|
+
BOTTOM: "b",
|
|
2225
|
+
BOTTOM_RIGHT: "br"
|
|
2226
|
+
};
|
|
2227
|
+
/**
|
|
2228
|
+
* Creates an outer shadow effect element.
|
|
2229
|
+
*
|
|
2230
|
+
* ## XSD Schema
|
|
2231
|
+
* ```xml
|
|
2232
|
+
* <xsd:complexType name="CT_OuterShadowEffect">
|
|
2233
|
+
* <xsd:sequence>
|
|
2234
|
+
* <xsd:group ref="EG_ColorChoice" minOccurs="1" maxOccurs="1"/>
|
|
2235
|
+
* </xsd:sequence>
|
|
2236
|
+
* <xsd:attribute name="blurRad" type="ST_PositiveCoordinate" default="0"/>
|
|
2237
|
+
* <xsd:attribute name="dist" type="ST_PositiveCoordinate" default="0"/>
|
|
2238
|
+
* <xsd:attribute name="dir" type="ST_PositiveFixedAngle" default="0"/>
|
|
2239
|
+
* <xsd:attribute name="sx" type="ST_Percentage" default="100%"/>
|
|
2240
|
+
* <xsd:attribute name="sy" type="ST_Percentage" default="100%"/>
|
|
2241
|
+
* <xsd:attribute name="kx" type="ST_FixedAngle" default="0"/>
|
|
2242
|
+
* <xsd:attribute name="ky" type="ST_FixedAngle" default="0"/>
|
|
2243
|
+
* <xsd:attribute name="algn" type="ST_RectAlignment" default="b"/>
|
|
2244
|
+
* <xsd:attribute name="rotWithShape" type="xsd:boolean" default="true"/>
|
|
2245
|
+
* </xsd:complexType>
|
|
2246
|
+
* ```
|
|
2247
|
+
*/
|
|
2248
|
+
const createOuterShadowEffect = (options) => {
|
|
2249
|
+
const attributes = {};
|
|
2250
|
+
if (options.blurRadius !== void 0) attributes.blurRad = {
|
|
2251
|
+
key: "blurRad",
|
|
2252
|
+
value: options.blurRadius
|
|
2253
|
+
};
|
|
2254
|
+
if (options.distance !== void 0) attributes.dist = {
|
|
2255
|
+
key: "dist",
|
|
2256
|
+
value: options.distance
|
|
2257
|
+
};
|
|
2258
|
+
if (options.direction !== void 0) attributes.dir = {
|
|
2259
|
+
key: "dir",
|
|
2260
|
+
value: options.direction
|
|
2261
|
+
};
|
|
2262
|
+
if (options.scaleX !== void 0) attributes.sx = {
|
|
2263
|
+
key: "sx",
|
|
2264
|
+
value: options.scaleX
|
|
2265
|
+
};
|
|
2266
|
+
if (options.scaleY !== void 0) attributes.sy = {
|
|
2267
|
+
key: "sy",
|
|
2268
|
+
value: options.scaleY
|
|
2269
|
+
};
|
|
2270
|
+
if (options.skewX !== void 0) attributes.kx = {
|
|
2271
|
+
key: "kx",
|
|
2272
|
+
value: options.skewX
|
|
2273
|
+
};
|
|
2274
|
+
if (options.skewY !== void 0) attributes.ky = {
|
|
2275
|
+
key: "ky",
|
|
2276
|
+
value: options.skewY
|
|
2277
|
+
};
|
|
2278
|
+
if (options.alignment !== void 0) attributes.algn = {
|
|
2279
|
+
key: "algn",
|
|
2280
|
+
value: RectAlignment[options.alignment]
|
|
2281
|
+
};
|
|
2282
|
+
if (options.rotWithShape === false) attributes.rotWithShape = {
|
|
2283
|
+
key: "rotWithShape",
|
|
2284
|
+
value: 0
|
|
2285
|
+
};
|
|
2286
|
+
return new BuilderElement({
|
|
2287
|
+
attributes,
|
|
2288
|
+
children: [createColorElement(options.color)],
|
|
2289
|
+
name: "a:outerShdw"
|
|
2290
|
+
});
|
|
2291
|
+
};
|
|
2292
|
+
//#endregion
|
|
2293
|
+
//#region src/drawingml/effects/preset-shadow.ts
|
|
2294
|
+
/**
|
|
2295
|
+
* Preset shadow effect for DrawingML shapes.
|
|
2296
|
+
*
|
|
2297
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_PresetShadowEffect
|
|
2298
|
+
*
|
|
2299
|
+
* @module
|
|
2300
|
+
*/
|
|
2301
|
+
/**
|
|
2302
|
+
* Preset shadow types (20 variations).
|
|
2303
|
+
*
|
|
2304
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, ST_PresetShadowVal
|
|
2305
|
+
*/
|
|
2306
|
+
const PresetShadowVal = {
|
|
2307
|
+
SHDW1: "shdw1",
|
|
2308
|
+
SHDW2: "shdw2",
|
|
2309
|
+
SHDW3: "shdw3",
|
|
2310
|
+
SHDW4: "shdw4",
|
|
2311
|
+
SHDW5: "shdw5",
|
|
2312
|
+
SHDW6: "shdw6",
|
|
2313
|
+
SHDW7: "shdw7",
|
|
2314
|
+
SHDW8: "shdw8",
|
|
2315
|
+
SHDW9: "shdw9",
|
|
2316
|
+
SHDW10: "shdw10",
|
|
2317
|
+
SHDW11: "shdw11",
|
|
2318
|
+
SHDW12: "shdw12",
|
|
2319
|
+
SHDW13: "shdw13",
|
|
2320
|
+
SHDW14: "shdw14",
|
|
2321
|
+
SHDW15: "shdw15",
|
|
2322
|
+
SHDW16: "shdw16",
|
|
2323
|
+
SHDW17: "shdw17",
|
|
2324
|
+
SHDW18: "shdw18",
|
|
2325
|
+
SHDW19: "shdw19",
|
|
2326
|
+
SHDW20: "shdw20"
|
|
2327
|
+
};
|
|
2328
|
+
/**
|
|
2329
|
+
* Creates a preset shadow effect element.
|
|
2330
|
+
*
|
|
2331
|
+
* ## XSD Schema
|
|
2332
|
+
* ```xml
|
|
2333
|
+
* <xsd:complexType name="CT_PresetShadowEffect">
|
|
2334
|
+
* <xsd:sequence>
|
|
2335
|
+
* <xsd:group ref="EG_ColorChoice" minOccurs="1" maxOccurs="1"/>
|
|
2336
|
+
* </xsd:sequence>
|
|
2337
|
+
* <xsd:attribute name="prst" type="ST_PresetShadowVal" use="required"/>
|
|
2338
|
+
* <xsd:attribute name="dist" type="ST_PositiveCoordinate" default="0"/>
|
|
2339
|
+
* <xsd:attribute name="dir" type="ST_PositiveFixedAngle" default="0"/>
|
|
2340
|
+
* </xsd:complexType>
|
|
2341
|
+
* ```
|
|
2342
|
+
*/
|
|
2343
|
+
const createPresetShadowEffect = (options) => {
|
|
2344
|
+
const attributes = { prst: {
|
|
2345
|
+
key: "prst",
|
|
2346
|
+
value: PresetShadowVal[options.preset]
|
|
2347
|
+
} };
|
|
2348
|
+
if (options.distance !== void 0) attributes.dist = {
|
|
2349
|
+
key: "dist",
|
|
2350
|
+
value: options.distance
|
|
2351
|
+
};
|
|
2352
|
+
if (options.direction !== void 0) attributes.dir = {
|
|
2353
|
+
key: "dir",
|
|
2354
|
+
value: options.direction
|
|
2355
|
+
};
|
|
2356
|
+
return new BuilderElement({
|
|
2357
|
+
attributes,
|
|
2358
|
+
children: [createColorElement(options.color)],
|
|
2359
|
+
name: "a:prstShdw"
|
|
2360
|
+
});
|
|
2361
|
+
};
|
|
2362
|
+
//#endregion
|
|
2363
|
+
//#region src/drawingml/effects/reflection.ts
|
|
2364
|
+
/**
|
|
2365
|
+
* Reflection effect for DrawingML shapes.
|
|
2366
|
+
*
|
|
2367
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_ReflectionEffect
|
|
2368
|
+
*
|
|
2369
|
+
* @module
|
|
2370
|
+
*/
|
|
2371
|
+
/**
|
|
2372
|
+
* Creates a reflection effect element.
|
|
2373
|
+
*
|
|
2374
|
+
* ## XSD Schema
|
|
2375
|
+
* ```xml
|
|
2376
|
+
* <xsd:complexType name="CT_ReflectionEffect">
|
|
2377
|
+
* <xsd:attribute name="blurRad" type="ST_PositiveCoordinate" default="0"/>
|
|
2378
|
+
* <xsd:attribute name="stA" type="ST_PositiveFixedPercentage" default="100%"/>
|
|
2379
|
+
* <xsd:attribute name="stPos" type="ST_PositiveFixedPercentage" default="0%"/>
|
|
2380
|
+
* <xsd:attribute name="endA" type="ST_PositiveFixedPercentage" default="0%"/>
|
|
2381
|
+
* <xsd:attribute name="endPos" type="ST_PositiveFixedPercentage" default="100%"/>
|
|
2382
|
+
* <xsd:attribute name="dist" type="ST_PositiveCoordinate" default="0"/>
|
|
2383
|
+
* <xsd:attribute name="dir" type="ST_PositiveFixedAngle" default="0"/>
|
|
2384
|
+
* <xsd:attribute name="fadeDir" type="ST_PositiveFixedAngle" default="5400000"/>
|
|
2385
|
+
* <xsd:attribute name="sx" type="ST_Percentage" default="100%"/>
|
|
2386
|
+
* <xsd:attribute name="sy" type="ST_Percentage" default="100%"/>
|
|
2387
|
+
* <xsd:attribute name="kx" type="ST_FixedAngle" default="0"/>
|
|
2388
|
+
* <xsd:attribute name="ky" type="ST_FixedAngle" default="0"/>
|
|
2389
|
+
* <xsd:attribute name="algn" type="ST_RectAlignment" default="b"/>
|
|
2390
|
+
* <xsd:attribute name="rotWithShape" type="xsd:boolean" default="true"/>
|
|
2391
|
+
* </xsd:complexType>
|
|
2392
|
+
* ```
|
|
2393
|
+
*/
|
|
2394
|
+
const createReflectionEffect = (options) => {
|
|
2395
|
+
if (!options) return new BuilderElement({ name: "a:reflection" });
|
|
2396
|
+
const attributes = {};
|
|
2397
|
+
if (options.blurRadius !== void 0) attributes.blurRad = {
|
|
2398
|
+
key: "blurRad",
|
|
2399
|
+
value: options.blurRadius
|
|
2400
|
+
};
|
|
2401
|
+
if (options.startAlpha !== void 0) attributes.stA = {
|
|
2402
|
+
key: "stA",
|
|
2403
|
+
value: options.startAlpha
|
|
2404
|
+
};
|
|
2405
|
+
if (options.startPosition !== void 0) attributes.stPos = {
|
|
2406
|
+
key: "stPos",
|
|
2407
|
+
value: options.startPosition
|
|
2408
|
+
};
|
|
2409
|
+
if (options.endAlpha !== void 0) attributes.endA = {
|
|
2410
|
+
key: "endA",
|
|
2411
|
+
value: options.endAlpha
|
|
2412
|
+
};
|
|
2413
|
+
if (options.endPosition !== void 0) attributes.endPos = {
|
|
2414
|
+
key: "endPos",
|
|
2415
|
+
value: options.endPosition
|
|
2416
|
+
};
|
|
2417
|
+
if (options.distance !== void 0) attributes.dist = {
|
|
2418
|
+
key: "dist",
|
|
2419
|
+
value: options.distance
|
|
2420
|
+
};
|
|
2421
|
+
if (options.direction !== void 0) attributes.dir = {
|
|
2422
|
+
key: "dir",
|
|
2423
|
+
value: options.direction
|
|
2424
|
+
};
|
|
2425
|
+
if (options.fadeDirection !== void 0) attributes.fadeDir = {
|
|
2426
|
+
key: "fadeDir",
|
|
2427
|
+
value: options.fadeDirection
|
|
2428
|
+
};
|
|
2429
|
+
if (options.scaleX !== void 0) attributes.sx = {
|
|
2430
|
+
key: "sx",
|
|
2431
|
+
value: options.scaleX
|
|
2432
|
+
};
|
|
2433
|
+
if (options.scaleY !== void 0) attributes.sy = {
|
|
2434
|
+
key: "sy",
|
|
2435
|
+
value: options.scaleY
|
|
2436
|
+
};
|
|
2437
|
+
if (options.skewX !== void 0) attributes.kx = {
|
|
2438
|
+
key: "kx",
|
|
2439
|
+
value: options.skewX
|
|
2440
|
+
};
|
|
2441
|
+
if (options.skewY !== void 0) attributes.ky = {
|
|
2442
|
+
key: "ky",
|
|
2443
|
+
value: options.skewY
|
|
2444
|
+
};
|
|
2445
|
+
if (options.alignment !== void 0) attributes.algn = {
|
|
2446
|
+
key: "algn",
|
|
2447
|
+
value: options.alignment
|
|
2448
|
+
};
|
|
2449
|
+
if (options.rotWithShape === false) attributes.rotWithShape = {
|
|
2450
|
+
key: "rotWithShape",
|
|
2451
|
+
value: 0
|
|
2452
|
+
};
|
|
2453
|
+
return new BuilderElement({
|
|
2454
|
+
attributes,
|
|
2455
|
+
name: "a:reflection"
|
|
2456
|
+
});
|
|
2457
|
+
};
|
|
2458
|
+
//#endregion
|
|
2459
|
+
//#region src/drawingml/effects/soft-edge.ts
|
|
2460
|
+
/**
|
|
2461
|
+
* Soft edge effect for DrawingML shapes.
|
|
2462
|
+
*
|
|
2463
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_SoftEdgesEffect
|
|
2464
|
+
*
|
|
2465
|
+
* @module
|
|
2466
|
+
*/
|
|
2467
|
+
/**
|
|
2468
|
+
* Creates a soft edge effect element.
|
|
2469
|
+
*
|
|
2470
|
+
* ## XSD Schema
|
|
2471
|
+
* ```xml
|
|
2472
|
+
* <xsd:complexType name="CT_SoftEdgesEffect">
|
|
2473
|
+
* <xsd:attribute name="rad" type="ST_PositiveCoordinate" use="required"/>
|
|
2474
|
+
* </xsd:complexType>
|
|
2475
|
+
* ```
|
|
2476
|
+
*
|
|
2477
|
+
* @param rad - Soft edge radius in EMUs (required)
|
|
2478
|
+
*/
|
|
2479
|
+
const createSoftEdgeEffect = (rad) => new BuilderElement({
|
|
2480
|
+
attributes: { rad: {
|
|
2481
|
+
key: "rad",
|
|
2482
|
+
value: rad
|
|
2483
|
+
} },
|
|
2484
|
+
name: "a:softEdge"
|
|
2485
|
+
});
|
|
2486
|
+
//#endregion
|
|
2487
|
+
//#region src/drawingml/effects/effect-list.ts
|
|
2488
|
+
/**
|
|
2489
|
+
* Effect list container for DrawingML shapes.
|
|
2490
|
+
*
|
|
2491
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_EffectList, EG_EffectProperties
|
|
2492
|
+
*
|
|
2493
|
+
* @module
|
|
2494
|
+
*/
|
|
2495
|
+
/**
|
|
2496
|
+
* Creates a blur effect element.
|
|
2497
|
+
*
|
|
2498
|
+
* ## XSD Schema
|
|
2499
|
+
* ```xml
|
|
2500
|
+
* <xsd:complexType name="CT_BlurEffect">
|
|
2501
|
+
* <xsd:attribute name="rad" type="ST_PositiveCoordinate" default="0"/>
|
|
2502
|
+
* <xsd:attribute name="grow" type="xsd:boolean" default="true"/>
|
|
2503
|
+
* </xsd:complexType>
|
|
2504
|
+
* ```
|
|
2505
|
+
*/
|
|
2506
|
+
const createBlurEffect$1 = (options) => {
|
|
2507
|
+
if (!(options.radius !== void 0 || options.grow === false)) return new BuilderElement({ name: "a:blur" });
|
|
2508
|
+
return new BuilderElement({
|
|
2509
|
+
attributes: {
|
|
2510
|
+
...options.radius !== void 0 && { rad: {
|
|
2511
|
+
key: "rad",
|
|
2512
|
+
value: options.radius
|
|
2513
|
+
} },
|
|
2514
|
+
...options.grow === false && { grow: {
|
|
2515
|
+
key: "grow",
|
|
2516
|
+
value: 0
|
|
2517
|
+
} }
|
|
2518
|
+
},
|
|
2519
|
+
name: "a:blur"
|
|
2520
|
+
});
|
|
2521
|
+
};
|
|
2522
|
+
/**
|
|
2523
|
+
* Creates an effect list element (a:effectLst).
|
|
2524
|
+
*
|
|
2525
|
+
* This is the EG_EffectProperties choice for a flat list of effects.
|
|
2526
|
+
* Effects are emitted in XSD order: blur, glow, innerShdw, outerShdw, prstShdw, reflection, softEdge.
|
|
2527
|
+
*
|
|
2528
|
+
* ## XSD Schema
|
|
2529
|
+
* ```xml
|
|
2530
|
+
* <xsd:complexType name="CT_EffectList">
|
|
2531
|
+
* <xsd:sequence>
|
|
2532
|
+
* <xsd:element name="blur" type="CT_BlurEffect" minOccurs="0"/>
|
|
2533
|
+
* <xsd:element name="fillOverlay" type="CT_FillOverlayEffect" minOccurs="0"/>
|
|
2534
|
+
* <xsd:element name="glow" type="CT_GlowEffect" minOccurs="0"/>
|
|
2535
|
+
* <xsd:element name="innerShdw" type="CT_InnerShadowEffect" minOccurs="0"/>
|
|
2536
|
+
* <xsd:element name="outerShdw" type="CT_OuterShadowEffect" minOccurs="0"/>
|
|
2537
|
+
* <xsd:element name="prstShdw" type="CT_PresetShadowEffect" minOccurs="0"/>
|
|
2538
|
+
* <xsd:element name="reflection" type="CT_ReflectionEffect" minOccurs="0"/>
|
|
2539
|
+
* <xsd:element name="softEdge" type="CT_SoftEdgesEffect" minOccurs="0"/>
|
|
2540
|
+
* </xsd:sequence>
|
|
2541
|
+
* </xsd:complexType>
|
|
2542
|
+
* ```
|
|
2543
|
+
*/
|
|
2544
|
+
const createEffectList = (options) => {
|
|
2545
|
+
const children = [];
|
|
2546
|
+
if (options.blur) children.push(createBlurEffect$1(options.blur));
|
|
2547
|
+
if (options.fillOverlay) children.push(createFillOverlayEffect(options.fillOverlay));
|
|
2548
|
+
if (options.glow) children.push(createGlowEffect(options.glow));
|
|
2549
|
+
if (options.innerShadow) children.push(createInnerShadowEffect(options.innerShadow));
|
|
2550
|
+
if (options.outerShadow) children.push(createOuterShadowEffect(options.outerShadow));
|
|
2551
|
+
if (options.presetShadow) children.push(createPresetShadowEffect(options.presetShadow));
|
|
2552
|
+
if (options.reflection) children.push(createReflectionEffect(options.reflection === true ? void 0 : options.reflection));
|
|
2553
|
+
if (options.softEdge !== void 0) children.push(createSoftEdgeEffect(options.softEdge));
|
|
2554
|
+
return new BuilderElement({
|
|
2555
|
+
children,
|
|
2556
|
+
name: "a:effectLst"
|
|
2557
|
+
});
|
|
2558
|
+
};
|
|
2559
|
+
//#endregion
|
|
2560
|
+
//#region src/drawingml/effects/effect-dag.ts
|
|
2561
|
+
/**
|
|
2562
|
+
* Effect container (effectDag) for DrawingML shapes.
|
|
2563
|
+
*
|
|
2564
|
+
* Provides CT_EffectContainer — a directed acyclic graph (DAG) of effects
|
|
2565
|
+
* supporting 28 effect types including alpha/color operations, nested containers,
|
|
2566
|
+
* and all effects from CT_EffectList.
|
|
2567
|
+
*
|
|
2568
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_EffectContainer, EG_Effect
|
|
2569
|
+
*
|
|
2570
|
+
* @module
|
|
2571
|
+
*/
|
|
2572
|
+
const buildOptionalAttributes = (options) => {
|
|
2573
|
+
const attrs = {};
|
|
2574
|
+
for (const [key, value] of Object.entries(options)) if (value !== void 0) attrs[key] = {
|
|
2575
|
+
key,
|
|
2576
|
+
value
|
|
2577
|
+
};
|
|
2578
|
+
return Object.keys(attrs).length > 0 ? attrs : void 0;
|
|
2579
|
+
};
|
|
2580
|
+
const createAlphaBiLevelEffect = (options) => new BuilderElement({
|
|
2581
|
+
name: "a:alphaBiLevel",
|
|
2582
|
+
attributes: { thresh: {
|
|
2583
|
+
key: "thresh",
|
|
2584
|
+
value: options.threshold
|
|
2585
|
+
} }
|
|
2586
|
+
});
|
|
2587
|
+
const createAlphaCeilingEffect = () => new BuilderElement({ name: "a:alphaCeiling" });
|
|
2588
|
+
const createAlphaFloorEffect = () => new BuilderElement({ name: "a:alphaFloor" });
|
|
2589
|
+
const createAlphaInverseEffect = (options) => new BuilderElement({
|
|
2590
|
+
name: "a:alphaInv",
|
|
2591
|
+
children: options?.color ? [createColorElement(options.color)] : void 0
|
|
2592
|
+
});
|
|
2593
|
+
const createAlphaModulateFixedEffect = (options) => {
|
|
2594
|
+
if (options?.amount === void 0) return new BuilderElement({ name: "a:alphaModFix" });
|
|
2595
|
+
return new BuilderElement({
|
|
2596
|
+
name: "a:alphaModFix",
|
|
2597
|
+
attributes: { amt: {
|
|
2598
|
+
key: "amt",
|
|
2599
|
+
value: options.amount
|
|
2600
|
+
} }
|
|
2601
|
+
});
|
|
2602
|
+
};
|
|
2603
|
+
const createAlphaOutsetEffect = (options) => {
|
|
2604
|
+
if (options?.radius === void 0) return new BuilderElement({ name: "a:alphaOutset" });
|
|
2605
|
+
return new BuilderElement({
|
|
2606
|
+
name: "a:alphaOutset",
|
|
2607
|
+
attributes: { rad: {
|
|
2608
|
+
key: "rad",
|
|
2609
|
+
value: options.radius
|
|
2610
|
+
} }
|
|
2611
|
+
});
|
|
2612
|
+
};
|
|
2613
|
+
const createAlphaReplaceEffect = (options) => new BuilderElement({
|
|
2614
|
+
name: "a:alphaRepl",
|
|
2615
|
+
attributes: { a: {
|
|
2616
|
+
key: "a",
|
|
2617
|
+
value: options.alpha
|
|
2618
|
+
} }
|
|
2619
|
+
});
|
|
2620
|
+
const createBiLevelEffect = (thresh) => new BuilderElement({
|
|
2621
|
+
name: "a:biLevel",
|
|
2622
|
+
attributes: { thresh: {
|
|
2623
|
+
key: "thresh",
|
|
2624
|
+
value: thresh
|
|
2625
|
+
} }
|
|
2626
|
+
});
|
|
2627
|
+
const createBlendEffect = (options) => new BuilderElement({
|
|
2628
|
+
name: "a:blend",
|
|
2629
|
+
attributes: { blend: {
|
|
2630
|
+
key: "blend",
|
|
2631
|
+
value: options.blend
|
|
2632
|
+
} },
|
|
2633
|
+
children: [createEffectContainer(options.container)]
|
|
2634
|
+
});
|
|
2635
|
+
const createColorChangeEffect = (options) => {
|
|
2636
|
+
const children = [new BuilderElement({
|
|
2637
|
+
name: "a:clrFrom",
|
|
2638
|
+
children: [createColorElement(options.from)]
|
|
2639
|
+
}), new BuilderElement({
|
|
2640
|
+
name: "a:clrTo",
|
|
2641
|
+
children: [createColorElement(options.to)]
|
|
2642
|
+
})];
|
|
2643
|
+
if (options.useA === false) return new BuilderElement({
|
|
2644
|
+
name: "a:clrChange",
|
|
2645
|
+
attributes: { useA: {
|
|
2646
|
+
key: "useA",
|
|
2647
|
+
value: 0
|
|
2648
|
+
} },
|
|
2649
|
+
children
|
|
2650
|
+
});
|
|
2651
|
+
return new BuilderElement({
|
|
2652
|
+
name: "a:clrChange",
|
|
2653
|
+
children
|
|
2654
|
+
});
|
|
2655
|
+
};
|
|
2656
|
+
const createColorReplaceEffect = (color) => new BuilderElement({
|
|
2657
|
+
name: "a:clrRepl",
|
|
2658
|
+
children: [createColorElement(color)]
|
|
2659
|
+
});
|
|
2660
|
+
const createDuotoneEffect = (options) => new BuilderElement({
|
|
2661
|
+
name: "a:duotone",
|
|
2662
|
+
children: [createColorElement(options.color1), createColorElement(options.color2)]
|
|
2663
|
+
});
|
|
2664
|
+
const createFillEffect = (options) => {
|
|
2665
|
+
let fillElement;
|
|
2666
|
+
if (options.noFill) fillElement = createNoFill();
|
|
2667
|
+
else if (options.solidFill) fillElement = createSolidFill(options.solidFill);
|
|
2668
|
+
else if (options.gradientFill) fillElement = createGradientFill(options.gradientFill);
|
|
2669
|
+
else if (options.patternFill) fillElement = createPatternFill(options.patternFill);
|
|
2670
|
+
else if (options.groupFill) fillElement = createGroupFill();
|
|
2671
|
+
else fillElement = createNoFill();
|
|
2672
|
+
return new BuilderElement({
|
|
2673
|
+
name: "a:fill",
|
|
2674
|
+
children: [fillElement]
|
|
2675
|
+
});
|
|
2676
|
+
};
|
|
2677
|
+
const createGrayscaleEffect = () => new BuilderElement({ name: "a:grayscl" });
|
|
2678
|
+
const createHSLEffect = (options) => {
|
|
2679
|
+
return new BuilderElement({
|
|
2680
|
+
name: "a:hsl",
|
|
2681
|
+
attributes: buildOptionalAttributes({
|
|
2682
|
+
hue: options?.hue,
|
|
2683
|
+
sat: options?.saturation,
|
|
2684
|
+
lum: options?.luminance
|
|
2685
|
+
})
|
|
2686
|
+
});
|
|
2687
|
+
};
|
|
2688
|
+
const createLuminanceEffect = (options) => {
|
|
2689
|
+
return new BuilderElement({
|
|
2690
|
+
name: "a:lum",
|
|
2691
|
+
attributes: buildOptionalAttributes({
|
|
2692
|
+
bright: options?.bright,
|
|
2693
|
+
contrast: options?.contrast
|
|
2694
|
+
})
|
|
2695
|
+
});
|
|
2696
|
+
};
|
|
2697
|
+
const createTintEffect = (options) => {
|
|
2698
|
+
return new BuilderElement({
|
|
2699
|
+
name: "a:tint",
|
|
2700
|
+
attributes: buildOptionalAttributes({
|
|
2701
|
+
hue: options?.hue,
|
|
2702
|
+
amt: options?.amount
|
|
2703
|
+
})
|
|
2704
|
+
});
|
|
2705
|
+
};
|
|
2706
|
+
const createRelativeOffsetEffect = (options) => {
|
|
2707
|
+
return new BuilderElement({
|
|
2708
|
+
name: "a:relOff",
|
|
2709
|
+
attributes: buildOptionalAttributes({
|
|
2710
|
+
tx: options?.translateX,
|
|
2711
|
+
ty: options?.translateY
|
|
2712
|
+
})
|
|
2713
|
+
});
|
|
2714
|
+
};
|
|
2715
|
+
const createTransformEffect = (options) => {
|
|
2716
|
+
return new BuilderElement({
|
|
2717
|
+
name: "a:xfrm",
|
|
2718
|
+
attributes: buildOptionalAttributes({
|
|
2719
|
+
sx: options?.scaleX,
|
|
2720
|
+
sy: options?.scaleY,
|
|
2721
|
+
kx: options?.skewX,
|
|
2722
|
+
ky: options?.skewY,
|
|
2723
|
+
tx: options?.translateX,
|
|
2724
|
+
ty: options?.translateY
|
|
2725
|
+
})
|
|
2726
|
+
});
|
|
2727
|
+
};
|
|
2728
|
+
const createEffectReference = (options) => new BuilderElement({
|
|
2729
|
+
name: "a:effect",
|
|
2730
|
+
attributes: { ref: {
|
|
2731
|
+
key: "ref",
|
|
2732
|
+
value: options.ref
|
|
2733
|
+
} }
|
|
2734
|
+
});
|
|
2735
|
+
const createBlurEffect = (options) => {
|
|
2736
|
+
if (!(options.radius !== void 0 || options.grow === false)) return new BuilderElement({ name: "a:blur" });
|
|
2737
|
+
return new BuilderElement({
|
|
2738
|
+
attributes: {
|
|
2739
|
+
...options.radius !== void 0 && { rad: {
|
|
2740
|
+
key: "rad",
|
|
2741
|
+
value: options.radius
|
|
2742
|
+
} },
|
|
2743
|
+
...options.grow === false && { grow: {
|
|
2744
|
+
key: "grow",
|
|
2745
|
+
value: 0
|
|
2746
|
+
} }
|
|
2747
|
+
},
|
|
2748
|
+
name: "a:blur"
|
|
2749
|
+
});
|
|
2750
|
+
};
|
|
2751
|
+
/**
|
|
2752
|
+
* Creates an effect container element (a:effectDag or a:cont).
|
|
2753
|
+
*
|
|
2754
|
+
* This is the CT_EffectContainer type — a recursive DAG of effects.
|
|
2755
|
+
* All 28 EG_Effect types are supported.
|
|
2756
|
+
*
|
|
2757
|
+
* ## XSD Schema
|
|
2758
|
+
* ```xml
|
|
2759
|
+
* <xsd:complexType name="CT_EffectContainer">
|
|
2760
|
+
* <xsd:group ref="EG_Effect" minOccurs="0" maxOccurs="unbounded"/>
|
|
2761
|
+
* <xsd:attribute name="type" type="ST_EffectContainerType" default="sib"/>
|
|
2762
|
+
* <xsd:attribute name="name" type="xsd:token" use="optional"/>
|
|
2763
|
+
* </xsd:complexType>
|
|
2764
|
+
* ```
|
|
2765
|
+
*
|
|
2766
|
+
* @param options - Container options with effects
|
|
2767
|
+
* @param elementName - Element name, defaults to "a:effectDag" for top-level
|
|
2768
|
+
*/
|
|
2769
|
+
const createEffectContainer = (options, elementName = "a:cont") => {
|
|
2770
|
+
const attrs = buildOptionalAttributes({
|
|
2771
|
+
type: options.type,
|
|
2772
|
+
name: options.name
|
|
2773
|
+
});
|
|
2774
|
+
const children = [];
|
|
2775
|
+
if (options.blur) children.push(createBlurEffect(options.blur));
|
|
2776
|
+
if (options.fillOverlay) children.push(createFillOverlayEffect(options.fillOverlay));
|
|
2777
|
+
if (options.glow) children.push(createGlowEffect(options.glow));
|
|
2778
|
+
if (options.innerShadow) children.push(createInnerShadowEffect(options.innerShadow));
|
|
2779
|
+
if (options.outerShadow) children.push(createOuterShadowEffect(options.outerShadow));
|
|
2780
|
+
if (options.presetShadow) children.push(createPresetShadowEffect(options.presetShadow));
|
|
2781
|
+
if (options.reflection) children.push(createReflectionEffect(options.reflection === true ? void 0 : options.reflection));
|
|
2782
|
+
if (options.softEdge !== void 0) children.push(createSoftEdgeEffect(options.softEdge));
|
|
2783
|
+
if (options.containers) for (const nested of options.containers) children.push(createEffectContainer(nested));
|
|
2784
|
+
if (options.effectRefs) for (const ref of options.effectRefs) children.push(createEffectReference(ref));
|
|
2785
|
+
if (options.alphaBiLevel) children.push(createAlphaBiLevelEffect(options.alphaBiLevel));
|
|
2786
|
+
if (options.alphaCeiling) children.push(createAlphaCeilingEffect());
|
|
2787
|
+
if (options.alphaFloor) children.push(createAlphaFloorEffect());
|
|
2788
|
+
if (options.alphaInverse) children.push(createAlphaInverseEffect(options.alphaInverse));
|
|
2789
|
+
if (options.alphaModulate) children.push(new BuilderElement({
|
|
2790
|
+
name: "a:alphaMod",
|
|
2791
|
+
children: [createEffectContainer(options.alphaModulate)]
|
|
2792
|
+
}));
|
|
2793
|
+
if (options.alphaModulateFixed) children.push(createAlphaModulateFixedEffect(options.alphaModulateFixed));
|
|
2794
|
+
if (options.alphaOutset) children.push(createAlphaOutsetEffect(options.alphaOutset));
|
|
2795
|
+
if (options.alphaReplace) children.push(createAlphaReplaceEffect(options.alphaReplace));
|
|
2796
|
+
if (options.biLevel) children.push(createBiLevelEffect(options.biLevel.threshold));
|
|
2797
|
+
if (options.blend) children.push(createBlendEffect(options.blend));
|
|
2798
|
+
if (options.colorChange) children.push(createColorChangeEffect(options.colorChange));
|
|
2799
|
+
if (options.colorReplace) children.push(createColorReplaceEffect(options.colorReplace));
|
|
2800
|
+
if (options.duotone) children.push(createDuotoneEffect(options.duotone));
|
|
2801
|
+
if (options.fill) children.push(createFillEffect(options.fill));
|
|
2802
|
+
if (options.grayscale) children.push(createGrayscaleEffect());
|
|
2803
|
+
if (options.hsl) children.push(createHSLEffect(options.hsl));
|
|
2804
|
+
if (options.luminance) children.push(createLuminanceEffect(options.luminance));
|
|
2805
|
+
if (options.tint) children.push(createTintEffect(options.tint));
|
|
2806
|
+
if (options.relativeOffset) children.push(createRelativeOffsetEffect(options.relativeOffset));
|
|
2807
|
+
if (options.transform) children.push(createTransformEffect(options.transform));
|
|
2808
|
+
return new BuilderElement({
|
|
2809
|
+
name: elementName,
|
|
2810
|
+
attributes: attrs,
|
|
2811
|
+
children: children.length > 0 ? children : void 0
|
|
2812
|
+
});
|
|
2813
|
+
};
|
|
2814
|
+
/**
|
|
2815
|
+
* Creates an effect DAG element (a:effectDag).
|
|
2816
|
+
*
|
|
2817
|
+
* This is the EG_EffectProperties choice alternative to effectLst,
|
|
2818
|
+
* supporting all 28 effect types with recursive nesting.
|
|
2819
|
+
*
|
|
2820
|
+
* @example
|
|
2821
|
+
* ```typescript
|
|
2822
|
+
* // Simple effect DAG with glow and outer shadow
|
|
2823
|
+
* createEffectDag({
|
|
2824
|
+
* glow: { radius: 50800, color: { value: "FF0000" } },
|
|
2825
|
+
* outerShadow: { color: { value: "000000" }, blurRadius: 76200 },
|
|
2826
|
+
* });
|
|
2827
|
+
*
|
|
2828
|
+
* // DAG with alpha effects and nested container
|
|
2829
|
+
* createEffectDag({
|
|
2830
|
+
* type: "tree",
|
|
2831
|
+
* alphaBiLevel: { threshold: 50000 },
|
|
2832
|
+
* containers: [{
|
|
2833
|
+
* glow: { color: { value: "FF0000" } },
|
|
2834
|
+
* }],
|
|
2835
|
+
* });
|
|
2836
|
+
* ```
|
|
2837
|
+
*/
|
|
2838
|
+
const createEffectDag = (options) => createEffectContainer(options, "a:effectDag");
|
|
2839
|
+
//#endregion
|
|
2840
|
+
//#region src/drawingml/three-d/scene-3d.ts
|
|
2841
|
+
/**
|
|
2842
|
+
* 3D scene module for DrawingML shapes.
|
|
2843
|
+
*
|
|
2844
|
+
* Provides CT_Scene3D — the 3D scene properties including camera, light rig,
|
|
2845
|
+
* and optional backdrop that define how a 3D shape is rendered.
|
|
2846
|
+
*
|
|
2847
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Scene3D
|
|
2848
|
+
*
|
|
2849
|
+
* @module
|
|
2850
|
+
*/
|
|
2851
|
+
const createSphereCoords = (coords) => new BuilderElement({
|
|
2852
|
+
name: "a:rot",
|
|
2853
|
+
attributes: {
|
|
2854
|
+
lat: {
|
|
2855
|
+
key: "lat",
|
|
2856
|
+
value: coords.lat
|
|
2857
|
+
},
|
|
2858
|
+
lon: {
|
|
2859
|
+
key: "lon",
|
|
2860
|
+
value: coords.lon
|
|
2861
|
+
},
|
|
2862
|
+
rev: {
|
|
2863
|
+
key: "rev",
|
|
2864
|
+
value: coords.rev
|
|
2865
|
+
}
|
|
2866
|
+
}
|
|
2867
|
+
});
|
|
2868
|
+
const createCamera = (options) => {
|
|
2869
|
+
const children = [];
|
|
2870
|
+
if (options.rotation) children.push(createSphereCoords(options.rotation));
|
|
2871
|
+
const attrs = { prst: {
|
|
2872
|
+
key: "prst",
|
|
2873
|
+
value: options.preset
|
|
2874
|
+
} };
|
|
2875
|
+
if (options.fov !== void 0) attrs.fov = {
|
|
2876
|
+
key: "fov",
|
|
2877
|
+
value: options.fov
|
|
2878
|
+
};
|
|
2879
|
+
if (options.zoom !== void 0) attrs.zoom = {
|
|
2880
|
+
key: "zoom",
|
|
2881
|
+
value: options.zoom
|
|
2882
|
+
};
|
|
2883
|
+
return new BuilderElement({
|
|
2884
|
+
name: "a:camera",
|
|
2885
|
+
attributes: attrs,
|
|
2886
|
+
children: children.length > 0 ? children : void 0
|
|
2887
|
+
});
|
|
2888
|
+
};
|
|
2889
|
+
const createLightRig = (options) => {
|
|
2890
|
+
const children = [];
|
|
2891
|
+
if (options.rotation) children.push(createSphereCoords(options.rotation));
|
|
2892
|
+
return new BuilderElement({
|
|
2893
|
+
name: "a:lightRig",
|
|
2894
|
+
attributes: {
|
|
2895
|
+
rig: {
|
|
2896
|
+
key: "rig",
|
|
2897
|
+
value: options.rig
|
|
2898
|
+
},
|
|
2899
|
+
dir: {
|
|
2900
|
+
key: "dir",
|
|
2901
|
+
value: options.direction
|
|
2902
|
+
}
|
|
2903
|
+
},
|
|
2904
|
+
children: children.length > 0 ? children : void 0
|
|
2905
|
+
});
|
|
2906
|
+
};
|
|
2907
|
+
const createPoint3D = (name, point) => new BuilderElement({
|
|
2908
|
+
name,
|
|
2909
|
+
attributes: {
|
|
2910
|
+
x: {
|
|
2911
|
+
key: "x",
|
|
2912
|
+
value: point.x
|
|
2913
|
+
},
|
|
2914
|
+
y: {
|
|
2915
|
+
key: "y",
|
|
2916
|
+
value: point.y
|
|
2917
|
+
},
|
|
2918
|
+
z: {
|
|
2919
|
+
key: "z",
|
|
2920
|
+
value: point.z
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
});
|
|
2924
|
+
const createVector3D = (name, vector) => new BuilderElement({
|
|
2925
|
+
name,
|
|
2926
|
+
attributes: {
|
|
2927
|
+
dx: {
|
|
2928
|
+
key: "dx",
|
|
2929
|
+
value: vector.dx
|
|
2930
|
+
},
|
|
2931
|
+
dy: {
|
|
2932
|
+
key: "dy",
|
|
2933
|
+
value: vector.dy
|
|
2934
|
+
},
|
|
2935
|
+
dz: {
|
|
2936
|
+
key: "dz",
|
|
2937
|
+
value: vector.dz
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
});
|
|
2941
|
+
const createBackdrop = (options) => new BuilderElement({
|
|
2942
|
+
name: "a:backdrop",
|
|
2943
|
+
children: [
|
|
2944
|
+
createPoint3D("a:anchor", options.anchor),
|
|
2945
|
+
createVector3D("a:norm", options.normal),
|
|
2946
|
+
createVector3D("a:up", options.up)
|
|
2947
|
+
]
|
|
2948
|
+
});
|
|
2949
|
+
/**
|
|
2950
|
+
* Creates a 3D scene element (a:scene3d).
|
|
2951
|
+
*
|
|
2952
|
+
* @example
|
|
2953
|
+
* ```typescript
|
|
2954
|
+
* // Simple scene with default camera and lighting
|
|
2955
|
+
* createScene3D({
|
|
2956
|
+
* camera: { preset: "perspectiveFront" },
|
|
2957
|
+
* lightRig: { rig: "threePt", direction: "t" },
|
|
2958
|
+
* });
|
|
2959
|
+
*
|
|
2960
|
+
* // Scene with rotated camera and backdrop
|
|
2961
|
+
* createScene3D({
|
|
2962
|
+
* camera: {
|
|
2963
|
+
* preset: "isometricTopUp",
|
|
2964
|
+
* rotation: { lat: 0, lon: 0, rev: 5400000 },
|
|
2965
|
+
* },
|
|
2966
|
+
* lightRig: { rig: "balanced", direction: "tl" },
|
|
2967
|
+
* backdrop: {
|
|
2968
|
+
* anchor: { x: 0, y: 0, z: 0 },
|
|
2969
|
+
* normal: { dx: 0, dy: 0, dz: 1 },
|
|
2970
|
+
* up: { dx: 0, dy: 1, dz: 0 },
|
|
2971
|
+
* },
|
|
2972
|
+
* });
|
|
2973
|
+
* ```
|
|
2974
|
+
*/
|
|
2975
|
+
const createScene3D = (options) => {
|
|
2976
|
+
const children = [createCamera(options.camera), createLightRig(options.lightRig)];
|
|
2977
|
+
if (options.backdrop) children.push(createBackdrop(options.backdrop));
|
|
2978
|
+
return new BuilderElement({
|
|
2979
|
+
name: "a:scene3d",
|
|
2980
|
+
children
|
|
2981
|
+
});
|
|
2982
|
+
};
|
|
2983
|
+
//#endregion
|
|
2984
|
+
//#region src/drawingml/three-d/bevel.ts
|
|
2985
|
+
/**
|
|
2986
|
+
* Bevel element for DrawingML 3D shapes.
|
|
2987
|
+
*
|
|
2988
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Bevel
|
|
2989
|
+
*
|
|
2990
|
+
* @module
|
|
2991
|
+
*/
|
|
2992
|
+
/**
|
|
2993
|
+
* Bevel preset types (12 variations).
|
|
2994
|
+
*
|
|
2995
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, ST_BevelPresetType
|
|
2996
|
+
*/
|
|
2997
|
+
const BevelPresetType = {
|
|
2998
|
+
RELAXED_INSET: "relaxedInset",
|
|
2999
|
+
CIRCLE: "circle",
|
|
3000
|
+
SLOPE: "slope",
|
|
3001
|
+
CROSS: "cross",
|
|
3002
|
+
ANGLE: "angle",
|
|
3003
|
+
SOFT_ROUND: "softRound",
|
|
3004
|
+
CONVEX: "convex",
|
|
3005
|
+
COOL_SLANT: "coolSlant",
|
|
3006
|
+
DIVOT: "divot",
|
|
3007
|
+
RIBLET: "riblet",
|
|
3008
|
+
HARD_EDGE: "hardEdge",
|
|
3009
|
+
ART_DECO: "artDeco"
|
|
3010
|
+
};
|
|
3011
|
+
/**
|
|
3012
|
+
* Creates a bevel element.
|
|
3013
|
+
*
|
|
3014
|
+
* ## XSD Schema
|
|
3015
|
+
* ```xml
|
|
3016
|
+
* <xsd:complexType name="CT_Bevel">
|
|
3017
|
+
* <xsd:attribute name="w" type="ST_PositiveCoordinate" default="76200"/>
|
|
3018
|
+
* <xsd:attribute name="h" type="ST_PositiveCoordinate" default="76200"/>
|
|
3019
|
+
* <xsd:attribute name="prst" type="ST_BevelPresetType" default="circle"/>
|
|
3020
|
+
* </xsd:complexType>
|
|
3021
|
+
* ```
|
|
3022
|
+
*/
|
|
3023
|
+
const createBevel = (options) => {
|
|
3024
|
+
if (!options) return new BuilderElement({ name: "a:bevelT" });
|
|
3025
|
+
const attributes = {};
|
|
3026
|
+
if (options.w !== void 0) attributes.w = {
|
|
3027
|
+
key: "w",
|
|
3028
|
+
value: options.w
|
|
3029
|
+
};
|
|
3030
|
+
if (options.h !== void 0) attributes.h = {
|
|
3031
|
+
key: "h",
|
|
3032
|
+
value: options.h
|
|
3033
|
+
};
|
|
3034
|
+
if (options.prst !== void 0) attributes.prst = {
|
|
3035
|
+
key: "prst",
|
|
3036
|
+
value: BevelPresetType[options.prst]
|
|
3037
|
+
};
|
|
3038
|
+
return new BuilderElement({
|
|
3039
|
+
attributes,
|
|
3040
|
+
name: "a:bevelT"
|
|
3041
|
+
});
|
|
3042
|
+
};
|
|
3043
|
+
/**
|
|
3044
|
+
* Creates a bottom bevel element (a:bevelB).
|
|
3045
|
+
*/
|
|
3046
|
+
const createBottomBevel = (options) => {
|
|
3047
|
+
if (!options) return new BuilderElement({ name: "a:bevelB" });
|
|
3048
|
+
const attributes = {};
|
|
3049
|
+
if (options.w !== void 0) attributes.w = {
|
|
3050
|
+
key: "w",
|
|
3051
|
+
value: options.w
|
|
3052
|
+
};
|
|
3053
|
+
if (options.h !== void 0) attributes.h = {
|
|
3054
|
+
key: "h",
|
|
3055
|
+
value: options.h
|
|
3056
|
+
};
|
|
3057
|
+
if (options.prst !== void 0) attributes.prst = {
|
|
3058
|
+
key: "prst",
|
|
3059
|
+
value: BevelPresetType[options.prst]
|
|
3060
|
+
};
|
|
3061
|
+
return new BuilderElement({
|
|
3062
|
+
attributes,
|
|
3063
|
+
name: "a:bevelB"
|
|
3064
|
+
});
|
|
3065
|
+
};
|
|
3066
|
+
//#endregion
|
|
3067
|
+
//#region src/drawingml/three-d/shape-3d.ts
|
|
3068
|
+
/**
|
|
3069
|
+
* 3D shape properties for DrawingML.
|
|
3070
|
+
*
|
|
3071
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Shape3D
|
|
3072
|
+
*
|
|
3073
|
+
* @module
|
|
3074
|
+
*/
|
|
3075
|
+
/**
|
|
3076
|
+
* Preset material types for 3D shapes (15 variations).
|
|
3077
|
+
*
|
|
3078
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, ST_PresetMaterialType
|
|
3079
|
+
*/
|
|
3080
|
+
const PresetMaterialType = {
|
|
3081
|
+
LEGACY_MATTE: "legacyMatte",
|
|
3082
|
+
LEGACY_PLASTIC: "legacyPlastic",
|
|
3083
|
+
LEGACY_METAL: "legacyMetal",
|
|
3084
|
+
LEGACY_WIREFRAME: "legacyWireframe",
|
|
3085
|
+
MATTE: "matte",
|
|
3086
|
+
PLASTIC: "plastic",
|
|
3087
|
+
METAL: "metal",
|
|
3088
|
+
WARM_MATTE: "warmMatte",
|
|
3089
|
+
TRANSLUCENT_POWDER: "translucentPowder",
|
|
3090
|
+
POWDER: "powder",
|
|
3091
|
+
DK_EDGE: "dkEdge",
|
|
3092
|
+
SOFT_EDGE: "softEdge",
|
|
3093
|
+
CLEAR: "clear",
|
|
3094
|
+
FLAT: "flat",
|
|
3095
|
+
SOFT_METAL: "softmetal"
|
|
3096
|
+
};
|
|
3097
|
+
/**
|
|
3098
|
+
* Creates a 3D shape properties element (a:sp3d).
|
|
3099
|
+
*
|
|
3100
|
+
* ## XSD Schema
|
|
3101
|
+
* ```xml
|
|
3102
|
+
* <xsd:complexType name="CT_Shape3D">
|
|
3103
|
+
* <xsd:sequence>
|
|
3104
|
+
* <xsd:element name="bevelT" type="CT_Bevel" minOccurs="0"/>
|
|
3105
|
+
* <xsd:element name="bevelB" type="CT_Bevel" minOccurs="0"/>
|
|
3106
|
+
* <xsd:element name="extrusionClr" type="CT_Color" minOccurs="0"/>
|
|
3107
|
+
* <xsd:element name="contourClr" type="CT_Color" minOccurs="0"/>
|
|
3108
|
+
* </xsd:sequence>
|
|
3109
|
+
* <xsd:attribute name="z" type="ST_Coordinate" default="0"/>
|
|
3110
|
+
* <xsd:attribute name="extrusionH" type="ST_PositiveCoordinate" default="0"/>
|
|
3111
|
+
* <xsd:attribute name="contourW" type="ST_PositiveCoordinate" default="0"/>
|
|
3112
|
+
* <xsd:attribute name="prstMaterial" type="ST_PresetMaterialType" default="warmMatte"/>
|
|
3113
|
+
* </xsd:complexType>
|
|
3114
|
+
* ```
|
|
3115
|
+
*/
|
|
3116
|
+
const createShape3D = (options) => {
|
|
3117
|
+
const children = [];
|
|
3118
|
+
if (options.bevelT) children.push(createBevel(options.bevelT));
|
|
3119
|
+
if (options.bevelB) children.push(createBottomBevel(options.bevelB));
|
|
3120
|
+
if (options.extrusionColor) children.push(new BuilderElement({
|
|
3121
|
+
children: [createColorElement(options.extrusionColor)],
|
|
3122
|
+
name: "a:extrusionClr"
|
|
3123
|
+
}));
|
|
3124
|
+
if (options.contourColor) children.push(new BuilderElement({
|
|
3125
|
+
children: [createColorElement(options.contourColor)],
|
|
3126
|
+
name: "a:contourClr"
|
|
3127
|
+
}));
|
|
3128
|
+
return new BuilderElement({
|
|
3129
|
+
attributes: options.z !== void 0 || options.extrusionH !== void 0 || options.contourW !== void 0 || options.prstMaterial !== void 0 ? {
|
|
3130
|
+
...options.z !== void 0 && { z: {
|
|
3131
|
+
key: "z",
|
|
3132
|
+
value: options.z
|
|
3133
|
+
} },
|
|
3134
|
+
...options.extrusionH !== void 0 && { extrusionH: {
|
|
3135
|
+
key: "extrusionH",
|
|
3136
|
+
value: options.extrusionH
|
|
3137
|
+
} },
|
|
3138
|
+
...options.contourW !== void 0 && { contourW: {
|
|
3139
|
+
key: "contourW",
|
|
3140
|
+
value: options.contourW
|
|
3141
|
+
} },
|
|
3142
|
+
...options.prstMaterial !== void 0 && { prstMaterial: {
|
|
3143
|
+
key: "prstMaterial",
|
|
3144
|
+
value: PresetMaterialType[options.prstMaterial]
|
|
3145
|
+
} }
|
|
3146
|
+
} : void 0,
|
|
3147
|
+
children,
|
|
3148
|
+
name: "a:sp3d"
|
|
3149
|
+
});
|
|
3150
|
+
};
|
|
3151
|
+
//#endregion
|
|
3152
|
+
//#region src/drawingml/geometry/adjustment-values.ts
|
|
3153
|
+
/**
|
|
3154
|
+
* Adjustment values module for preset geometries.
|
|
3155
|
+
*
|
|
3156
|
+
* This module provides adjustment value lists that can modify the appearance
|
|
3157
|
+
* of preset shape geometries.
|
|
3158
|
+
*
|
|
3159
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_GeomGuideList, CT_GeomGuide
|
|
3160
|
+
*
|
|
3161
|
+
* @module
|
|
3162
|
+
*/
|
|
3163
|
+
/**
|
|
3164
|
+
* Creates an adjustment values list element (a:avLst).
|
|
3165
|
+
*
|
|
3166
|
+
* The adjustment values list contains geometry guides that modify
|
|
3167
|
+
* the appearance of a preset geometric shape. When empty, default
|
|
3168
|
+
* values are used.
|
|
3169
|
+
*
|
|
3170
|
+
* ## XSD Schema
|
|
3171
|
+
* ```xml
|
|
3172
|
+
* <xsd:complexType name="CT_GeomGuideList">
|
|
3173
|
+
* <xsd:sequence>
|
|
3174
|
+
* <xsd:element name="gd" type="CT_GeomGuide" minOccurs="0" maxOccurs="unbounded"/>
|
|
3175
|
+
* </xsd:sequence>
|
|
3176
|
+
* </xsd:complexType>
|
|
3177
|
+
* ```
|
|
3178
|
+
*
|
|
3179
|
+
* @example
|
|
3180
|
+
* ```typescript
|
|
3181
|
+
* // Empty adjustment values (defaults)
|
|
3182
|
+
* createAdjustmentValues();
|
|
3183
|
+
*
|
|
3184
|
+
* // With guides
|
|
3185
|
+
* createAdjustmentValues([
|
|
3186
|
+
* { name: "adj", formula: "val 16667" },
|
|
3187
|
+
* ]);
|
|
3188
|
+
* ```
|
|
3189
|
+
*/
|
|
3190
|
+
const createAdjustmentValues = (guides) => {
|
|
3191
|
+
const children = [];
|
|
3192
|
+
if (guides) for (const guide of guides) children.push(new BuilderElement({
|
|
3193
|
+
attributes: {
|
|
3194
|
+
name: {
|
|
3195
|
+
key: "name",
|
|
3196
|
+
value: guide.name
|
|
3197
|
+
},
|
|
3198
|
+
fmla: {
|
|
3199
|
+
key: "fmla",
|
|
3200
|
+
value: guide.formula
|
|
3201
|
+
}
|
|
3202
|
+
},
|
|
3203
|
+
name: "a:gd"
|
|
3204
|
+
}));
|
|
3205
|
+
return new BuilderElement({
|
|
3206
|
+
children,
|
|
3207
|
+
name: "a:avLst"
|
|
3208
|
+
});
|
|
3209
|
+
};
|
|
3210
|
+
//#endregion
|
|
3211
|
+
//#region src/drawingml/geometry/preset-geometry-attributes.ts
|
|
3212
|
+
/**
|
|
3213
|
+
* Preset geometry attributes for DrawingML shapes.
|
|
3214
|
+
*
|
|
3215
|
+
* This module defines the shape type attribute for preset geometries.
|
|
3216
|
+
*
|
|
3217
|
+
* @module
|
|
3218
|
+
*/
|
|
3219
|
+
/**
|
|
3220
|
+
* Attributes for preset geometry.
|
|
3221
|
+
*
|
|
3222
|
+
* Defines the shape type identifier for a preset geometry.
|
|
3223
|
+
*
|
|
3224
|
+
* ## XSD Schema
|
|
3225
|
+
* ```xml
|
|
3226
|
+
* <xsd:attribute name="prst" type="ST_ShapeType" use="required"/>
|
|
3227
|
+
* ```
|
|
3228
|
+
*
|
|
3229
|
+
* @internal
|
|
3230
|
+
*/
|
|
3231
|
+
var PresetGeometryAttributes = class extends XmlAttributeComponent {
|
|
3232
|
+
xmlKeys = { prst: "prst" };
|
|
3233
|
+
};
|
|
3234
|
+
//#endregion
|
|
3235
|
+
//#region src/drawingml/geometry/preset-geometry.ts
|
|
3236
|
+
/**
|
|
3237
|
+
* Preset geometry module for DrawingML shapes.
|
|
3238
|
+
*
|
|
3239
|
+
* This module provides predefined shape geometries that can be applied
|
|
3240
|
+
* to pictures and shapes without requiring custom path definitions.
|
|
3241
|
+
*
|
|
3242
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_PresetGeometry2D
|
|
3243
|
+
*
|
|
3244
|
+
* @module
|
|
3245
|
+
*/
|
|
3246
|
+
/**
|
|
3247
|
+
* Represents a preset geometry for a DrawingML shape.
|
|
3248
|
+
*
|
|
3249
|
+
* This element specifies when a preset geometric shape should be used instead
|
|
3250
|
+
* of a custom geometry. It includes a shape preset identifier and optional
|
|
3251
|
+
* adjustment values that modify the base shape.
|
|
3252
|
+
*
|
|
3253
|
+
* ## XSD Schema
|
|
3254
|
+
* ```xml
|
|
3255
|
+
* <xsd:complexType name="CT_PresetGeometry2D">
|
|
3256
|
+
* <xsd:sequence>
|
|
3257
|
+
* <xsd:element name="avLst" type="CT_GeomGuideList" minOccurs="0" maxOccurs="1"/>
|
|
3258
|
+
* </xsd:sequence>
|
|
3259
|
+
* <xsd:attribute name="prst" type="ST_ShapeType" use="required"/>
|
|
3260
|
+
* </xsd:complexType>
|
|
3261
|
+
* ```
|
|
3262
|
+
*
|
|
3263
|
+
* @example
|
|
3264
|
+
* ```typescript
|
|
3265
|
+
* // Default rectangle
|
|
3266
|
+
* const geometry = new PresetGeometry();
|
|
3267
|
+
*
|
|
3268
|
+
* // Rounded rectangle with adjustment
|
|
3269
|
+
* const geometry = new PresetGeometry({
|
|
3270
|
+
* preset: "roundRect",
|
|
3271
|
+
* adjustmentValues: [{ name: "adj", formula: "val 16667" }],
|
|
3272
|
+
* });
|
|
3273
|
+
* ```
|
|
3274
|
+
*/
|
|
3275
|
+
var PresetGeometry = class extends XmlComponent {
|
|
3276
|
+
constructor(options) {
|
|
3277
|
+
super("a:prstGeom");
|
|
3278
|
+
this.root.push(new PresetGeometryAttributes({ prst: options?.preset ?? "rect" }));
|
|
3279
|
+
this.root.push(createAdjustmentValues(options?.adjustmentValues));
|
|
3280
|
+
}
|
|
3281
|
+
};
|
|
3282
|
+
//#endregion
|
|
3283
|
+
//#region src/drawingml/geometry/custom-geometry.ts
|
|
3284
|
+
/**
|
|
3285
|
+
* Custom geometry module for DrawingML shapes.
|
|
3286
|
+
*
|
|
3287
|
+
* Provides CT_CustomGeometry2D — user-defined 2D geometry with paths,
|
|
3288
|
+
* guides, adjust handles, connection sites, and a text insertion rectangle.
|
|
3289
|
+
*
|
|
3290
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_CustomGeometry2D
|
|
3291
|
+
*
|
|
3292
|
+
* @module
|
|
3293
|
+
*/
|
|
3294
|
+
/**
|
|
3295
|
+
* Creates a geometry guide list element (a:avLst or a:gdLst).
|
|
3296
|
+
*
|
|
3297
|
+
* Both CT_GeomGuideList types share the same structure — a list of `a:gd` children.
|
|
3298
|
+
* The only difference is the wrapper element name.
|
|
3299
|
+
*/
|
|
3300
|
+
const createGuideList = (name, guides) => {
|
|
3301
|
+
return new BuilderElement({
|
|
3302
|
+
name,
|
|
3303
|
+
children: guides.map((guide) => new BuilderElement({
|
|
3304
|
+
attributes: {
|
|
3305
|
+
name: {
|
|
3306
|
+
key: "name",
|
|
3307
|
+
value: guide.name
|
|
3308
|
+
},
|
|
3309
|
+
fmla: {
|
|
3310
|
+
key: "fmla",
|
|
3311
|
+
value: guide.formula
|
|
3312
|
+
}
|
|
3313
|
+
},
|
|
3314
|
+
name: "a:gd"
|
|
3315
|
+
}))
|
|
3316
|
+
});
|
|
3317
|
+
};
|
|
3318
|
+
const createAdjPoint = (name, point) => new BuilderElement({
|
|
3319
|
+
name,
|
|
3320
|
+
children: [new BuilderElement({
|
|
3321
|
+
name: "a:pt",
|
|
3322
|
+
attributes: {
|
|
3323
|
+
x: {
|
|
3324
|
+
key: "x",
|
|
3325
|
+
value: point.x
|
|
3326
|
+
},
|
|
3327
|
+
y: {
|
|
3328
|
+
key: "y",
|
|
3329
|
+
value: point.y
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3332
|
+
})]
|
|
3333
|
+
});
|
|
3334
|
+
const createPathCommand = (cmd) => {
|
|
3335
|
+
switch (cmd.command) {
|
|
3336
|
+
case "moveTo": return createAdjPoint("a:moveTo", cmd.point);
|
|
3337
|
+
case "lineTo": return createAdjPoint("a:lnTo", cmd.point);
|
|
3338
|
+
case "arcTo": return new BuilderElement({
|
|
3339
|
+
name: "a:arcTo",
|
|
3340
|
+
attributes: {
|
|
3341
|
+
wR: {
|
|
3342
|
+
key: "wR",
|
|
3343
|
+
value: cmd.widthRadius
|
|
3344
|
+
},
|
|
3345
|
+
hR: {
|
|
3346
|
+
key: "hR",
|
|
3347
|
+
value: cmd.heightRadius
|
|
3348
|
+
},
|
|
3349
|
+
stAng: {
|
|
3350
|
+
key: "stAng",
|
|
3351
|
+
value: cmd.startAngle
|
|
3352
|
+
},
|
|
3353
|
+
swAng: {
|
|
3354
|
+
key: "swAng",
|
|
3355
|
+
value: cmd.sweepAngle
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
});
|
|
3359
|
+
case "quadBezTo": return new BuilderElement({
|
|
3360
|
+
name: "a:quadBezTo",
|
|
3361
|
+
children: cmd.points.map((pt) => new BuilderElement({
|
|
3362
|
+
name: "a:pt",
|
|
3363
|
+
attributes: {
|
|
3364
|
+
x: {
|
|
3365
|
+
key: "x",
|
|
3366
|
+
value: pt.x
|
|
3367
|
+
},
|
|
3368
|
+
y: {
|
|
3369
|
+
key: "y",
|
|
3370
|
+
value: pt.y
|
|
3371
|
+
}
|
|
3372
|
+
}
|
|
3373
|
+
}))
|
|
3374
|
+
});
|
|
3375
|
+
case "cubicBezTo": return new BuilderElement({
|
|
3376
|
+
name: "a:cubicBezTo",
|
|
3377
|
+
children: cmd.points.map((pt) => new BuilderElement({
|
|
3378
|
+
name: "a:pt",
|
|
3379
|
+
attributes: {
|
|
3380
|
+
x: {
|
|
3381
|
+
key: "x",
|
|
3382
|
+
value: pt.x
|
|
3383
|
+
},
|
|
3384
|
+
y: {
|
|
3385
|
+
key: "y",
|
|
3386
|
+
value: pt.y
|
|
3387
|
+
}
|
|
3388
|
+
}
|
|
3389
|
+
}))
|
|
3390
|
+
});
|
|
3391
|
+
case "close": return new BuilderElement({ name: "a:close" });
|
|
3392
|
+
}
|
|
3393
|
+
};
|
|
3394
|
+
const createPath = (options) => {
|
|
3395
|
+
const attrs = {};
|
|
3396
|
+
if (options.w !== void 0) attrs.w = {
|
|
3397
|
+
key: "w",
|
|
3398
|
+
value: options.w
|
|
3399
|
+
};
|
|
3400
|
+
if (options.h !== void 0) attrs.h = {
|
|
3401
|
+
key: "h",
|
|
3402
|
+
value: options.h
|
|
3403
|
+
};
|
|
3404
|
+
if (options.fill !== void 0) attrs.fill = {
|
|
3405
|
+
key: "fill",
|
|
3406
|
+
value: options.fill
|
|
3407
|
+
};
|
|
3408
|
+
if (options.stroke !== void 0) attrs.stroke = {
|
|
3409
|
+
key: "stroke",
|
|
3410
|
+
value: options.stroke
|
|
3411
|
+
};
|
|
3412
|
+
if (options.extrusionOk !== void 0) attrs.extrusionOk = {
|
|
3413
|
+
key: "extrusionOk",
|
|
3414
|
+
value: options.extrusionOk
|
|
3415
|
+
};
|
|
3416
|
+
return new BuilderElement({
|
|
3417
|
+
name: "a:path",
|
|
3418
|
+
attributes: Object.keys(attrs).length > 0 ? attrs : void 0,
|
|
3419
|
+
children: options.commands.map(createPathCommand)
|
|
3420
|
+
});
|
|
3421
|
+
};
|
|
3422
|
+
const createAdjustHandlePos = (position) => new BuilderElement({
|
|
3423
|
+
name: "a:pos",
|
|
3424
|
+
attributes: {
|
|
3425
|
+
x: {
|
|
3426
|
+
key: "x",
|
|
3427
|
+
value: position.x
|
|
3428
|
+
},
|
|
3429
|
+
y: {
|
|
3430
|
+
key: "y",
|
|
3431
|
+
value: position.y
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
});
|
|
3435
|
+
const createXYAdjustHandle = (handle) => {
|
|
3436
|
+
const attrs = {};
|
|
3437
|
+
if (handle.guideRefX !== void 0) attrs.gdRefX = {
|
|
3438
|
+
key: "gdRefX",
|
|
3439
|
+
value: handle.guideRefX
|
|
3440
|
+
};
|
|
3441
|
+
if (handle.minX !== void 0) attrs.minX = {
|
|
3442
|
+
key: "minX",
|
|
3443
|
+
value: handle.minX
|
|
3444
|
+
};
|
|
3445
|
+
if (handle.maxX !== void 0) attrs.maxX = {
|
|
3446
|
+
key: "maxX",
|
|
3447
|
+
value: handle.maxX
|
|
3448
|
+
};
|
|
3449
|
+
if (handle.guideRefY !== void 0) attrs.gdRefY = {
|
|
3450
|
+
key: "gdRefY",
|
|
3451
|
+
value: handle.guideRefY
|
|
3452
|
+
};
|
|
3453
|
+
if (handle.minY !== void 0) attrs.minY = {
|
|
3454
|
+
key: "minY",
|
|
3455
|
+
value: handle.minY
|
|
3456
|
+
};
|
|
3457
|
+
if (handle.maxY !== void 0) attrs.maxY = {
|
|
3458
|
+
key: "maxY",
|
|
3459
|
+
value: handle.maxY
|
|
3460
|
+
};
|
|
3461
|
+
return new BuilderElement({
|
|
3462
|
+
name: "a:ahXY",
|
|
3463
|
+
attributes: Object.keys(attrs).length > 0 ? attrs : void 0,
|
|
3464
|
+
children: [createAdjustHandlePos(handle.position)]
|
|
3465
|
+
});
|
|
3466
|
+
};
|
|
3467
|
+
const createPolarAdjustHandle = (handle) => {
|
|
3468
|
+
const attrs = {};
|
|
3469
|
+
if (handle.guideRefRadius !== void 0) attrs.gdRefR = {
|
|
3470
|
+
key: "gdRefR",
|
|
3471
|
+
value: handle.guideRefRadius
|
|
3472
|
+
};
|
|
3473
|
+
if (handle.minRadius !== void 0) attrs.minR = {
|
|
3474
|
+
key: "minR",
|
|
3475
|
+
value: handle.minRadius
|
|
3476
|
+
};
|
|
3477
|
+
if (handle.maxRadius !== void 0) attrs.maxR = {
|
|
3478
|
+
key: "maxR",
|
|
3479
|
+
value: handle.maxRadius
|
|
3480
|
+
};
|
|
3481
|
+
if (handle.guideRefAngle !== void 0) attrs.gdRefAng = {
|
|
3482
|
+
key: "gdRefAng",
|
|
3483
|
+
value: handle.guideRefAngle
|
|
3484
|
+
};
|
|
3485
|
+
if (handle.minAngle !== void 0) attrs.minAng = {
|
|
3486
|
+
key: "minAng",
|
|
3487
|
+
value: handle.minAngle
|
|
3488
|
+
};
|
|
3489
|
+
if (handle.maxAngle !== void 0) attrs.maxAng = {
|
|
3490
|
+
key: "maxAng",
|
|
3491
|
+
value: handle.maxAngle
|
|
3492
|
+
};
|
|
3493
|
+
return new BuilderElement({
|
|
3494
|
+
name: "a:ahPolar",
|
|
3495
|
+
attributes: Object.keys(attrs).length > 0 ? attrs : void 0,
|
|
3496
|
+
children: [createAdjustHandlePos(handle.position)]
|
|
3497
|
+
});
|
|
3498
|
+
};
|
|
3499
|
+
const createConnectionSite = (site) => new BuilderElement({
|
|
3500
|
+
name: "a:cxn",
|
|
3501
|
+
attributes: { ang: {
|
|
3502
|
+
key: "ang",
|
|
3503
|
+
value: site.angle
|
|
3504
|
+
} },
|
|
3505
|
+
children: [createAdjustHandlePos(site.position)]
|
|
3506
|
+
});
|
|
3507
|
+
const createGeomRect = (rect) => new BuilderElement({
|
|
3508
|
+
name: "a:rect",
|
|
3509
|
+
attributes: {
|
|
3510
|
+
l: {
|
|
3511
|
+
key: "l",
|
|
3512
|
+
value: rect.left
|
|
3513
|
+
},
|
|
3514
|
+
t: {
|
|
3515
|
+
key: "t",
|
|
3516
|
+
value: rect.top
|
|
3517
|
+
},
|
|
3518
|
+
r: {
|
|
3519
|
+
key: "r",
|
|
3520
|
+
value: rect.right
|
|
3521
|
+
},
|
|
3522
|
+
b: {
|
|
3523
|
+
key: "b",
|
|
3524
|
+
value: rect.bottom
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
});
|
|
3528
|
+
/**
|
|
3529
|
+
* Creates a custom 2D geometry element (a:custGeom).
|
|
3530
|
+
*
|
|
3531
|
+
* @example
|
|
3532
|
+
* ```typescript
|
|
3533
|
+
* // Diamond shape
|
|
3534
|
+
* const geom = createCustomGeometry({
|
|
3535
|
+
* pathList: [{
|
|
3536
|
+
* commands: [
|
|
3537
|
+
* { command: "moveTo", point: { x: "5000000", y: "0" } },
|
|
3538
|
+
* { command: "lineTo", point: { x: "10000000", y: "5000000" } },
|
|
3539
|
+
* { command: "lineTo", point: { x: "5000000", y: "10000000" } },
|
|
3540
|
+
* { command: "lineTo", point: { x: "0", y: "5000000" } },
|
|
3541
|
+
* { command: "close" },
|
|
3542
|
+
* ],
|
|
3543
|
+
* }],
|
|
3544
|
+
* textRect: { left: "2000000", top: "2000000", right: "8000000", bottom: "8000000" },
|
|
3545
|
+
* });
|
|
3546
|
+
* ```
|
|
3547
|
+
*/
|
|
3548
|
+
const createCustomGeometry = (options) => {
|
|
3549
|
+
const children = [];
|
|
3550
|
+
if (options.adjustmentValues) children.push(createGuideList("a:avLst", options.adjustmentValues));
|
|
3551
|
+
if (options.guides) children.push(createGuideList("a:gdLst", options.guides));
|
|
3552
|
+
if (options.adjustHandles && options.adjustHandles.length > 0) children.push(new BuilderElement({
|
|
3553
|
+
name: "a:ahLst",
|
|
3554
|
+
children: options.adjustHandles.map((h) => h.type === "xy" ? createXYAdjustHandle(h) : createPolarAdjustHandle(h))
|
|
3555
|
+
}));
|
|
3556
|
+
if (options.connectionSites && options.connectionSites.length > 0) children.push(new BuilderElement({
|
|
3557
|
+
name: "a:cxnLst",
|
|
3558
|
+
children: options.connectionSites.map(createConnectionSite)
|
|
3559
|
+
}));
|
|
3560
|
+
if (options.textRect) children.push(createGeomRect(options.textRect));
|
|
3561
|
+
children.push(new BuilderElement({
|
|
3562
|
+
name: "a:pathLst",
|
|
3563
|
+
children: options.pathList.map(createPath)
|
|
3564
|
+
}));
|
|
3565
|
+
return new BuilderElement({
|
|
3566
|
+
name: "a:custGeom",
|
|
3567
|
+
children
|
|
3568
|
+
});
|
|
3569
|
+
};
|
|
3570
|
+
//#endregion
|
|
3571
|
+
//#region src/drawingml/blip/blip-extentions.ts
|
|
3572
|
+
/**
|
|
3573
|
+
* Blip extensions module for SVG support.
|
|
3574
|
+
*
|
|
3575
|
+
* This module provides extension elements that enable SVG image support
|
|
3576
|
+
* within blip elements using Office-specific extensions.
|
|
3577
|
+
*
|
|
3578
|
+
* Reference: http://officeopenxml.com/drwPic.php
|
|
3579
|
+
*
|
|
3580
|
+
* @module
|
|
3581
|
+
*/
|
|
3582
|
+
/**
|
|
3583
|
+
* Creates an SVG blip element for embedding SVG images.
|
|
3584
|
+
*
|
|
3585
|
+
* This element is a Microsoft Office extension that allows SVG images
|
|
3586
|
+
* to be referenced within a blip.
|
|
3587
|
+
*
|
|
3588
|
+
* @param svgReferenceId - The reference ID for the SVG image
|
|
3589
|
+
* @returns An XML component representing the SVG blip element
|
|
3590
|
+
* @internal
|
|
3591
|
+
*/
|
|
3592
|
+
const createSvgBlip = (svgReferenceId) => new BuilderElement({
|
|
3593
|
+
attributes: {
|
|
3594
|
+
asvg: {
|
|
3595
|
+
key: "xmlns:asvg",
|
|
3596
|
+
value: "http://schemas.microsoft.com/office/drawing/2016/SVG/main"
|
|
3597
|
+
},
|
|
3598
|
+
embed: {
|
|
3599
|
+
key: "r:embed",
|
|
3600
|
+
value: `{${svgReferenceId}}`
|
|
3601
|
+
}
|
|
3602
|
+
},
|
|
3603
|
+
name: "asvg:svgBlip"
|
|
3604
|
+
});
|
|
3605
|
+
/**
|
|
3606
|
+
* Creates an extension element for SVG support.
|
|
3607
|
+
*
|
|
3608
|
+
* This element wraps the SVG blip extension with the appropriate URI
|
|
3609
|
+
* to identify it as an SVG extension.
|
|
3610
|
+
*
|
|
3611
|
+
* @param svgReferenceId - The reference ID for the SVG image
|
|
3612
|
+
* @returns An XML component representing the extension element
|
|
3613
|
+
* @internal
|
|
3614
|
+
*/
|
|
3615
|
+
const createExtention = (svgReferenceId) => new BuilderElement({
|
|
3616
|
+
attributes: { uri: {
|
|
3617
|
+
key: "uri",
|
|
3618
|
+
value: "{96DAC541-7B7A-43D3-8B79-37D633B846F1}"
|
|
3619
|
+
} },
|
|
3620
|
+
children: [createSvgBlip(svgReferenceId)],
|
|
3621
|
+
name: "a:ext"
|
|
3622
|
+
});
|
|
3623
|
+
/**
|
|
3624
|
+
* Creates an extension list for SVG images.
|
|
3625
|
+
*
|
|
3626
|
+
* This element contains the extensions needed to embed SVG images
|
|
3627
|
+
* within a blip. It wraps the SVG-specific extension elements.
|
|
3628
|
+
*
|
|
3629
|
+
* ## XSD Schema
|
|
3630
|
+
* ```xml
|
|
3631
|
+
* <xsd:complexType name="CT_OfficeArtExtensionList">
|
|
3632
|
+
* <xsd:sequence>
|
|
3633
|
+
* <xsd:element name="ext" type="CT_OfficeArtExtension" minOccurs="0" maxOccurs="unbounded"/>
|
|
3634
|
+
* </xsd:sequence>
|
|
3635
|
+
* </xsd:complexType>
|
|
3636
|
+
* ```
|
|
3637
|
+
*
|
|
3638
|
+
* @param svgReferenceId - The reference ID for the SVG image
|
|
3639
|
+
* @returns An XML component representing the extension list
|
|
3640
|
+
*/
|
|
3641
|
+
const createExtentionList = (svgReferenceId) => new BuilderElement({
|
|
3642
|
+
children: [createExtention(svgReferenceId)],
|
|
3643
|
+
name: "a:extLst"
|
|
3644
|
+
});
|
|
3645
|
+
//#endregion
|
|
3646
|
+
//#region src/drawingml/blip/blip.ts
|
|
3647
|
+
/**
|
|
3648
|
+
* Blip (Binary Large Image or Picture) module for DrawingML.
|
|
3649
|
+
*
|
|
3650
|
+
* This module provides the blip element that references the actual
|
|
3651
|
+
* image data within a picture.
|
|
3652
|
+
*
|
|
3653
|
+
* Reference: http://officeopenxml.com/drwPic.php
|
|
3654
|
+
*
|
|
3655
|
+
* @module
|
|
3656
|
+
*/
|
|
3657
|
+
/**
|
|
3658
|
+
* Creates a blip element for an image.
|
|
3659
|
+
*
|
|
3660
|
+
* A blip references the actual image data stored in the document package
|
|
3661
|
+
* through a relationship ID. For SVG images, it includes extensions that
|
|
3662
|
+
* reference the SVG data.
|
|
3663
|
+
*
|
|
3664
|
+
* Reference: http://officeopenxml.com/drwPic.php
|
|
3665
|
+
*
|
|
3666
|
+
* ## XSD Schema
|
|
3667
|
+
* ```xml
|
|
3668
|
+
* <xsd:complexType name="CT_Blip">
|
|
3669
|
+
* <xsd:sequence>
|
|
3670
|
+
* <xsd:choice minOccurs="0" maxOccurs="unbounded">
|
|
3671
|
+
* <xsd:element name="alphaBiLevel" type="CT_AlphaBiLevelEffect"/>
|
|
3672
|
+
* <xsd:element name="alphaCeiling" type="CT_AlphaCeilingEffect"/>
|
|
3673
|
+
* <xsd:element name="alphaFloor" type="CT_AlphaFloorEffect"/>
|
|
3674
|
+
* <xsd:element name="alphaInv" type="CT_AlphaInverseEffect"/>
|
|
3675
|
+
* <xsd:element name="alphaMod" type="CT_AlphaModulateEffect"/>
|
|
3676
|
+
* <xsd:element name="alphaModFix" type="CT_AlphaModulateFixedEffect"/>
|
|
3677
|
+
* <xsd:element name="alphaRepl" type="CT_AlphaReplaceEffect"/>
|
|
3678
|
+
* <xsd:element name="biLevel" type="CT_BiLevelEffect"/>
|
|
3679
|
+
* <xsd:element name="blur" type="CT_BlurEffect"/>
|
|
3680
|
+
* <xsd:element name="clrChange" type="CT_ColorChangeEffect"/>
|
|
3681
|
+
* <xsd:element name="clrRepl" type="CT_ColorReplaceEffect"/>
|
|
3682
|
+
* <xsd:element name="duotone" type="CT_DuotoneEffect"/>
|
|
3683
|
+
* <xsd:element name="fillOverlay" type="CT_FillOverlayEffect"/>
|
|
3684
|
+
* <xsd:element name="grayscl" type="CT_GrayscaleEffect"/>
|
|
3685
|
+
* <xsd:element name="hsl" type="CT_HSLEffect"/>
|
|
3686
|
+
* <xsd:element name="lum" type="CT_LuminanceEffect"/>
|
|
3687
|
+
* <xsd:element name="tint" type="CT_TintEffect"/>
|
|
3688
|
+
* </xsd:choice>
|
|
3689
|
+
* <xsd:element name="extLst" type="CT_OfficeArtExtensionList" minOccurs="0"/>
|
|
3690
|
+
* </xsd:sequence>
|
|
3691
|
+
* <xsd:attribute ref="r:embed"/>
|
|
3692
|
+
* <xsd:attribute ref="r:link"/>
|
|
3693
|
+
* <xsd:attribute name="cstate" type="ST_BlipCompression"/>
|
|
3694
|
+
* </xsd:complexType>
|
|
3695
|
+
* ```
|
|
3696
|
+
*
|
|
3697
|
+
* @param options - Blip options including referenceId and type
|
|
3698
|
+
* @param blipEffects - Optional blip effects (brightness, contrast, etc.)
|
|
3699
|
+
* @returns An XML component representing the blip element
|
|
3700
|
+
*/
|
|
3701
|
+
const createBlip = (options, blipEffects) => {
|
|
3702
|
+
const children = [];
|
|
3703
|
+
if (blipEffects) children.push(...createBlipEffects(blipEffects));
|
|
3704
|
+
if (options.type === "svg" && options.fallbackFileName) children.push(createExtentionList(options.referenceId));
|
|
3705
|
+
return new BuilderElement({
|
|
3706
|
+
attributes: {
|
|
3707
|
+
cstate: {
|
|
3708
|
+
key: "cstate",
|
|
3709
|
+
value: "none"
|
|
3710
|
+
},
|
|
3711
|
+
embed: {
|
|
3712
|
+
key: "r:embed",
|
|
3713
|
+
value: `{${options.type === "svg" && options.fallbackFileName ? options.fallbackFileName : options.referenceId}}`
|
|
3714
|
+
}
|
|
3715
|
+
},
|
|
3716
|
+
children,
|
|
3717
|
+
name: "a:blip"
|
|
3718
|
+
});
|
|
3719
|
+
};
|
|
3720
|
+
//#endregion
|
|
3721
|
+
//#region src/drawingml/blip/blip-fill.ts
|
|
3722
|
+
/**
|
|
3723
|
+
* Blip fill module for DrawingML pictures.
|
|
3724
|
+
*
|
|
3725
|
+
* This module defines how an image (blip) fills a picture shape,
|
|
3726
|
+
* including stretching and cropping options.
|
|
3727
|
+
*
|
|
3728
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_BlipFillProperties
|
|
3729
|
+
*
|
|
3730
|
+
* @module
|
|
3731
|
+
*/
|
|
3732
|
+
/**
|
|
3733
|
+
* Creates a blip fill element.
|
|
3734
|
+
*
|
|
3735
|
+
* This element specifies the type of fill used for a picture. It contains the blip (image)
|
|
3736
|
+
* reference, an optional source rectangle for cropping, and the fill mode (typically stretch).
|
|
3737
|
+
*
|
|
3738
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_BlipFillProperties
|
|
3739
|
+
*
|
|
3740
|
+
* ## XSD Schema
|
|
3741
|
+
* ```xml
|
|
3742
|
+
* <xsd:complexType name="CT_BlipFillProperties">
|
|
3743
|
+
* <xsd:sequence>
|
|
3744
|
+
* <xsd:element name="blip" type="CT_Blip" minOccurs="0" maxOccurs="1"/>
|
|
3745
|
+
* <xsd:element name="srcRect" type="CT_RelativeRect" minOccurs="0" maxOccurs="1"/>
|
|
3746
|
+
* <xsd:group ref="EG_FillModeProperties" minOccurs="0" maxOccurs="1"/>
|
|
3747
|
+
* </xsd:sequence>
|
|
3748
|
+
* <xsd:attribute name="dpi" type="xsd:unsignedInt" use="optional"/>
|
|
3749
|
+
* <xsd:attribute name="rotWithShape" type="xsd:boolean" use="optional"/>
|
|
3750
|
+
* </xsd:complexType>
|
|
3751
|
+
* ```
|
|
3752
|
+
*
|
|
3753
|
+
* @param blipOptions - Blip options including referenceId and type
|
|
3754
|
+
* @param fillOptions - Optional blip fill options
|
|
3755
|
+
*/
|
|
3756
|
+
const createBlipFill = (blipOptions, fillOptions) => {
|
|
3757
|
+
const children = [];
|
|
3758
|
+
children.push(createBlip(blipOptions, fillOptions?.blipEffects));
|
|
3759
|
+
children.push(createSourceRectangle(fillOptions?.srcRect));
|
|
3760
|
+
if (fillOptions?.tile) children.push(createTileInfo(fillOptions.tile));
|
|
3761
|
+
else children.push(new Stretch());
|
|
3762
|
+
const attributes = {};
|
|
3763
|
+
if (fillOptions?.dpi !== void 0) attributes.dpi = {
|
|
3764
|
+
key: "dpi",
|
|
3765
|
+
value: fillOptions.dpi
|
|
3766
|
+
};
|
|
3767
|
+
if (fillOptions?.rotWithShape !== void 0) attributes.rotWithShape = {
|
|
3768
|
+
key: "rotWithShape",
|
|
3769
|
+
value: fillOptions.rotWithShape ? 1 : 0
|
|
3770
|
+
};
|
|
3771
|
+
return new BuilderElement({
|
|
3772
|
+
attributes: Object.keys(attributes).length > 0 ? attributes : void 0,
|
|
3773
|
+
children,
|
|
3774
|
+
name: "pic:blipFill"
|
|
3775
|
+
});
|
|
3776
|
+
};
|
|
3777
|
+
//#endregion
|
|
3778
|
+
//#region src/drawingml/transform.ts
|
|
3779
|
+
/**
|
|
3780
|
+
* 2D transform for DrawingML shapes.
|
|
3781
|
+
*
|
|
3782
|
+
* This module provides factory functions for creating transform elements
|
|
3783
|
+
* (a:xfrm) used in shape properties, picture properties, and group shapes.
|
|
3784
|
+
*
|
|
3785
|
+
* Reference: ISO/IEC 29500-4, dml-main.xsd, CT_Transform2D / CT_GroupTransform2D
|
|
3786
|
+
*
|
|
3787
|
+
* @module
|
|
3788
|
+
*/
|
|
3789
|
+
function buildXfrmAttrs(options) {
|
|
3790
|
+
const attrs = {};
|
|
3791
|
+
if (options.flipHorizontal !== void 0) attrs.flipH = {
|
|
3792
|
+
key: "flipH",
|
|
3793
|
+
value: options.flipHorizontal
|
|
3794
|
+
};
|
|
3795
|
+
if (options.flipVertical !== void 0) attrs.flipV = {
|
|
3796
|
+
key: "flipV",
|
|
3797
|
+
value: options.flipVertical
|
|
3798
|
+
};
|
|
3799
|
+
if (options.rotation !== void 0) attrs.rot = {
|
|
3800
|
+
key: "rot",
|
|
3801
|
+
value: options.rotation
|
|
3802
|
+
};
|
|
3803
|
+
return Object.keys(attrs).length > 0 ? attrs : void 0;
|
|
3804
|
+
}
|
|
3805
|
+
/**
|
|
3806
|
+
* Creates a 2D transform element (a:xfrm).
|
|
3807
|
+
*
|
|
3808
|
+
* @param options - Transform options including position, size, rotation, and flip.
|
|
3809
|
+
* @param elementName - Element name, defaults to "a:xfrm".
|
|
3810
|
+
*/
|
|
3811
|
+
const createTransform2D = (options, elementName = "a:xfrm") => {
|
|
3812
|
+
const children = [];
|
|
3813
|
+
if (options.x !== void 0 || options.y !== void 0) children.push(new BuilderElement({
|
|
3814
|
+
name: "a:off",
|
|
3815
|
+
attributes: {
|
|
3816
|
+
x: {
|
|
3817
|
+
key: "x",
|
|
3818
|
+
value: options.x ?? 0
|
|
3819
|
+
},
|
|
3820
|
+
y: {
|
|
3821
|
+
key: "y",
|
|
3822
|
+
value: options.y ?? 0
|
|
3823
|
+
}
|
|
3824
|
+
}
|
|
3825
|
+
}));
|
|
3826
|
+
if (options.width !== void 0 || options.height !== void 0) children.push(new BuilderElement({
|
|
3827
|
+
name: "a:ext",
|
|
3828
|
+
attributes: {
|
|
3829
|
+
cx: {
|
|
3830
|
+
key: "cx",
|
|
3831
|
+
value: options.width ?? 0
|
|
3832
|
+
},
|
|
3833
|
+
cy: {
|
|
3834
|
+
key: "cy",
|
|
3835
|
+
value: options.height ?? 0
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3838
|
+
}));
|
|
3839
|
+
return new BuilderElement({
|
|
3840
|
+
name: elementName,
|
|
3841
|
+
attributes: buildXfrmAttrs(options),
|
|
3842
|
+
children: children.length > 0 ? children : void 0
|
|
3843
|
+
});
|
|
3844
|
+
};
|
|
3845
|
+
/**
|
|
3846
|
+
* Creates a group transform element (a:xfrm with chOff/chExt children).
|
|
3847
|
+
*/
|
|
3848
|
+
const createGroupTransform2D = (options, elementName = "a:xfrm") => {
|
|
3849
|
+
const base = createTransform2D(options, elementName);
|
|
3850
|
+
base["root"].push(new BuilderElement({
|
|
3851
|
+
name: "a:chOff",
|
|
3852
|
+
attributes: {
|
|
3853
|
+
x: {
|
|
3854
|
+
key: "x",
|
|
3855
|
+
value: options.childOffsetX ?? 0
|
|
3856
|
+
},
|
|
3857
|
+
y: {
|
|
3858
|
+
key: "y",
|
|
3859
|
+
value: options.childOffsetY ?? 0
|
|
3860
|
+
}
|
|
3861
|
+
}
|
|
3862
|
+
}));
|
|
3863
|
+
base["root"].push(new BuilderElement({
|
|
3864
|
+
name: "a:chExt",
|
|
3865
|
+
attributes: {
|
|
3866
|
+
cx: {
|
|
3867
|
+
key: "cx",
|
|
3868
|
+
value: options.childExtentWidth ?? 0
|
|
3869
|
+
},
|
|
3870
|
+
cy: {
|
|
3871
|
+
key: "cy",
|
|
3872
|
+
value: options.childExtentHeight ?? 0
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
}));
|
|
3876
|
+
return base;
|
|
3877
|
+
};
|
|
3878
|
+
//#endregion
|
|
3879
|
+
//#region src/drawingml/media/transformation.ts
|
|
3880
|
+
/**
|
|
3881
|
+
* Media transformation utilities for DrawingML.
|
|
3882
|
+
*
|
|
3883
|
+
* Converts user-facing transformation options (pixels) to internal
|
|
3884
|
+
* transformation data (pixels + EMUs).
|
|
3885
|
+
*
|
|
3886
|
+
* @module
|
|
3887
|
+
*/
|
|
3888
|
+
/**
|
|
3889
|
+
* Converts user-facing transformation options (pixels) to internal
|
|
3890
|
+
* transformation data (pixels + EMUs).
|
|
3891
|
+
*
|
|
3892
|
+
* @param options - User-facing transformation in pixels
|
|
3893
|
+
* @returns Internal transformation data with both pixel and EMU values
|
|
3894
|
+
*/
|
|
3895
|
+
const createTransformation = (options) => ({
|
|
3896
|
+
emus: {
|
|
3897
|
+
x: convertPixelsToEmu(options.width),
|
|
3898
|
+
y: convertPixelsToEmu(options.height)
|
|
3899
|
+
},
|
|
3900
|
+
flip: options.flip,
|
|
3901
|
+
offset: {
|
|
3902
|
+
emus: {
|
|
3903
|
+
x: convertPixelsToEmu(options.offset?.left ?? 0),
|
|
3904
|
+
y: convertPixelsToEmu(options.offset?.top ?? 0)
|
|
3905
|
+
},
|
|
3906
|
+
pixels: {
|
|
3907
|
+
x: Math.round(options.offset?.left ?? 0),
|
|
3908
|
+
y: Math.round(options.offset?.top ?? 0)
|
|
3909
|
+
}
|
|
3910
|
+
},
|
|
3911
|
+
pixels: {
|
|
3912
|
+
x: Math.round(options.width),
|
|
3913
|
+
y: Math.round(options.height)
|
|
3914
|
+
},
|
|
3915
|
+
rotation: options.rotation ? options.rotation * 6e4 : void 0
|
|
3916
|
+
});
|
|
3917
|
+
//#endregion
|
|
3918
|
+
export { BevelPresetType, BlendMode, CompoundLine, LineCap, LineEndLength, LineEndType, LineEndWidth, LineJoin, PathShadeType, PenAlignment, PresetColor, PresetDash, PresetGeometry, PresetGeometryAttributes, PresetMaterialType, PresetPattern, PresetShadowVal, RectAlignment, SchemeColor, Stretch, SystemColor, TileAlignment, TileFlipMode, buildFill, createAdjustmentValues, createBevel, createBlip, createBlipEffects, createBlipFill, createBottomBevel, createColorElement, createColorTransforms, createCustomDash, createCustomGeometry, createEffectDag, createEffectList, createExtentionList, createFillOverlayEffect, createGlowEffect, createGradientFill, createGradientStop, createGroupFill, createGroupTransform2D, createHslColor, createInnerShadowEffect, createLineEnd, createNoFill, createOuterShadowEffect, createOutline, createPatternFill, createPresetColor, createPresetShadowEffect, createReflectionEffect, createRgbColor, createScRgbColor, createScene3D, createSchemeColor, createShape3D, createSoftEdgeEffect, createSolidFill, createSourceRectangle, createSystemColor, createTileInfo, createTransform2D, createTransformation, extractBlipFillMedia };
|