LA CURVA C O CURVA DEL DRAGON Codigo Fuente fscommand("showMenu",false); stop(); _root.createEmptyMovieClip("fractal", 1); fractal.lineStyle(.01, 0xffffff, 100); stack = new Array();
function sqr(x) { return x*x; }
maxiters = 1; maxn = Math.pow(2, maxiters);
function FindAngle(x1, x2, y1, y2) { dx = x1-x2; dy = y1-y2; angle2 = -Math.atan2(dy, dx)*(180/Math.PI); return 180-angle2; }
function radTodeg(x) { return 180/Math.PI*x; } function degTorad(x) { return Math.PI/180*x; }
//dibuja las lineas iniciales Iterate(150, 200, 400, 200);
//grafica el fractal cuando se crea un nuevo movieclip onEnterFrame = function() { if (n<maxn-2) { n++; deactivated = false; x1 = stack.shift(); //shift: extrae y elimina el primer dato del array y1 = stack.shift(); x2 = stack.shift(); y2 = stack.shift(); Iterate(x1, y1, x2, y2); } else { iterInc._visible = true; //no muestra el boton iterar mientras el fractal no haya terminado su iteracion deactivated = true; } }
_root.iterInc.onPress = function() { if (deactivated) { //controla si el boton esta visible _root.createEmptyMovieClip("fractal", 1); fractal.lineStyle(.01, 0xffffff, 100); iterInc._visible = false; maxiters++; maxn = Math.pow(2, maxiters); } }
Ver Prpgrama http://img86.xooimage.com/files/7/8/0/trabajo-de-fractal-366e585.swf Ver Programa Completo http://tienda10.perusystem.com/flash/trabajo_de_fractal.swf
Este comentario ha sido eliminado por el autor.
ResponderEliminarArbol de n Ramas
ResponderEliminarhttp://manualesnet.blogspot.com/
LA CURVA C O CURVA DEL DRAGON
ResponderEliminarCodigo Fuente
fscommand("showMenu",false);
stop();
_root.createEmptyMovieClip("fractal", 1);
fractal.lineStyle(.01, 0xffffff, 100);
stack = new Array();
function sqr(x)
{
return x*x;
}
maxiters = 1;
maxn = Math.pow(2, maxiters);
function FindAngle(x1, x2, y1, y2)
{
dx = x1-x2;
dy = y1-y2;
angle2 = -Math.atan2(dy, dx)*(180/Math.PI);
return 180-angle2;
}
function radTodeg(x)
{
return 180/Math.PI*x;
}
function degTorad(x)
{
return Math.PI/180*x;
}
function Iterate(startx, starty, endx, endy) //creacion del fractal
{
with(fractal){
totaldist = Math.sqrt(sqr(endx-startx)+sqr(endy-starty));
angle = FindAngle(startx, endx, starty, endy);
dist = Math.sqrt(2*sqr(totaldist/2));
moveTo(startx, starty);
x2 = startx-dist*Math.cos(degTorad(angle+135));
y2 = starty-dist*Math.sin(degTorad(angle+135));
lineTo(x2, y2);
lineTo(endx, endy);
stack.push(startx, starty, x2, y2);
stack.push(endx, endy, x2, y2);
}
}
//dibuja las lineas iniciales
Iterate(150, 200, 400, 200);
//grafica el fractal cuando se crea un nuevo movieclip
onEnterFrame = function()
{
if (n<maxn-2)
{
n++;
deactivated = false;
x1 = stack.shift(); //shift: extrae y elimina el primer dato del array
y1 = stack.shift();
x2 = stack.shift();
y2 = stack.shift();
Iterate(x1, y1, x2, y2);
}
else
{
iterInc._visible = true; //no muestra el boton iterar mientras el fractal no haya terminado su iteracion
deactivated = true;
}
}
_root.iterInc.onPress = function()
{
if (deactivated) { //controla si el boton esta visible
_root.createEmptyMovieClip("fractal", 1);
fractal.lineStyle(.01, 0xffffff, 100);
iterInc._visible = false;
maxiters++;
maxn = Math.pow(2, maxiters);
}
}
Ver Prpgrama
http://img86.xooimage.com/files/7/8/0/trabajo-de-fractal-366e585.swf
Ver Programa Completo
http://tienda10.perusystem.com/flash/trabajo_de_fractal.swf