How to create pixel gif animations 🐔
Tags: opensource, tutorial, beginners, showdev
Published: 2022-12-08 08:27:10

##Hello everyone!

Today, I wanted to share what I have learned working on the [issue of creating a new pet animations](https://github.com/tonybaloney/vscode-pets/issues/242) for the VSCode extension [VS Code Pets](https://github.com/tonybaloney/vscode-pets).


## Little backstory 🗃

VS Code Pets is one of my favourite extensions which creates a little window next to the code editor where you can play with different pets while working on your projects. I browsed through the [open issues](https://github.com/tonybaloney/vscode-pets/issues) inside the repo as I wanted to contribute to the tool and found one which touched me. One guy used the extension a lot but missed his favourite pet - chicken (he even had chicken toy on his GitHub profile photo and chicken emoji in the status message). So, I could not resist but help to add chicken as a new pet.

{% embed https://github.com/tonybaloney/vscode-pets/issues/242 %}


## Task 🎯

He did not know how to create required animations and looked for help. He tried copying one from the internet but you cannot do that due to copyright. You either have to create gifs yourself or look for art with applicable permissions. 


## Skills 🪄

To be honest, I had **absolutely no experience** when I decided to work on that issue, so if I could do it, then you definitely can too! All of the software is free and accessible through basic internet browser, so all you need is your enthusiasm. 


## Process 🛠

As I had no knowledge, my first obvious step was to go the modern library which is YouTube. I found this guy, [@Saultoons](https://www.youtube.com/@saultoons/featured), who had [the series of videos dedicated to basics of pixel animation art](https://www.youtube.com/watch?v=tFsETEP01k8&list=PLp99DFIAFv-xM8l6Uzmg83yvGRu6jMfid). I watched a few videos and got a general idea of where to start, how the frames work and what techniques can be used for different motions.

Then I had to find a tool, where I am going to draw the animations. [Aseprite](https://www.aseprite.org) which was featured in the video costed around $20, so I looked for free alternatives and found [Pixilart](https://www.pixilart.com/draw). 

Pixilart had very intuitive interface and I could start drawing right away. I googled some pixel chicken pictures to use as a reference and started outlining my base frame. Once I got the basic design which I liked, I added colour and shades to the picture. 

This is what I got:
![pixel chicken picture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z8gqs1nqvqqepc33lnni.jpg)

Later, I had to figure out what motions I need to produce. As I was drawing a chicken, I came up with 5 states:

1. idle / standing
2. grain picking 
3. walking
4. fast walking / flying 
5. with a ball (required by the project)

For all of them, I researched and observed the real chicken natural behaviour performing that motion to replicate it in the animation (which meant that I have watched dozens of chicken farm videos on YouTube lol). 
> Fun fact: chickens move their necks back and forth while walking. 

I would break down the motion into multiple frames and try to measure what would be the best time for each of them. Sometimes, you need one part to be quicker than another or on the other hand, some motions are pretty constant. 


## Tips ✨

Some of the things I learned the hard way, so I guess I will share them, so you do not have to repeat my mistakes:

- Always **download your work** not only as gif but also **as pixil**. Gif only holds the result and does not perfectly transform back into pixels. So, it will be hard to make changes. However, pixil holds all your project info and will import back perfectly. 

- If you want to have a transparent background, you will need to color it in some unique to your drawing color that you did not use and go to another tool to make it transparent. You have to use this workaround as Pixilart will not export your gif properly even if it has a transparent background, somehow it will always be white. [Onlinegiftools](https://onlinegiftools.com/create-transparent-gif) worked well for me. 


## Some additional work 🧹

Because I was working for the existing project, they had their own requirements regarding the size. So, I had to change that as well. For resizing and cropping, I used [ezgif.com](https://ezgif.com/resize/ezgif-2-a7c729d5b6.gif).


## Final result 🌟

So, at the end, I got [my pull request](https://github.com/tonybaloney/vscode-pets/pull/338) merged and now, chicken can stand, pick grain from the ground, walk, run and hold the ball. 🎉

![chicken pixel gif](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jiymd757ykwrph6x6hy7.gif)

![chicken pixel gif](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z1b2pqk3ozx31sp8bixt.gif)

![chicken pixel gif](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ofuzggdcwmyv3q5ym412.gif)

![chicken pixel gif](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6t52ps0nj16iidlhf1gh.gif)

![chicken pixel gif](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y6wz1y3h7skkmvduxznz.gif)