Source

PyCessing / pycessing / data / examples / screengrab.cess

Full commit
# screenGrab("myfile.jpg") takes a snapshot of your image and saves
# it to a file.
# this boring example just draws a polygon on the screen and saves 
# the result on the desktop
# NOTE: change the file name and folder so this won't try to save to the
#   application folder where pycessing lives
points = [(10, 10), (10, 50), (60, 70), (90, 20) ]

def setup():
    pycessing.noLoop = True

def draw():
    polygon(points)
    screenGrab("/home/mute/Desktop/test.jpg")