AUTOR PREGUNTA #1
Publicado 25 mayo 2014 - 17:37
¿Cómo puedo dibujar imágenes con el canvas de html5 pero que se ejecute con un bucle for, para que sean varias?
-
¿Tienes la misma pregunta? Yo también
PREGUNTAS SIMILARES
#2
Publicado 25 mayo 2014 - 20:39
Prueba con lo siguiente, te dejo identificado el array de las imágenes:
var imagenes=[]; var imgIndex = 0; for (var x=0;x<width;x++){ for(var y=0;y<height;y++){ imagenes[imgIndex] = new Image(); var rand = Math.floor(Math.random()*11); var texLoc = getImageNameFromRand(rand,y,height); imagenes[imgIndex].onload = function(){ var thisX = x*16, thisY = y*16; return function () { ctx.drawImage(this,thisX,thisY); }; }(); imagenes[imgIndex].src=texLoc; imgIndex += 1; } }
AUTOR PREGUNTA #3
Publicado 26 mayo 2014 - 00:14
Gracias Nieves