* Resolve overall image opacity from OOXML blip alpha modifiers. * * Supported today: * - alphaModFix amt="N" * - alphaMod val="N" * - alphaOff val="N"
(blip: SafeXmlNode)
| 188 | * - alphaOff val="N" |
| 189 | */ |
| 190 | function resolveBlipOpacity(blip: SafeXmlNode): number { |
| 191 | let alpha = 1 |
| 192 | |
| 193 | const alphaModFix = blip.child('alphaModFix') |
| 194 | if (alphaModFix.exists()) { |
| 195 | alpha *= (alphaModFix.numAttr('amt') ?? 100000) / 100000 |
| 196 | } |
| 197 | |
| 198 | const alphaMod = blip.child('alphaMod') |
| 199 | if (alphaMod.exists()) { |
| 200 | alpha *= (alphaMod.numAttr('val') ?? 100000) / 100000 |
| 201 | } |
| 202 | |
| 203 | const alphaOff = blip.child('alphaOff') |
| 204 | if (alphaOff.exists()) { |
| 205 | alpha += (alphaOff.numAttr('val') ?? 0) / 100000 |
| 206 | } |
| 207 | |
| 208 | return Math.max(0, Math.min(1, alpha)) |
| 209 | } |
| 210 | |
| 211 | /** |
| 212 | * Render a video element inside the wrapper. |
no test coverage detected