Saturday, January 23, 2010

Swirving

float theta = 0;
float frame = 0;
int rcolor,gcolor,bcolor;
float r = 10.0;
float ratio;
int i;
float y = -1000;
float disp1 = 2;
float disp2 = 2;
float ringsize = 4;
float stepsize =  0.08;
float[] startingAngles = new float[40];
float[] speeds = new float[40];



void setup() {
  size(800,600);
  background(0);
  theta = 0;
  noStroke();
for (int counter = 0; counter < 40; counter++){
startingAngles[counter] = random(0,radians(360));
speeds[counter] = random(0.5,2);
}
}

void draw() {


  //fill(0,0,0,5);
  //rect(0,0,width,height);

  theta += stepsize ;
  r = 13*abs(sin(frame/400));

  translate(width/2-r,height/2);
  frame +=1;


  noStroke();

  stepsize = 0.001;
  ringsize = 1.0/20.0;

for (int multiplePointsAlpha = 0; multiplePointsAlpha < 40; multiplePointsAlpha++){


float alpha = disp2 + sin(theta *speeds[multiplePointsAlpha])/ringsize + startingAngles[multiplePointsAlpha];
  
 float beta = disp1 + cos(theta *speeds[multiplePointsAlpha])/ringsize + startingAngles[multiplePointsAlpha];
      
    float x = 20*r*cos(alpha+r)+cos(beta+alpha+r);
    y = 20*r*sin(alpha+r);
    float z = 20*r*cos(alpha+r)*sin(beta+r);

  //float displacementPerc = 1+(1/(-z-1))/100;
  //x -= displacementPerc;
  //y -= displacementPerc;


  int rectangleSize = int(3+((2*r+1)-z/6)/10);

  
          fill( int(100 -z/2 + rcolor + r + alpha * 10), int(100 -z/2 + gcolor +r - alpha * 10), int(100 -z/2 + bcolor + r - alpha * 10),40);
          ellipse(x,y,rectangleSize,rectangleSize);
  

}
  }

infoinfo

submitted by: DARYL_Gamma
views: 



treeThis sketch has a parent
Tags:

commentscomment

loading loading...

 

Add a comment: