Processing random 畫
- May 10, 2017
- 2 min read
void setup() { size(700, 800); fill(255,255,215);//lightyellow rect(500, 0, 200, 800); fill(0); rect(525, 20, 150, 50);//next rect(525, 150, 150, 50);//pre rect(525, 280, 150, 50);//random rect(525, 430, 150, 50);//next rect(525, 560, 150, 50);//pre rect(525, 690, 150, 50);//random fill(255); textSize(20); text("Next",580,50);//next text("Previous",560,180);//previos text("Random",560,310);//random text("Next",580,460);//next text("Previous",560,590);//previos text("Save",580,720);//random frameRate(12); } int t = 1; int b = 1; int picCount = 20; void draw(){ //int front = int(random(1, picCount)); // Select the front card //int back = int(random(1, picCount)); // Select the back card println(mouseX + " : " + mouseY); PImage imgFront = loadImage(t + "t.jpg"); PImage imgBack = loadImage(b + "b.jpg"); image(imgFront, 0, 0); image(imgBack, 0, 400); if (mouseX >=525 && mouseX <= 675 && mouseY >=20 && mouseY <= 70 && mousePressed == true && mouseButton == LEFT) { if(t < picCount){ t++; }else{ t = 1; } }else if (mouseX >=525 && mouseX < 675 && mouseY >=150 && mouseY <= 200 && mousePressed == true && mouseButton == LEFT) { if(t > 1){ t--; }else{ t = picCount; } }else if (mouseX >=525 && mouseX < 675 && mouseY >=280 && mouseY <= 330 && mousePressed == true && mouseButton == LEFT) { t = int(random(1, picCount)); // Select the front card b = int(random(1, picCount)); // Select the back card }else if (mouseX >=525 && mouseX < 675 && mouseY >=430 && mouseY <= 480 && mousePressed == true && mouseButton == LEFT) { if(b < picCount){ b++; }else{ b = 1; } }else if (mouseX >=525 && mouseX < 675 && mouseY >=560 && mouseY <= 610 && mousePressed == true && mouseButton == LEFT) { if(t > 1){ b--; }else{ b = picCount; } }else if (mouseX >=525 && mouseX < 675 && mouseY >=690 && mouseY <= 740 && mousePressed == true && mouseButton == LEFT) { saveFrame("x-##.jpg");; //save } }









Comments