# HG changeset patch # User Edwin Razafimahatratra # Date 1355174375 -3600 # Node ID 6605de5fe0bd3ee98a237ddd564746537c6cd7aa # Parent cdbb56b876c98306b225af5931e245075dfa9011 mosaic effect done diff -r cdbb56b876c9 -r 6605de5fe0bd web/index.html --- a/web/index.html Mon Dec 10 20:55:18 2012 +0100 +++ b/web/index.html Mon Dec 10 22:19:35 2012 +0100 @@ -102,9 +102,12 @@ incResize.init("content", "top", "mosaic", "bottom", "footer", 130, 1800/750, null, incMosaic.registerPostNewCanvasSize); // Set mosaic pair of images - incMosaic.addPairImages("static/res/img/accueil-00.jpg", "static/res/img/accueil-01.jpg"); - incMosaic.addPairImages("static/res/img/accueil-02.jpg", "static/res/img/accueil-03.jpg"); - incMosaic.addPairImages("static/res/img/accueil-04.jpg", "static/res/img/accueil-05.jpg"); + incMosaic.addImageUrl("static/res/img/accueil-00.jpg"); + incMosaic.addImageUrl("static/res/img/accueil-01.jpg"); + incMosaic.addImageUrl("static/res/img/accueil-02.jpg"); + incMosaic.addImageUrl("static/res/img/accueil-03.jpg"); + incMosaic.addImageUrl("static/res/img/accueil-04.jpg"); + incMosaic.addImageUrl("static/res/img/accueil-05.jpg"); // Start mosaic effect incMosaic.start("mosaic", 9, 5); diff -r cdbb56b876c9 -r 6605de5fe0bd web/inter_choix.html --- a/web/inter_choix.html Mon Dec 10 20:55:18 2012 +0100 +++ b/web/inter_choix.html Mon Dec 10 22:19:35 2012 +0100 @@ -23,7 +23,8 @@
-
+ +

3 ÉCRANS

CHOISISSEZ UN MOT PAR ÉCRANS

COMPOSEZ VOTRE FILM

diff -r cdbb56b876c9 -r 6605de5fe0bd web/static/res/js/incmosaic.js --- a/web/static/res/js/incmosaic.js Mon Dec 10 20:55:18 2012 +0100 +++ b/web/static/res/js/incmosaic.js Mon Dec 10 22:19:35 2012 +0100 @@ -11,7 +11,8 @@ this.imageData; /// Images - this.pairUrl = []; + this.imageUrls = []; + this.listeUrls = []; // The images list to blend this.pairImages = []; this.imagesLoaded = 0; this.imageWidth; @@ -34,10 +35,9 @@ // Functions // -------------------------------------------------------------------------------------------------------------------- - this.addPairImages = function(url1, url2) + this.addImageUrl = function(url) { - var urls = new IncPairUrl(url1, url2); - this.pairUrl.push(urls); + this.imageUrls.push(url); }; this.start = function(canvasId, squareCountX, squareCountY) @@ -94,15 +94,44 @@ incMosaic.squareHeight = Math.floor(newCanvasHeight / incMosaic.squareCountY); }; + this.fillListUrl = function() + { + var urls = []; + for (var i = 1; i < this.imageUrls.length; ++i) { + urls.push(this.imageUrls[i]); + } + + // Set random url + + // The first images is always the first in this array + this.listeUrls.push(this.imageUrls[0]); + + while (urls.length > 0) { + var randInd = this.randomInt(0, urls.length); + this.listeUrls.push(urls[randInd]); + urls.remove(randInd); + } + }; + this.setRandomPairImages = function() { - this.imagesLoaded = 0; - var randInd = this.randomInt(0, this.pairUrl.length); - var pairUrl = this.pairUrl[randInd]; + if (this.listeUrls.length == 0) { + this.fillListUrl(); + } - this.pairImages.length = 0; - this.pairImages.push(this.getImageFromUrl(pairUrl.imageUrl1)); - this.pairImages.push(this.getImageFromUrl(pairUrl.imageUrl2)); + if (this.pairImages.length == 0) { + this.imagesLoaded = 0; + this.pairImages.push(this.getImageFromUrl(this.listeUrls[0])); + this.pairImages.push(this.getImageFromUrl(this.listeUrls[1])); + this.listeUrls.remove(0); + } else { + this.imagesLoaded = 1; + this.pairImages[0] = this.pairImages[1]; // Swap + this.pairImages[1] = this.getImageFromUrl(this.listeUrls[0]) + } + this.listeUrls.remove(0); + + // Todo preload the next image }; this.setRandomSquareEffect = function() @@ -288,12 +317,6 @@ }; } -function IncPairUrl(url1, url2) -{ - this.imageUrl1 = url1; - this.imageUrl2 = url2; -} - // -------------------------------------------------------------------------------------------------------------------- // Effects // -------------------------------------------------------------------------------------------------------------------- @@ -443,5 +466,11 @@ }; })(); +Array.prototype.remove = function(from, to) { + var rest = this.slice((to || from) + 1 || this.length); + this.length = from < 0 ? this.length + from : from; + return this.push.apply(this, rest); +}; + var incMosaic = new IncMosaic();