gis-common 5.1.34 → 5.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gis-common.es.js +26 -5
- package/dist/gis-common.umd.js +1 -1
- package/dist/index.d.ts +23 -2
- package/package.json +1 -1
package/dist/gis-common.es.js
CHANGED
|
@@ -3424,23 +3424,44 @@ class CanvasDrawer {
|
|
|
3424
3424
|
this.ctx.stroke();
|
|
3425
3425
|
}
|
|
3426
3426
|
}
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3427
|
+
/**
|
|
3428
|
+
* 绘制图像
|
|
3429
|
+
*
|
|
3430
|
+
* @param coordinate 绘制位置的坐标
|
|
3431
|
+
* @param image 要绘制的图像(ImageBitmap)
|
|
3432
|
+
* @param options 绘制选项,包括宽度、高度和旋转角度
|
|
3433
|
+
* @throws 当画布上下文不存在时抛出错误
|
|
3434
|
+
*/
|
|
3435
|
+
drawImage({ x, y }, image, options = {}) {
|
|
3436
|
+
const width = options.width || image.width;
|
|
3437
|
+
const height = options.height || image.height;
|
|
3438
|
+
const angle = options.angle || 0;
|
|
3439
|
+
this.ctx.save();
|
|
3430
3440
|
this.ctx.translate(x, y);
|
|
3431
|
-
if (
|
|
3432
|
-
const angleRad =
|
|
3441
|
+
if (angle) {
|
|
3442
|
+
const angleRad = angle * Math.PI / 180;
|
|
3433
3443
|
this.ctx.rotate(angleRad);
|
|
3434
3444
|
}
|
|
3435
3445
|
this.ctx.drawImage(image, -width / 2, -height / 2, width, height);
|
|
3436
3446
|
this.ctx.restore();
|
|
3437
3447
|
}
|
|
3448
|
+
/**
|
|
3449
|
+
* 绘制文本
|
|
3450
|
+
*
|
|
3451
|
+
* @param coordinate 绘制位置的坐标
|
|
3452
|
+
* @param text 要绘制的文本内容
|
|
3453
|
+
* @param options 绘制选项,包括字体和颜色
|
|
3454
|
+
* @throws 当画布上下文不存在时抛出错误
|
|
3455
|
+
*/
|
|
3438
3456
|
drawText({ x, y }, text, options) {
|
|
3439
3457
|
this.ctx.font = options.font || "10px sans-serif";
|
|
3440
3458
|
this.ctx.strokeStyle = options.color || "#000";
|
|
3441
3459
|
this.ctx.lineWidth = 2;
|
|
3442
3460
|
this.ctx.strokeText(text, x, y);
|
|
3443
3461
|
}
|
|
3462
|
+
destroy() {
|
|
3463
|
+
this.canvas.remove();
|
|
3464
|
+
}
|
|
3444
3465
|
static createCanvas(width = 1, height = 1) {
|
|
3445
3466
|
const canvas = document.createElement("canvas");
|
|
3446
3467
|
if (width) {
|