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

Function getSolidFill

packages/@openmaic/importer/src1/fill.js:711–791  ·  view source on GitHub ↗
(solidFill, clrMap, phClr, warpObj)

Source from the content-addressed store, hash-verified

709}
710
711export function getSolidFill(solidFill, clrMap, phClr, warpObj) {
712 if (!solidFill) return ''
713
714 let color = ''
715 let clrNode
716
717 if (solidFill['a:srgbClr']) {
718 clrNode = solidFill['a:srgbClr']
719 color = getTextByPathList(clrNode, ['attrs', 'val'])
720 }
721 else if (solidFill['a:schemeClr']) {
722 clrNode = solidFill['a:schemeClr']
723 const schemeClr = 'a:' + getTextByPathList(clrNode, ['attrs', 'val'])
724 color = getSchemeColorFromTheme(schemeClr, warpObj, clrMap, phClr) || ''
725 }
726 else if (solidFill['a:scrgbClr']) {
727 clrNode = solidFill['a:scrgbClr']
728 const defBultColorVals = clrNode['attrs']
729 const red = (defBultColorVals['r'].indexOf('%') !== -1) ? defBultColorVals['r'].split('%').shift() : defBultColorVals['r']
730 const green = (defBultColorVals['g'].indexOf('%') !== -1) ? defBultColorVals['g'].split('%').shift() : defBultColorVals['g']
731 const blue = (defBultColorVals['b'].indexOf('%') !== -1) ? defBultColorVals['b'].split('%').shift() : defBultColorVals['b']
732 color = toHex(255 * (Number(red) / 100)) + toHex(255 * (Number(green) / 100)) + toHex(255 * (Number(blue) / 100))
733 }
734 else if (solidFill['a:prstClr']) {
735 clrNode = solidFill['a:prstClr']
736 const prstClr = getTextByPathList(clrNode, ['attrs', 'val'])
737 color = getColorName2Hex(prstClr)
738 }
739 else if (solidFill['a:hslClr']) {
740 clrNode = solidFill['a:hslClr']
741 const defBultColorVals = clrNode['attrs']
742 const hue = Number(defBultColorVals['hue']) / 100000
743 const sat = Number((defBultColorVals['sat'].indexOf('%') !== -1) ? defBultColorVals['sat'].split('%').shift() : defBultColorVals['sat']) / 100
744 const lum = Number((defBultColorVals['lum'].indexOf('%') !== -1) ? defBultColorVals['lum'].split('%').shift() : defBultColorVals['lum']) / 100
745 const hsl2rgb = hslToRgb(hue, sat, lum)
746 color = toHex(hsl2rgb.r) + toHex(hsl2rgb.g) + toHex(hsl2rgb.b)
747 }
748 else if (solidFill['a:sysClr']) {
749 clrNode = solidFill['a:sysClr']
750 const sysClr = getTextByPathList(clrNode, ['attrs', 'lastClr'])
751 if (sysClr) color = sysClr
752 }
753
754 let isAlpha = false
755 const alpha = parseInt(getTextByPathList(clrNode, ['a:alpha', 'attrs', 'val'])) / 100000
756 if (!isNaN(alpha)) {
757 const al_color = tinycolor(color)
758 al_color.setAlpha(alpha)
759 color = al_color.toHex8()
760 isAlpha = true
761 }
762
763 const hueMod = parseInt(getTextByPathList(clrNode, ['a:hueMod', 'attrs', 'val'])) / 100000
764 if (!isNaN(hueMod)) {
765 color = applyHueMod(color, hueMod, isAlpha)
766 }
767 const lumMod = parseInt(getTextByPathList(clrNode, ['a:lumMod', 'attrs', 'val'])) / 100000
768 if (!isNaN(lumMod)) {

Callers 11

getTableCellParamsFunction · 0.90
getTableRowParamsFunction · 0.90
genTableFunction · 0.90
getFontColorFunction · 0.90
getShadowFunction · 0.90
getGradientFillFunction · 0.85
getPatternFillFunction · 0.85
getBgGradientFillFunction · 0.85
getSlideBackgroundFillFunction · 0.85
getShapeFillFunction · 0.85
findFillInGroupHierarchyFunction · 0.85

Calls 11

getTextByPathListFunction · 0.90
getSchemeColorFromThemeFunction · 0.90
toHexFunction · 0.90
getColorName2HexFunction · 0.90
hslToRgbFunction · 0.90
applyHueModFunction · 0.90
applyLumModFunction · 0.90
applyLumOffFunction · 0.90
applySatModFunction · 0.90
applyShadeFunction · 0.90
applyTintFunction · 0.90

Tested by

no test coverage detected