fork download
  1. //q12243404442
  2.  
  3. class Cyc {
  4. int index;
  5. int max;
  6. ArrayList<PVector> dirs;
  7.  
  8. Cyc(int max) {
  9. this.max = max;
  10. index = 0;
  11.  
  12. dirs = new ArrayList<PVector>();
  13.  
  14. for(int i=0; i<max; i++){
  15. float x = cos(i*TWO_PI/max);
  16. float y = sin(i*TWO_PI/max);
  17. dirs.add(new PVector(x, y));
  18. }
  19. }
  20.  
  21. PVector get() {
  22. return dirs.get(index);
  23. }
  24. void next() {
  25. index++;
  26. if (index == max) {
  27. index = 0;
  28. }
  29. }
  30. }
  31.  
  32. void setup() {
  33. size(800, 600);
  34.  
  35. Cyc cyc = new Cyc(4);
  36. PVector start = new PVector(width/2, height/2);
  37. PVector end = new PVector(width/2, height/2);
  38.  
  39. background(0);
  40.  
  41. float w = 30;
  42. PVector d = new PVector(w, w);
  43. PVector base = new PVector(w, w);
  44.  
  45. stroke(255);
  46.  
  47. int loop = 37;
  48. for (int i=0; i<loop; i++) {
  49. if (i>0) {
  50. if (i%2==0) {
  51. d.add(base);
  52. }
  53. }
  54.  
  55. end.add(new PVector(d.x*cyc.get().x, d.y*cyc.get().y));
  56. cyc.next();
  57.  
  58. line(start.x, start.y, end.x, end.y);
  59.  
  60. start = end.copy();
  61. }
  62. }
  63.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty