配置
int r=50; void setup() { size(800, 800); colorMode(HSB, 360, 100, 100); background(0, 0, 100); } void draw() { pushMatrix(); translate(width/2, height/2); fill(0, 100, 100); //一番上 ellipse(0, -300, r, r); fill(30, 100, 100); ellipse(100, -200, r, r); fill(60, 100, 100); ellipse(200, -100, r, r); fill(90, 100, 100); ellipse(300, 0, r, r); fill(120, 100, 100); ellipse(200, 100, r, r); fill(150, 100, 100); ellipse(100, 200, r, r); fill(180, 100, 100); ellipse(0, 300, r, r); fill(360-150, 100, 100); ellipse(-100, 200, r, r); fill(360-120, 100, 100); ellipse(-200, 100, r, r); fill(360-90, 100, 100); ellipse(-300, 0, r, r); fill(360-60, 100, 100); ellipse(-200, -100, r, r); fill(360-30, 100, 100); ellipse(-100, -200, r, r); popMatrix(); }
新しい勉強内容を使っていないということにスケッチを終えた後に気づく。pushMatrixとpopMatrixは♯11の内容だから許して。HSBモードの色の把握ついでに。本当は円形に配置したかった。
int a=35; void setup() { size(600, 600); colorMode(HSB, 360, 100, 100); background(0, 0, 100); } void draw() { translate(width/2, height/2); scale(0.5); pushMatrix(); translate(0, -200); scale(a); rotate(radians(45)); noStroke(); rectMode(CENTER); fill(0, 100, 100, 50); rect(0, 0, 10, 10); popMatrix(); pushMatrix(); translate(0, 200); scale(a); rotate(radians(45)); noStroke(); rectMode(CENTER); fill(180, 100, 100, 50); rect(0, 0, 10, 10); popMatrix(); pushMatrix(); translate(-200, 0); scale(a); rotate(radians(45)); noStroke(); rectMode(CENTER); fill(180+90, 100, 100, 50); rect(0, 0, 10, 10); popMatrix(); pushMatrix(); translate(200, 0); scale(a); rotate(radians(45)); noStroke(); rectMode(CENTER); fill(90, 100, 100, 50); rect(0, 0, 10, 10); popMatrix(); noLoop(); }
ちゃんと勉強したことを生かせたスケッチができた!おしゃれというかシンプルでかわいいものができた。このrectを45度回転させたものを配置 - 記録に使いたかったんだけど無理だったのでellipseにしたかった当時。
今日の勉強【Processing入門♯11】
rotate(radians(角度));
scale(横方向へn倍,縦方向へn倍);