Advertisement
Guest User

Code

a guest
Oct 1st, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. void setup() {
  2.  size(600, 600, P2D);
  3. }
  4.  
  5. int dots = 4;
  6. PVector coords[] = new PVector[9999];
  7.  
  8. void mouseClicked() {
  9.   dots++;
  10.   clear();
  11.   background(80);
  12.   drawCircle(dots,width/2);
  13. }
  14. void draw() {
  15.   background(80);
  16.  translate(width/2,height/2);
  17.  drawCircle(dots,width/3);
  18. }
  19.  
  20. void drawCircle(int sides, float r)
  21. {
  22.  float angle = 360 / sides;
  23.  noFill();
  24.  beginShape();
  25.  for (int i = 0; i < sides; i++) {
  26.  float x = cos( radians( i * angle ) ) * r;
  27.  float y = sin( radians( i * angle ) ) * r;
  28.  coords[i] = new PVector(x,y);
  29.  vertex(x,y);
  30.  }
  31.  endShape(CLOSE);
  32.  connect(coords);
  33. }
  34.  
  35. void connect(PVector[] coords) {
  36.  for(PVector coord : coords) {
  37.    if(coord != null) {
  38.  for(PVector coord1 : coords) {
  39.    if(coord1 != null) {
  40.  line(coord.x, coord.y, coord1.x, coord1.y);
  41.  }
  42.  }
  43.  }
  44.  }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement