{"id":13530127,"url":"https://github.com/extrapixel/gif-animation","last_synced_at":"2025-04-01T17:32:01.248Z","repository":{"id":14100682,"uuid":"16805071","full_name":"extrapixel/gif-animation","owner":"extrapixel","description":"GifAnimation is a Processing library to play and export GIF animations","archived":false,"fork":false,"pushed_at":"2021-10-06T00:23:49.000Z","size":372,"stargazers_count":171,"open_issues_count":10,"forks_count":38,"subscribers_count":14,"default_branch":"3.0","last_synced_at":"2024-11-02T16:35:54.483Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/extrapixel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-02-13T14:21:25.000Z","updated_at":"2023-12-27T15:59:18.000Z","dependencies_parsed_at":"2022-09-21T05:30:45.004Z","dependency_job_id":null,"html_url":"https://github.com/extrapixel/gif-animation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extrapixel%2Fgif-animation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extrapixel%2Fgif-animation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extrapixel%2Fgif-animation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extrapixel%2Fgif-animation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/extrapixel","download_url":"https://codeload.github.com/extrapixel/gif-animation/tar.gz/refs/heads/3.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246680370,"owners_count":20816688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T07:00:44.173Z","updated_at":"2025-04-01T17:32:00.824Z","avatar_url":"https://github.com/extrapixel.png","language":"Java","funding_links":[],"categories":["Libraries"],"sub_categories":["Java"],"readme":"# gifAnimation processing library\n\nGifAnimation is a [Processing][1] library to play and export GIF animations. \nOriginal code by [Patrick Meister][5] .\nThe GIFEncoder \u0026amp; GIFDecoder classes were written by Kevin Weiner.\nPlease see the separate copyright notice in the headers of the GifDecoder \u0026amp; GifEncoder classes.\nProcessing 3.x port by [Jerome Saint-Clair][3]\n\n\n## DOWNLOAD\n\n[gifAnimation.zip][4] (compatible with Processing 3.x)\n\n##  INSTALLATION:\n### Processing 3.x\nDownload and unzip the gifAnimation.zip and copy the gifAnimation-folder into your processing libraries folder.\n\n\n## USAGE:\n\nBesides this reference, there are basic examples included in the download. To use gifAnimation library, you need to import it into your sketch by using the menu or typing\n\n\n```java\nimport gifAnimation.*;\n```\n\n### DISPLAYING A GIF ANIMATION:\n\nThe class to access/display GIF animations is called `Gif`. It has two possibilities to access the frame pixel data:\n\nExtract all frames of an animated Gif into a PImage[] array using the static method \"getPImages()\". you need to pass a reference to the PApplet and a filename to it. The file should be in the sketch data folder. This method is useful if you just want to mess with the frames yourself and don't need the playback possibilities. The method is static, so you have no separate thread going.\n\n```java\nPImage[] allFrames = Gif.getPImages(this, \"lavalamp.gif\");\n```\nThe second way to access the animation is to play it like a video. This will play the animation with the frame delays specified in the GIF file. Gif extends PImage, so any instance of Gif fits wherever PImage can be used.\n\n#### Create a new Gif object\n\n\n```java\nGif myAnimation = new Gif(PApplet parent, String filename);\n```\n\nIn a sketch this would look like this:\n\n```java\nGif myAnimation;\n\nvoid setup() {\n    size(400,400);\n    myAnimation = new Gif(this, \"lavalamp.gif\");\n    myAnimation.play();\n}\n\nvoid draw() {\n    image(myAnimation, 10, 10);\n}\n```\n\n### EXPORTING A GIF ANIMATION\n\nThe class to export GIF animations is called `GifMaker`. To start recording\ninto a GIF file, create a GifMaker object in one of the following ways:\n\n```java\nGifMaker gifExport = new GifMaker(PApplet parent, String filename);\n```\n```java\nGifMaker gifExport = new GifMaker(PApplet parent, String filename, int quality);\n```\n```java\nGifMaker gifExport = new GifMaker(PApplet parent, String filename, int quality, int transparentColor);\n```\n\nIn a sketch this would look like this:\n\n```java\nvoid setup() {\nsize(200,200);\n    frameRate(12);\n\n    gifExport = new GifMaker(this, \"export.gif\");\n    gifExport.setRepeat(0);\t\t\t\t// make it an \"endless\" animation\n    gifExport.setTransparent(0,0,0);\t// black is transparent\n\n}\n\nvoid draw() {\n    background(0);\n    fill(255);\n    ellipse(mouseX, mouseY, 10, 10);\n\n    gifExport.setDelay(1);\n    gifExport.addFrame();\n}\n\nvoid mousePressed() {\n    gifExport.finish();\t\t\t\t\t// write file\n}\n```\n\n\n## DOCUMENTATION\n### The 'Gif' Class\n\n#### void play()\nplays the animation without loop\n\n#### void pause()\npauses the animation\n\n#### void stop()\nstops and rewinds the animation\n\n#### void loop()\nstarts the animation. it will play in a loop and ignore the\nGIF repeat setting.\n\n#### void noLoop()\ndisables looping\n\n#### void ignoreRepeat()\nGIF-files can have a repeat-count setting. It states the amount of loops this animation should perform. if you call `ignoreRepeat()` on a Gif object, it will ingore this setting when playing. If you start animations using `loop()`, repeat settings will always be ignored.\n\n#### void jump(int where)\njumps to a specific frame in the animation if that frame exists\n\n#### boolean isPlaying()\nwhether the Animation is currently playing\n\n#### boolean isLooping()\nwhether the Animation has its loop-flag set\n\n#### boolean isIgnoringRepeat()\nwhether this Gif has its ignoreRepeat-flag set or not.\nSee also `ignoreRepeat()`\n\n#### int currentFrame()\nreturns the number of the frame that is currently displayed\n\n#### PImage[] getPImages()\nreturns an array of PImages containing the animation frames. note that this method is called in an instance of Gif, while `Gif.getPImages(PApplet, String)` is a static method\n\n#### int getRepeat()\nreturns the number of repeats that is specified in the GIF-file\n\n### The GifMaker Class\n\n#### void setTransparent(int color)\n#### void setTransparent(int red, int green, int blue)\n#### void setTransparent(float red, float green, float blue)\nSets the transparent color of the GIF file. Unlike other image formats\nthat support alpha (e.g. PNG), GIF does not support semi-transparent pixels.\nThe way to achieve transparency is to set a color that will be transparent\nwhen rendering the GIF. So, if you set the transparent color to black, the\nblack pixels in your gif file will be transparent.\n\n#### void setQuality(int qualtiy)\nSets the quality of the color quantization process. GIF only supports 256 indexed colors per frame. So, the colors that come in your images need to be reduced to a set of 256 colors. The quality of this process can be set using this method (or by instantiating the GifMaker object with the respective constructor). Default is 10 and seems to produce good results. Higher qualities will cause the quantization process to be more expensive in terms of cpu-usage.\n\n#### void setSize(int width, int height)\nSets the size of the new GIF file. If this method is not invoked, the image dimensions of the first added frame will be the size of the GIF.\n\n#### void setRepeat(int count)\nSets the repeat setting in the GIF file. GIF renderers like web browsers should respect this setting and loop the animation that many times before stopping. Default is 1. 0 means endless loop.\n\n#### void addFrame()\nAdds the current sketch window content as a new gif frame.\n#### void addFrame(PImage image)\nPass a PImage to add it as a new gif frame\n#### void addFrame(int[] pixelArray, int width, int height)\nPass a int pixel array and the width and height to add it as a new gif frame.\n\n#### void setDelay(int ms)\nSets the delay (the \"framerate\") for the most recently added frame. This is measured in Milliseconds. This can be different for every frame. Note, this effects the playback speed of the resulting GIF-file only. So, the speed / framerate with which you wrote the frames has no effect on play-\nback speed.\n\n#### void setDispose(int mode)\nSets the disposal mode for the current frame. Disposal modes are a special concept used in the GIF file format. It basically determines whether a frame will be overriden by the next frame, or if the next frame should be added, layed over the last frame.\nFor convenience there are constants for the different disposal modes:\n\n| Dispose mode |  |\n|--------|--------|\n| GifMaker.DISPOSE_NOTHING | Nothing special |\n| GifMaker.DISPOSE_KEEP | retain the current image |\n| GifMaker.DISPOSE\\_RESTORE\\_BACKGROUND|restore the background color|\n| GifMaker.DISPOSE_REMOVE |restore the background color|\n\n#### boolean finish()\nFinishes GIF recording and saves the GIF file to the given file name in\nthe sketch folder. Returns true if saving the file was successful, false if not.\n\n   [1]: http://www.processing.org\n   [2]: http://www.fmsware.com/stuff/gif.html\n   [3]: http://www.saint-clair.net\n   [4]: https://github.com/extrapixel/gif-animation/raw/master/distribution/gifAnimation.zip\n   [5]: https://github.com/extrapixel\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextrapixel%2Fgif-animation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fextrapixel%2Fgif-animation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextrapixel%2Fgif-animation/lists"}