# Weird issue with pgraphics

**URL:** https://discourse.processing.org/t/weird-issue-with-pgraphics/2063
**Category:** Coding Questions
**Created:** [July 25, 2018, 9:20am UTC](https://discourse.processing.org/t/weird-issue-with-pgraphics/2063 "2018-07-25T09:20:39Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [July 25, 2018, 11:11am UTC](https://discourse.processing.org/t/weird-issue-with-pgraphics/2063/4 "2018-07-25T11:11:05Z")

</div>

```auto
/**
 * PGraphics arrayCopy() (v1.1)
 * GoToLoop (2018/Jul/25)
 * Discourse.Processing.org/t/weird-issue-with-pgraphics/2063/4
 */

static final String FILENAME = "balls.", EXT = ".jpg";
static final String FC = "Frames: ", SC = " - Shots: ";

static final int BALLS = 200, DIAM = 20, RAD = DIAM >> 1;

PGraphics left, right;

void setup() {
  size(640, 480);
  left = createGraphics(width >> 1, height);
  right = createGraphics(width >> 1, height);

  left.beginDraw();
  left.background((color) random(#000000));
  left.endDraw();

  right.beginDraw();
  right.background((color) random(#000000));
  right.endDraw();
  set(width >> 1, 0, right);
}

void draw() {
  final int shots = frameCount / BALLS;
  final String fc = FC + frameCount, sc = SC + shots;
  getSurface().setTitle(fc + sc);

  left.beginDraw();

  final float x = random(RAD, left.width - RAD);
  final float y = random(RAD, left.height - RAD);
  left.ellipse(x, y, DIAM, DIAM);

  if (frameCount % BALLS == 0) {
    left.loadPixels();
    arrayCopy(left.pixels, right.pixels);
    right.updatePixels();
    set(width >> 1, 0, right);

    final String filename = FILENAME + nf(shots, 3) + EXT;
    right.save(dataPath(filename));

    left.background((color) random(#000000));
  }

  left.endDraw();
  set(0, 0, left);
}

```

---

_[View the full topic](https://discourse.processing.org/t/weird-issue-with-pgraphics/2063)._
