Shapes, images and mouse
in
Programming Questions
•
1 year ago
Hey all,
Just started to get into processing and I've hit a bit of stumbling block. I'm trying to create a menu where you select an image and information appear, but as of now I'm just having difficulty making a white shape over one of the images change its opacity when I hover over the certain image. If I run the shape section without the image code it works perfectly but when I integrate it either nothing happens (when noLoop is on) or one of the images fades to black (when loop is on). Very confused and I've hit a block in trying to solve the problem.
This may be a really simple problem but it's got me stumped, thanks anyone who can guide me on this.
- PImage a, b;
- int x = 0;
- int y = 250;
- int w = 500;
- int h = 250;
- void setup() {
- size(500, 500);
- b = loadImage("rathmines.jpg");
- a = loadImage("jamesjoyce.jpg");
- noLoop();
- }
- void draw() {
- background(255);
- loop();
- if (mouseX > x && mouseX < x + w && mouseY > y && mouseY < y + h) {
- fill(0);
- }
- else {
- fill(175);
- }
- rect(x, y, w, h);
- noLoop();
- a.resize(0, 600);
- image(a, -10, 230);
- image(b, 0, -170);
- line(0, height/2, width, height/2);
- }
1