We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I want the images to scale slowly, given an array of values I have, when I click. I also want the text in the corner to change at the same time. What do I need to change in both my logic of this as well as the code to make this work?
//Project in Visualization
void setup()
{
size(700,700);
smooth();
USA = loadImage("map.png");
bfly = loadImage("bfly.jpg");
}
void draw()
{
background(255);
image(USA,-160,-50,1000,880);
for (int i = 0; i < 4; i++)
{
if(mousePressed)
{
i++;
//florida
image(bfly,450,460,F[i],F[i]);
//New England
image(bfly,460,360,NE[i],NE[i]);
//mexico
image(bfly,280,540,M[i],M[i]);
//north dakocta
image(bfly,290,280,ND[i],ND[i]);
}
}
}
void mousePressed()
{
textSize(60);
fill(0);
text("2000", 30, 600);
noLoop();
}
PImage USA;
PImage bfly;
Comments
1.
put global vars at the start of the sketch, not the end
2.
when you want to increase the images when the mouse is clicked and the images stay bigger when you let go of the mouse:
The line
noLoop()
is a bad idea when you want something to happen on the screendon't have this in draw()
@chrisir I have added the text I wanted (four different texts to correspond with the four different sizes of images) into an array. Could you then use i++ in a way to change all of theses?
sure! show your code...
@chrisir Ok so what I have now is this, I do get the numbers and the images to scale properly. The only thing that it isn't doing well is slowly changing to the size instead of abruptly going from one size to the next as well as going back to 0 once you click 4 times (when you click 4 times the project errors out).
@chrisir for changing slowly the only way I have found is to add some fraction (like .5) to the length and width. But I am unsure how to do that with the array, specifically because I only want it to change after you click the mouse.
for the
pls look at lerp()
this allows you to go from one value in e.g. 10 steps
;-)