// ******************3つ並んだ円を描く****************** size(400,200); for(int i = 0; i < 3; i++){ ellipse(100 + 100 * i, 100, 60, 60); } // ******************繰り返しを繰り返す(for文を入れ子にする)****************** size(400,400); for (int j = 0; j < 3; j++) { for (int i = 0; i < 3; i++) { ellipse(100 + 100 * i, 100 + 100 * j, 60, 60); } } // ******************繰り返しを繰り返す(for文を入れ子にする)色をつける****************** size(200, 200); colorMode(HSB, 100); //HSBモード(色相,彩度,明度) background(99); noStroke(); //縁に色を付けない for(int y = 0; y < 10; y++){ for(int x = 0; x < 10 ; x++){ fill(10*x, 10+y*10, 99); rect(x*20, y*20, 10, 10); } } // ******************ランダムに決める****************** size(200, 200); colorMode(RGB, 100); background(99); for(int i = 0; i < 100; i++){ stroke(random(100), random(100), random(100)); //(R,G,B)の値をランダムに決めます.stroke(R,G,B)は線の色を決めます. line(random(width), random(height), random(width), random(height)); } // ******************ifの勉強(1)****************** int i = 0; if (i > 0) { //iが0だからifの{}内は実行されない.よって円は描かれない. background(255, 0, 0); ellipse(50, 50, 50, 50); } // ******************ifの勉強(2)****************** //とりあえず線をたくさん描くだけ.問の答えは下 for(int i = 0; i < width; i++){ line(i, 0, i, height); } //********************************************************************************** 問題の答え //********************************************************************************** // ******************5つ並んだ円を描く****************** size(600,200); for(int i = 0; i < 5; i++){ ellipse(100 + 100 * i, 100, 60, 60); } // ******************一定の大きさで小さくなる円を3つ描く****************** size(400,200); for(int i = 0; i < 3; i++){ ellipse(100 + 100 * i, 100, 60-10*i, 60-10*i); } // ******************ifの勉強(1)****************** int i = 10; if (i > 0) { //iが10だからifの{}内は実行される. background(255, 0, 0); ellipse(50, 50, 50, 50); } // ******************ifの勉強(2)****************** for(int i = 0; i < width; i++){ if(i>=3&&i<=33){ line(i, 0, i, height); } }