Beginner questions school project
in
Programming Questions
•
1 month ago
Hello out there!
First of all thanks for a great community! I've used processing for two weeks at school and I've found sooo much help here:)
I am currently working on a project creating an interactive poster for my line of study!
The interactions have to be really simple so I hope you can help me :)
First of all, I have loaded the image of the poster into processing.
I need to make some rectangles with text in them when I move the mouse close to certain points on the screen. I know what I have to do, but I can't assemble it:
-Determine the specified area on the screen that should respond with interaction
-make a rect() that appears automatically when the mouse icon is moved into the area.
-apply text to the rect()
The second thing is that I've made a couple of mouse-click functions. Blue rectangles appear by left click. Green circles by right click. Erase by scroll click.
Now, I would like these shapes to slowly descend and exit the image, preferably with some sort of "feather falling towards the ground"-effect. This should happen as soon as you click the mouse and the shape appears.
Sorry for the long post, I am terrible at writing these things :)
Feel free to try it, just put in another image !
Here is the code so far:
float rectGrow = 10;
float ellipseGrow = 10;
void setup(){
size(500,707);
image(loadImage("poster.jpg"),0,0);
}
void mousePressed(){
if (mouseButton == RIGHT) {
strokeWeight(2);
stroke(54,242,149);
noFill();
ellipse(mouseX,mouseY,ellipseGrow*random(0.5,2.5),ellipseGrow*random(0.5,2.5));
ellipseGrow += random(0.05,0.2);
}
else if (mouseButton == LEFT){
strokeWeight(2);
stroke(31,252,251);
noFill();
rect(mouseX,mouseY,rectGrow*random(0.5,2.5),rectGrow*random(0.5,2.5));
rectGrow += random(0.05,0.2);
}
else if (mouseButton == CENTER){
image(loadImage("poster.jpg"),0,0);
}
}
void keyPressed(){
if (key == CODED){
if (keyCode == UP)
fill(color(random(255),random(255),random(255),80));
rect(0,0,width,height);
}
{
if (keyCode == DOWN)
image(loadImage("poster.jpg"),0,0);
}
}
1