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

Method adjustCanvasSize

src/common/overlay/levelRenderer/Util.js:188–229  ·  view source on GitHub ↗

* @function LevelRenderer.Tool.Util.prototype.adjustCanvasSize * @description 如果坐标处在_canvas外部,改变_canvas的大小,修改canvas的大小 需要重新设置translate * * @param {number} x - 横坐标。 * @param {number} y - 纵坐标。 *

(x, y)

Source from the content-addressed store, hash-verified

186 *
187 */
188 adjustCanvasSize(x, y) {
189 var _canvas = this._canvas;
190 var _pixelCtx = this._pixelCtx;
191 var _width = this._width;
192 var _height = this._height;
193 var _offsetX = this._offsetX;
194 var _offsetY = this._offsetY;
195
196 // 每次加的长度
197 var _v = 100;
198 var _flag;
199
200 if (x + _offsetX > _width) {
201 _width = x + _offsetX + _v;
202 _canvas.width = _width;
203 _flag = true;
204 }
205
206 if (y + _offsetY > _height) {
207 _height = y + _offsetY + _v;
208 _canvas.height = _height;
209 _flag = true;
210 }
211
212 if (x < -_offsetX) {
213 _offsetX = Math.ceil(-x / _v) * _v;
214 _width += _offsetX;
215 _canvas.width = _width;
216 _flag = true;
217 }
218
219 if (y < -_offsetY) {
220 _offsetY = Math.ceil(-y / _v) * _v;
221 _height += _offsetY;
222 _canvas.height = _height;
223 _flag = true;
224 }
225
226 if (_flag) {
227 _pixelCtx.translate(_offsetX, _offsetY);
228 }
229 }
230
231
232 /**

Callers 1

UtilSpec.jsFile · 0.80

Calls 1

translateMethod · 0.80

Tested by

no test coverage detected