![]() | ![]() | ![]() |
Creating | animated GIFs |
|
There
are many ways of creating animations for your Web pages
but using the GIF 89a format is one of the simplest and
most effective. Here's how.
What is a GIF animationCreating an animated GIF file allows you to emulate a Java or Shockwave application such as a scrolling banner, without having to write a line of code. However, GIFs don’t allow you to incorporate sound or interactivity which you can create with Java and Shockwave. However, if all you want is a quick and easy animation then GIFs are great. The GIF file format allows you to store multiple images in the one file, together with information telling the viewing program how long to wait before displaying the next image. It is this timed sequential display of images that gives us an ‘animated’ effect. In addition GIFs can include a ‘loop’ allowing the animation to play over and over again. While, in the past, we’ve suggested you make sure your graphics are as small as possible, GIF animations can be bigger because they display as they load. However if you have too many files in your animation you’ll find that it probably won’t run smoothly the first time because of the time taken to download each image. If the file contains a loop, though, it’ll run faster the second time as the file will be loaded from your browser’s cache and not downloaded again.
Tools for the jobTo create an animated GIF you’ll need a series of bitmap graphics. When you are starting, use the same palette for all of them and make them the same size. Save each of the files as a separate bitmap file, eg a .bmp, .gif, .jpg, .pic, .pcx, .wpg etc. You’ll find it easier to remember which order they belong in if you save them with sequential filenames eg pic01.bmp, pic02.bmp etc. You can use your own bitmap files or these eight example files for you to download: pcuser1.bmp, pcuser2.bmp, pcuser3.bmp, pcuser4.bmp, pcuser5.bmp, pcuser6.bmp, pcuser7.bmp, pcuser8.bmp. Now, to create an animated GIF file, you’ll need some additional software and one of the best programs is the shareware GIF Construction Set. It's available on our January 1997 PC User Offline CD-ROM, and from Alchemy Mindworks' Web site at http://www.mindworkshop.com/alchemy/alchemy.html.
Using GIF Construction SetGIF Construction Set has a Wizard which helps automate the process of creating an animated file. However, we’ll step through creating a file from scratch just so you can see how it is done because at some stage you’ll need to know the basics. Our instructions create an animated PCUser flag from the files pcuser1.bmp - pcuser8.bmp. Open the GIF Construction Set and select File, New and you’ll see the Header block appear on your screen. Each line in the file is called a block and there will always be one header block in a file.
With this Control block still selected, select the Edit menu and click on Copy. Now click on the first Image block and select Edit, Paste. Repeat this so that every Image block is preceded by a Control block. Notice that each Control block is pasted immediately after the selected block.
The technical stuffA GIF file is made up of a number of blocks. It will always have a Header block and one Image block and it can contain other Image blocks, Control blocks and other types of blocks not covered here. When you open a GIF file in the GIF Construction Set you see it, not as a single image, but rather as a collection of blocks defining it. A Control block affects the image immediately following it, so only include one Control block for each Image block in the file. The Control block allows you to set the Transparency information for each graphic and specify the delay after the image has been loaded. User input is not supported by Netscape and don’t use Remove by: Previous image as it isn’t compatible with Netscape. In Netscape 2 the number of iterations in the Loop block is ignored and the animation will loop forever if the Loop block is present. Netscape 3 will not ignore the number of iterations, and setting them to 0 will provide infinite looping; 1 plays the animation twice (ie first time and one repeat); 2 plays it 3 times etc. To play it once only, omit the Loop block altogether. You’ll find that the Loop block will always appear as the second block in the file.
Adding graphicsWe’ve pointed out throughout this series that, although adding graphics to your web page can make it visually more appealing, it will also slow it down. Keep in mind the tradeoff between speed and looks with any graphic, although because they display as they download, you can allow yourself a little more leeway if you use animated GIFs. The tag for including your animated GIF in a file is <IMG SRC = "pcuser.gif">, the same as for any graphic. You can place the graphic in a table or use the ALIGN attribute to control text flow around it as we showed in last month’s column.
Loading a small one firstIn our tutorial on using graphics in your Web pages, we showed you how you could use the tag <IMG SRC="parrot.gif" LOWSRC="parrot_s.gif" ALT="A crimson parrot " WIDTH=200 HEIGHT=152> to load a low resolution graphic first, which is replaced by the higher resolution graphic as it is downloaded. We pointed out that this is a Netscape extension and not incorporated into HTML 3.2, so not all browsers will support it, however some web designers get a similar effect by using an animated GIF. In this case the GIF file would contain both the low resolution graphic and the higher resolution one and load the lower resolution one first, replacing it with the higher resolution one as it was downloaded. The following two files show two ways of doing this. In parrot1.gif the lower resolution graphic is centred in the area that the higher resolution (and larger) graphic will eventually take up. This has been done by editing the Image block and positioning the smaller graphic in from the left and down from the top of the position the larger graphic will eventually occupy. In parrot2.gif the lower resolution graphic is the same size as the higher resolution one so there is no need to ‘center’ it in the area that the larger resolution graphic will occupy as they’ll occupy the same space.
EffectsThe possible animation effects you can get are limited only by your imagination, try creating logos which explode onto the screen or which dissolve in and out. Or perhaps create a more classical moving animation or a tickertape information display. Remember, though, that as with any effect, less is more, so choose one or two animations for your page and resist the temptation to overdo it.
ReferencesTo check out the animations discussed in this article, and a couple of additional ones, click here. If you see an animation you like, save it to your local hard disc, open it in the GIF Construction Set and ‘edit’ the blocks to see how the effects have been achieved. You should also try Royal Frazier’s great tutorial at http://www.reiworld.com/royalef/gifabout.htm.
Top 10 (more advanced) tips
|
|||||||
![]() ![]() |
Full text ©1996 Australian Consolidated Press |