Diagonal drawer

It draws all diagonals of an n-sided polygon. Idk why it would be useful but have fun!

int n = 10, r = 200,cx = 300, cy = 300;
void setup() {
  size(600,600);
}

void draw() {
  background(0);
  stroke(255);
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      line( cx + cos(TWO_PI/n*i)*r, cy + sin(TWO_PI/n*i)*r, cx + cos(TWO_PI/n*j) * r, cy + sin(TWO_PI/n*j)*r);
    }
  }
}

and an optimized version:

int n = 20, r = 200, cx = 300, cy = 300;
size(600, 600);
background(0);
stroke(255);
for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) {
  line( cx + cos(TWO_PI/n*i)*r, cy + sin(TWO_PI/n*i)*r, cx + cos(TWO_PI/n*j) * r, cy + sin(TWO_PI/n*j)*r);
}

2 Likes

by the rate I’m creating posts it would be considered spam : P

1 Like

Ahah yeah you are too fast for us :grin:

What about making a repository of your sketches then sharing it one the forum with a single link? (rather than creating a lot of posts) For that you can use GitLab, GitHub, BitBucket, or create your own website!

2 Likes

sorry about that. I just really got into programming again and yeah… What do you recommend? I personally don’t like github because I have no idea how to use it. Well if you recommend github I’ll just look into it.

I am not a fan of paid things so I don’t feel comfortable hosting my own website. And It’s a lot of hassle to set it up and run it.

Ahah that’s the fun part of system administration and web development (which is also interesting if you’re really into programming). :hugs:

If it’s your thing, GitHub and other source control technologies are an important step in software development. I am not a big fan of GitHub itself (the platform) but a lot of open source projects are hosted here. It could be a nice way to organize your work.

But again GitHub is not the only platform for hosting your code, remember that!

1 Like

Or just use www.openprocessing.org

2 Likes