Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 循环使循环增长_Java_Loops_For Loop_Processing - Fatal编程技术网

Java 循环使循环增长

Java 循环使循环增长,java,loops,for-loop,processing,Java,Loops,For Loop,Processing,谁能帮我做一个环,让形成花的椭圆生长。 有5个椭圆作为花瓣和一个中心的花椭圆 Stem myStem; Circle circles[]; float scaleFactor=0.5; void setup() { size(floor(400*scaleFactor), floor(800*scaleFactor)); myStem = new Stem(200,800); //mpoved this to setup, no need to recreate each frame c

谁能帮我做一个环,让形成花的椭圆生长。 有5个椭圆作为花瓣和一个中心的花椭圆

Stem myStem;
Circle circles[];

float scaleFactor=0.5;

void setup() {


size(floor(400*scaleFactor), floor(800*scaleFactor));
myStem = new Stem(200,800);
//mpoved this to setup, no need to recreate each frame
circles = new Circle[6];
circles[0]  = new Circle(0, -40, 50, 50);
circles[1]  = new Circle(0, -40, 50, 50);
circles[2]  = new Circle(0, -40, 50, 50);
circles[3]  = new Circle(0, -40, 50, 50);
circles[4]  = new Circle(0, -40, 50, 50);
circles[5]  = new Circle(0, 0, 50, 50);
// also smooth only needs to be called once
// unless ther is a noSmooth() somewhere
// smooth();
}

void draw() {

  float grow = 0;
  //translate(myStem.initalloX, myStem.initalloY);  
  myStem.drawStem();
  //set centre point
  if (frameCount>grow) {
    translate(myStem.initalloX, ((frameCount>250)?myStem.initalloY-      500:myStem.initalloY-(2*frameCount)));
    fill(170, 14, 24); // red
    for (int i = 0; i < circles.length-1; i++) {
      ellipse(circles[i].c1+grow, circles[i].c2+grow, circles[i].c3+grow, circles[i].c4+grow);
      rotate(radians(72));
    }
    fill(14, 17, 170); // blue
    ellipse(circles[5].c1, circles[5].c2, circles[5].c3, circles[5].c4);
 }
}

class Stem { 
int initalloX=200;
int initalloY=800;

Stem(int tempInitalloX, int tempInitalloY) {
  initalloX = tempInitalloX;
  initalloY = tempInitalloY;

}

void drawStem() {
  background(#0DBADB);
  scale(scaleFactor, scaleFactor);
  stroke (12, 149, 11);
  fill (12, 149, 11);
  strokeWeight(10);
  line(initalloX, initalloY, initalloX, ((frameCount>250)?initalloY-500:initalloY-(2*frameCount)));
  //stem1
  if (frameCount>101) {
    noStroke();
    translate(initalloX, initalloY-200);
    scale(min((float)(frameCount-100)/100, 1), min((float)(frameCount-100)/100, 1));
    beginShape();
    vertex(0, 0);
    bezierVertex(-40, -5, -30, -40, -80, -20);
    bezierVertex(-47, -16, -52, 8, 0, 0);
    endShape(CLOSE);
    scale(1/min((float)(frameCount-100)/100, 1), 1/min((float)(frameCount-100)/100, 1));
    translate(-initalloX, -(initalloY-200));
    noStroke();
  }
  //stem2
  if (frameCount>151) {
//  noStroke();
    translate(initalloX, initalloY-300);
    scale(-min((float)(frameCount-150)/150, 1), min((float)(frameCount-150)/150, 1));
    beginShape();
    vertex(0, 0);
    bezierVertex(-40, -5, -30, -40, -80, -20);
    bezierVertex(-47, -16, -52, 8, 0, 0);
    endShape(CLOSE);
    scale(-1/min((float)(frameCount-150)/150, 1), 1/min((float)(frameCount-150)/150, 1));
    translate(-initalloX, -(initalloY-300));

    }
  }
 }

class Circle {

  int c1 = 0;
  int c2 = -40;
  float c3 = 50;
  float c4 = 50;

  Circle(int tc1, int tc2, float tc3, float tc4) {
    c1 = tc1;
    c2 = tc2;
    c3 = tc3;
    c4 = tc4;
   }
 }
Stem-myStem;
圆圈[];
浮点数比例因子=0.5;
无效设置(){
尺寸(地板(400*scaleFactor)、地板(800*scaleFactor));
myStem=新杆(200800);
//将其导入设置,无需重新创建每个帧
圆圈=新圆圈[6];
圆[0]=新的圆(0,-40,50,50);
圆[1]=新的圆(0,-40,50,50);
圆[2]=新的圆(0,-40,50,50);
圆[3]=新的圆(0,-40,50,50);
圆[4]=新的圆(0,-40,50,50);
圆[5]=新的圆(0,0,50,50);
//同样,平滑只需要调用一次
//除非某处有一个不光滑的地方
//光滑的();
}
作废提款(){
浮动增长=0;
//翻译(myStem.initalloX、myStem.initalloY);
myStem.drawStem();
//设置中心点
如果(帧数>增长){
翻译(myStem.initalloX,((frameCount>250)?myStem.initalloY-500:myStem.initalloY-(2*frameCount));
填充(170、14、24);//红色
对于(int i=0;i250)?initalloY-500:initalloY-(2*帧数));
//stem1
如果(帧数>101){
仰泳();
翻译(initalloX,initalloY-200);
刻度(最小((浮动)(帧数-100)/100,1),最小((浮动)(帧数-100)/100,1));
beginShape();
顶点(0,0);
贝塞尔顶点(-40,-5,-30,-40,-80,-20);
贝塞尔顶点(-47,-16,-52,8,0,0);
端形(闭合);
刻度(1/min((浮动)(帧数-100)/100,1),1/min((浮动)(帧数-100)/100,1));
翻译(-initalloX,-(initalloY-200));
仰泳();
}
//stem2
如果(帧数>151){
//仰泳();
翻译(initalloX,initalloY-300);
刻度(-min((浮动)(帧数-150)/150,1),min((浮动)(帧数-150)/150,1));
beginShape();
顶点(0,0);
贝塞尔顶点(-40,-5,-30,-40,-80,-20);
贝塞尔顶点(-47,-16,-52,8,0,0);
端形(闭合);
刻度(-1/min((浮动)(帧计数-150)/150,1),1/min((浮动)(帧计数-150)/150,1));
翻译(-initalloX,-(initalloY-300));
}
}
}
班级圈子{
int c1=0;
int c2=-40;
浮动c3=50;
浮球c4=50;
圆(整数tc1、整数tc2、浮点tc3、浮点tc4){
c1=tc1;
c2=tc2;
c3=tc3;
c4=tc4;
}
}
这是程序中的一个函数,是在处理过程中编写的。
提前感谢您的帮助/输入

\u嗨,theolc,为了你正在生长的花朵,我会做这样的事情,对你来说是一个非常简单的开始;)。看看是否有用。我选择了三角法,因为在这种情况下,它似乎比旋转更容易控制。查看它(单击鼠标增长/单击按住任意键收缩):

Stem-myStem;
圆圈[];
花p=新花();
浮点数比例因子=0.5;
无效设置(){
尺寸(地板(400*scaleFactor)、地板(800*scaleFactor));
myStem=新茎(200800);
p=新花(0,0);
//将其导入设置,无需重新创建每个帧
圆圈=新圆圈[6];
圆[0]=新的圆(0,-40,50,50);
圆[1]=新的圆(0,-40,50,50);
圆[2]=新的圆(0,-40,50,50);
圆[3]=新的圆(0,-40,50,50);
圆[4]=新的圆(0,-40,50,50);
圆[5]=新的圆(0,0,50,50);
//同样,平滑只需要调用一次
//除非某处有一个不光滑的地方
光滑的();
}
作废提款(){
浮动增长=0;
//翻译(myStem.initalloX、myStem.initalloY);
myStem.drawStem();
//设置中心点
如果(帧数>增长){
翻译(myStem.initalloX,((frameCount>250)?myStem.initalloY-500:myStem.initalloY-(2*frameCount));
填充(170、14、24);//红色
对于(int i=0;i250)?initalloY-500:initalloY-(2*帧数));
//stem1
如果(帧数>101){
仰泳();
翻译(initalloX,initalloY-200);
刻度(最小((浮动)(帧数-100)/100,1),最小((浮动)(帧数-100)/100,1));
beginShape();
顶点(0,0);
贝塞尔顶点(-40,-5,-30,-40,-80,-20);
贝塞尔顶点(-47,-16,-52,8,0,0);
端形(闭合);
刻度(1/min((浮动)(帧数-100)/100,1),1/min((浮动)(帧数-100)/100,1));
翻译(-initalloX,-(initalloY-200));
仰泳();
}
//stem2
如果(帧数>151){
//仰泳();
翻译(initalloX,initalloY-300);
刻度(-min((浮动)(帧数-150)/150,1),min((浮动)(帧数-150)/150,1));
beginShape();
顶点(0,0);
贝塞尔顶点(-40,-5,-30,-40,-80,-20);
贝塞尔顶点(-47,-16,-52,8,0,0);
端形(闭合);
刻度(-1/min((浮动)(帧计数-150)/150,1),1/min((浮动)(帧计数-150)/150,1));
翻译(-initalloX,-(initalloY-300));
Stem myStem;
Circle circles[];
Flower p = new Flower();

float scaleFactor=0.5;


void setup() {


  size(floor(400*scaleFactor), floor(800*scaleFactor));
  myStem = new Stem(200, 800);
  p = new Flower (0, 0);
  //mpoved this to setup, no need to recreate each frame
  circles = new Circle[6];
  circles[0]  = new Circle(0, -40, 50, 50);
  circles[1]  = new Circle(0, -40, 50, 50);
  circles[2]  = new Circle(0, -40, 50, 50);
  circles[3]  = new Circle(0, -40, 50, 50);
  circles[4]  = new Circle(0, -40, 50, 50);
  circles[5]  = new Circle(0, 0, 50, 50);
  // also smooth only needs to be called once
  // unless ther is a noSmooth() somewhere
  smooth();
}

void draw() {

  float grow = 0;
  //translate(myStem.initalloX, myStem.initalloY);  
  myStem.drawStem();
  //set centre point
  if (frameCount>grow) {

    translate(myStem.initalloX, ((frameCount>250)?myStem.initalloY-      500:myStem.initalloY-(2*frameCount)));


    fill(170, 14, 24); // red
    for (int i = 0; i < circles.length-1; i++) {
      ellipse(circles[i].c1+grow, circles[i].c2+grow, circles[i].c3+grow, circles[i].c4+grow);
      rotate(radians(72));
    }
    fill(14, 17, 170); // blue
    ellipse(circles[5].c1, circles[5].c2, circles[5].c3, circles[5].c4);
    p.grow();
  }

  p.display();
}

class Stem { 
  int initalloX=200;
  int initalloY=800;

  Stem(int tempInitalloX, int tempInitalloY) {
    initalloX = tempInitalloX;
    initalloY = tempInitalloY;
  }

  void drawStem() {
    background(#0DBADB);
    scale(scaleFactor, scaleFactor);
    stroke (12, 149, 11);
    fill (12, 149, 11);
    strokeWeight(10);
    line(initalloX, initalloY, initalloX, ((frameCount>250)?initalloY-500:initalloY-(2*frameCount)));
    //stem1
    if (frameCount>101) {
      noStroke();
      translate(initalloX, initalloY-200);
      scale(min((float)(frameCount-100)/100, 1), min((float)(frameCount-100)/100, 1));
      beginShape();
      vertex(0, 0);
      bezierVertex(-40, -5, -30, -40, -80, -20);
      bezierVertex(-47, -16, -52, 8, 0, 0);
      endShape(CLOSE);
      scale(1/min((float)(frameCount-100)/100, 1), 1/min((float)(frameCount-100)/100, 1));
      translate(-initalloX, -(initalloY-200));
      noStroke();
    }
    //stem2
    if (frameCount>151) {
      //  noStroke();
      translate(initalloX, initalloY-300);
      scale(-min((float)(frameCount-150)/150, 1), min((float)(frameCount-150)/150, 1));
      beginShape();
      vertex(0, 0);
      bezierVertex(-40, -5, -30, -40, -80, -20);
      bezierVertex(-47, -16, -52, 8, 0, 0);
      endShape(CLOSE);
      scale(-1/min((float)(frameCount-150)/150, 1), 1/min((float)(frameCount-150)/150, 1));
      translate(-initalloX, -(initalloY-300));
    }
  }
}

class Circle {

  int c1 = 0;
  int c2 = -40;
  float c3 = 50;
  float c4 = 50;

  Circle(int tc1, int tc2, float tc3, float tc4) {
    c1 = tc1;
    c2 = tc2;
    c3 = tc3;
    c4 = tc4;
  }
}






class Flower {


  float centerX;
  float centerY;
  float posX;
  float posY;
  float maxSize = 51;
  float maxFactor = 40;
  float sizes = 0;
  float factor = 0;
  float speed = 0.17;

  Flower() {
  }
  Flower(float _centerX, float _centerY)
  {
    centerX = _centerX;
    centerY = _centerY;
  }

  void setCenter(float x, float y)
  {
    centerX = x;
    centerY = y;
  }

  void display()
  {
    for (int i = -18; i < 360; i+=72)
    {
       posX = centerX + cos(radians(i)) * factor;
       posY = centerY + sin(radians(i)) * factor;
      noStroke();
      fill(14, 170, 170 ); // blue
      ellipse(posX, posY, sizes, sizes);
    }
    fill(145, 170, 170);

    ellipse(centerX, centerY, sizes , sizes );
  }


  void grow()
  {
    factor = (factor < maxFactor )?  factor + speed: maxFactor;
    sizes = (sizes < maxSize )?  sizes + speed*1.3 : maxSize;

  }
}// end of Flower