Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup(){
- size(800,800);
- background(255);
- poligonoRegular(7);
- }
- void poligonoRegular(int Lados){
- if(Lados <=2){
- println("Quantidade inválida");
- return;
- }
- float angulo = 2*PI/Lados;
- float tHeight = 120;
- int tWidth = ceil(tan(angulo/2)*tHeight);
- fill(0);
- noStroke();
- translate(width/2,height/2);
- for(int i=0; i<Lados; i++){
- rotate(angulo);
- triangle(0,0, -tWidth, tHeight, tWidth, tHeight);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement