|
@@ -13,79 +13,80 @@ export default {
|
|
|
components: {},
|
|
|
data() {
|
|
|
return {
|
|
|
- modelImgSrc: require("@/assets/common/image/others/carTopView.png"),
|
|
|
+ // modelImgSrc: require("@/assets/common/image/others/carTopView.png"),
|
|
|
aSrc: require("@/assets/common/image/others/sensorIcon.png"),
|
|
|
+ ctx: null,
|
|
|
+ ctxBg: null,
|
|
|
+ imgBg: null,
|
|
|
+ imgIcon: null,
|
|
|
};
|
|
|
},
|
|
|
|
|
|
- // props: {
|
|
|
- // width: {
|
|
|
- // type: Number,
|
|
|
- // default: 300,
|
|
|
- // },
|
|
|
- // height: {
|
|
|
- // type: Number,
|
|
|
- // default: 150,
|
|
|
- // },
|
|
|
- // x: {
|
|
|
- // type: Number,
|
|
|
- // default: 0,
|
|
|
- // },
|
|
|
- // y: {
|
|
|
- // type: Number,
|
|
|
- // default: 0,
|
|
|
- // },
|
|
|
- // },
|
|
|
+ props: {
|
|
|
+ coordinate: {
|
|
|
+ type: Object,
|
|
|
+ default: { x: 0, y: 0 },
|
|
|
+ },
|
|
|
+ modelImgSrc: {
|
|
|
+ type: String,
|
|
|
+ default: require("@/assets/common/image/others/carTopView.png"),
|
|
|
+ },
|
|
|
+ },
|
|
|
|
|
|
- // computed: {
|
|
|
- // scale() {
|
|
|
- // return this.width / 1000;
|
|
|
- // },
|
|
|
- // },
|
|
|
+ watch: {
|
|
|
+ coordinate(val) {
|
|
|
+ this.draw(val);
|
|
|
+ },
|
|
|
+ modelImgSrc(val) {
|
|
|
+ this.drawBg();
|
|
|
+ },
|
|
|
+ },
|
|
|
|
|
|
methods: {
|
|
|
- draw() {
|
|
|
- var ctx = document.getElementById("canvas").getContext("2d");
|
|
|
- var ctxA = document.getElementById("canvasA").getContext("2d");
|
|
|
- // ctx.translate(60, 60)
|
|
|
- var img = new Image();
|
|
|
- img.onload = () => {
|
|
|
- ctxA.drawImage(img, 0, 0, 1000, 500);
|
|
|
- // ctxA.translate(60, 60);
|
|
|
- // img1.src = "";
|
|
|
+ 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();
|
|
|
- };
|
|
|
+ // ctx.save();
|
|
|
+ // };
|
|
|
// console.log(ctx);
|
|
|
// ctx.save();
|
|
|
var img1 = new Image();
|
|
|
img.src = this.modelImgSrc;
|
|
|
img1.src = this.aSrc;
|
|
|
img1.onload = () => {
|
|
|
- ctx.drawImage(img1, 900, 150, 29, 41);
|
|
|
+ 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();
|
|
|
+ // // ctx.save();
|
|
|
// // img1.src = this.aSrc;
|
|
|
- // ctx.drawImage(img1, 40, 0, 15, 20);
|
|
|
- // ctx.restore();
|
|
|
- // }, 1000);
|
|
|
- // setTimeout((_) => {
|
|
|
- // ctx.save();
|
|
|
- // img1.src = this.aSrc;
|
|
|
- // // ctx.clearRect(20,20,100,50);
|
|
|
- // ctx.drawImage(img, -60, -60, this.width, this.height);
|
|
|
- // ctx.drawImage(img1, 10, 10, 15, 20);
|
|
|
- // ctx.restore();
|
|
|
+ // // ctx.clearRect(-250,960,1000,500)
|
|
|
+ // ctx.clearRect(-250,-40,500,1000)
|
|
|
+ // ctx.drawImage(img1, -10, 510, 29, 41);
|
|
|
+ // // ctx.restore();
|
|
|
// }, 2000);
|
|
|
// setTimeout((_) => {
|
|
|
- // ctx.save();
|
|
|
- // img1.src = this.aSrc;
|
|
|
- // ctx.drawImage(img, -60, -60, this.width, this.height);
|
|
|
- // ctx.drawImage(img1, 20, 20, 15, 20);
|
|
|
- // ctx.restore();
|
|
|
- // // ctx.clearRect(60,60,100,50);
|
|
|
+ // ctx.clearRect(-250,-40,500,1000)
|
|
|
+ // ctx.drawImage(img1, -180, 810, 29, 41);
|
|
|
// }, 3000);
|
|
|
// setTimeout((_) => {
|
|
|
// ctx.save();
|
|
@@ -94,26 +95,46 @@ export default {
|
|
|
// ctx.drawImage(img1, 0, 0, 15, 20);
|
|
|
// }, 4000);
|
|
|
},
|
|
|
+ draw(data) {
|
|
|
+ if (!data.x || !data.y) return;
|
|
|
+ this.ctx.clearRect(-250, -40, 500, 1000);
|
|
|
+ this.ctx.drawImage(this.imgIcon, data.x, data.y, 41, 29);
|
|
|
+ },
|
|
|
+ clear() {
|
|
|
+ this.ctx.clearRect(-250, -40, 500, 1000);
|
|
|
+ },
|
|
|
+ drawBg(){
|
|
|
+ this.ctxBg.clearRect(0,0 , 1000, 500);
|
|
|
+ this.imgBg.src = this.modelImgSrc;
|
|
|
+ this.ctxBg.drawImage(this.imgBg, 0, 0, 1000, 500);
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
$(document).ready(() => {
|
|
|
- // console.log(12678);
|
|
|
- // $("#canvas").css({
|
|
|
- // width: $(
|
|
|
- // ".vehicleConfigurationDetailPanel .model"
|
|
|
- // ).outerWidth(),
|
|
|
- // height:
|
|
|
- // $(".vehicleConfigurationDetailPanel .model").outerWidth() /
|
|
|
- // 2,
|
|
|
- // });
|
|
|
- this.draw();
|
|
|
+ this.ctx = document.getElementById("canvas").getContext("2d");
|
|
|
+ this.ctxBg = document.getElementById("canvasA").getContext("2d");
|
|
|
+
|
|
|
+ this.ctx.translate(960, 250);
|
|
|
+ this.ctx.rotate(Math.PI / 2);
|
|
|
+
|
|
|
+ this.imgBg = new Image();
|
|
|
+ this.imgBg.src = this.modelImgSrc;
|
|
|
+ this.imgBg.onload = () => {
|
|
|
+ this.ctxBg.drawImage(this.imgBg, 0, 0, 1000, 500);
|
|
|
+ };
|
|
|
+
|
|
|
+ this.imgIcon = new Image();
|
|
|
+ this.imgIcon.src = this.aSrc;
|
|
|
+ // this.imgIcon.onload = () => {
|
|
|
+ // this.ctx.drawImage(this.imgIcon, 0, 0, 29, 41);
|
|
|
+ // };
|
|
|
});
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style lang='less' scoped>
|
|
|
+<style lang="less" scoped>
|
|
|
.canvasPanel {
|
|
|
position: relative;
|
|
|
|