Advertisement
xeromino

triCol

Aug 16th, 2016
427
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int num = 1, frms = 100;
  2. float theta;
  3. color[] col = {color(255, 50, 0), color(0, 255, 50), color(0, 50, 255)};
  4.  
  5. void setup() {
  6.   size(540, 540, P2D);
  7. }
  8.  
  9. void draw() {
  10.   //background(0);
  11.   noStroke();
  12.   fill(20, 30);
  13.   rect(0, 0, width, height);
  14.   for (int i=0; i<num; i++) {
  15.     float offSet = HALF_PI/num*i;
  16.     drawTriangle(offSet);
  17.   }
  18.  
  19.   theta += TWO_PI/frms;
  20.   if (frameCount> 100 && frameCount<=(100+frms)) saveFrame("image-###.png");
  21. }
  22.  
  23. void drawTriangle(float offSet) {
  24.   float r = map(sin(theta),-1,1,50,150);
  25.   pushMatrix();
  26.   translate(width/2, height/2);
  27.   rotate(theta+offSet);
  28.   beginShape();
  29.   for (int i=0; i<3; i++) {
  30.     float x = cos(TWO_PI/3*i)*r;
  31.     float y = sin(TWO_PI/3*i)*r;
  32.     fill(col[i]);
  33.     vertex(x, y);
  34.   }
  35.   endShape();
  36.   popMatrix();
  37. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement