Releases: py5coding/py5generator
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
gto access the primary Py5Graphics object is now deprecated. Users will receive a warning message instructing them to useget_graphics()intead. Allowing the single charactergto be a reserved variable name is problematic for users coding in Imported Mode. Consider that thegvariable is often used in a rgb variable triplet. Thegvariable 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
Py5Shapemethodsvertices(),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
Py5Vectorto make it more consistent with Processing's PVector class - The
create_image_from_numpy()method now supportsBGRandBGRAcolor 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 #249
- @AsadNizami made their first contribution in #251
Bug Fixes
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_randomproperty - New
gproperty - 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:
py5 with generic python interpreter
py5 => Java 17
New Features:
- py5 now requires Java 17 to be installed on your computer. If
JAVA_HOMEis set, it must point to your Java 17 installation. - Update Processing jars to version 4.0b6. This means py5 now supports the new features in that release, including the new commands for controlling the Sketch window such as
window_move()andwindow_title(). - Improvements to py5 to enable packaging with pyinstaller. In the near future I will add documentation to the py5 website explaining how to do this. If you can't wait that long, have a look at this gist for a working example. That example has room for improvement, and will be improved before the documentation is finalized.
- The typehints have been updated to conform to PEP 585. Also, the numpy typing package
nptypinghas been removed in favor of using the numpy typehint features introduced in versions 1.20 and 1.21. This version of py5 now requiresnumpy>=1.21, but that shouldn't be a problem for anyone because that version has been out for almost a year now and most likely you have version 1.22 installed already. - The
run_sketchcommand line tool now accepts command line arguments that will get passed to Processing. Among other things, this will allow the Thonny plugin to set the window position. (see #60)
Bug fixes:
Reworked noise functionality and new Py5Vector class
New Features:
- Reworked noise functionality. The Python noise library is no longer used to generate noise; the library has been removed as dependency. Instead, py5 uses the OpenSimplex noise algorithm and Processing's noise algorithm. The OpenSimplex algorithm is provided by KdotJPG's OpenSimplex2S implementation.
- New Py5Vector class
Fixes:
New Context Manager feature + Important Bug Fixes
New Features:
- Context Managers: methods like
begin_shape()orpush_matrix()can be used as context managers - py5bot now supports the SVG and PDF renderers
- Update to the latest Processing 4.0 beta 2 jars
- The
save()andsave_frame()methods can now save to aio.BytesIOobject - Version number conforms to proper semantic versioning standards
Fixes: