apde吧 关注:15贴子:57
  • 2回复贴,共1

apde多边形代码效果

只看楼主收藏回复




IP属地:广东来自Android客户端1楼2020-12-05 11:19回复
    PShape q3bx,q4bx,q5bx,q6bx,q7bx,q8bx,q9bx,q10bx;
    float circleRad = 100;
    void setup() {
    size(displayWidth,displayHeight, P3D);
    dbx();
    }
    void dbx() {
    q3bx = createShape();
    q3bx.beginShape(POLYGON);
    q3bx.fill(201,165,255);
    for (int i = 0; i <3; i++) {
    float angle = TWO_PI * i /3;
    float x = circleRad * sin(angle)-400;
    float y = circleRad * cos(angle)-900;
    float z = 0;
    q3bx.vertex(x, y, z);
    }
    q3bx.endShape(CLOSE);
    q4bx = createShape();
    q4bx.beginShape(POLYGON);
    q4bx.fill(201,165,255);
    for (int i = 0; i <4; i++) {
    float angle = TWO_PI * i /4;
    float x = circleRad * sin(angle)-200;
    float y = circleRad * cos(angle)-900;
    float z = 0;
    q4bx.vertex(x, y, z);
    }
    q4bx.endShape(CLOSE);
    q5bx = createShape();
    q5bx.beginShape(POLYGON);
    q5bx.fill(201,165,255);
    for (int i = 0; i <5; i++) {
    float angle = TWO_PI * i /5;
    float x = circleRad * sin(angle);
    float y = circleRad * cos(angle)-900;
    float z = 0;
    q5bx.vertex(x, y, z);
    }
    q5bx.endShape(CLOSE);
    q6bx = createShape();
    q6bx.beginShape(POLYGON);
    q6bx.fill(201,165,255);
    for (int i = 0; i <6; i++) {
    float angle = TWO_PI * i /6;
    float x = circleRad * sin(angle)+200;
    float y = circleRad * cos(angle)-900;
    float z = 0;
    q6bx.vertex(x, y, z);
    }
    q6bx.endShape(CLOSE);
    q7bx = createShape();
    q7bx.beginShape(POLYGON);
    q7bx.fill(201,165,255);
    for (int i = 0; i <7; i++) {
    float angle = TWO_PI * i /7;
    float x = circleRad * sin(angle)+400;
    float y = circleRad * cos(angle)-900;
    float z = 0;
    q7bx.vertex(x, y, z);
    }
    q7bx.endShape(CLOSE);
    q8bx = createShape();
    q8bx.beginShape(POLYGON);
    q8bx.fill(201,165,255);
    for (int i = 0; i <8; i++) {
    float angle = TWO_PI * i /8;
    float x = circleRad * sin(angle)-400;
    float y = circleRad * cos(angle)-600;
    float z = 0;
    q8bx.vertex(x, y, z);
    }
    q8bx.endShape(CLOSE);


    IP属地:广东来自Android客户端2楼2020-12-05 11:20
    回复
      q9bx = createShape();
      q9bx.beginShape(POLYGON);
      q9bx.fill(201,165,255);
      for (int i = 0; i <9; i++) {
      float angle = TWO_PI * i /9;
      float x = circleRad * sin(angle)-150;
      float y = circleRad * cos(angle)-600;
      float z = 0;
      q9bx.vertex(x, y, z);
      }
      q9bx.endShape(CLOSE);
      q10bx = createShape();
      q10bx.beginShape(POLYGON);
      q10bx.fill(201,165,255);
      for (int i = 0; i <10; i++) {
      float angle = TWO_PI * i /10;
      float x = circleRad * sin(angle)+100;
      float y = circleRad * cos(angle)-600;
      float z = 0;
      q10bx.vertex(x, y, z);
      }
      q10bx.endShape(CLOSE);
      }
      void draw() {
      background(65,165,255);
      translate(width/2, height/2);
      //rotateX(frameCount * 0.01f);
      //rotateY(frameCount * 0.01f);
      //rotateX(mouseY * 0.01f);
      //rotateY(mouseX * 0.01f);
      shape(q3bx);shape(q4bx);shape(q5bx);
      shape(q6bx);shape(q7bx);shape(q8bx);
      shape(q9bx);shape(q10bx);
      }


      IP属地:广东来自Android客户端3楼2020-12-05 11:21
      回复