MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / setContext

Method setContext

src/common/overlay/levelRenderer/Shape.js:360–384  ·  view source on GitHub ↗

* @function LevelRenderer.Shape.prototype.setContext * @description 设置 fillStyle, strokeStyle, shadow 等通用绘制样式。 * * @param {CanvasRenderingContext2D} ctx - Context2D 上下文。 * @param {Object} style - 样式。 *

(ctx, style)

Source from the content-addressed store, hash-verified

358 *
359 */
360 setContext(ctx, style) {
361 var STYLE_CTX_MAP = [
362 ['color', 'fillStyle'],
363 ['strokeColor', 'strokeStyle'],
364 ['opacity', 'globalAlpha'],
365 ['lineCap', 'lineCap'],
366 ['lineJoin', 'lineJoin'],
367 ['miterLimit', 'miterLimit'],
368 ['lineWidth', 'lineWidth'],
369 ['shadowBlur', 'shadowBlur'],
370 ['shadowColor', 'shadowColor'],
371 ['shadowOffsetX', 'shadowOffsetX'],
372 ['shadowOffsetY', 'shadowOffsetY']
373 ];
374
375 for (var i = 0, len = STYLE_CTX_MAP.length; i < len; i++) {
376 var styleProp = STYLE_CTX_MAP[i][0];
377 var styleValue = style[styleProp];
378 var ctxProp = STYLE_CTX_MAP[i][1];
379
380 if (typeof styleValue != 'undefined') {
381 ctx[ctxProp] = styleValue;
382 }
383 }
384 }
385
386
387 /**

Callers 4

beforeBrushMethod · 0.95
brushMethod · 0.80
brushMethod · 0.80
brushMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected