Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

Dandelion-like Fractals

10. November 2010

My goal was to create a dandelion-like (pusteblumen-aehnliche) fractals. I came up with the idea of using all kinds of spirals. Some spirals shown are variations, with different parameters and are itself recursive: each spiral dot can call a new spiral etc. This is the last version which creates the last pictures seen below:

/* ----------------------------------------------------------------------------
 *  codingSpace - 5
 * ----------------------------------------------------------------------------
 *  fractals
 * ----------------------------------------------------------------------------
 *  prog: eddi.lecesne@zhdk.ch
 * ----------------------------------------------------------------------------
 * 09.11.2010
 */

void setup()
{
  size(800,600);      // def. fenstergroesse

  randomSeed(millis());  // seed random

  smooth();           // aktiviere antialiasing
  strokeWeight(5);    // linienbreite

  noLoop();
}

void draw()
{
  background(255);

  pushMatrix();
  translate(width *.5,height - 20);
  wurzel(7);
  popMatrix();
}

void mousePressed()
{
  redraw();
}

// funktion
void wurzel(int tiefe)
{
  int depth= 50;

  if(tiefe <=0)    // teste ob das ende erreicht worden ist
  {
    // zeichen blueten
    pushStyle();
    int clr = (int)random(100,255);
    figure(true, depth, 0.0, 0.0);
    popStyle();
    return;
  }

  // zeichne zweige
  int x;
  int y;

  int count = (int)random(1,3);
  for(int i = 0; i < count;i++)
  {
    x = (int)random(-100,100);
    y = -(int)random(10,150);

    noFill();
   line(0,0,x,y);
   //bezier(0, 0,x+14, y+10,x+3, y+8, x, y);  //optional: bezier curve

    pushMatrix();
    translate(x,y);
    scale(random(.3,.95));
    wurzel(tiefe-1);
    popMatrix();
  }
}
//parameter: [ellipse or line], [rekursiv deepnes], [start of older x & y value (needed for recursion)]
void figure(boolean select, float depth, float x_old, float y_old) {
  float x=0;
  float y=0;
  float r = 0;  //radius

  for(float theta=0; theta<50; theta+=0.1) {  //incement angle

    r=theta*40.0;  //increase radius (multiplicator can be changed to in-/decrease spiral size)

    // Polar to Cartesian conversion
    x = (r * cos(theta));  //calculate x coordinate from radius r and angle
    y = (r * sin(theta));  //calculate x coordinate from radius r and angle

    if(select) {  //true: then ellipse

      ellipse(x, y, 64, 64);
    }
    else {  //false: then point
      point(x,y);
    }
  }
  //recursion
  if(depth>0) {
    rotate(PI/4.0);
    figure(false, depth-=1, depth*40.0*cos(depth),depth*40.0*sin(depth));  //recursive call
  }
}

 
Here are some screenshots with different kind of code-presets: