Image

A brief reference to the Image class.

circle-info

Image is a Renderable with some methods modified, add, or removed.

Renderable Quick Reference Image Documentationarrow-up-right

circle-exclamation

Initialization

You can create an image with a similar constructor:

(Supported image types: PNG, GIF, JPG, and PPM)

image = Image(screen, image_file, x, y, width, height)
circle-info

Again, if you are not using the PIP version of pyDraw, you may need to install 'Pillowarrow-up-right' before passing the width and height into the constructor.

Color

It is still possible to call the color() method and colorize the image:

image.color(color)  # Tints the image by the passed Color

Flip

You can flip the image across the X or Y axes (the plural of axis 😜arrow-up-right):

image.flip(axis)  # accepts 'x' or 'y'

Animation (GIF)

It is possible to access the individual frames of an animated GIF file by first calling this after initialization:

Then you can access individual frames via:

Or you can just push the frame forward by one with:

circle-info

next() will automatically loop back to index 0 when it reaches the last frame.

The total number of frames is available too:

Last updated