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

Method setColorToCanvas

src/openlayers/core/StyleUtils.js:1134–1146  ·  view source on GitHub ↗

* @function StyleUtils.setColorToCanvas 将颜色,透明度等样式设置到canvas上 * @param {Object} canvas - 渲染的canvas对象 * @param {Object} parameters - 样式参数 * @returns {Object} style对象

(canvas, parameters)

Source from the content-addressed store, hash-verified

1132 * @returns {Object} style对象
1133 */
1134 static setColorToCanvas(canvas, parameters) {
1135 let context = canvas.getContext('2d');
1136 let fillColor = StyleUtils.hexToRgb(parameters.fillColor);
1137 fillColor && fillColor.push(parameters.fillOpacity);
1138 let strokeColor = StyleUtils.hexToRgb(parameters.strokeColor);
1139 strokeColor && strokeColor.push(parameters.strokeOpacity);
1140 context.fillStyle = StyleUtils.formatRGB(fillColor);
1141 context.fill();
1142 context.strokeStyle = StyleUtils.formatRGB(strokeColor);
1143 context.lineWidth = parameters.strokeWidth;
1144 context.stroke();
1145 return canvas;
1146 }
1147 /**
1148 * @function StyleUtils.getImageStyle 获取图片样式
1149 * @param {Object} styleParams - 样式参数

Callers 2

StyleUtils2Spec.jsFile · 0.80
getSVGStyleMethod · 0.80

Calls 4

hexToRgbMethod · 0.80
pushMethod · 0.80
formatRGBMethod · 0.80
getContextMethod · 0.45

Tested by

no test coverage detected