title: In Processing, how can I save part of the window as an image?
body: <p>I am using Processing under Fedora 20, and I want to display an image of the extending tracks of objects moving across part of the screen, with each object displayed at its current position at the end of the track. To avoid having to record all the co-ordinates of the tracks, I use<code>save("image.png");</code> to save the tracks so far, then draw the objects. In the next frame I use <code>img = loadImage("image.png");</code> to restore the tracks made so far, without the objects, which would still be in their previous positions.. I extend the tracks to their new positions, then use<code>save("image.png");</code> to save the extended tracks, still without the objects, ready for the next loop round. Then I draw the objects in their new positions at the end of their extended tracks. In this way successive loops show the objects advancing, with their previous positions as tracks behind them. </p>
  
  <p>This has worked well in tests where the image is the whole frame, but now I need to put that display in a corner of the whole frame, and leave the rest unchanged. I expect that <code>createImage(...)</code> will be the answer, but I cannot find any details of how to to so. </p>
  
  <p>A similar question asked here has this recommendation: "The PImage class contains a save() function that exports to file. The API should be your first stop for questions like this." Of course I've looked at that <a href="https://processing.org/examples/createimage.html" rel="nofollow">API</a>, but I don't think it helps here, unless I have to create the image to save pixel by pixel, in which case I would expect it to slow things down a lot. </p>
  
  <p>So my question is: in <code>Processing</code> can I save and restore just part of the frame as an image, without affecting the rest of the frame?</p>