agv角度
This commit is contained in:
@@ -57,23 +57,23 @@ export const queryDevice = (t) => {
|
|||||||
let res = {}
|
let res = {}
|
||||||
if (t === 0) {
|
if (t === 0) {
|
||||||
res = {
|
res = {
|
||||||
data: {car1: {x: 105, y: 312, angle: 'up'}}
|
data: {car1: {x: 105, y: 312, angle: 90}}
|
||||||
}
|
}
|
||||||
} else if (t === 1) {
|
} else if (t === 1) {
|
||||||
res = {
|
res = {
|
||||||
data: {car1: {x: 105, y: 262, angle: 'up'}}
|
data: {car1: {x: 105, y: 262, angle: 180}}
|
||||||
}
|
}
|
||||||
} else if (t === 2) {
|
} else if (t === 2) {
|
||||||
res = {
|
res = {
|
||||||
data: {car1: {x: 105, y: 202, angle: 'up'}}
|
data: {car1: {x: 105, y: 202, angle: 180}}
|
||||||
}
|
}
|
||||||
} else if (t === 3) {
|
} else if (t === 3) {
|
||||||
res = {
|
res = {
|
||||||
data: {car1: {x: 105, y: 262, angle: 'down'}}
|
data: {car1: {x: 105, y: 262, angle: 90}}
|
||||||
}
|
}
|
||||||
} else if (t === 4) {
|
} else if (t === 4) {
|
||||||
res = {
|
res = {
|
||||||
data: {car1: {x: 105, y: 312, angle: 'down'}}
|
data: {car1: {x: 105, y: 312, angle: 90}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|||||||
BIN
src/images/agv.png
Normal file
BIN
src/images/agv.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
@@ -63,7 +63,7 @@ export default {
|
|||||||
},
|
},
|
||||||
handleCanvasCar () {
|
handleCanvasCar () {
|
||||||
let img = new Image()
|
let img = new Image()
|
||||||
img.src = require(`../images/agv_${this.angle}.png`)
|
img.src = require(`../images/agv.png`)
|
||||||
let nextX
|
let nextX
|
||||||
let nextY
|
let nextY
|
||||||
// 第一帧执行的时间
|
// 第一帧执行的时间
|
||||||
@@ -89,11 +89,14 @@ export default {
|
|||||||
const partProgress = (progress - (lineIndex - 1) * partProportion) / partProportion
|
const partProgress = (progress - (lineIndex - 1) * partProportion) / partProportion
|
||||||
// 绘制方法
|
// 绘制方法
|
||||||
const draw = () => {
|
const draw = () => {
|
||||||
this.ctx.beginPath()
|
|
||||||
this.ctx.clearRect(0, 0, 680, 467)
|
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)
|
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)
|
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()
|
draw()
|
||||||
if (progress < 1) {
|
if (progress < 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user