open-audiovisual
Search GitHub

oav-p5 reference · Recording

OAVp5.record.shot()#

functionoav-p5
OAVp5.record.shot([o])

Saves the canvas alone as a PNG picture (not the 🎹, not the cards) and downloads it.

It is the button 📷 in the 🎹 panel as a function. The file is named oav-20261015-183005.png (with name in the middle when you give one) and is downloaded at once; on a phone that can share files a Share button appears on a card instead. The picture has the size of the canvas in pixels, so a retina screen gives twice the width and height. p5's own saveCanvas('name', 'png') does the same thing without the card.

Parameters

NameTypeDescription
oObjectOptions: canvas (the canvas to save: a <canvas>, a p5 canvas or a createGraphics() buffer; the biggest p5 canvas on the page by default) and name (a word for the file name). optional

Returns

Promise<Object | null> Resolves to { name, blob, url, width, height, bytes }, or to null when there is no canvas or it cannot be read (an image from another site on it, no CORS).

Notes

  • With the loading option record=off the 📷 button is gone and startRecording() does nothing, but this function still saves the PNG (tried).

Examples

jsOpenProcessing ↗
function setup() {
  createCanvas(400, 300);
}

function keyPressed() {
  if (key === 'p') OAVp5.record.shot({ name: 'still' });
}

function draw() {
  background(20);
  circle(mouseX, mouseY, 60);
  fill(255);
  text('press p to save a PNG of the canvas', 20, 30);
}
Move the circle with the mouse and press p: a PNG of the canvas is downloaded.

Related

  • startRecording() Records the canvas and the sound your sketch makes into one video file, and returns a promise that says whether the recording began.
  • OAVp5.record The object behind the recording names: the state, the time, the last file, the formats this browser can write and the screenshot function.
  • recordingSaved() An event you define: it is called when a recording has been saved and checked, with an info object about the file.

p5/oav-p5.js, line 1922

↑ Back to top · All names