Stick Figures

Just for fun and to have a little special something for the blog I decided to do some animated GIFs of Stick Figures. So I created a little tool called “StickFigure” (Windows only sorry) designed for making animated Match stick men and other drawings like that.

The tool works like this:

  1. Plan your animation
  2. Draw the key frames
  3. Generate in between frames.
  4. Generate PNGs
  5. Generate JPGs
  6. Generate the GIF

For a more detailed description see the Readme

I used MonoGame to implement StickFigure because I am very experienced with XNA and MonoGame.

The PNGs are generated by Drawing on a RenderTarget2D and then saving it like this:

public static void Save(RenderTarget2D renderTarget, string fileName)
    var folder = Path.GetDirectoryName(fileName);
    if (!Directory.Exists(folder))

    using (var fs = new FileStream(fileName, FileMode.Create))
        renderTarget.SaveAsPng(fs, renderTarget.Width, renderTarget.Height);

The JPGS are generated by copying the PNGs using System.Drawing like this:

        public static void ConvertPngToJpg(string pngFile, string jpgFolder)
            using (var img = Image.FromFile(pngFile))

                var jpgFile = Path.Combine(jpgFolder,
                    Path.ChangeExtension(Path.GetFileNameWithoutExtension(pngFile), "jpg"));

                img.Save(jpgFile, ImageFormat.Jpeg);

The GIFs are created by combining the JPGs using code from here

The code is free for you to use on Github it is very hack & slashy so you should probably modify it if you want to use it for anything serious.

The resulting stickfigures you are not allowed to use (and why would you use such ugly creations :) ) You can see some on the left side-bar of this blog a new one every time you press F5.

Some of them are created by my 5 year old with no previous mouse training… Yes it’s that easy !

Funny thing is that my own figures also looks like they are made by a 5 year old :)


Comments closed.