pydraw
  • Home
  • Documentation
  • Guides
    • Installation and Setup
    • Getting Started
    • Quickstart Examples
  • Quick Reference
    • Screen
    • Color
    • Location
    • Renderable
    • Text
    • Line
    • Image
    • Input
    • Scene
Powered by GitBook
On this page
  • Initialization
  • Color
  • Flip
  • Animation (GIF)

Was this helpful?

  1. Quick Reference

Image

A brief reference to the Image class.

PreviousLineNextInput

Last updated 2 years ago

Was this helpful?

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

If you have pyDraw installed as the library file in your project directory, you must ensure '' 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:

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

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

Again, if you are not using the PIP version of pyDraw, you may need to install '' 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 ():

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:

image.load()

Then you can access individual frames via:

image.frame()  # Get the current frame
image.frame(frame)  # Set the current frame

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

image.next()  # Goes to next frame.

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

The total number of frames is available too:

image.frames()  # Returns integer number of frames

Renderable Quick Reference
Image Documentation
Pillow
Pillow
the plural of axis 😜