Site hosted by Angelfire.com: Build your free website today!
FRACTALES DINÁMICOS

FUEGOS juegos;

void setup(){
framerate (25);
size (500,500);
background (255);
juegos=new FUEGOS(1,30,0,1.25,1.75,0.1);
}

//**loop**//
void loop(){
juegos.modo();
translate (width/2,width/2,-15500); //centra la figura en el plano
juegos.modoFractal();
}

//**mouse event**//

void mouseReleased(){
juegos.cval();
}

//**clase**//

class FUEGOS
{
float varz;
float z;
float zz= (PI/6)/30 ;
float x; //Var deremina la figura
float y ; //crecer
float yy ; //decrecer
float r; //rojo
float g; //verde
float c; // rotacion en z
float cc; //rotacion en z
float v; //azul
float rr; //rojo
float gg; //verde
float vv; //azul
float h; //parametro crecer (cantidad de puntos dentro del for)
float sval; //zoom
float colval;
int a;
float paramx;
boolean mouse = false;
boolean modoA = true;
float grand=2;

//**constructor**//

FUEGOS(float Y, float YY, float RR, float GG, float VV, float CC){
//a=A;
y=Y;
yy=YY;
rr=RR;
gg=GG;
vv=VV;
cc=CC;
}

//**Metodo modoFractal -- presentar, dibujar, parar, mostrar**//

void modoFractal(){
if (grand==1){
if (modoA==true){
moverY();
}
if (modoA==false){
background (255);
moverY();
}
}

if (grand==2){
background (255);
presentar();
}
}

//**Metodo rotando -- rota fig en z**//

void rotando(){
rotateZ(c);
}

//**Metodo rotando -- rota fig en y**//

void rotandoY(){
rotateY(c);
}

//**Metodo cambio -- zoom y key pressed**//

void cambio(boolean mouse){

if (grand==1){
c = c + cc;// vel rotacion z
if (mouse){
if (mousePressed){
z=z;
sval += 0.5;
c=c;
a=1;
}

else {sval -= 0.1;}
if(sval > 50) { sval = 50; }
if(sval < 1.0) { sval = 1.0; }
scale(sval);
}

if (!mouse) {
sval=0;
}
}

if (keyPressed){
if (key == 'c' || key == 'C') {
paramx=random (0,3);
grand = 2;
}
}
}

//**Metodo modo -- dibujar o no dibujar

void modo(){
if (key == 'm' || key == 'M') {
modoA=true;
}
if (key == 'b' || key == 'B') {
modoA=false;
}
}

//**Metodo cval -- cambio de direccion en Z cuando mouseReleased**//

void cval(){
if (cc == +cc){
cc=-cc;
}
}

//** Metodo Presentar -- Presenta figura con la que se va a dibujar

void presentar(){
if (grand==2){
z=PI/2;
push();
translate ((-10000+(h*1000)),26000,-50000);
moverY();
pop();
if (mousePressed){
grand = 1;
background (255);
}
}
}

//**Metodo parametro -- control crecer y aparecer**//

void parametro(){
h=y++;
if (h>=30){
h = yy--;
}
if (h<=0){
y = 1;
h = y++;
yy =30;
}
}

//**Metodo giro -- rota cada figura del fractal en z**//

void giro(){
rotateZ (x);
}

//**Metodo dibujo -- Fractal**//

void dibujo(){
for (int j=0; j<h;j++){
translate (j*100,0);
giro();
push();
for (int i=0; i<h;i++){
translate (i*7,0);
giro();
push();
for (int m=0; m< h; m++){
giro();
point (0.1-m/2,2);
}
pop();
}
pop();
}
}

//**Metodo fractal -- dibuja fractal con cambios**//

void fractal(){
noStroke();
cambio(mouse); //eventos de mouse
parametro(); //parametros de h
rotando(); //rota figura
dibujo(); //dibuja la iteracion de la iteracion
}

//**Metodo moverY -- gira fractal en eje Y y colorea...**//

void moverY(){
for (int i=0; i<1; i++){
x=(paramx-(i+1));
colval= i+ varz;
push();
rotadorY();
if (juegos.grand==1){
if (key == 'y' || key == 'Y') {
rotateY (colval);
}
else if (key == 'z' || key == 'Z') {
rotateZ (colval);
}
else {
rotateY (colval);
}
}
if (juegos.grand==2){
rotateY (colval);
}
translate (width*16,0,0);
push();
rotateY (89.5);
if (juegos.grand==1){
if (juegos.modoA==true){
if (key == 's' || key == 'S') {
}
else {
juegos.fractal();}
}
else {
juegos.fractal();
}
}
if (juegos.grand==2){
juegos.fractal();
}
pop();
pop();
}
}

//**Metodo rotadorY** -- determina giro en Y, parar y cambiar//

void rotadorY(){
varz=z -zz;
if ((pmouseX>=225) || (pmouseX<=275)){
z=z;mouse=true;
}
if ((pmouseX<=225)||(pmouseX>=275)){
mouse=false;
if (pmouseX>=275){
z=z-zz;
}
if (pmouseX<=275){
z=z+zz;
}
}
if (varz == z +zz){
if (varz>= TWO_PI){
z=0; varz=z-zz;
}
}
if (varz == z -zz){
if (varz<= 0){
z=TWO_PI; varz=z-zz;
}
}
}
}

Que hace este código?