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

Method brush

src/common/overlay/levelRenderer/SmicImage.js:64–176  ·  view source on GitHub ↗

* @function LevelRenderer.Shape.SmicImage.prototype.buildPath * @description 创建图片。 * * @param {CanvasRenderingContext2D} ctx - Context2D 上下文。 * @param {Object} style - style。 *

(ctx, isHighlight, refresh)

Source from the content-addressed store, hash-verified

62 *
63 */
64 brush(ctx, isHighlight, refresh) {
65 if (!this.refOriginalPosition || this.refOriginalPosition.length !== 2) {
66 this.refOriginalPosition = [0, 0];
67 }
68 var __OP = this.refOriginalPosition;
69
70 var style = this.style || {};
71
72 if (isHighlight) {
73 // 根据style扩展默认高亮样式
74 style = this.getHighlightStyle(
75 style, this.highlightStyle || {}
76 );
77 }
78
79 var image = style.image;
80 var me = this;
81
82 if (typeof(image) === 'string') {
83 var src = image;
84 if (this._imageCache[src]) {
85 image = this._imageCache[src];
86 } else {
87 image = new Image();
88 image.onload = function () {
89 image.onload = null;
90 clearTimeout(SmicImage._refreshTimeout);
91 SmicImage._needsRefresh.push(me);
92 // 防止因为缓存短时间内触发多次onload事件
93 SmicImage._refreshTimeout = setTimeout(function () {
94 refresh && refresh(SmicImage._needsRefresh);
95 // 清空 needsRefresh
96 SmicImage._needsRefresh = [];
97 }, 10);
98 };
99
100 image.src = src;
101 this._imageCache[src] = image;
102 }
103 }
104 if (image) {
105 // 图片已经加载完成
106 if (image.nodeName.toUpperCase() == 'IMG') {
107 if (window.ActiveXObject) {
108 if (image.readyState != 'complete') {
109 return;
110 }
111 } else {
112 if (!image.complete) {
113 return;
114 }
115 }
116 }
117 // Else is canvas
118 var width = style.width || image.width;
119 var height = style.height || image.height;
120 var x = style.x + __OP[0];
121 var y = style.y + __OP[1];

Callers

nothing calls this directly

Calls 9

getHighlightStyleMethod · 0.80
pushMethod · 0.80
saveMethod · 0.80
doClipMethod · 0.80
setContextMethod · 0.80
setTransformMethod · 0.80
drawTextMethod · 0.80
restoreMethod · 0.80
refreshFunction · 0.50

Tested by

no test coverage detected