xeromino

spiral

Dec 25th, 2013
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. void setup() {
  2.   size(800, 800);
  3.   background(255);
  4.   float sw=0;
  5.   float theta = 0;
  6.   int centX = width/2;
  7.   int centY = height/2;
  8.  
  9.   stroke(20, 50, 70);
  10.   float radius = 5;      
  11.   float x, y;
  12.   float lastx = -999;
  13.   float lasty = -999;
  14.   for (float ang = 0; ang <= 8*360; ang += 4) {
  15.     sw = map(sin(theta*1.5), -1, 1, 4, 40);
  16.     strokeWeight(sw);  
  17.     radius += 0.8;
  18.     float rad = radians(ang);
  19.     x = centX + (radius * cos(rad));
  20.     y = centY + (radius * sin(rad));
  21.     if (lastx > -999) {
  22.       line(x, y, lastx, lasty);
  23.     }
  24.     lastx = x;
  25.     lasty = y;
  26.     theta += 0.05;
  27.   }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment