Skip to main content

A sprite based PyGame class to use animated GIFs

Project description

GIFImage_ext

GitHub Pages available

Extension of the GIFImage library on pygame.org written by Matthew Roe.

I found it here: http://pygame.org/project-GIFImage-1039-.html

Small bits of code - a couple of instance variables and methods have been added. I've changed very little of Matthews code - most of the changes are additions, but where I have made a change, I've commented out the original line so that it's easy to see what was there vs. what is there now.

methods added:

next_frame()

  • pauses the animation if it is currently playing
  • advances to next frame if the animation is paused
  • goes to first frame if the current frame = frames[-1]

previous_frame()

  • inverse of next_frame()

slow_down()

  • slows the playback speed by increasing the 'duration' variable

speed_up()

  • increases the playback speed by decreasing the 'duration' variable

scale(scale_factor)

  • scale_factor is added to the image_scale variable - pass positive numbers to increase the image size, negative numbers to decrease size gif_image.scale(.05) #increases image size by 5% gif_image.scale(-.05) #decreases image size by 5% -in the .render method, pygame.transform.scale is called on the current frame if img_scale != 1 and the width and height of the original image are multiplied by the image_scale value (It would be more efficient from a processing standpoint to copy all frames out to a new frame list as they are scaled, then use the cached frames in the new list for subsequent playback loops. That would be overkill for my needs though.) -the transformed image is assigned to a new surface which is blitted to the screen so that the original image quality is retained

reset_scale()

  • resets the img_scale value to 1

Persistant Problems:

  • there is still a pallet handling issue as described on the pygame.org website. Time permitting, I'll look into this, but I'm no expert on the GIF image format and this was really a one-off kind of thing for a quick and dirty prototype for a larger project.

Contributing

Bug reports and feature requests can be entered in the Issues menu.

To ask questions about the project, you can create a new issue in the Issues menu with the label ~question.

To contribute any changes simply clone the project on GitHub: https://github.com/Jokymon/GIFImage_ext, push your changes to your own GitHub project and send a pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygame-animatedgif-0.1.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

pygame_animatedgif-0.1.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file pygame-animatedgif-0.1.0.tar.gz.

File metadata

  • Download URL: pygame-animatedgif-0.1.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for pygame-animatedgif-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c7f54bb0c47b018244747a611593a1f1ea04785b03626f7a674f1551be977288
MD5 95a7e7957151137e39fbb9b9d1f87028
BLAKE2b-256 d136fbf1283ea23426d73bd111c7c0ebd9687912ae38e3335574bce764733a23

See more details on using hashes here.

File details

Details for the file pygame_animatedgif-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pygame_animatedgif-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for pygame_animatedgif-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd4a7e9497ad2bc06bd353f313aadc204ef21e521739eecbb871d10dc90d8aeb
MD5 f7388a98533c49031512d485e2e3408d
BLAKE2b-256 f06d85ef7ae5a30523428943a681675e8396f17d121b416057335120c0177d0f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page