For loop 如何调整此代码以在for循环中包含顶点?

For loop 如何调整此代码以在for循环中包含顶点?,for-loop,vertex,p5.js,For Loop,Vertex,P5.js,//研究并使用beginShape()和endShape()绘制3个单独的草图。每个草图必须包含顶点(顶点()。您将需要的工具:beginShape()、endShape()、vertex(),用于循环 //我们应该制作云纹图案。我已经用下面的代码得到了期望的结果,但它不包括指定要求的顶点。如何编辑和调整此代码以包括顶点,但提供相同的输出 var theta = 0.0; var circWidthMultiplier = 17.5; var circHeightMultiplier = 12.

//研究并使用beginShape()和endShape()绘制3个单独的草图。每个草图必须包含顶点(顶点()。您将需要的工具:beginShape()、endShape()、vertex(),用于循环

//我们应该制作云纹图案。我已经用下面的代码得到了期望的结果,但它不包括指定要求的顶点。如何编辑和调整此代码以包括顶点,但提供相同的输出

var theta = 0.0;
var circWidthMultiplier = 17.5;
var circHeightMultiplier = 12.5;
var rectWidthMultiplier = 12.5;
var rectHeightMultiplier =17.5;
var rotationSpeed = 0.005;
function setup() {
  createCanvas(windowWidth,windowHeight);
  rectMode(CENTER);
}

function draw() {
  background(100);
  noFill();

  push();
  beginShape();
  translate(width/2, height/2);
  for(var i =0; i < 50; i+=5){
    ellipse(0, 0,
    i*rectWidthMultiplier,
    i*rectHeightMultiplier);
  }
  endShape();
  pop();


  push();
  beginShape();
  translate(width/2, height/2);
  rotate(theta);
  for(var i =0; i < 50; i+=5){
    ellipse(0, 0,
    i*circWidthMultiplier,
    i*circHeightMultiplier);
  }
  endShape();

  pop();
  beginShape();
  translate(width/2, height/2);
  for(var i =0; i < 50; i+=2){
    rect(0, 0,
    i*circWidthMultiplier,
    i*circHeightMultiplier);
  }
  endShape();
  pop();
  theta += rotationSpeed;
}
varθ=0.0;
风险值乘数=17.5;
var Circheight乘数=12.5;
var系数乘数=12.5;
var recthheightmultiplier=17.5;
var旋转速度=0.005;
函数设置(){
createCanvas(窗口宽度、窗口高度);
矩形模式(中心);
}
函数绘图(){
背景(100);
noFill();
推();
beginShape();
平移(宽度/2,高度/2);
对于(变量i=0;i<50;i+=5){
椭圆(0,0,
我是一个乘法器,
i*垂直高度倍增器);
}
endShape();
pop();
推();
beginShape();
平移(宽度/2,高度/2);
旋转(θ);
对于(变量i=0;i<50;i+=5){
椭圆(0,0,
我*我是一个乘法器,
i*圆周高度倍增器);
}
endShape();
pop();
beginShape();
平移(宽度/2,高度/2);
对于(变量i=0;i<50;i+=2){
rect(0,0,
我*我是一个乘法器,
i*圆周高度倍增器);
}
endShape();
pop();
θ+=旋转速度;
}

现在,您正在使用诸如
eliple()
rect()
之类的函数来绘制图形。可以使用
beginShape()
vertex()
endShape()
来绘制图形

首先替换
rect()
函数。您已经知道矩形的位置和大小。因此,用四次调用
vertex()
函数来替换它应该很容易

圆圈有点棘手,但仍然可行。你需要使用基本的三角学来计算圆周围的顶点。谷歌是你在这里的朋友

但老实说,这似乎有点毫无意义。为什么要麻烦使用
vertex()
来绘制处理已经为您绘制的形状?您可能需要与您的讲师核实,以确保您正确理解作业