MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / drawBackground

Function drawBackground

libs/echarts/echarts-en.simple.js:8772–8835  ·  view source on GitHub ↗
(hostEl, ctx, style, x, y, width, height)

Source from the content-addressed store, hash-verified

8770// style: {textBackgroundColor, textBorderWidth, textBorderColor, textBorderRadius, text}
8771// shape: {x, y, width, height}
8772function 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;

Callers 3

renderPlainTextFunction · 0.70
drawRichTextFunction · 0.70
placeTokenFunction · 0.70

Calls 6

isStringFunction · 0.70
setCtxFunction · 0.70
buildPathFunction · 0.70
isObject$1Function · 0.70
createOrUpdateImageFunction · 0.70
isImageReadyFunction · 0.70

Tested by

no test coverage detected