Can you resize an image and only show the new Image

please format code with </> button * homework policy * asking questions

Hi, so I have an easy question (I think). I’m trying to show an image and then resize it. Is there a way to only display the resized image and not the original?
(This is probably a dumb question, but I’ve tried everything I can and haven’t found anything on the internet either)

The short answer is yes, you can resize an image to show only the new image.
But I think a little more information is required for a good answer.
For example, in what manner do you want to resize the object?
Do you want it to be timing based?
Please elaborate a bit more.

:nerd_face:

Hi

Many ways to do that

1 Like

@Kalarila
Hi with boolean you can

boolean show= true;
PImage flower;

void setup() {
  size(800, 600);
  flower = loadImage("k.png");
}

void draw() {
  background(0);
  if (show)  image(flower, 0, 0);
}
void mousePressed() {
  show = !show;
  flower.resize(0, 500); 
  //image(flower, 0, 0);
}

1 Like

thx for the help, it’s working now :).

1 Like

Hello @Kalarila,

Keep in mind that there are may resources (tutorials, references, examples, etc.) here:

It is worthwhile to peruse these and get familiar with them.
It gets easier to navigate and find what you are looking for with experience.
I find them to be an invaluable resource!

For example:
https://processing.org/reference/PImage.html
Which leads to:
https://processing.org/reference/PImage_resize_.html

Have fun coding!

:)