create_image()#

Creates a new Py5Image (the datatype for storing images).

Examples#

example picture for create_image()
1def setup():
2    img = py5.create_image(66, 66, py5.RGB)
3    img.load_pixels()
4    for i in range(0, len(img.pixels)):
5        img.pixels[i] = "#005A66"
6
7    img.update_pixels()
8    py5.image(img, 17, 17)
example picture for create_image()
1def setup():
2    img = py5.create_image(66, 66, py5.ARGB)
3    img.load_pixels()
4    for i in range(0, len(img.pixels)):
5        img.pixels[i] = py5.color(0, 90, 102, i%img.width*2)
6
7    img.update_pixels()
8    py5.image(img, 17, 17)
9    py5.image(img, 34, 34)

Description#

Creates a new Py5Image (the datatype for storing images). This provides a fresh buffer of pixels to play with. Set the size of the buffer with the w and h parameters. The format parameter defines how the pixels are stored. See the Py5Image reference for more information.

Be sure to include all three parameters, specifying only the width and height (but no format) will produce a strange error.

Advanced users please note that create_image() should be used instead of the syntax Py5Image().

Underlying Processing method: createImage

Syntax#

create_image(w: int, h: int, format: int, /) -> Py5Image

Parameters#

  • format: int - Either RGB, ARGB, ALPHA (grayscale alpha channel)

  • h: int - height in pixels

  • w: int - width in pixels

Updated on November 12, 2021 11:30:58am UTC