# Help with Painting Program

**URL:** https://discourse.processing.org/t/help-with-painting-program/15840
**Category:** Coding Questions
**Created:** [November 26, 2019, 5:09pm UTC](https://discourse.processing.org/t/help-with-painting-program/15840 "2019-11-26T17:09:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![keeg23](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@keeg23](https://discourse.processing.org/u/keeg23)
#### Post date: [November 26, 2019, 5:09pm UTC](https://discourse.processing.org/t/help-with-painting-program/15840/1 "2019-11-26T17:09:57Z")

</div>

When I use the save function it changes the background to red and erases what is painted, Wondering how I can save without it going away and background staying orange. Also need help with creating a way to have the other paint buckets work only can get the blue one to work as of now… Thank you

```auto
PImage myElonStart, myMonroe, myLennon, 
  myBlueCan, myRedCan, myPinkCan, myGreenCan, myTanCan, 
  mySave, myRestart, myBrush1, myBrush2, myBrush3;
PFont thePopArtFont;
boolean saveTheImage =false;

// ***********COLORS*****************
color bluePaint = color(0, 144, 255);
color currentColor = color(0, 144, 255);
color black = color(0);
color redPaint = color(255, 4, 4);
color greenPaint = color (92, 207, 102);
color pinkPaint = color (253, 80, 116);
color tanPaint = color (245, 170, 91);
color orgBackground = color (255, 122, 10);

boolean typeIsCan=true;

void setup() {
  size (1280, 720);
  background(orgBackground);
  //load images
  myElonStart = loadImage("elonData.png");
  myMonroe = loadImage("monroeData.png");
  myLennon = loadImage("lennonData.png");
  myBlueCan = loadImage("blueCan.png");
  myRedCan = loadImage("redCan.png");
  myPinkCan = loadImage("pinkCan.png");
  myGreenCan = loadImage("greenCan.png");
  myTanCan = loadImage("tanCan.png");
  mySave = loadImage("save.png");
  myRestart = loadImage("restart.png");
  myBrush1 = loadImage("brush1.png");
  myBrush2 = loadImage("brush2.png");
  myBrush3 = loadImage("brush3.png");

  //load font
  thePopArtFont = createFont("GoldenHillsDEMO.ttf", 50);
  textFont(thePopArtFont);
}

void draw() {
  fill(black);
  text("Pop Art Paint Program", width/3, 50);
  fill(bluePaint);
  text("Pop Art Paint Program", width/3.01, 47);
  checkRollovers();
  myBorder(); //Draws blue border around window
  myDrawPeople(); //puts three pictures of options to paint
  myButtonLayout();

  if (mousePressed)
  {
    noStroke();
    fill(currentColor);
    if (typeIsCan)
    {
      if ((mouseX>10) && (mouseX<80) && (mouseY>5) && (mouseY<121))
      {
        fill(bluePaint);
        ellipse(mouseX, mouseY, 20, 20);
        ellipse(pmouseX, pmouseY, 40, 40);
      }
    } else
    {
      fill(currentColor);
      ellipse(mouseX, mouseY, 20, 20);
      line(pmouseX, pmouseY, mouseX, mouseY);
    }
  }
}

void mousePressed() {

  if ((mouseX>10) && (mouseX<80) && (mouseY>5) && (mouseY<121))
  {
    typeIsCan =false;
    currentColor = bluePaint;
  }
}
void checkRollovers () {
  //Save button rollover
  if ((mouseX >155) && (mouseX <250) && (mouseY >618) && (mouseY <718)) {
    saveTheImage=true;
    cursor(WAIT);
  } else {
    saveTheImage=false;
    cursor(ARROW);
  }
}
void mouseReleased() {
  if (saveTheImage == true) {
    saveImage();
   background(redPaint);

    saveTheImage = false;
  }
  
}

void myBorder() {
  fill(0, 144, 255);
  noStroke();
  rect(0, 0, 100, 611);
  rect(0, 610, 1280, 720);
  rect(1180, 0, 1280, 620);
}

void myButtonLayout() {
  //Paint Cans
  image(myBlueCan, 10, 5);
  image(myRedCan, 10, 128);
  image(myPinkCan, 10, 250);
  image(myGreenCan, 10, 374);
  image(myTanCan, 10, 495);
  //Paint Brushes
  image(myBrush1, 1200, 136);
  image(myBrush2, 1200, 260);
  image(myBrush3, 1200, 382);
  //Start Restart Button
  image(mySave, 155, 615);
  image(myRestart, 870, 615);
}

void myDrawPeople() {
  image(myElonStart, 156, 219);
  image(myMonroe, 520, 220);
  image(myLennon, 840, 220);
}

 void saveImage() {
  PImage partialSave = get(115, 65, 1000, 535);

  String path = sketchPath("Images/");

  File file = new File(path);
  int folderSize = 0;
  if (file.exists() && file.isDirectory()) {
    folderSize = file.listFiles().length;
  }
  partialSave.save(path+"PopArtImage" + folderSize + "jpg");
}![blueCan|77x116](upload://7eTMlQ5zagBXIbc4xQ5q93MsQbQ.png) ![brush1|60x60](upload://p9bycQ5Z5AouFyF0FEU6wdJ3DdP.png) ![brush2|60x60](upload://lqtupt8G0f6w6SVleCC1f2SkoJw.png) ![brush3|60x60](upload://mwqs9mubhRFfHIm0xfF2kHNkLTv.png) ![elonData|312x228](upload://lGZbaK64cv10ySP3jpauAnjW7RC.png) ![greenCan|77x116](upload://waMeSnPTf9zs0Liu5Ph5J5Xh68o.png) ![lennonData|312x228](upload://nVam0HHkOYTOzBY7q2UeNwglluu.png) ![monroeData|312x228](upload://7GBOwLEJMbhLt8EL4Cb6XsxZWY.png) ![pinkCan|77x116](upload://hUsQQ0eAr58cOyAcVFKxdQPcX50.png) ![redCan|77x116](upload://oIcnpq2tspvqyOqdKF0FUyO6YZq.png) ![restart|255x96](upload://izJl8ZZfRSoZknIfgmhp4Mk8VpA.png) ![save|100x100](upload://3klccvppF4im2DgdqUG5NjSqNF7.png) ![tanCan|77x116](upload://6JZ1RidEjTaBrGGp72fCLD8aXer.png) ![blueCan|77x116](upload://7eTMlQ5zagBXIbc4xQ5q93MsQbQ.png) ![brush1|60x60](upload://p9bycQ5Z5AouFyF0FEU6wdJ3DdP.png) ![brush2|60x60](upload://lqtupt8G0f6w6SVleCC1f2SkoJw.png) ![brush3|60x60](upload://mwqs9mubhRFfHIm0xfF2kHNkLTv.png) ![elonData|312x228](upload://lGZbaK64cv10ySP3jpauAnjW7RC.png) ![greenCan|77x116](upload://waMeSnPTf9zs0Liu5Ph5J5Xh68o.png) ![lennonData|312x228](upload://nVam0HHkOYTOzBY7q2UeNwglluu.png) ![monroeData|312x228](upload://7GBOwLEJMbhLt8EL4Cb6XsxZWY.png) ![pinkCan|77x116](upload://hUsQQ0eAr58cOyAcVFKxdQPcX50.png) ![redCan|77x116](upload://oIcnpq2tspvqyOqdKF0FUyO6YZq.png) ![restart|255x96](upload://izJl8ZZfRSoZknIfgmhp4Mk8VpA.png) ![save|100x100](upload://3klccvppF4im2DgdqUG5NjSqNF7.png) ![tanCan|77x116](upload://6JZ1RidEjTaBrGGp72fCLD8aXer.png) 

```

---

<div class="post-metadata">

### Author: ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)
#### Post date: [November 26, 2019, 7:57pm UTC](https://discourse.processing.org/t/help-with-painting-program/15840/2 "2019-11-26T19:57:16Z")

</div>

Hi there Keeg23, welcome to the forum.

Unfortunately we can’t test your code because we don’t have the images nor the font. Best thing to do in these situations is rewrite a minimal version of your sketch which reproduces the problem, which doesn’t required external files such as images (and if the image is required, add it 🙂 )

Although I can’t run your code, I noticed the following:

```auto
void mouseReleased() {
  if (saveTheImage == true) {
    saveImage();
    background(redPaint);
    saveTheImage = false;
  }
}

```

The moment `saveTheImage ` becomes `true`, it saves the image with the function `saveImage();`. Right after you’re telling your sketch to fill the background with a red colour. Does removing this solve your first issue?

---

<div class="post-metadata">

### Author: ![clankill3r](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/clankill3r/32/1098_2.png) [@clankill3r](https://discourse.processing.org/u/clankill3r)
#### Post date: [November 26, 2019, 9:18pm UTC](https://discourse.processing.org/t/help-with-painting-program/15840/3 "2019-11-26T21:18:05Z")

</div>

> [@Tiemen](#):
>
> if (saveTheImage == true) {

Minor thing, basically you are testing `true == true` or `false == true`. You could just type `if (saveTheImage) {`.
