New py5 Release: 0.9.0a0
It has been over 5 months since the last py5 release, which is a long time compared to previous releases. The main reason for this is the time and effort that went into completing two new features that I am very excited about: Hybrid Programming and Processing Mode. More on that in a moment.
This is a major release with important new features and many bug fixes. Thanks as always to Alexandre Villares (@email@example.com) for finding many of the now fixed bugs and for helpful design discussions. Thanks to @AsadNizami for two pull requests, thanks to @dmorenog01 for a pull request, and thanks to @marziabil for inspiring the enhancement behind issue #247.
Hybrid Programming & Processing Mode
Hybrid Programming refers to the ability to add your own Java (Processing) code to py5. Think of it as a way to add custom Processing extensions to py5. Hybrid Programming is useful for boosting py5's performance and making Java libraries more accessible to py5.
Processing Mode is a completely new way to use py5. This feature is built for the Java Processing users. It allows py5 to function as a bridge, connecting the Java code users write for Processing sketches to the Python ecosystem. Processing Mode gives Processing users a new method
callPython(), which gives everyone an easy way to call Python code from Processing.
Both Hybrid Programming and Processing Mode are documented extensively on the py5 documentation website. There's also a GitHub repo with example code. As these are new features, the documentation and example code will grow as questions come up and issues are raised. Stay tuned!
I'm thrilled to finally be able to share these new features with the py5 community. I hope you find them useful and easy to use. I'm looking forward to seeing what people do with them.
On the subject of documentation, there is now a page explaining how py5 actually works. I've wanted to write this documentation for a long time. This information will be useful for advanced coders who want to better understand how py5 works and for developers who want to contribute to py5. More documentation does need to be written about py5's internals, but this is a good start. The documentation will evolve as readers ask questions and I make improvements to the text.
get() method has been renamed
get_pixels() and a new method
set_pixels() has been added. The discussion for this is in issue #198.
set_pixels() method is analogous to Processing's set() method. Naming py5's method
set() would conflict with the builtin Python
set data type so we chose
set_pixels() instead. The
get() method was changed to
get_pixels() to make it consistent with
The documentation for both get_pixels() and set_pixels() reflects these changes.
random_choice() method has been renamed
random_sample() and a new implementation of
random_choice() has been created. The discussion for this is in issue #199 and issue #200. The changes for this might be confusing, and we apologize for that. We felt we needed to address some poor design decisions that were made earlier in py5's evolution.
Moving forward, the
random_choice() method will always return one and only one random item from a list or array.
random_sample() will return a list of random items from a list. If the input type is a Python list or a numpy array, the output type will also be a Python list or a numpy array, respectively.
The documentation for both random_choice() and random_sample() reflects these changes.
There were two pull requests from @AsadNizami. The first pull request was to add
__repr__() implementations to py5 objects (issue #209) and the second pull request was some small improvements to
Py5Vector (issue #243). Thank you, @AsadNizami, for your contributions!
There was one pull request from @dmorenog01. This pull request was to update some small errors in the reference documentation (issue #246).
py5 will now provide suggestions for mistyped commands (issue #224 and issue #276). 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 with
normalize()to make it more consistent with Processing's PVector (issue #243). The
set_mag()method will now support negative values. The
normalize()method will warn if the vector is a zero vector. Previously it would throw an exception.
create_image_from_numpy()method now supports
BGRAcolor channels (issue #247).
This might be a record number of closed issues for a py5 release. Thanks to everyone who contributed to this release by reporting bugs and suggesting improvements!
New matplotlib related features
importcommand for py5 "imported mode" code