Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

randomアニメーション練習 #6

Open
cancancanda opened this issue Oct 26, 2020 · 0 comments
Open

randomアニメーション練習 #6

cancancanda opened this issue Oct 26, 2020 · 0 comments

Comments

@cancancanda
Copy link

cancancanda commented Oct 26, 2020

### 色とスピードが毎回ランダムな円のアニメーション

int count =0;
int circle_length= 28; //丸を何個作るか
int start_angle = 0;  //スタート地点の角度

int [] diameters = new int[circle_length], //円の直径
       angles =    new int[circle_length], //角度
       speeds =    new int[circle_length], //速度
       hues =       new int[circle_length];//色


void settings(){
size(1000,600);
}

void setup(){

  colorMode(HSB, 360, 100, 100); //RGBだと綺麗な色になりにくいらしい?
  smooth();
  frameRate(60);//一秒間に60回再描画をかける
  background(0);
  strokeWeight(2);
  noFill(); 
  
  for (int i =0; i < circle_length; i++) {
     hues[i] =floor(random(361));
     diameters[i] = 20 * i + 20 ;
     angles[i] = start_angle;
     speeds[i] = floor(random(2,8));
  }
}

void draw(){
  if (count<=360){       //360を超えた段階でおわり
    for(int i =0; i < circle_length; i++) {
      if (angles[i] <= 360){
        stroke(hues[i],100,100);   
        float rad = radians(angles[1]);
        arc(width/2, height/2,diameters[i],diameters[i],0, rad, OPEN);
        angles[i]+= speeds[i];
         if (angles[i] >= 360) {
             angles[i]= 360;
      }
    }
    }
 
 count++;               //再描画をかける度にcountをインクリメントする
 
  }
}

スクリーンショット (43)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant