Fractal zoom

So i´ve just started with fractals watching shiffman nature of code videos, and im very interesting in developing fractals with infinite zoom but i´ve haven´t figured it out,i´ve already tryd with scale and zoom in z, but with no succes.

this is my try :

float zoom;
float zoomspeed;
float zoomacel;
float size;

int counter;
void setup() {

  size(600, 600, P3D);
  zoomspeed = 1;
  zoomacel = 0;
  size = 100;
}

void draw() {
  background(255);
  zoomspeed +=zoomacel;
  zoom += zoomspeed;

  translate(0, 0, zoom);
  fill(0);
  drawcircle(width/2,height/2,600);


  fill(255, 0, 0);

}

void drawcircle(float x,float y,float size) {


  fill(255);
  ellipse(x, y, size, size);
  fill(0);
  ellipse(x, y, size*0.90, size*0.90);

  if (size > 0.1) {
    counter++;
    size*=0.75;
    drawcircle(x,y,size);
    //println("SIZE :", size);
  }
}

Answers

  • This is not infinite and not smooth but ...

    boolean flag;
    int count=0;
    int acc=1;
    double space=0.75;
    int stop=0;
    void setup(){
     size(600,600,P3D);
     stop=(int)(width*2/space/space-width*2);
     noStroke();
    }
    void draw(){
     background(255);
     flag=true;
     count+=acc;
     if(frameCount%10==0)acc++;
     for(float i=width*2+count%stop;i>1;i*=space){
      flag=!flag;
      fill(flag?0:255);
      ellipse(width/2,height/2,i,i);
     }
    }
    
  • Thanks ! That code works beatifully, i don´t get it why you say is not infinite

    Yet i noticed that is not that smooth.

    I´ve created this effect based on your code yet i still have a lot to improved.

    `boolean flag;
    int count=0;
    int acc=1;
    double space=0.90;
    int stop=0;
    
    float colorinc = 0;
    
    float rotangle;
    float posy;
    void setup() {
      //size(600, 600, P3D);
    
      fullScreen(P3D);
      stop=(int)(width*2/space/space-width*2);
      noStroke();
    }
    void draw() {
      background(255);
      rotangle+=TWO_PI*0.001;
    
    
      flag=true;
      count+=acc;
      if (frameCount%50==0) {
        acc++;
      }
    
      colorinc++;
      pushMatrix();
      translate(width/2,height/2);
      rotate(rotangle);
      drawcircle(0, 0, width*2+count%stop, 0.1, space,colorinc);
      popMatrix();
    }
    
    
    void drawcircle(float x, float y, float size, float umbral, double space,float _c) {
    
      //fill(flag?  color(random(200), 0, random(155)):color(random(100), 255, random(200,255)));
    
    
      color color1 = color(map(size,0,width,200,0), 150, 0);
      color color2 = color(0, 150, map(size,0,width,0,200));
    
      fill(flag?  color1:color2);
      ellipse(x, y, size, size);
      ellipse(x-size/2+20*cos(posy), y+20*sin(posy), size, size);
      ellipse(x+size/2+20*cos(posy+PI/2), y+20*sin(posy+PI/2), size, size);
      ellipse(x+20*cos(posy+PI), y+size/2+20*sin(posy+PI), size, size);
      ellipse(x+20*cos(posy+PI/2+PI), y-size/2+20*sin(posy+PI/2+PI), size, size);
      ellipse(x+20*cos(posy+PI/2+PI), y-size/2+20*sin(posy+PI/2+PI), size, size);
    
    
        if (size > umbral) {
        _c+=0.1;
        posy+=0.001;
       // if (_c > 255) _c =0; 
    
        flag=!flag;
        size*= space;
        drawcircle(x, y, size, umbral, space,_c);
        //drawcircle(x-size/2, y, size, umbral, space);
        //drawcircle(x+size/2, y, size, umbral, space);
      }
    }
    `
    
  • edited August 2017

    Here is a simplified,smooth and stable version of it:

    boolean flag;
    int count=0;
    int acc=3;
    double space=0.90;
    int stop=0;
    
    float colorinc = 0;
    
    float rotangle;
    float posy;
    void setup() {
      size(600, 600, P3D);
    
      // fullScreen(P3D);
      stop=(int)(width*2/space/space-width*2);
      noStroke();
    }
    void draw() {
      background(255);
    
      acc = int(map(mouseX, 0, width, -200, 200));
    
      flag=true;
      count+=acc;
      if (count < 0) count += stop;
    
      drawcircle(width/2, height/2, width*2+count%stop, 0.1, space, colorinc);
    }
    
    
    void drawcircle(float x, float y, float size, float umbral, double space, float _c) {
    
      color color1 = color(map(size, 0, width, 200, 0), 150, 50);
      color color2 = color(50, 150, map(size, 0, width, 0, 200));
    
      fill(flag?  color1:color2);
      ellipse(x, y, size, size);
    
    
      if (size > umbral) {
        _c+=0.1;
        posy+=0.001;
        flag=!flag;
        size*= space;
        drawcircle(x, y, size, umbral, space, _c);
      }
    }
    
Sign In or Register to comment.