<template>
<div class="a">
<canvas id="myCanvas"></canvas>
</div>
</template>
<script>
import chat from "./chat.vue";
export default {
components: { chat },
name: "trainCity",
data() {
return {
canvas: null,
context: null,
};
},
mounted() {
this.doew();
},
methods: {
doew() {
this.canvas = document.getElementById("myCanvas");
this.canvas.width = "800";
this.canvas.height = "800";
this.context = this.canvas.getContext("2d");
this.context.beginPath();
this.context.arc(150, 75, 70, 0, 2 * Math.PI);
this.context.stroke();
this.context.beginPath();
this.context.arc(120, 55, 5, 0, 2 * Math.PI);
this.context.stroke();
this.context.beginPath();
this.context.arc(180, 55, 5, 0, 2 * Math.PI);
this.context.stroke();
this.context.beginPath();
this.context.arc(120, 55, 10, 0, 2 * Math.PI);
this.context.stroke();
this.context.beginPath();
this.context.arc(180, 55, 10, 0, 2 * Math.PI);
this.context.stroke();
this.context.beginPath();
this.context.moveTo(120, 10);
this.context.quadraticCurveTo(20, 0, 80, 80);
this.context.stroke();
this.context.beginPath();
this.context.moveTo(180, 10);
this.context.quadraticCurveTo(280, 0, 220, 75);
this.context.stroke();
this.context.beginPath();
this.context.ellipse(150, 100, 45, 30, 0, 10, Math.PI, true);
this.context.stroke();
this.context.beginPath();
this.context.ellipse(120, 100, 5, 10, 0, 10, Math.PI, true);
this.context.stroke();
this.context.beginPath();
this.context.ellipse(180, 100, 5, 10, 0, 10, Math.PI, true);
this.context.stroke();
},
},
};
</script>