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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| <!doctype html>
<html lang="fr">
<head>
<title>HTML5 : Canvas</title>
<meta charset="utf-8">
<style>
canvas {
position:absolute;
left:100px;
top:150px;
border:5px solid #666;
background:white;
border-radius:4px;
box-shadow:0px 0px 20px #666;
}
#c4 {
position:absolute;
left:100px;
top:150px;
}
</style>
</head>
<body>
<div><canvas id="c5" width="480" height = "300" ></canvas>
<div id="c4" width="480" height = "300" >
<button onclick="draw_Noir();return true;">Noir</button>
<button onclick="draw_Rouge();return true;">Rouge</button>
<button onclick="draw_Bleu();return true;">Bleu</button>
</div>
</div>
<script>
var c5 = document.getElementById("c5");
var c5_context = c5.getContext("2d");
var Noir = new Image();
Noir.src = 'images/TshirtNoir.jpg';
var Rouge = new Image();
Rouge.src = 'images/TshirtRouge.jpg';
var Bleu = new Image();
Bleu.src = 'images/TshirtBleu.jpg';
function draw_Noir() {
c5_context.drawImage(Noir, 100, 5, 300, 300);
}
function draw_Rouge() {
c5_context.drawImage(Rouge, 100, 5, 300, 300);
}
function draw_Bleu() {
c5_context.drawImage(Bleu, 100, 5, 300, 300);
}
</script>
</body>
</html> |
Partager