MCPcopy
hub / github.com/THU-MAIC/OpenMAIC / getBgGradientFill

Function getBgGradientFill

packages/@openmaic/importer/src1/fill.js:237–270  ·  view source on GitHub ↗
(bgPr, phClr, slideMasterContent, warpObj)

Source from the content-addressed store, hash-verified

235}
236
237export function getBgGradientFill(bgPr, phClr, slideMasterContent, warpObj) {
238 if (bgPr) {
239 const grdFill = bgPr['a:gradFill']
240 const gsLst = grdFill['a:gsLst']['a:gs']
241 const colors = []
242
243 for (let i = 0; i < gsLst.length; i++) {
244 const lo_color = getSolidFill(gsLst[i], slideMasterContent['p:sldMaster']['p:clrMap']['attrs'], phClr, warpObj)
245 const pos = getTextByPathList(gsLst[i], ['attrs', 'pos'])
246
247 colors[i] = {
248 pos: pos ? (pos / 1000 + '%') : '',
249 color: lo_color,
250 }
251 }
252 const lin = grdFill['a:lin']
253 let rot = 0
254 let pathType = 'line'
255 if (lin) rot = angleToDegrees(lin['attrs']['ang']) + 0
256 else {
257 const path = grdFill['a:path']
258 if (path && path['attrs'] && path['attrs']['path']) pathType = path['attrs']['path']
259 }
260 return {
261 rot,
262 path: pathType,
263 colors: colors.sort((a, b) => parseInt(a.pos) - parseInt(b.pos)),
264 }
265 }
266 else if (phClr) {
267 return phClr.indexOf('#') === -1 ? `#${phClr}` : phClr
268 }
269 return null
270}
271
272export async function getSlideBackgroundFill(warpObj) {
273 const slideContent = warpObj['slideContent']

Callers 1

getSlideBackgroundFillFunction · 0.85

Calls 3

getTextByPathListFunction · 0.90
angleToDegreesFunction · 0.90
getSolidFillFunction · 0.85

Tested by

no test coverage detected