ajouter systeme de dessin, membre par membre

front
gwen 1 year ago
parent b3b5e41cf6
commit 1e163854a4

@ -3,87 +3,110 @@ export default{
props:["vieRestantes"], //maximum 10 props:["vieRestantes"], //maximum 10
data(){ data(){
return { return {
viesEpuisees:10-(this.vieRestantes??10),
ordreDessin:[
this.potenceBas,
this.potenceVertical,
this.potencePoutre,
this.potenceEquerre,
this.corde,
this.tete,
this.corps,
this.brasGauche,
this.brasDroit,
this.jambeDroite,
this.jambeGauche
],
ctx:null
} }
}, },
methods:{ mounted(){
dessiner: function(){
// Récupérer le contexte de dessin 2D
this.$refs.pendu.width=200 this.$refs.pendu.width=200
this.$refs.pendu.height=200 this.$refs.pendu.height=200
this.ctx = this.$refs.pendu.getContext("2d");
const ctx = this.$refs.pendu.getContext("2d"); },
methods:{
// Tracer la potence (trait bas) dessiner(){
ctx.beginPath(); if(this.viesEpuisees<=10){
ctx.moveTo(50, 200); this.ordreDessin[this.viesEpuisees]()
ctx.lineTo(150, 200); this.viesEpuisees++;
ctx.stroke(); }
},
// Tracer la potence (trait vertical) potenceBas: function(){
ctx.beginPath(); // Tracer la potence (trait bas)
ctx.moveTo(100, 200); this.ctx.beginPath();
ctx.lineTo(100, 50); this.ctx.moveTo(50, 200);
ctx.stroke(); this.ctx.lineTo(150, 200);
this.ctx.stroke();
// Tracer la potence (poutre) },
ctx.beginPath(); potenceVertical: function(){
ctx.moveTo(100, 50); // Tracer la potence (trait vertical)
ctx.lineTo(150, 50); this.ctx.beginPath();
ctx.stroke(); this.ctx.moveTo(100, 200);
this.ctx.lineTo(100, 50);
// Tracer la potence (equerre) this.ctx.stroke();
ctx.beginPath(); },
ctx.moveTo(100, 70); potencePoutre: function(){
ctx.lineTo(130, 50); // Tracer la potence (poutre)
ctx.stroke(); this.ctx.beginPath();
this.ctx.moveTo(100, 50);
// Tracer la corde this.ctx.lineTo(150, 50);
ctx.beginPath(); this.ctx.stroke();
ctx.moveTo(150, 50); // Déplacer le point de départ au sommet de la potence },
ctx.lineTo(150, 75); // Tracer une ligne verticale jusqu'à la tête du pendu potenceEquerre: function(){
ctx.stroke(); // Dessiner le trait // Tracer la potence (equerre)
this.ctx.beginPath();
// Tracer l'équerre this.ctx.moveTo(100, 70);
ctx.beginPath(); this.ctx.lineTo(130, 50);
ctx.moveTo(150, 100); this.ctx.stroke();
ctx.lineTo(150, 150); },
ctx.stroke(); corde: function(){
// Tracer la corde
// Tracer la tête this.ctx.beginPath();
ctx.beginPath(); this.ctx.moveTo(150, 50); // Déplacer le point de départ au sommet de la potence
ctx.arc(150, 87, 12, 0, Math.PI * 2); this.ctx.lineTo(150, 75); // Tracer une ligne verticale jusqu'à la tête du pendu
ctx.stroke(); this.ctx.stroke(); // Dessiner le trait
},
// Tracer le corps tete: function(){
ctx.beginPath(); // Tracer la tête
ctx.moveTo(150, 100); this.ctx.beginPath();
ctx.lineTo(150, 150); this.ctx.arc(150, 87, 12, 0, Math.PI * 2);
ctx.stroke(); this.ctx.stroke();
},
// Tracer le bras gauche corps: function(){
ctx.beginPath(); // Tracer le corps
ctx.moveTo(150, 110); this.ctx.beginPath();
ctx.lineTo(130, 130); this.ctx.moveTo(150, 100);
ctx.stroke(); this.ctx.lineTo(150, 150);
this.ctx.stroke();
// Tracer le bras droit },
ctx.beginPath(); brasGauche: function(){
ctx.moveTo(150, 110); // Tracer le bras gauche
ctx.lineTo(170, 130); this.ctx.beginPath();
ctx.stroke(); this.ctx.moveTo(150, 110);
this.ctx.lineTo(130, 130);
// Tracer la jambe gauche this.ctx.stroke();
ctx.beginPath(); },
ctx.moveTo(150, 150); brasDroit: function(){
ctx.lineTo(130, 180); // Tracer le bras droit
ctx.stroke(); this.ctx.beginPath();
this.ctx.moveTo(150, 110);
// Tracer la jambe droite this.ctx.lineTo(170, 130);
ctx.beginPath(); this.ctx.stroke();
ctx.moveTo(150, 150); },
ctx.lineTo(170, 180); jambeGauche: function(){
ctx.stroke(); // Tracer la jambe gauche
this.ctx.beginPath();
this.ctx.moveTo(150, 150);
this.ctx.lineTo(130, 180);
this.ctx.stroke();
},
jambeDroite: function(){
// Tracer la jambe droite
this.ctx.beginPath();
this.ctx.moveTo(150, 150);
this.ctx.lineTo(170, 180);
this.ctx.stroke();
} }
} }
} }

Loading…
Cancel
Save