function getCanvasData(obj, w, h) {
      var canvasData = canvasDataCache.shift();

      if (canvasData === undef) {
        canvasData = {};
        canvasData.canvas = document.createElement("canvas");
        canvasData.context = canvasData.canvas.getContext('2d');
      }

      canvasDataCache.push(canvasData);

      var canvas = canvasData.canvas, context = canvasData.context,
          width = w || obj.width, height = h || obj.height;

      canvas.width = width;
      canvas.height = height;

      if (!obj) {
        context.clearRect(0, 0, width, height);
      } else if ("data" in obj) { // ImageData
        context.putImageData(obj, 0, 0);
      } else {
        context.clearRect(0, 0, width, height);
        context.drawImage(obj, 0, 0, width, height);
      }
      return canvasData;
    }
Saves an image from the display window. Images are saved in TIFF, TARGA, JPEG, and PNG format
depending on the extension within the filename  parameter. For example, "image.tif" will have
a TIFF image and "image.png" will save a PNG image. If no extension is included in the filename,
the image will save in TIFF format and .tif will be added to the name. These files are saved to
the sketch's folder, which may be opened by selecting "Show sketch folder" from the "Sketch" menu.
It is not possible to use save() while running the program in a web browser.  All images saved
from the main drawing window will be opaque. To save images without a background, use createGraphics().

@param {String} filename      any sequence of letters and numbers

@see saveFrame
@see createGraphics