p5 version 0.5.0 is the final release for the Google Summer of Code 2018 project by Abhik Pal. The project was supervised by Manindra Mohrarna of the Processing Foundation. The goal of the project were:
- Move the internal windowing and OpenGL framework to vispy
- Add support for user defined polygons
- Add image support
We met all of these goals completely. The first was covered by a release from earlier in the summer. These release notes summarize our later two goals. In addition to the stated goals we were also able to add minimal typography support and port some tutorials from Processing to p5:
p5.PShapeclass is equivalent to PShape in Processing. This allows creation of arbitrary user defined polygons that can have their own style (fill, stroke, etc) and transform (rotation, translation) attributes.
p5.PImageclass allows for manipulating images in p5. Most of the API is similar to that of Processing’s. Each image object “pretends” to be a 2D array and hence operations for cropping, copying, and pasting data can have implemented as indexing operations on the image. For instance, given some image
imgwith dimensions 800 × 600,
img[400:, :300]gives a new image with the required region. Individual pixels can be set / read as
p5.Colorobjects though indices into the image. The class also includes functionality to apply filters and blend two images together.
p5.image()function allow, respectively, loading and displaying images on the screen.
p5.image_mode()function controls how parameters to
p5.tint()and the related
p5.no_tint()function allow for setting and disabling tinting of images that are drawn on the screen.
p5.load_pixels()context manager loads the current display as a global
pixelsPImage object. This combines functionality of Processing’s loadPixels() and updatePixels().
p5.save_frame()methods allow users to either save the current state of the sketch or the final rendered frame as an image.
- This release also introduces some basic typography functions like
p5.text()for displaying text on screen. The
p5.create_font()allow loading font files to change the display typeface using
text_font(). As of now, only TrueType (ttf) and bitmap fonts are supported.