Skip to content

Commit

Permalink
change sketch portal default throttle frame rate to 30
Browse files Browse the repository at this point in the history
  • Loading branch information
hx2A committed Aug 3, 2021
1 parent 0a80f33 commit 82de091
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion generator/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
'hook_post_draw: bool = False'], 'List[PIL.Image]')
],
('Py5Tools', 'sketch_portal'): [
(['*', 'time_limit: float = 0.0', 'throttle_frame_rate: float = None',
(['*', 'time_limit: float = 0.0', 'throttle_frame_rate: float = 30',
'scale: float = 1.0', 'quality: int = 75',
'portal_widget: Py5SketchPortal = None', 'sketch: Sketch = None',
'hook_post_draw: bool = False'], 'None')
Expand Down
6 changes: 3 additions & 3 deletions py5_docs/Reference/api_en/Py5Tools_sketch_portal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ category = sketch_hooks
subcategory = None

@@ signatures
sketch_portal(*, time_limit: float = 0.0, throttle_frame_rate: float = None, scale: float = 1.0, quality: int = 75, portal_widget: Py5SketchPortal = None, sketch: Sketch = None, hook_post_draw: bool = False) -> None
sketch_portal(*, time_limit: float = 0.0, throttle_frame_rate: float = 30, scale: float = 1.0, quality: int = 75, portal_widget: Py5SketchPortal = None, sketch: Sketch = None, hook_post_draw: bool = False) -> None

@@ variables
hook_post_draw: bool = False - attach hook to Sketch's post_draw method instead of draw
portal_widget: Py5SketchPortal = None - Py5SketchPortal object to send stream to
quality: int = 75 - JPEG stream quality between 1 (worst) and 100 (best)
scale: float = 1.0 - scale factor to adjust the height and width of the portal
sketch: Sketch = None - running Sketch
throttle_frame_rate: float = None - throttle portal frame rate below Sketch's frame rate
throttle_frame_rate: float = 30 - throttle portal frame rate below Sketch's frame rate
time_limit: float = 0.0 - time limit in seconds for Sketch portal; set to 0 (default) for no limit

@@ description
Expand All @@ -29,7 +29,7 @@ If you are using Jupyter Lab, try right clicking in the output area of the cell

This command can be called before :doc:`run_sketch` if the current Sketch is in the :doc:`is_ready` state.

Use the ``time_limit`` parameter to set a time limit (seconds). Use ``throttle_frame_rate`` to throttle the stream's frame rate (frames per second) to a slower pace than the Sketch's actual draw frame rate. The ``scale`` parameter is a scaling factor that can adjust the portal height and width. The ``quality`` parameter sets the JPEG quality factor (default 75) for the stream, which must be between 1 (worst) and 100 (best). If the portal causes the Sketch's frame rate to drop, try adjusting the portal's throttle frame rate, quality, and scale.
Use the ``time_limit`` parameter to set a time limit (seconds). Use ``throttle_frame_rate`` to throttle the stream's frame rate (frames per second) to a slower pace than the Sketch's actual draw frame rate. By default, ``throttle_frame_rate`` is set to 30, which is half of the Sketch's default draw frame rate of 60 frames per second. Set this parameter to ``None`` to disable throttling. The ``scale`` parameter is a scaling factor that can adjust the portal height and width. The ``quality`` parameter sets the JPEG quality factor (default 75) for the stream, which must be between 1 (worst) and 100 (best). If the portal causes the Sketch's frame rate to drop, try adjusting the portal's throttle frame rate, quality, and scale.

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.

Expand Down
2 changes: 1 addition & 1 deletion py5_resources/py5_module/py5_tools/hooks/zmq_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Py5SketchPortal(widgets.Image):
pass


def sketch_portal(*, time_limit: float = 0.0, throttle_frame_rate: float = None,
def sketch_portal(*, time_limit: float = 0.0, throttle_frame_rate: float = 30,
scale: float = 1.0, quality: int = 75,
portal: Py5SketchPortal = None, sketch: Sketch = None,
hook_post_draw: bool = False) -> None:
Expand Down

0 comments on commit 82de091

Please sign in to comment.