Releases: py5coding/py5
Live Coding
New Feature: Live Coding
py5 has a new feature: Live Coding. The basic idea is to have a live coding environment where you can write and modify your py5 code and see the results in real time. It is designed to support rapid prototyping of ideas and experimentation. You'll be able to write code in an editor or Jupyter Notebook and see the results in a running Sketch immediately, without having to exit a running Sketch and then start a new one.
You can read more about Live Coding on the documentation website:
https://py5coding.org/content/live_coding.html
Closed Issues:
- Issue #17 - Why can't run_example_code.py do a complete run-through of all of the reference documentation example code?
- Issue #490 - py5 rejects valid static mode code
- Issue #501 - Py5Shape's
get_children()
method should return[]
when there are no children - Issue #506 - Incorrect variable description for
vertex()
methods - Issue #507 - py5_tools should use
__all__
to control what is importable - Issue #528 - Improve error messages for invalid named colors
Small release with a few new features
Enhancements and Changes
- Minimum Python version now 3.9
- Update library dependencies, including allowing numpy 2.0
- New
convert_cached_image()
andconvert_cached_shape()
methods
Closed Issues
- Issue #420 - new
convert_cached_image()
andconvert_cached_shape()
methods - Issue #441 - improve error message when sketch file is executed without ever being saved
- Issue #443 - repairing the
Py5Image.copy()
method - Issue #446 - unpin numpy, allowing py5 to be installed alongside numpy 2.0
- Issue #447 - repairing and enhancing
set_println_stream()
. This change was needed to support the future project py5ascii.
Small release with a few new features
This is a small release with two new features and a handful of bug fixes.
Numpy Version
The main reason why this py5 release is happening now and not later is because numpy will soon have a major release that is not completely backwards compatible. Version 2.0 of numpy will be released soon and library maintainers have been advised to pin dependencies to numpy<2.0
and then test with numpy 2.0 when it is available. This is to ensure that py5 and every library py5 depends on is ready for the new version and does not cause users any problems.
Once the new numpy version is released and I verify py5 works well with it, I will do another release of py5 that removes the numpy<2.0
pin.
New Contributors
Recently py5 had two first-time contributors. Many thanks to keko24 (Andrej) for PR #406 - Implemented corresponding changes to convert_image and convert_shape, addressing Issue #405. Also, thanks to JulienBacquart for PR #416 correct constrain documentation, addressing some documentation errors.
New Features
Neither of these new features are that significant and most likely they won't be useful for most users. However, they have been useful for me as I've done the prototyping experiments for a gallery show, opening next Friday in Detroit.
- The new
predraw_update()
user function is called before each call todraw()
. The purpose of this function is to provide a small performance boost by moving non-drawing update code to a function that executes during a time when the Python interpreter would otherwise be idle. If you want to read more about this feature, visit the new Update Function section of the new User Functions page. - Processing Mode users can now use the
jclass_params
keyword parameter to pass arguments to the constructors of their Java Classes. Read the Processing Mode documentation to learn more about this use of py5.
Closed Issues
- Issue #405 -
convert_image()
andconvert_shape()
methods should support Py5Image, Py5Graphics, and Py5Shape objects - Issue #394 -
save_frame()
cannot be called from a mouse or keyboard event function but that works fine in Processing - Issue #421 - Add
display_progress
param topy5_tools.offline_frame_processing()
py5's Python Ecosystem Integration
This is a major release with many new features.
New Features
The major theme of this release is expanding and improving py5's Python ecosystem integrations. This release includes new features for working with matplotlib, Shapely, and Trimesh through the new convert_shape() method and the upgraded convert_image() method. It also includes a new color mode called CMAP that is built around matplotlib colormaps.
The documentation for these new features is extensive. There is now a new section in the documentation called Python Ecosystem Integrations that explains how py5 integrates with other Python libraries. This covers the new features in this release as well as existing features that perhaps some people didn't know about.
Removed Features
Unfortunately, the py5_tools.sketch_portal() function has been removed from py5. The functionality was broken because of recent upgrades in Jupyter. I tried to fix it but couldn't figure out how to make it work again. I know it has something to do with changes to Jupyter and Jupyter Widgets. Programming Jupyter Widgets is very difficult and involves a lot of confusing Python and TypeScript code.
The SketchPortal feature wasn't that great of a tool to begin with and it doesn't seem that very many people were using it anyway.
My plan for the future is to re-implement this feature using the Python library anywidget. This seems to be a much more robust and reliable approach that will cause less headaches for me.
Other Changes
- Using g to access the primary Py5Graphics object is no longer supported. Users should use get_graphics() instead.
- New to_pil() and get_np_pixels() methods added to Sketch, Py5Graphics, and Py5Image. Issue #329: feature idea: how about a get_np_pixels() method?
- The py5_tools.animated_gif() and py5_tools.capture_frames() functions now have a frame_numbers parameter. Issue #350: Enhancement: Add precise frame control to py5_tool.animated_gif()
- Py5Shape objects now have height, width, and depth properties. Issue #352: Could Py5Shape objects have a .width and a .height using @property?
Closed Issues
- Issue #381: Fix or update example code that makes assumptions about non-blocking run_sketch()
- Issue #378: Binder link/button missing on py5coding.org and other issues.
- Issue #354: Malformed Py5Shape objects if Processing's loadShape() returns null
- Issue #348: color() not working with the hex notation when used before setup()
- Issue #330: get_pixels() does not work correctly for Py5Image objects
- Issue #322: Remove g from py5
- Issue #316: Issue with install on mac M2 - import py5 in Jupyter causes kernel to die
- Issue #241: documentation gap: named colors
There are many more bugs fixes in this release than the ones listed here. When I find small bugs with easy solutions I often fix them right away without opening an issue recording it.
Processing Code Changes
In addition to the above, this release includes a few Processing code bug fixes.
- Issue #643 - beginContour() and endContour() doesn't work on PShape
- Issue #781 - PShape.getSpecular(), PShape.getEmissive(), and PShape.getShininess() don't work correctly
The new convert_shape() method needed a fix for issue #643 so I found a fix for it. It took two PRs because my first PR wasn't quite right.
The second issue, #781, was discovered while reviewing py5's example code. It was an easy fix.
None of these code changes have been part of a Processing release yet and one of the PRs still hasn't been merged into the main branch. I can't wait for that to happen so this py5 release is using the fix791 branch of my fork of the Processing repo. Once the last PR is merged and the code is released, py5 will go back to using the latest Processing core jars.
Imported Mode Code Importing & Improvements to Py5Shape
...and bug fixes.
We are moving back to py5's previous release frequency of a release every 2-3 months. This is minor release with one important feature to support Thonny users, as well as a handful of bug fixes and other improvements.
Imported Mode Code Importing feature
Python projects with moderate to large amounts of code will be typically split into multiple files that will be imported
from from one file to another. However, due to the way py5's Imported Mode works, this couldn't be done with py5 Imported Mode code. This new feature changes that, supporting the ability to import Imported Mode code from one file to another. How to do this is described in more detail in the documentation page Importing Imported Mode Code.
Other Changes
- Using
g
to access the primary Py5Graphics object is now deprecated. Users will receive a warning message instructing them to useget_graphics()
intead. Allowing the single characterg
to be a reserved variable name is problematic for users coding in Imported Mode. Consider that theg
variable is often used in a rgb variable triplet. Theg
variable will be removed in the next release. - Update dependency versions for numpy from 1.23 to 1.24 and for pillow from 9.2 to 9.5
- New
Py5Shape.color_mode()
method, similar toPy5Graphics.color_mode()
andpy5.color_mode()
- New
Py5Shape
methodsvertices()
,bezier_vertices()
,quadratic_vertices()
, andcurve_vertices()
, analogous to the other methods of the same name.
Closed Issues
- Issue #301: Imported mode validation should not allow new function definitions for py5 reserved words
- Issue #302: Py5Shape class should have a Java Py5ShapeHelper class, analogous to Py5GraphicsHelper for Py5Graphics
- Issue #303: Py5Graphics.create_shape() method cannot create GROUP shapes
- Issue #304: Add color_mode() method to Py5Shape
- Issue #307: Py5Graphics methods points(), vertices(), etc have no type hints or docstrings
- Issue #295: py5_tools.register_processing_mode_key() should be optional for same-name keys in the namespace setup() and draw() are found
- Issue #314: Spaces in def setup() definition are tripping up the run_sketch utility
- Issue #317: Removing g from the list of py5 "reserved words" breaks things
- Issue #318: The %%py5draw magic is broken
- Issue #319: constrain() returns zero-dimensional array instead of float
- Issue #323: Improve NameError exception message when Imported mode users have a py5. somewhere in their code
Processing Mode and Hybrid Coding
This is a major release with big improvements to py5's functionality. This release was a lot of work!
What Changed?
You can read about all of the changes and the reasons behind them on the maintainers blog. The main highlights are:
- Processing Mode - gives Processing users a new
callPython()
method to make arbitrary calls to Python. Here, py5 functions as a bridge from Java to the Python world - Hybrid Programming - augment your py5 Sketches with Java code
- Attribute Errors now provide coding suggestions. For example:
py5 encountered an error in your code:
File "<ipython-input-6-b7441cc777da>", line 2, in setup
1 def setup():
--> 2 c = py5.colorr(255)
3 py5.background(c)
..................................................
py5.colorr = # AttributeError
py5 = <module 'py5' from '/Users/jim/INSTALL/anaconda3/envs/
py5/lib/python3.8/site-packages/py5/__init__.py'>
..................................................
AttributeError: py5 has no function or field named "colorr". Did you mean "color"?
- Small changes to
Py5Vector
to make it more consistent with Processing's PVector class - The
create_image_from_numpy()
method now supportsBGR
andBGRA
color channel ordering
API changes
- The
get()
method has been renamedget_pixels()
and a new methodset_pixels()
has been added - The
random_choice()
method has been renamedrandom_sample()
and a new implementation ofrandom_choice()
has been created
New Contributors
- @dmorenog01 made their first contribution in py5coding/py5generator#249
- @AsadNizami made their first contribution in py5coding/py5generator#251
Bug Fixes
- #195
- #198
- #199
- #200
- #201
- #203
- #207
- #209
- #224
- #229
- #231
- #233
- #234
- #243
- #246
- #247
- #254
- #276
Full Changelog: py5-1286-0018-0.8.3a1...py5-1292-0019-0.9.0a0
More bug fixes and small features
This is a minor release with a handful of bug fixes and small enhancements. Most of the bug fixes are small improvements to the documentation or error messages. Thanks again to Alexandre Villares for raising the majority of the now fixed bugs.
Enhancements
- New methods for saving and loading data. The new methods are
load_strings()
,save_strings()
,load_bytes()
,save_bytes()
,load_pickle()
, andsave_pickle()
- New
join_thread()
method
Pull Requests
There was one pull request from zztkm to fix the bug they reported. Thank you!
Bug fixes
Lots of bug fixes
Color features and lots of bug fixes
New features:
- Any valid matplotlib color string is now a valid color to use in py5 (if matplotlib is installed)
- New
hex_color()
method - New
select_folder()
,select_input()
, andselect_output()
methods - Upgraded
random_choice()
method - New
np_random
property - New
g
property - New
next_page()
method for the PDF renderer - Proper object equality
See the blog post for more information about this release.
Bug fixes:
py5 events and improved sketch portal
New Features:
- Py5KeyboardEvent and Py5MouseEvent classes
- User-defined event functions such as
mouse_moved()
andkey_pressed()
can take an parameter, and an instance of Py5KeyboardEvent and Py5MouseEvent will be passed when it is called - New py5jupyter library to contain all of py5's Jupyter functionality
- The Sketch Portal is now interactive
Use of py5 + Jupyter without py5jupyter installed is now deprecated. See the blog post for more information about this release.
Bug Fixes:
- #74
- #78
- #81