Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public void setup()
  2. {
  3. size(512, 512);
  4. }
  5.  
  6. public void draw()
  7. {
  8. background(255);
  9.  
  10. int numberOfPoints = 10 + (mouseX * 2) - 1;
  11.  
  12. float fromAngle = 0;
  13. float toAngle = TWO_PI;
  14.  
  15. float radius1 = 200.0f;
  16. float radius2 = 100.0f;
  17.  
  18. fill(0);
  19. noStroke();
  20. beginShape();
  21.  
  22. for (int i = 0 ; i < numberOfPoints ; i++)
  23. {
  24. float p = i / (numberOfPoints - 1.0f);
  25.  
  26. float cA = lerp(fromAngle, toAngle, p);
  27.  
  28. float radius;
  29.  
  30. if (i % 2 == 0)
  31. {
  32. radius = radius1;
  33. }
  34. else
  35. {
  36. radius = radius2;
  37. }
  38.  
  39. vertex(
  40. width / 2.0f + cos(cA) * radius,
  41. height / 2.0f + sin(cA) * radius
  42. );
  43. }
  44.  
  45. endShape();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement