(hostEl, ctx, style, x, y, width, height)
| 8770 | // style: {textBackgroundColor, textBorderWidth, textBorderColor, textBorderRadius, text} |
| 8771 | // shape: {x, y, width, height} |
| 8772 | function drawBackground(hostEl, ctx, style, x, y, width, height) { |
| 8773 | var textBackgroundColor = style.textBackgroundColor; |
| 8774 | var textBorderWidth = style.textBorderWidth; |
| 8775 | var textBorderColor = style.textBorderColor; |
| 8776 | var isPlainBg = isString(textBackgroundColor); |
| 8777 | |
| 8778 | setCtx(ctx, 'shadowBlur', style.textBoxShadowBlur || 0); |
| 8779 | setCtx(ctx, 'shadowColor', style.textBoxShadowColor || 'transparent'); |
| 8780 | setCtx(ctx, 'shadowOffsetX', style.textBoxShadowOffsetX || 0); |
| 8781 | setCtx(ctx, 'shadowOffsetY', style.textBoxShadowOffsetY || 0); |
| 8782 | |
| 8783 | if (isPlainBg || (textBorderWidth && textBorderColor)) { |
| 8784 | ctx.beginPath(); |
| 8785 | var textBorderRadius = style.textBorderRadius; |
| 8786 | if (!textBorderRadius) { |
| 8787 | ctx.rect(x, y, width, height); |
| 8788 | } |
| 8789 | else { |
| 8790 | buildPath(ctx, { |
| 8791 | x: x, y: y, width: width, height: height, r: textBorderRadius |
| 8792 | }); |
| 8793 | } |
| 8794 | ctx.closePath(); |
| 8795 | } |
| 8796 | |
| 8797 | if (isPlainBg) { |
| 8798 | setCtx(ctx, 'fillStyle', textBackgroundColor); |
| 8799 | |
| 8800 | if (style.fillOpacity != null) { |
| 8801 | var originalGlobalAlpha = ctx.globalAlpha; |
| 8802 | ctx.globalAlpha = style.fillOpacity * style.opacity; |
| 8803 | ctx.fill(); |
| 8804 | ctx.globalAlpha = originalGlobalAlpha; |
| 8805 | } |
| 8806 | else { |
| 8807 | ctx.fill(); |
| 8808 | } |
| 8809 | } |
| 8810 | else if (isObject$1(textBackgroundColor)) { |
| 8811 | var image = textBackgroundColor.image; |
| 8812 | |
| 8813 | image = createOrUpdateImage( |
| 8814 | image, null, hostEl, onBgImageLoaded, textBackgroundColor |
| 8815 | ); |
| 8816 | if (image && isImageReady(image)) { |
| 8817 | ctx.drawImage(image, x, y, width, height); |
| 8818 | } |
| 8819 | } |
| 8820 | |
| 8821 | if (textBorderWidth && textBorderColor) { |
| 8822 | setCtx(ctx, 'lineWidth', textBorderWidth); |
| 8823 | setCtx(ctx, 'strokeStyle', textBorderColor); |
| 8824 | |
| 8825 | if (style.strokeOpacity != null) { |
| 8826 | var originalGlobalAlpha = ctx.globalAlpha; |
| 8827 | ctx.globalAlpha = style.strokeOpacity * style.opacity; |
| 8828 | ctx.stroke(); |
| 8829 | ctx.globalAlpha = originalGlobalAlpha; |
no test coverage detected