Sierpinski con attrattore

final int   quanti = 200;
final color colore = color(0);

float X,  Y,
      X1, Y1,
      X2, Y2,
      X3, Y3;

void setup()
{
  size(500, 500);
  frameRate(30);  
  
  X1=0;       Y1=height; 
  X2=width;   Y2=height;
  X3=width/2; Y3=0;
  
  inizia();
}

void mousePressed()
{
   inizia();
}

void inizia()
{
  background(255);
  X = mouseX;
  Y = mouseY;
}

void draw()
{ 
  for(int i=0; i < quanti; i++)
  {
	switch((int)random(3))
	{
	  case 0: X=(X+X1)/2.0;  Y=(Y+Y1)/2.0; break;
	  case 1: X=(X+X2)/2.0;  Y=(Y+Y2)/2.0; break;
	  case 2: X=(X+X3)/2.0;  Y=(Y+Y3)/2.0; break;
	}
	set(round(X), round(Y), colore);
  }
}