7
edits
| No edit summary | |||
| Line 327: | Line 327: | ||
|   ellipse ( x, y, 40, 40 ); |   ellipse ( x, y, 40, 40 ); | ||
|   rect ( x, y, 10, 10 ); |   rect ( x, y, 10, 10 ); | ||
| } | |||
| '''EMIR GENC''' | |||
| [[File:Afro_pattern.jpg ]] | |||
| color blue=color (22, 131, 201); | |||
| void setup() { | |||
|   size(500, 500); | |||
| } | |||
| void draw() { | |||
|   background(blue); | |||
|   noFill(); | |||
|   float o=40; | |||
|   float p=10; | |||
|   for (int x=0; x<500; x+=2*o+2*o*sin (PI/6)) { | |||
|     for (int y=0; y<500; y+=2*o*cos (PI/6)) { | |||
|       if (mouseX <250) { | |||
|         drawHexagon(x, y, p); | |||
|         drawHexagon(x+o+o*sin(PI/6), y+o*cos(PI/6), p); | |||
|       } else { | |||
|         drawHexagon(x, y, p+10); | |||
|         drawHexagon(x+o+o*sin(PI/6), y+o*cos(PI/6), p+10); | |||
|       } | |||
|     } | |||
|   } | |||
|   for (int x=0; x<500; x+=2*o+2*o*sin (PI/6)) { | |||
|     for (int y=0; y<500; y+=2*o*cos (PI/6)) { | |||
|       drawHexagon(x, y, o); | |||
|       drawHexagon(x+o+o*sin(PI/6), y+o*cos(PI/6), o); | |||
|     } | |||
|   } | |||
| } | |||
| void mousePressed() { | |||
|   blue +=10; | |||
| } | |||
| void drawHexagon(float x, float y, float radius) { | |||
|   if (mousePressed) { | |||
|     stroke(255); | |||
|   } else { | |||
|     stroke(0); | |||
|   } | |||
|   pushMatrix(); | |||
|   translate(x, y); | |||
|   beginShape(); | |||
|   for (int i = 0; i < 6; i++) { | |||
|     pushMatrix(); | |||
|     float angle = PI*i/3; | |||
|     vertex(cos(angle) * radius, sin(angle) * radius); | |||
|     popMatrix(); | |||
|   } | |||
|   endShape(CLOSE); | |||
|   popMatrix(); | |||
| } | } | ||
edits