MCPcopy Index your code
hub / github.com/simstudioai/sim / renderBgPr

Function renderBgPr

apps/sim/lib/pptx-renderer/renderer/background-renderer.ts:94–138  ·  view source on GitHub ↗

* Render background from bgPr (background properties). * Contains direct fill definitions: solidFill, gradFill, blipFill, etc.

(
  bgPr: SafeXmlNode,
  ctx: RenderContext,
  container: HTMLElement,
  rels?: Map<string, RelEntry>
)

Source from the content-addressed store, hash-verified

92 * Contains direct fill definitions: solidFill, gradFill, blipFill, etc.
93 */
94function renderBgPr(
95 bgPr: SafeXmlNode,
96 ctx: RenderContext,
97 container: HTMLElement,
98 rels?: Map<string, RelEntry>
99): void {
100 // solidFill
101 const solidFill = bgPr.child('solidFill')
102 if (solidFill.exists()) {
103 const { color, alpha } = resolveColor(solidFill, ctx)
104 const hex = color.startsWith('#') ? color : `#${color}`
105 if (alpha < 1) {
106 const { r, g, b } = hexToRgb(hex)
107 container.style.backgroundColor = compositeOnWhite(r, g, b, alpha)
108 } else {
109 container.style.backgroundColor = hex
110 }
111 return
112 }
113
114 // gradFill
115 const gradFill = bgPr.child('gradFill')
116 if (gradFill.exists()) {
117 const css = resolveFill(bgPr, ctx)
118 if (css) {
119 container.style.background = css
120 }
121 return
122 }
123
124 // blipFill (image background)
125 const blipFill = bgPr.child('blipFill')
126 if (blipFill.exists()) {
127 renderBlipBackground(blipFill, ctx, container, rels)
128 return
129 }
130
131 // noFill — still render as white; the slide is a self-contained element
132 // and transparent backgrounds break when embedded in dark containers
133 const noFill = bgPr.child('noFill')
134 if (noFill.exists()) {
135 container.style.backgroundColor = '#FFFFFF'
136 return
137 }
138}
139
140/**
141 * Render background from bgRef (theme format scheme reference).

Callers 1

renderBackgroundFunction · 0.85

Calls 7

resolveColorFunction · 0.90
hexToRgbFunction · 0.90
resolveFillFunction · 0.90
compositeOnWhiteFunction · 0.85
renderBlipBackgroundFunction · 0.85
childMethod · 0.80
existsMethod · 0.80

Tested by

no test coverage detected