begin_record()#

Opens a new file and all subsequent drawing functions are echoed to this file as well as the display window.

Examples#

 1def setup():
 2    py5.size(400, 400)
 3    py5.begin_record(py5.PDF, "everything.pdf")
 4
 5
 6def draw():
 7    py5.ellipse(py5.mouse_x, py5.mouse_y, 10, 10)
 8
 9
10def mouse_pressed():
11    py5.end_record()
12    py5.exit_sketch()
1def setup():
2    py5.size(200, 200)
3
4    with py5.begin_record(py5.SVG, "/tmp/test.svg") as r:
5        py5.rect_mode(py5.CENTER)
6        r.fill("#F00")  # affects the recorded output only
7
8        for _ in range(10):
9            py5.square(py5.random(py5.width), py5.random(py5.height), 10)

Description#

Opens a new file and all subsequent drawing functions are echoed to this file as well as the display window. The begin_record() function requires two parameters, the first is the renderer and the second is the file name. This function is always used with end_record() to stop the recording process and close the file.

Note that begin_record() will only pick up any settings that happen after it has been called. For instance, if you call text_font() before begin_record(), then that font will not be set for the file that you’re recording to.

begin_record() works only with the PDF and SVG renderers.

This method can be used as a context manager to ensure that end_record() always gets called, as shown in the last example.

Underlying Processing method: beginRecord

Syntax#

begin_record(recorder: Py5Graphics, /) -> None
begin_record(renderer: str, filename: str, /) -> Py5Graphics

Parameters#

  • filename: str - filename for output

  • recorder: Py5Graphics - Py5Graphics object to record drawing commands to

  • renderer: str - PDF or SVG

Updated on November 12, 2021 11:30:58am UTC