Ver Mensaje Individual
  #9 (permalink)  
Antiguo 02/05/2012, 16:00
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 19 años, 10 meses
Puntos: 834
Respuesta: Borrar imagenes canvas

Esta es otra manera de hacer lo mismo, sólo que tampoco funcionará en explorer 8:
Código PHP:
<script type="text/javascript">
var 
c,ctx,cero,uno,dos,historial=[];
function 
_(x){return document.getElementById(x);}
function 
inicio(){
    
c=document.getElementById('c');
    
ctx=c.getContext('2d');
    
ctx.fillStyle ="#F00";
    
ctx.fillRect(0,0,300,300);
    
    
cero=ctx.getImageData(00300300);
    
historial.push(cero);
}
function 
addSmile1(){
    
ctx.drawImage(_('im1'),5,10);
    
    
uno=ctx.getImageData(00300300);
    
historial.push(uno);
}
function 
addSmile2(){
    
ctx.drawImage(_('im2'),100,100);
    
    
dos=ctx.getImageData(00300300);;
    
historial.push(dos);
}
function 
revert(){
    
historial.pop();
    if(
historial.length){
        
        
ctx.putImageData(historial.pop(), 00);
        
    }else{
        
inicio();
    }
}
onload=inicio;
</script> 
Para explorer 8 hay que seguir pensando...