Animated GIF Demo (VEXcode)

vexcode
#1

Hers’s another demo that can be built with VEXcode. It’s not very well developed and uses a couple of C API’s that we don’t usually expose that were added to vexos 1.0.5. I’ll also explain a couple of more advanced aspects of the setup in another post later, specifically how to allow VEXcode access to more dynamic memory than is available with the default project build scripts.

output looks like this.
gifdemo

and uses this animated gif.
world

You can display more than one gif by creating additional instances of the gif class, however, if they overlap you will still see flicker with this initial version.

The code uses an open source gif reading library. The gif is included with the project and should be copied to an SD card which is then inserted into the brain.

displaying on the V5 screen is very simple, all it takes is this.

vex::brain       Brain;

int main() {
  int count = 0;

  vex::Gif gif("world.gif", 120, 0 );
  
  while(1) {
    Brain.Screen.printAt( 5, 230, "render %d", count++ );
    Brain.Screen.render();
  }
}

pass the name of the file and the x, y coordinates of the top left corner.

It’s not guaranteed to work with all gifs but most I have tested so far will work, keep them under the brain screen size of 480 x 240 pixels.

gifdemo.zip (485.2 KB)

5 Likes

Stopwatch demo (VEXcode)