Py5 Functions#
The py5 Functions are extra utility functions that make py5 easier to use.
Examples#
py5.create_font_file('Comic Sans', 20)
sketch = py5.get_current_sketch()
assert sketch.is_ready
py5.run_sketch(block=False)
assert sketch.is_running
py5.exit_sketch()
assert sketch.is_dead
@py5.render(400, 200)
def draw_message(s: py5.Sketch):
s.background(255)
s.fill(255, 0, 0)
s.text_size(20)
s.text_align(s.CENTER, s.CENTER)
s.text('hello world', s.width/2, s.height/2)
frame = draw_message()
Description#
The py5 Functions are extra utility functions that make py5 easier to use. For example, you can use these to Processing’s vlw font files without having to use Processing’s IDE.
The following functions are provided:
@render(): Decorator function to render a single frame using the decorated
draw
function.@render_sequence(): Decorator function to render a sequence of frames using the decorated
draw
function.create_font_file(): Utility function to create Processing’s vlw font data files.
get_current_sketch(): Get the py5 module’s current
Sketch
instance.prune_tracebacks(): Set py5’s exception handling to prune unhelpful stack trace frames when exceptions are thrown by a running Sketch.
register_image_conversion(): Register new image conversion functionality to be used by convert_image().
register_shape_conversion(): Register new shape conversion functionality to be used by convert_shape().
render_frame(): Helper function to render a single frame using the passed
draw
function argument.render_frame_sequence(): Helper function to render a sequence of frames using the passed
draw
function argument.reset_py5(): Reset the py5 module’s current
Sketch
instance.set_stackprinter_style(): Set the formatting style for py5’s stack traces.
Updated on March 06, 2023 02:49:26am UTC