Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup() {
- size(600, 600, P2D);
- }
- int dots = 4;
- PVector coords[] = new PVector[9999];
- void mouseClicked() {
- dots++;
- clear();
- background(80);
- drawCircle(dots,width/2);
- }
- void draw() {
- background(80);
- translate(width/2,height/2);
- drawCircle(dots,width/3);
- }
- void drawCircle(int sides, float r)
- {
- float angle = 360 / sides;
- noFill();
- beginShape();
- for (int i = 0; i < sides; i++) {
- float x = cos( radians( i * angle ) ) * r;
- float y = sin( radians( i * angle ) ) * r;
- coords[i] = new PVector(x,y);
- vertex(x,y);
- }
- endShape(CLOSE);
- connect(coords);
- }
- void connect(PVector[] coords) {
- for(PVector coord : coords) {
- if(coord != null) {
- for(PVector coord1 : coords) {
- if(coord1 != null) {
- line(coord.x, coord.y, coord1.x, coord1.y);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement