# Making a Transparent Background and Exporting to PNG

**URL:** <https://discourse.processing.org/t/making-a-transparent-background-and-exporting-to-png/37073>\
**Category:** Beginners\
**Created:** [May 25, 2022, 2:53am UTC](https://discourse.processing.org/t/making-a-transparent-background-and-exporting-to-png/37073 "2022-05-25T02:53:44Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)\
**Post date:** [May 25, 2022, 8:50am UTC](https://discourse.processing.org/t/making-a-transparent-background-and-exporting-to-png/37073/3 "2022-05-25T08:50:55Z")

</div>

Create a PGraphics image to draw it all to then save that,  
took off the P2D because it flickers like crazy on my screen for some reason

```auto
int horiz = 17;
int vert = 11;
PGraphics img;

void setup() {
  size(720, 480);
  img = createGraphics(width,height);
  background(99, 10, 200,0);

  img.beginDraw();
  img.clear();
  img.translate(30, 30);
  for (int x=0; x<horiz; x++) {
    img.pushMatrix();
    img.translate(x*40, 0);
    for (int y=0; y<vert; y++) {
      img.pushMatrix();
      img.translate(0, y*40);
      img.circle(0, 0, 20);  
      img.popMatrix();
    }
    img.popMatrix();
  }
  img.endDraw();
  image(img,0,0);
  
  img.save("test.png");
}

```

---

_[View the full topic](https://discourse.processing.org/t/making-a-transparent-background-and-exporting-to-png/37073)._
