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:{
dessiner(){
if(this.viesEpuisees<=10){
this.ordreDessin[this.viesEpuisees]()
this.viesEpuisees++;
}
},
potenceBas: function(){
// Tracer la potence (trait bas) // Tracer la potence (trait bas)
ctx.beginPath(); this.ctx.beginPath();
ctx.moveTo(50, 200); this.ctx.moveTo(50, 200);
ctx.lineTo(150, 200); this.ctx.lineTo(150, 200);
ctx.stroke(); this.ctx.stroke();
},
potenceVertical: function(){
// Tracer la potence (trait vertical) // Tracer la potence (trait vertical)
ctx.beginPath(); this.ctx.beginPath();
ctx.moveTo(100, 200); this.ctx.moveTo(100, 200);
ctx.lineTo(100, 50); this.ctx.lineTo(100, 50);
ctx.stroke(); this.ctx.stroke();
},
potencePoutre: function(){
// Tracer la potence (poutre) // Tracer la potence (poutre)
ctx.beginPath(); this.ctx.beginPath();
ctx.moveTo(100, 50); this.ctx.moveTo(100, 50);
ctx.lineTo(150, 50); this.ctx.lineTo(150, 50);
ctx.stroke(); this.ctx.stroke();
},
potenceEquerre: function(){
// Tracer la potence (equerre) // Tracer la potence (equerre)
ctx.beginPath(); this.ctx.beginPath();
ctx.moveTo(100, 70); this.ctx.moveTo(100, 70);
ctx.lineTo(130, 50); this.ctx.lineTo(130, 50);
ctx.stroke(); this.ctx.stroke();
},
corde: function(){
// Tracer la corde // Tracer la corde
ctx.beginPath(); this.ctx.beginPath();
ctx.moveTo(150, 50); // Déplacer le point de départ au sommet de la potence this.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 this.ctx.lineTo(150, 75); // Tracer une ligne verticale jusqu'à la tête du pendu
ctx.stroke(); // Dessiner le trait this.ctx.stroke(); // Dessiner le trait
},
// Tracer l'équerre tete: function(){
ctx.beginPath();
ctx.moveTo(150, 100);
ctx.lineTo(150, 150);
ctx.stroke();
// Tracer la tête // Tracer la tête
ctx.beginPath(); this.ctx.beginPath();
ctx.arc(150, 87, 12, 0, Math.PI * 2); this.ctx.arc(150, 87, 12, 0, Math.PI * 2);
ctx.stroke(); this.ctx.stroke();
},
corps: function(){
// Tracer le corps // Tracer le corps
ctx.beginPath(); this.ctx.beginPath();
ctx.moveTo(150, 100); this.ctx.moveTo(150, 100);
ctx.lineTo(150, 150); this.ctx.lineTo(150, 150);
ctx.stroke(); this.ctx.stroke();
},
brasGauche: function(){
// Tracer le bras gauche // Tracer le bras gauche
ctx.beginPath(); this.ctx.beginPath();
ctx.moveTo(150, 110); this.ctx.moveTo(150, 110);
ctx.lineTo(130, 130); this.ctx.lineTo(130, 130);
ctx.stroke(); this.ctx.stroke();
},
brasDroit: function(){
// Tracer le bras droit // Tracer le bras droit
ctx.beginPath(); this.ctx.beginPath();
ctx.moveTo(150, 110); this.ctx.moveTo(150, 110);
ctx.lineTo(170, 130); this.ctx.lineTo(170, 130);
ctx.stroke(); this.ctx.stroke();
},
jambeGauche: function(){
// Tracer la jambe gauche // Tracer la jambe gauche
ctx.beginPath(); this.ctx.beginPath();
ctx.moveTo(150, 150); this.ctx.moveTo(150, 150);
ctx.lineTo(130, 180); this.ctx.lineTo(130, 180);
ctx.stroke(); this.ctx.stroke();
},
jambeDroite: function(){
// Tracer la jambe droite // Tracer la jambe droite
ctx.beginPath(); this.ctx.beginPath();
ctx.moveTo(150, 150); this.ctx.moveTo(150, 150);
ctx.lineTo(170, 180); this.ctx.lineTo(170, 180);
ctx.stroke(); this.ctx.stroke();
} }
} }
} }

Loading…
Cancel
Save