Save 2 pictures at same time with different stroke & fill parameters

Hello,
I’m not a coder but wish to solve a little problem :
How do i save 2 pictures at same time with mousePressed fonction with 2 different “stroke” & “fill” parameters

like :

PImage img; // Variable init
int counter = 1; // moussePressed increment

void draw(){

// the draw code...
  
noStroke(); // condition for pic1
fill(0); // condition for pic1

stroke(0); // condition for pic2
fill (255); //// condition for pic2

// save the pictures
void mousePressed() {
  save("pic1" + counter + ".png");
  save("pic2" + counter + ".png");
  counter++;
}

Thanks for anyone who could help
Gabriel

1 Like

One approach would be to use a PGraphics array and then iterate the array to save the images.
https://processing.org/reference/PGraphics.html

You can also use a command variable to tell the Sketch what to
do. Name it saveSituation.

Before setup() you say int saveSituation=0;

in mousePressed say
saveSituation=1;// don’t repeat the word int here

in draw() we evaluate saveSituation with

if… else if… else if…

(or even switch ())

so :

if(saveSituation==0) {
  do nothing or just draw a standard image 
}
else if(saveSituation==1) {
  set stroke and fill before drawing and draw image1
  save.... 
  saveSituation++;
}
else if(saveSituation==2) {
  set stroke and fill before drawing and draw image2
  save.... 
  saveSituation=0;//reset
}

It’s very important to use else if and not only if
(or use switch())

You can place the image in a function that you call twice (or thrice)

1 Like

Hello,

Marvelous, it works well.
Thanks a lot for the help.
I’m using this “processing” software only for an art-work of mine but i realize how powerful it can be.
Perhaps i will take a closer look to this.

Cordialement,
Gabriel

1 Like