py5's Python Ecosystem Integration
Pre-releaseThis 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.