1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| var canvasPlateau= document.getElementById("morpion_plateau");
var convasPlateauContext;
var plateauLongueur = 400;
var plateauLargeur = 400;
var dessinerPlateau = function() {
// canvasPlateauContext.fillStyle = couleurPlateau;
var img= new Image();
img.src = 'bois.png';
img.onload= function() {
canvasPlateauContext.fillRect(100, 100, plateauLongueur, plateauLargeur);
canvasPlateauContext.drawImage(img,0,0, plateauLongueur, plateauLargeur);
canvasPlateauContext.beginPath();
canvasPlateauContext.lineWidth=4;
canvasPlateauContext.moveTo(133,0);
canvasPlateauContext.lineTo(133,400);
canvasPlateauContext.moveTo(266,0);
canvasPlateauContext.lineTo(266,400);
canvasPlateauContext.moveTo(0,133);
canvasPlateauContext.lineTo(400,133);
canvasPlateauContext.moveTo(0,266);
canvasPlateauContext.lineTo(400,266);
canvasPlateauContext.fill();
canvasPlateauContext.stroke();
}
}
var initialisation = function() {
canvasPlateau.width = plateauLongueur;
canvasPlateau.height = plateauLargeur;
document.body.appendChild(canvasPlateau);
canvasPlateauContext = canvasPlateau.getContext('2d');
dessinerPlateau();
} |
Partager