Advertisement
bethdps

Polígono

Jan 24th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. void setup(){
  2.   size(800,800);
  3.   background(255);
  4.  
  5.   poligonoRegular(7);
  6. }
  7.  
  8. void poligonoRegular(int Lados){
  9.  
  10.    if(Lados <=2){
  11.      println("Quantidade inválida");
  12.      return;
  13.    }
  14.  
  15.    float angulo = 2*PI/Lados;
  16.    float tHeight = 120;
  17.    int tWidth = ceil(tan(angulo/2)*tHeight);
  18.    
  19.    fill(0);
  20.    noStroke();  
  21.    
  22.    translate(width/2,height/2);
  23.    
  24.    for(int i=0; i<Lados; i++){
  25.      rotate(angulo);
  26.      triangle(0,0, -tWidth, tHeight, tWidth, tHeight);
  27.    }
  28.    
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement