Ver Mensaje Individual
  #5 (permalink)  
Antiguo 24/12/2003, 21:10
Avatar de derkenuke
derkenuke
Colaborador
 
Fecha de Ingreso: octubre-2003
Ubicación: self.location.href
Mensajes: 2.665
Antigüedad: 20 años, 6 meses
Puntos: 45
Bueno tengo este codigo, si les apetece leerlo y analizarlo me gustaria mucho que encontraran una solucion. pto() hace de clase. Los metodos getProp y ponerProp lo unico que hacen es devolver o poner respectivamente la propiedad que se les indique del style de un pto. La function rect() crea un rectangulo, la idea era crear los 4 vertices e ir alargando cada punto hasta que el rectangulo se cierre y quede dibujado.

<style>
.pto { font-size:1px; background-color:black; width:1;height:1;position:absolute; }
</style>

<script>
cont=0;
function pto() {
documento.innerHTML+="<div id='pto"+cont+"' class='pto'></div>";
this.ref="pto"+cont; cont++;
this.mover=moverPto;
this.getProp=propPto; this.ponerProp=ponerPropPto;
this.crecer=crecerPto;
}

function moverPto(x,y) { eval(this.ref+".style.top="+y+";"); eval(this.ref+".style.left="+x+";"); }
function propPto(prop) { return eval("parseInt("+this.ref+".style."+prop+")"); }
function ponerPropPto(prop,val) { eval(this.ref+".style."+prop+"="+val); }

function rect(l,t,w,h) {
A=new pto(); A.mover(l,t);
B=new pto(); B.mover(l+w,t);
C=new pto(); C.mover(l+w,t+h);
D=new pto(); D.mover(l,t+h);
A.crecer("width",w);
}

function crecerPto(prop,fin) {
if(this.getProp(prop)<fin || isNaN(this.getProp(prop))) {
if(isNaN(this.getProp(prop))) {
this.ponerProp(prop,2);
}
else {
this.ponerProp(prop,(this.getProp(prop)+1));
alert("No es NaN\nejecutado crecer:\nlacapa."+prop+"="+this.getProp(prop));
}
setTimeout("this.crecer('"+prop+"',"+fin+")",1000) ;
}
}

rect(100,100,500,200);

</script>


Espero que me ayuden. Un saludo.
__________________
- Haz preguntas inteligentes, y obtendrás más y mejores respuestas.
- Antes de postearlo Inténtalo y Búscalo.
- Escribe correctamente tus mensajes.