agv角度

This commit is contained in:
蔡玲
2024-09-26 09:32:38 +08:00
parent 83acbb40d4
commit 8de50f979f
3 changed files with 11 additions and 8 deletions

View File

@@ -57,23 +57,23 @@ export const queryDevice = (t) => {
let res = {}
if (t === 0) {
res = {
data: {car1: {x: 105, y: 312, angle: 'up'}}
data: {car1: {x: 105, y: 312, angle: 90}}
}
} else if (t === 1) {
res = {
data: {car1: {x: 105, y: 262, angle: 'up'}}
data: {car1: {x: 105, y: 262, angle: 180}}
}
} else if (t === 2) {
res = {
data: {car1: {x: 105, y: 202, angle: 'up'}}
data: {car1: {x: 105, y: 202, angle: 180}}
}
} else if (t === 3) {
res = {
data: {car1: {x: 105, y: 262, angle: 'down'}}
data: {car1: {x: 105, y: 262, angle: 90}}
}
} else if (t === 4) {
res = {
data: {car1: {x: 105, y: 312, angle: 'down'}}
data: {car1: {x: 105, y: 312, angle: 90}}
}
}
return res

BIN
src/images/agv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -63,7 +63,7 @@ export default {
},
handleCanvasCar () {
let img = new Image()
img.src = require(`../images/agv_${this.angle}.png`)
img.src = require(`../images/agv.png`)
let nextX
let nextY
// 第一帧执行的时间
@@ -89,11 +89,14 @@ export default {
const partProgress = (progress - (lineIndex - 1) * partProportion) / partProportion
// 绘制方法
const draw = () => {
this.ctx.beginPath()
this.ctx.clearRect(0, 0, 680, 467)
this.ctx.save()
nextX = ~~(this.keyPoints[lineIndex - 1].x + ((this.keyPoints[lineIndex]).x - this.keyPoints[lineIndex - 1].x) * partProgress)
nextY = ~~(this.keyPoints[lineIndex - 1].y + ((this.keyPoints[lineIndex]).y - this.keyPoints[lineIndex - 1].y) * partProgress)
this.ctx.drawImage(img, nextX - 10, nextY - 19, 20, 38)
this.ctx.translate(nextX, nextY)
this.ctx.rotate(this.angle * Math.PI / 180)
this.ctx.drawImage(img, -img.width / 2, -img.height / 2)
this.ctx.restore()
}
draw()
if (progress < 1) {