|
@@ -19,6 +19,7 @@ export default {
|
|
|
ctxBg: null,
|
|
|
imgBg: null,
|
|
|
imgIcon: null,
|
|
|
+ rate: 70, // 换算比例
|
|
|
};
|
|
|
},
|
|
|
|
|
@@ -37,74 +38,26 @@ export default {
|
|
|
coordinate(val) {
|
|
|
this.draw(val);
|
|
|
},
|
|
|
- modelImgSrc(val) {
|
|
|
+ modelImgSrc() {
|
|
|
this.drawBg();
|
|
|
},
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
- draw1(data) {
|
|
|
- // var ctx = document.getElementById("canvas").getContext("2d");
|
|
|
- // var ctxA = document.getElementById("canvasA").getContext("2d");
|
|
|
- // ctx.translate(960, 250);
|
|
|
- // ctx.rotate(Math.PI / 2);
|
|
|
- // var img = new Image();
|
|
|
- // img.onload = () => {
|
|
|
- // ctxA.drawImage(img, 0, 0, 1000, 500);
|
|
|
- // ctx.translate(960, 250);
|
|
|
- // ctx.rotate(Math.PI/2);
|
|
|
- // ctxA.translate(60, 60);
|
|
|
- // img1.src = "";
|
|
|
-
|
|
|
- // ctx.save();
|
|
|
- // };
|
|
|
- // console.log(ctx);
|
|
|
- // ctx.save();
|
|
|
- var img1 = new Image();
|
|
|
- img.src = this.modelImgSrc;
|
|
|
- img1.src = this.aSrc;
|
|
|
- img1.onload = () => {
|
|
|
- ctx.drawImage(img1, 0, 0, 41, 29);
|
|
|
- ctx.rotate(-Math.PI / 2);
|
|
|
- ctx.translate(-960, -250);
|
|
|
- };
|
|
|
-
|
|
|
- setTimeout((_) => {
|
|
|
- // ctx.save();
|
|
|
- // img1.src = this.aSrc;
|
|
|
- ctx.clearRect(-250, -40, 500, 1000);
|
|
|
- ctx.drawImage(img1, 30, 30, 41, 29);
|
|
|
- // ctx.restore();
|
|
|
- }, 1000);
|
|
|
- // setTimeout((_) => {
|
|
|
- // // ctx.save();
|
|
|
- // // img1.src = this.aSrc;
|
|
|
- // // ctx.clearRect(-250,960,1000,500)
|
|
|
- // ctx.clearRect(-250,-40,500,1000)
|
|
|
- // ctx.drawImage(img1, -10, 510, 29, 41);
|
|
|
- // // ctx.restore();
|
|
|
- // }, 2000);
|
|
|
- // setTimeout((_) => {
|
|
|
- // ctx.clearRect(-250,-40,500,1000)
|
|
|
- // ctx.drawImage(img1, -180, 810, 29, 41);
|
|
|
- // }, 3000);
|
|
|
- // setTimeout((_) => {
|
|
|
- // ctx.save();
|
|
|
- // img1.src = this.aSrc;
|
|
|
- // ctx.drawImage(img, -60, -60, this.width, this.height);
|
|
|
- // ctx.drawImage(img1, 0, 0, 15, 20);
|
|
|
- // }, 4000);
|
|
|
- },
|
|
|
draw(data) {
|
|
|
if (data.x === "" || data.y === "" || data.h === "") return;
|
|
|
- this.ctx.clearRect(-250, -40, 500, 1000);
|
|
|
- this.ctx.drawImage(this.imgIcon, data.x, data.y, 20.5, 14.5);
|
|
|
- this.ctx.beginPath();
|
|
|
|
|
|
- let x = +data.x + 6;
|
|
|
- let y = +data.y + 12;
|
|
|
+ let rate = this.rate;
|
|
|
+ // 摄像头从自己左上角的原点开始绘制,需要移到自己的中心点
|
|
|
+ let x = +data.x * rate;
|
|
|
+ let y = +data.y * rate;
|
|
|
let h1 = 90 - +data.h / 2;
|
|
|
let h2 = 90 + +data.h / 2;
|
|
|
+
|
|
|
+ this.ctx.clearRect(-250, -40, 500, 1000);
|
|
|
+ this.ctx.drawImage(this.imgIcon, x - 6, y - 6, 20.5, 14.5);
|
|
|
+ this.ctx.beginPath();
|
|
|
+
|
|
|
//定义起点
|
|
|
this.ctx.moveTo(x, y);
|
|
|
//以起点为圆心,画一个半径为100的圆弧
|