• fullscreen
  • i3B_trojSrand_1.pde
  • void setup() {
      size(700, 700);
      background(0);
      stroke(color(255, 100));
      smooth();
      fill(255);
    }
    
    int Dx = 0;
    int Dy = height;
    
    void draw() 
    {
      for (int i = 0; i < 100; i++)
      {
        switch(int(random(3)))
        {
        case 0:
          Dx = (0+Dx)/2;
          Dy = (height+Dy)/2;
          break;
        case 1:
          Dx = (width+Dx)/2;
          Dy = (height+Dy)/2;
          break;      
        case 2:
          Dx = (width/2+Dx)/2;
          Dy = (0+Dy)/2;
          break;
        }
        point(Dx, Dy);
      }
    }
    
    
    
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Paweł Sikorski

    sierpinski triangle chaos game

    Add to Faves Me Likey@!
    You must login/register to add this sketch to your favorites.

    "1. Take 3 points in a plane to form a triangle, you need not draw it.
    2. Randomly select any point inside the triangle and consider that your current position.
    3. Randomly select any one of the 3 vertex points.
    4. Move half the distance from your current position to the selected vertex.
    5. Plot the current position.
    6. Repeat from step 3."

    from Wikipedia, the free encyclopedia

    You need to login/register to comment.