//Let's make pizza by processing! //import javax.swing.*;//http://turtley-fms.hatenablog.com/entry/2017/12/02/165458 //import java.awt.*;//http://turtley-fms.hatenablog.com/entry/2017/12/02/165458 //JLayeredPane pane;//http://turtley-fms.hatenablog.com/entry/2017/12/02/165458 //JTextField field;//http://turtley-fms.hatenablog.com/entry/2017/12/02/165458 int screen=1; int one = 0; int pen = 0; int sauce = 0; int cheese = 0; int basil = 0; int salami = 0; int ketchup = 0; int pepper = 0; String name; String advice; PFont myFont; void setup() { size(500, 500); name = new String(); //Canvas canvas = (Canvas) surface.getNative();//http://turtley-fms.hatenablog.com/entry/2017/12/02/165458 //pane = (JLayeredPane) canvas.getParent().getParent();//http://turtley-fms.hatenablog.com/entry/2017/12/02/165458 //field = new JTextField();//http://turtley-fms.hatenablog.com/entry/2017/12/02/165458 //field.setBounds(395, 375, 100, 30);//http://turtley-fms.hatenablog.com/entry/2017/12/02/165458 //pane.add(field);//http://turtley-fms.hatenablog.com/entry/2017/12/02/165458 } void draw() { //println( field.getText());//http://turtley-fms.hatenablog.com/entry/2017/12/02/165458 if (screen == 1) { if (one == 0) { first(); sauceB(); cheeseB(); basilB(); salamiB(); ketchupB(); pepperB(); one++; } if (mousePressed == true){ if (mouseX > 100 && mouseX < 400 && mouseY > 100 && mouseY < 400) { if (pen == 0) { frameRate(20); strokeWeight(60); stroke(#FF0000, 30); line(mouseX, mouseY, pmouseX, pmouseY); if (sauce==0) { sauce++; } noStroke(); } if (pen == 1) { frameRate(5); cheeseM(); if (cheese==0) { cheese++; } } if (pen == 2) { frameRate(5); int b =int(random(2)); int w = 0; int h = 0; int i = 0; switch(b) { case 0: w = 30; h = 40; i = 90; basilM(w, h, i); break; case 1: w = 40; h = 30; basilM(w, h, i); break; } if (basil==0) { basil++; } } if (pen == 3) { frameRate(5); noStroke(); salamiM(); if (salami==0) { salami++; } } if (pen == 4) { frameRate(60); strokeWeight(8); stroke(#F50F02); line(mouseX, mouseY, pmouseX, pmouseY); if (ketchup==0) { ketchup++; } noStroke(); } if (pen == 5) { frameRate(10); noStroke(); fill(0); ellipse(mouseX, mouseY, 2, 2); if (pepper==0) { pepper++; } } } } } } void mousePressed(){ if (mouseX > 10 && mouseX < 160 && mouseY > 0 && mouseY < 40) { frameRate(60); pen = 0; fill(0, 100); rect( 10, 0, 150, 40); } if (mouseX > 170 && mouseX < 320 && mouseY > 0 && mouseY < 40) { frameRate(60); pen = 1; fill(0, 100); rect(170, 0, 150, 40); } if (mouseX > 330 && mouseX < 480 && mouseY > 0 && mouseY < 40) { frameRate(60); pen = 2; fill(0, 100); rect(330, 0, 150, 40); } if (mouseX > 10 && mouseX < 160 && mouseY > 50 && mouseY < 90) { frameRate(60); pen = 3; fill(0, 100); rect(10, 50, 150, 40); } if (mouseX > 170 && mouseX < 320 && mouseY > 50 && mouseY < 90) { frameRate(60); pen = 4; fill(0, 100); rect(170, 50, 150, 40); } if (mouseX > 330 && mouseX < 480 && mouseY > 50 && mouseY < 90) { frameRate(60); pen = 5; fill(0, 100); rect(330, 50, 150, 40); } } // if (mousePressed == false) { // if (mouseX > 10 && mouseX < 160 && mouseY > 0 && mouseY < 40) { // sauceB(); // } // if (mouseX > 170 && mouseX < 320 && mouseY > 0 && mouseY < 40) { // cheeseB(); // } // if (mouseX > 330 && mouseX < 480 && mouseY > 0 && mouseY < 40) { // basilB(); // } // if (mouseX > 10 && mouseX < 160 && mouseY > 50 && mouseY < 90) { // salamiB(); // } // if (mouseX > 170 && mouseX < 320 && mouseY > 50 && mouseY < 90) { // ketchupB(); // } // if (mouseX > 330 && mouseX < 480 && mouseY > 50 && mouseY < 90) { // pepperB(); // } // } void mouseClicked() { if (screen == 1) { if ( mouseX > 340 && mouseX < 490 && mouseY > 450 && mouseY < 490 ) { noStroke(); fill(#FCA503, 25); ellipse(250, 250, 300, 300); screen = 2; fill(#27CE06); rect(0, 0, 500, 92); fill(#E50202); rect(0, 410, 500, 90); stroke(0); strokeWeight(1); fill(255); rect(340, 450, 150, 40); fill(0); //textSize(30); //textAlign(CENTER, CENTER); myFont = createFont("Meiryo", 26); textFont(myFont); text("はじめから", 340, 450, 150, 40); textAlign(LEFT, TOP); myFont = createFont("Meiryo", 15); textFont(myFont); text("※Web移植版のみスクショができません", 10, 380, 490, 80); text("Enterキーを押すと、作ったピザのスクリーンショットを保存できるよ!", 10, 420, 490, 80); myFont = createFont("Meiryo", 12); textFont(myFont);text("(画像はデスクトップに保存されます)", 10, 440, 490, 80); textFont(myFont);text("(作成者を変更した直後は保存できないため、コメントボッ", 10, 455, 325, 80); textFont(myFont);text("クス以外をクリックしてからEnterキーを押してください。)", 10, 470, 325, 80); textAlign(CENTER, TOP); myFont = createFont("Meiryo", 18); textFont(myFont); text("今回のピザは【"+(sauce+cheese+basil+salami+ketchup+pepper)+" 種類】の具材を使用して作ったよ!", 20, 15, 460, 60); int i =int(random(5)); switch(i) { case 0: advice = "①はじめにピザソースをみみより内側に塗る!"; break; case 1: advice = "②具材は欲張りすぎず控えめに!"; break; case 2: advice = "③たくさんのチーズ×ケチャップでお絵描きもできる!"; break; case 3: advice = "④「窯で焼く」で焼き目がつくのは気づいたかな?"; break; case 4: advice = "⑤ピザソース×チーズ×バジルはやっぱり王道&見た目が美味しそう"; break; } textAlign(CENTER, CENTER); myFont = createFont("Meiryo", 15); textFont(myFont); text("上手に作るコツやひとこと(全5種類):", 20, 20, 460, 60); text(advice, 20, 40, 460, 60); } } else if (screen == 2) { if ( mouseX > 340 && mouseX < 490 && mouseY > 450 && mouseY < 490 ) { screen = 1; one = 0; sauce = 0; cheese = 0; basil = 0; salami = 0; ketchup = 0; pepper = 0; name = new String(); } } } void keyPressed() { if (screen == 1){ char keys[] = {key}; if(keyCode == SHIFT){ name = name; } else{ name += new String(keys); } fill(255); rect(395,373,100,30); myFont = createFont("Meiryo", 15); textFont(myFont); fill(0); text(name,395,380,100,30); } else if (screen == 2) { if (keyCode == ENTER) { textAlign(CENTER, CENTER); myFont = createFont("Meiryo", 15); textFont(myFont); //String i = field.getText();//http://turtley-fms.hatenablog.com/entry/2017/12/02/165458 //text(name,395, 373, 100, 30); String path = System.getProperty("user.home") + "/Desktop/Screenshot";//https://note.com/ky0ju/n/ne804ca09324d String sketchName = "/" + getClass().getName() + "/";//https://note.com/ky0ju/n/ne804ca09324d String now = year() + "_" + month() + "_" + day() + "_" + hour() + "_" + minute() + "_" + second();//https://note.com/ky0ju/n/ne804ca09324d save(path + sketchName + now + ".jpg");//https://note.com/ky0ju/n/ne804ca09324d println(path + sketchName + now + ".jpg");//https://note.com/ky0ju/n/ne804ca09324d } } } void first() { background(255); noStroke(); fill(#D1F3FF); rect(0, 0, 500, 92); rect(0, 410, 500, 90); fill(#FFF1AD); ellipse(250, 250, 300, 300); fill(#FFFBE5); ellipse(250, 250, 240, 240); stroke(0); strokeWeight(1); fill(255); rect(340, 450, 150, 40); fill(0); //textSize(30); textAlign(CENTER, CENTER); myFont = createFont("Meiryo", 18); textFont(myFont); text("生地の上に具材をトッピングして、ピザを作ろう!", 10, 400, 490, 40); textAlign(LEFT, TOP); myFont = createFont("Meiryo", 15); textFont(myFont); text("①テキストボックスに名前を入力する。", 10, 433, 320, 80); text("②左クリックで具材を選択する。", 10, 453, 320, 80); text("③左クリック&プッシュで具材をのせる。", 10, 473, 320, 80); text(year()+" / "+month()+" / "+day(), 10, 105); text("作成者:", 340, 380); //textAlign(LEFT, CENTER); myFont = createFont("Meiryo", 26); textFont(myFont); text("④窯で焼く", 340, 450, 150, 40); } void sauceB() { stroke(0); strokeWeight(1); fill(255); rect( 10, 0, 150, 40); fill(0); textSize(30); //textAlign(CENTER, CENTER); myFont = createFont("Meiryo", 26); textFont(myFont); text("ピザソース", 10, 5, 150, 40); } void cheeseB() { stroke(0); strokeWeight(1); fill(255); rect(170, 0, 150, 40); fill(0); textSize(30); //textAlign(CENTER, CENTER); myFont = createFont("Meiryo", 26); textFont(myFont); text("チーズ", 170, 5, 150, 40); } void basilB() { stroke(0); strokeWeight(1); fill(255); rect(330, 0, 150, 40); fill(0); textSize(30); //textAlign(CENTER, CENTER); myFont = createFont("Meiryo", 26); textFont(myFont); text("バジル", 330, 5, 150, 40); } void salamiB() { stroke(0); strokeWeight(1); fill(255); rect(10, 50, 150, 40); fill(0); textSize(30); //textAlign(CENTER, CENTER); myFont = createFont("Meiryo", 26); textFont(myFont); text("サラミ", 10, 55, 150, 40); } void ketchupB() { stroke(0); strokeWeight(1); fill(255); rect(170, 50, 150, 40); fill(0); textSize(30); //textAlign(CENTER, CENTER); myFont = createFont("Meiryo", 26); textFont(myFont); text("ケチャップ", 170, 55, 150, 40); } void pepperB() { stroke(0); strokeWeight(1); fill(255); rect(330, 50, 150, 40); fill(0); textSize(30); //textAlign(CENTER); myFont = createFont("Meiryo", 26); textFont(myFont); text("ペッパー", 330, 55, 150, 40); } void basilM(int w, int h, int i) { noStroke(); fill(#1BA002); arc(mouseX, mouseY, w, h, radians(0+i), radians(180+i) ); fill(#188B01); arc(mouseX, mouseY, w, h, radians(180+i), radians(360+i) ); } void salamiM() { fill(#C62A2D); ellipse(mouseX, mouseY, 40, 40); fill(#F76669); ellipse(mouseX, mouseY, 32, 32); fill(#F5B4B6); ellipse(mouseX-8, mouseY-8, 8, 8); ellipse(mouseX+7, mouseY-3, 6, 6); ellipse(mouseX-2, mouseY, 4, 4); ellipse(mouseX+1, mouseY-14, 2, 2); ellipse(mouseX+9, mouseY+8, 7, 7); ellipse(mouseX-13, mouseY+5, 3, 3); ellipse(mouseX-3, mouseY+12, 5, 5); } void cheeseM() { noStroke(); fill(255); ellipse(mouseX, mouseY, 50, 50); fill(#FAF9F5); ellipse(mouseX+3, mouseY-3, 40, 40); }