OK, since you made efforts and some base code, I will show what I meant.
Note: I made also some beginner's errors, like initializing dx where I declare it, outside of setup(), which is wrong because the size is known only after setup() has run, while global inits are done before everything. Or using currentImage before it was set!
I just have enough experience to quickly find what is going wrong and to fix it...
Code:void setup() {
size(360,443);
images[0]=loadImage("D:/_PhiLhoSoft/images/earth.gif");
images[1]=loadImage("D:/_PhiLhoSoft/images/Engine.png");
strokeWeight(2);
dx = width/9; dy = height/6;
}
PImage currentImage;
PImage[] images = new PImage[2];
int dx, dy;
ArrayList lines = new ArrayList();
void draw() {
background(255);
if (currentImage != null) {
image(currentImage, 0, 0, width, height);
}
image(images[0],0,0,dx,dy);
image(images[1],dx,0,dx,dy);
if(mousePressed) {
if (mouseX < dx && mouseY < dy) {
currentImage = images[0];
} else if (mouseX >= dx && mouseX < 2*dx && mouseY < dy) {
currentImage = images[1];
} else {
PVector node = new PVector(mouseX, mouseY);
lines.add(node);
}
}
stroke(0);
for (int i = 0; i < lines.size(); i++) {
if (i > 0) {
PVector prevNode = (PVector)lines.get(i - 1);
PVector node = (PVector)lines.get(i);
line(prevNode.x, prevNode.y, node.x, node.y);
}
}
}
Note I defined dx and dy to avoid using "magic numbers" sprinkled all over the code: thus if I want bigger images, I just have to change a limited amount of code.