Advertisement
Guest User

Untitled

a guest
Jul 7th, 2016
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. float t;
  2. PShape curve;
  3. void setup(){
  4.   size(600,600);
  5.   t = 0.0;
  6. }
  7.  
  8. void draw(){
  9.   background(0);
  10.  
  11.   curve = createShape();
  12.   curve.beginShape();
  13.   curve.fill(255);
  14.   curve.noStroke();
  15.  
  16.   float theta = 0;
  17.   while (theta < TWO_PI){
  18.     float r = funct(theta, t);
  19.     float x = r * cos(theta);
  20.     float y = r * sin(theta);
  21.    
  22.     x = map(x,-2,2,0,width);
  23.     y = map(y,-2,2,height,0);
  24.    
  25.     curve.vertex(x,y);
  26.     theta += TWO_PI/200;
  27.   }
  28.  
  29.   curve.endShape(CLOSE);
  30.   shape(curve,0,0);
  31.  
  32.   t += 0.2/400;
  33.  
  34.   //saveFrame("./data/frame#####.tif");
  35.  
  36.   if (t > 0.2){
  37.     //println("done capturing");
  38.     //exit();
  39.     t = 0;
  40.   }
  41. }
  42.  
  43. float funct(float theta, float t){
  44.   return 1 + t * sin(7*theta);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement