0.5.0¶
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:
API Additions¶
- The
p5.PShape
class 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. - The
p5.PImage
class 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 imageimg
with dimensions 800 × 600,img[400:, :300]
gives a new image with the required region. Individual pixels can be set / read asp5.Color
objects though indices into the image. The class also includes functionality to apply filters and blend two images together. - The
p5.load_image()
andp5.image()
function allow, respectively, loading and displaying images on the screen. - The
p5.image_mode()
function controls how parameters top5.image()
are interpreted. p5.tint()
and the relatedp5.no_tint()
function allow for setting and disabling tinting of images that are drawn on the screen.- The
p5.load_pixels()
context manager loads the current display as a globalpixels
PImage object. This combines functionality of Processing’s loadPixels() and updatePixels(). p5.save()
andp5.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. Thep5.load_font()
andp5.create_font()
allow loading font files to change the display typeface usingtext_font()
. As of now, only TrueType (ttf) and bitmap fonts are supported.