"Script Nou" - Processing

ID Autor Duplicat din Ultima modificare
#5658 Serafimovici Bogdan (MagicFoca) - Duminica, 20 aug 2023, 15:28
x
 
1
void setup(){
2
  size(640, 360);
3
}
4
5
void draw(){
6
  background(102);
7
  
8
  pushMatrix();
9
  translate(width*0.2, height*0.5);
10
  rotate(frameCount / 200.0);
11
  polygon(0, 0, 82, 3);  // Triangle
12
  popMatrix();
13
  
14
  pushMatrix();
15
  translate(width*0.5, height*0.5);
16
  rotate(frameCount / 50.0);
17
  polygon(0, 0, 80, 20);  // Icosagon
18
  popMatrix();
19
  
20
  pushMatrix();
21
  translate(width*0.8, height*0.5);
22
  rotate(frameCount / -100.0);
23
  polygon(0, 0, 70, 7);  // Heptagon
24
  popMatrix();
25
}
26
27
void polygon(float x, float y, float radius, int npoints){
28
  float angle = TWO_PI / npoints;
29
  beginShape();
30
  for (float a = 0; a < TWO_PI; a += angle){
31
    float sx = x + cos(a) * radius;
32
    float sy = y + sin(a) * radius;
33
    vertex(sx, sy);
34
  }
35
  endShape(CLOSE);
36
}
Du-te sus!