Skip to content

Instantly share code, notes, and snippets.

@tboydar
Created October 4, 2013 03:41
Show Gist options
  • Save tboydar/6820664 to your computer and use it in GitHub Desktop.
Save tboydar/6820664 to your computer and use it in GitHub Desktop.
processing in 實踐
//show photos
PImage photo_a;
PImage photo_b;
PImage photo_c;
int mode = 0;
void setup() //設定
{
size(300, 300);
photo_a = loadImage("a.jpg");
photo_b = loadImage("b.jpg");
photo_c = loadImage("c.jpg");
frameRate(10);
}
//area1 = 0 ~ width/3,
//area2 = width/3 ~ (width/3)*2,
//area3 = (width/3)*2 ~ (width/3)*3
void draw() //繪圖
{
background(0);
stroke(255);
line(width/3, 0, width/3, height);
line(width/3*2, 0, width/3*2, height);
if (mode == 0) image(photo_a, 30, 10, 30, 30);
if (mode == 1) image(photo_b, 30, 50, 30, 30);
if (mode == 2) image(photo_c, 30, 90, 30, 30);
}
void mousePressed() //滑鼠按下
{
if (mouseX > 0 && mouseX < width/3)
mode = 0;
if (mouseX > width/3 && mouseX < (width/3)*2)
mode = 1;
if ( mouseX > (width/3)*2 && mouseX < (width/3)*3)
mode = 2;
println("mode:"+mode);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment