Advertisement
xeromino

color

May 10th, 2014
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. int x, y, counter;
  2. float outsideRadius, insideRadius, theta;
  3. int numPoints = 120;
  4. int[] palette = new int[numPoints];
  5.  
  6. void setup() {
  7.   size(400, 400, P2D);
  8.   background(255);
  9.   x = width/2;
  10.   y = height/2;
  11.   frameRate(15);
  12.  
  13.   for (int i=0; i<numPoints; i++) {
  14.     palette[i] = int(255/numPoints*i);
  15.   }
  16. }
  17.  
  18. void draw() {
  19.   background(0);
  20.   stroke(0);
  21.   strokeWeight(5);
  22.   noStroke();
  23.  
  24.   float angle = 0;
  25.   float angleStep = 180.0/numPoints;
  26.  
  27.   insideRadius =80;
  28.   outsideRadius = insideRadius*2;
  29.  
  30.   beginShape(TRIANGLE_STRIP);
  31.   for (int i = 0; i <= numPoints; i++) {
  32.     float px = x + cos(radians(angle)) * outsideRadius;
  33.     float py = y + sin(radians(angle)) * outsideRadius;
  34.     angle += angleStep;
  35.     vertex(px, py);
  36.     colorMode(HSB, 360, 100, 100);
  37.     fill((i+counter)%numPoints*360/numPoints, 100, 80);
  38.     px = x + cos(radians(angle)) * insideRadius;
  39.     py = y + sin(radians(angle)) * insideRadius;
  40.     vertex(px, py);
  41.     colorMode(RGB);
  42.     angle += angleStep;
  43.   }
  44.   endShape();
  45.   counter++;
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement