Ver Mensaje Individual
  #5 (permalink)  
Antiguo 23/06/2010, 00:16
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: Indicador de Progreso Circular

Con un poco de css:
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title></title>
<
style>
*{
margin:0padding:0}
#e{ width:100px; height:100px; overflow:hidden; position:absolute; top:50%; left:50%; z-index:360; margin-left:-50px; margin-top:-50px; border:1px dashed #999}
#c{ width:100px; height:2px; overflow:hidden; position:absolute; top:50%;  }
.rwidth:50pxheight:2pxbackground:#F00}
</style>
<
script>
function 
rotate(angle){
    var 
rotation Math.PI angle 180;
    var 
costheta Math.cos(rotation);
    var 
sintheta Math.sin(rotation); 
    if(!
window.ActiveXObject){
        
this.style.position='absolute';
        
this.style.webkitTransform ='rotate('+angle+'deg)';    
        
this.style.MozTransform='rotate('+angle+'deg)';    
        
this.style.OTransform='rotate('+angle+'deg)';
        
this.style.transform='rotate('+angle+'deg)';
    }else{
        
this.style.filter="progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand')";
        
this.filters.item(0).M11 costheta;
        
this.filters.item(0).M12 = -sintheta;
        
this.filters.item(0).M21 sintheta;
        
this.filters.item(0).M22 costheta
        
this.style.top=50-this.offsetHeight/2+'px';
        
this.style.left=50-this.offsetWidth/2+'px';
    }
}
onload=function(){
    var 
progress=0;
    var 
i=setInterval(function(){
        
progress++;
        var 
o=    document.getElementById('c').cloneNode(1);
        
o.style.zIndex=360-progress;
        
document.getElementById('e').appendChild(o);
        
rotate.call(o,progress);
        if(
progress==360){
            
clearInterval(i);
            
alert('listo');
        }
    },
100);
    
}
</script>
</head>

<body>
<div id="e"><div id="c"><div class="r"></div></div></div>
</body>
</html> 
O así (lo mismo, pero en forma de anillo):
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title></title>
<
style>
*{
margin:0padding:0}
#e{ width:100px; height:100px; overflow:hidden; position:absolute; top:50%; left:50%; z-index:360; margin-left:-50px; margin-top:-50px; border:1px dashed #999}
#c{ width:100px; height:2px; overflow:hidden; position:absolute; top:50%;  }
.rwidth:33pxheight:2pxbackground:#F00}
</style>
<
script>
function 
rotate(angle){
    var 
rotation Math.PI angle 180;
    var 
costheta Math.cos(rotation);
    var 
sintheta Math.sin(rotation); 
    if(!
window.ActiveXObject){
        
this.style.position='absolute';
        
this.style.webkitTransform ='rotate('+angle+'deg)';    
        
this.style.MozTransform='rotate('+angle+'deg)';    
        
this.style.OTransform='rotate('+angle+'deg)';
        
this.style.transform='rotate('+angle+'deg)';
    }else{
        
this.style.filter="progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand')";
        
this.filters.item(0).M11 costheta;
        
this.filters.item(0).M12 = -sintheta;
        
this.filters.item(0).M21 sintheta;
        
this.filters.item(0).M22 costheta
        
this.style.top=50-this.offsetHeight/2+'px';
        
this.style.left=50-this.offsetWidth/2+'px';
    }
}
onload=function(){
    var 
progress=0;
    var 
i=setInterval(function(){
        
progress++;
        var 
o=    document.getElementById('c').cloneNode(1);
        
o.style.zIndex=360-progress;
        
document.getElementById('e').appendChild(o);
        
rotate.call(o,progress);
        if(
progress==360){
            
clearInterval(i);
            
alert('listo');
        }
    },
100);
    
}
</script>
</head>

<body>
<div id="e"><div id="c"><div class="r"></div></div></div>
</body>
</html> 
Claro que con canvas sería más sencillo, pero esta es una manera ;)

Última edición por Panino5001; 23/06/2010 a las 07:16 Razón: Contemplar el standar de rotación de w3c, de futura implementación