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
| var context;
var x = 0;
var ind;
var offset;
var chemin="";
var nbPhotos, url;
var photos = new Array();
function chargePhoto ()
{
var url = document.write(window.location.hash);
switch (url) {
case "#2":
chemin = "./photos/concerts";
nbPhotos = 26;
break;
case "#3":
chemin = "./photos/sports";
nbPhotos = 17;
break;
default:
chemin = "./photos/divers";
nbPhotos = 12;
break;
}
for(var i=1; i<nbPhotos; i++) {
im = new Image();
im.src = chemin + "photo" + i + ".jpg";
photos.push(im);
}
}
function init() {
context = document.getElementsByTagName('CANVAS').getContext('2d');
setInterval(loop, 1);
}
function loop() {
x += (slider.value - x) * 0.04;
ind = Math.floor(x/600);
offset = x % 600;
context.drawImage(photos[ind], offset, 0, 600-offset, 400, 0, 0, 600-offset, 400);
context.drawImage(photos[ind+1], 0, 0, 600, 400, 600-offset, 0, 600, 400);
} |
Partager