Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Nagon {
- float x[];
- float y[];
- int n;
- Nagon(int numberOfVertex, float xPos, float yPos, float rad, float theta) {
- n = numberOfVertex;
- x = new float[n];
- y = new float[n];
- int step = n - 1;
- if (n % 2 == 0) step = 2;
- for(int i = 0; i < n; i++){
- x[i] = xPos + rad * cos( theta + (i * step * PI) / n );
- y[i] = yPos + rad * sin( theta + (i * step * PI) / n );
- }
- }
- void DrawNagon () {
- for (int i = 0; i < n; i++){
- if (n % 2 != 0){
- line(x[i],y[i],x[(i+2)%n],y[(i+2)%n]);
- } else {
- line(x[i],y[i],x[(i+1)%n],y[(i+1)%n]);
- }
- }
- }
- }
- void setup () {
- size (1000, 1600);
- background (0);
- stroke(255);
- smooth();
- for(int i = 0; i < 7; i++){
- for(int j = 0; j < 4; j++){
- for(int k = 1; k < 20; k++){
- Nagon n = new Nagon(i+3,200 + 200*j, 200 + 200*i,k*5 ,k*j*2/PI);
- n.DrawNagon();
- }
- }
- }
- noLoop();
- }
- //this function ripped from code written by http://markusbenjamin.tumblr.com/ who has a cool blog which you should check out
- void keyPressed() {
- if (key=='s') {
- save(nf(random(1)*1000, 4, 4)+".png");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement