Image
A brief reference to the Image class.
Image is a Renderable with some methods modified, add, or removed.
Renderable Quick Reference Image Documentation
If you have pyDraw installed as the library file in your project directory, you must ensure 'Pillow' is installed, or you won't be able to resize the image, modify any image attributes, or use image types other than PNG, GIF, and PPM.

Initialization

You can create an image with a similar constructor:
1
image = Image(screen, image_file, x, y, width, height)
Copied!
Again, if you are not using the PIP version of pyDraw, you may need to install 'Pillow' before passing the width and height into the constructor.

Color

It is still possible to call the color() method and colorize the image:
1
image.color(color) # Tints the image by the passed Color
Copied!

Animation (GIF)

It is possible to access the individual frames of an animated GIF file by first calling this after initialization:
1
image.load()
Copied!
Then you can access individual frames via:
1
image.frame() # Get the current frame
2
image.frame(frame) # Set the current frame
Copied!
Or you can just push the frame forward by one with:
1
image.next() # Goes to next frame.
Copied!
next() will automatically loop back to index 0 when it reaches the last frame.
The total number of frames is available too:
1
image.frames() # Returns integer number of frames
Copied!
Last modified 7mo ago