/* @pjs preload="Baby.gif,Child.gif,Student.gif,OfficeLady.gif,Bride.gif,PregnantWomen.gif"; */ float y1,y2; float angle = 0; int Red=30; int Green=10; int Blue=0; int Size=570; PImage baby = loadImage("Baby.gif"); PImage child = loadImage("Child.gif"); PImage student = loadImage("Student.gif"); PImage officeLady = loadImage("OfficeLady.gif"); PImage bride = loadImage("Bride.gif"); PImage pregnantWomen = loadImage("PregnantWomen.gif"); void setup() { //画面サイズ size(500, 500); //画像 baby.resize(width, height); child.resize(width, height); student.resize(width, height); officeLady.resize(width, height); bride.resize(width, height); pregnantWomen.resize(width, height); //映写・背景グラデーション for(int i=0; i<150; i++){ Red +=1; Blue +=1; Green +=1; Size -=3; fill(Red,Green,Blue); noStroke(); ellipse(250,200,Size+50,Size); } //映写・操作説明文 fill(#fffffc); textAlign(CENTER); //textFont(createFont("HGP教科書体",40)); text("左下のスイッチを", 50, 120, 400, 400); text("押し続けてください", 50, 200, 400, 400); frameRate(15); } void draw() { noStroke(); //ボタン「Baby」の効果 if(mousePressed == true && mouseX>=30 && mouseX<=105 && mouseY>=410 && mouseY<=450){ noStroke(); for(int i = 0; i < 1000; i++){ PVector location = new PVector(random(500),random(500)); color col = baby.get(int(location.x), int(location.y)); fill(col, 255); float brightnerr = red(col) + green(col) + blue(col); float diameter = map(brightnerr, 0, 255*3, 0, 5); ellipse(location.x, location.y, diameter, diameter); } } //ボタン「Child」の効果 if(mousePressed == true && mouseX>=120 && mouseX<=195 && mouseY>=410 && mouseY<=450){ noStroke(); for(int i = 0; i < 3000; i++){ PVector location = new PVector(random(500),random(500)); color col = child.get(int(location.x), int(location.y)); fill(col, 255); float brightnerr = red(col) + green(col) + blue(col); float diameter = map(brightnerr, 0, 255*3, 0, 5); ellipse(location.x, location.y, diameter, diameter); } } //ボタン「Student」の効果 if(mousePressed == true && mouseX>=210 && mouseX<=285 && mouseY>=410 && mouseY<=450){ noStroke(); for(int i = 0; i < 3000; i++){ PVector location = new PVector(random(500),random(500)); color col = student.get(int(location.x), int(location.y)); fill(col, 255); float brightnerr = red(col) + green(col) + blue(col); float diameter = map(brightnerr, 0, 255*3, 0, 5); ellipse(location.x, location.y, diameter, diameter); } } //ボタン「OfficeLady」の効果 if(mousePressed == true && mouseX>=30 && mouseX<=105 && mouseY>=455 && mouseY<=495){ noStroke(); for(int i = 0; i < 3000; i++){ PVector location = new PVector(random(500),random(500)); color col = officeLady.get(int(location.x), int(location.y)); fill(col, 255); float brightnerr = red(col) + green(col) + blue(col); float diameter = map(brightnerr, 0, 255*3, 0, 5); ellipse(location.x, location.y, diameter, diameter); } } //ボタン「Bride」の効果 if(mousePressed == true && mouseX>=120 && mouseX<=195 && mouseY>=455 && mouseY<=495){ noStroke(); for(int i = 0; i < 2000; i++){ PVector location = new PVector(random(500),random(500)); color col = bride.get(int(location.x), int(location.y)); fill(col, 255); float brightnerr = red(col) + green(col) + blue(col); float diameter = map(brightnerr, 0, 255*3, 0, 5); ellipse(location.x, location.y, diameter, diameter); } } //ボタン「PregnantWomen」の効果 if(mousePressed == true && mouseX>=210 && mouseX<=285 && mouseY>=455 && mouseY<=495){ noStroke(); for(int i = 0; i < 2000; i++){ PVector location = new PVector(random(500),random(500)); color col = pregnantWomen.get(int(location.x), int(location.y)); fill(col, 255); float brightnerr = red(col) + green(col) + blue(col); float diameter = map(brightnerr, 0, 255*3, 0, 5); ellipse(location.x, location.y, diameter, diameter); //「画像の色を取得して円で再生成描画」の方法 //出典:田所淳著 技術評論社出版 『Processing クリエイティブ・コーディング入門 コードが生み出す創造表現』P152 } } //テープの黒 fill(0); rect(0,0,50,500); rect(450,0,500,500); //テープの白 fill(#ffffff); y1 += 15; //毎フレームで正方形のx座標を15ずつ増やす if (y1 > height-300) y1 = y1-500; strokeJoin(ROUND); rect(10, y1-140, 30, 30); rect(10, y1-70, 30, 30); rect(10, y1, 30, 30); rect(10, y1+70, 30, 30); rect(10, y1+140, 30, 30); rect(10, y1+210, 30, 30); rect(10, y1+280, 30, 30); rect(10, y1+350, 30, 30); rect(10, y1+420, 30, 30); rect(10, y1+490, 30, 30); rect(10, y1+560, 30, 30); rect(10, y1+630, 30, 30); y2 += 15; if (y2 > height-300) y2 = y2-500; rect(460, y2-140, 30, 30); rect(460, y2-70, 30, 30); rect(460, y2, 30, 30); rect(460, y2+70, 30, 30); rect(460, y2+140, 30, 30); rect(460, y2+210, 30, 30); rect(460, y2+280, 30, 30); rect(460, y2+350, 30, 30); rect(460, y2+420, 30, 30); rect(460, y2+490, 30, 30); rect(460, y2+560, 30, 30); rect(460, y2+630, 30, 30); //機台 fill(#9d8e87); quad(0, 400, 400, 400, 400, 500, 0, 500); Baby(30,410); Child(120,410); Student(210,410); OfficeLady(30,455); Bride(120,455); PregnantWomen(210,455); fill(#432f2f); //テープ fill(#432f2f); quad(300, 500, 310, 500, 390, 400, 380, 400); translate(450,450); //原点を移動 rotate(angle); //原点を中心に座標全体を回転 tape(100,100); angle += 0.1; } //ボタン「Baby」 void Baby(float x,float y){ fill(#fff799); rect(x,y,75,40); fill(0); rect(x+3,y+3,69,34); fill(#ffffff); //textFont(createFont("Prestige Elite Std",14)); text("Baby", x+10,y+14,56,45); } //ボタン「Child」 void Child(float x,float y){ fill(#fff799); rect(x,y,75,40); fill(0); rect(x+3,y+3,69,34); fill(#ffffff); //textFont(createFont("Prestige Elite Std",14)); text("Child", x+9,y+14,56,45); } //ボタン「Student」 void Student(float x,float y){ fill(#fff799); rect(x,y,75,40); fill(0); rect(x+3,y+3,69,34); fill(#ffffff); //textFont(createFont("Prestige Elite Std",14)); text("Student", x,y+14,75,45); } //ボタン「OfficeLady」 void OfficeLady(float x,float y){ fill(#fff799); rect(x,y,75,40); fill(0); rect(x+3,y+3,69,34); fill(#ffffff); //textFont(createFont("Prestige Elite Std",12)); text("Office", x,y+9,75,45); text("Lady", x,y+20,75,45); } //ボタン「Bride」 void Bride(float x,float y){ fill(#fff799); rect(x,y,75,40); fill(0); rect(x+3,y+3,69,34); fill(#ffffff); //textFont(createFont("Prestige Elite Std",14)); text("Bride", x,y+14,75,45); } //ボタン「PregnantWomen」 void PregnantWomen(float x,float y){ fill(#fff799); rect(x,y,75,40); fill(0); rect(x+3,y+3,69,34); fill(#ffffff); //textFont(createFont("Prestige Elite Std",12)); text("Pregnant", x,y+9,75,45); text("Women", x,y+20,75,45); } //映写機テープの本体 void tape(float x,float y){ fill(#ffffff); pushMatrix(); ellipse(0,0,200,200); fill(0); ellipse(0,0,25,25); ellipse(30,0,10,10); ellipse(0,30,10,10); ellipse(-30,0,10,10); ellipse(0,-30,10,10); ellipse(40,40,50,50); ellipse(40,-40,50,50); ellipse(-40,40,50,50); ellipse(-40,-40,50,50); popMatrix(); }