py5_tools.screenshot()#

Take a screenshot of a running Sketch.

Examples#

1import time
2import py5_tools
3
4py5.run_sketch()
5# take a screenshot of the running sketch after a two second delay
6time.sleep(2)
7img = py5_tools.screenshot()
8img.save('image.png')

Description#

Take a screenshot of a running Sketch.

The returned image is a PIL.Image object. It can be assigned to a variable or embedded in the notebook.

By default the Sketch will be the currently running Sketch, as returned by get_current_sketch(). Use the sketch parameter to specify a different running Sketch, such as a Sketch created using Class mode.

If your Sketch has a post_draw() method, use the hook_post_draw parameter to make this function run after post_draw() instead of draw(). This is important when using Processing libraries that support post_draw() such as Camera3D or ColorBlindness.

Syntax#

screenshot(*, sketch: Sketch = None, hook_post_draw: bool = False) -> PIL.Image

Parameters#

  • hook_post_draw: bool = False - attach hook to Sketch’s post_draw method instead of draw

  • sketch: Sketch = None - running Sketch

Updated on September 11, 2021 16:51:34pm UTC