|
Writing HTML | About | FAQ | References | Tags | Lessons | previous | next |29a. Animate my GIF!
ObjectivesAfter this lesson you will be able to:
LessonWe doubt we have to describe what animated GIF image looks like, as you can find them all over the web. These range from animated icons, to commercial advertisements ("ad banners"), to web site "credits", first pages of web sites that look like the opening screens to a movie. GIF animations are useful because you can count on them being able to be viewed on almost every web browser and they do not require any special add-ons to work.
An animated GIF image is just an extension of the same file format used for inline GIF images we saw in lesson 7. But rather than just showing one image, an animated GIF has layers of different images, and information in the file can control how long it waits before displaying the next image, and how many times to loop through the entire sequence. Several current graphics programs should have options to create animated GIF files. Plus, you can find free or low cost shareware programs (e.g. http://shareware.com/) that can turn a series of images into a GIF animation. And since the web is fully of dancing, blinking, and moving GIFs, there are plenty of free clip-art sites where you can download animations to use for your own pages. We provide a list of links to these sites at the end of this lesson. Another advantage of this media type is that the entire graphics file does not have to be downloaded before it starts to play; an animated GIF will commence as soon as enough information is downloaded to display the first "frame" of the animation. Therefore, it appears to "stream" the animation and you can create animation files that are several hundred k in size that may start playing when perhaps 20% of the file has been received be the viewer. What are some down sides of animated GIFs? The primary one is that because the movement attracts your eye, they can be distracting to someone trying to comprehend the other information on the same page. The other disadvantage so that they generally tend to be used as a novelty, and after the first few times you see the same animated teddy bear. it can start to look cliché or juvenile. Animations can be very useful to show time-ordered information, i.e. to show changes in a feature over time (e.g. erosion of a beach, growth of a plant, changes in stock market prices) or to demonstrate a process (e.g. how to change a tire, how blood moves through the heart). Like GIF images, the files are much smaller for graphics that have large continuous regions of solid color and sharp edges, as compared to images with more spatial variation such as photographs. HTML for Inserting an Animated GIFThis should be an easy lesson since the HTML code for inserting an animated GIF is exactly the same as we learned for inserting a "regular" ("un-animated"?) GIF that we saw in lesson 7a: <img src="filename.gif" alt="alternative text" width=X height=Y> where X is the width of the image and Y is the height of the image in pixels. You can also include the left and right alignment options we saw in lesson 20. Adding a GIF-animated Slide ShowNote: If you do not have the working documents from the previous lessons, download a copy now. For our Volcano Web site we are going to add an animated GIF slide show that reviews the events that led to the May 18, 1980 eruption of Mount St Helens. This consists of photographs, and diagrams, used courtesy of the USGS/Cascades Volcano Observatory. To view and download the GIF animation, visit the Lesson 29a Image Studio. Save this image inside of your pictures folder/directory with your other image files. We are going to first create a basic HTML page that displays the GIF animation. Then we will build a link from our Volcanic Places in the USA page that will load this animation in a separate browser window.
Now we will modify the HTML in the Volcanic Places in the USA file usa.html so that it uses JavaScript to display our new document in a smaller web browser window.
<p> <a href="msh_may18.html" onClick="window.open('msh_may18.html', 'msh', 'width=440,height=280,status,menubar'); return false" onMouseOver="window.status='view animation of eruption events'; return true"><img src="../pictures/projector.gif" alt="showtime!" width="46" height="32px" align="left" border=0></a> See the <a href="msh_may18.html" onClick="window.open('msh_may18.html', 'msh', 'width=440,height=280,status,menubar'); return false" onMouseOver="window.status='view animation of eruption events'; return true">animation of events</a> for this volcanic eruption [194k GIF Animation]. NOTE: We are using JavaScript code from lesson 27d to open a specific HTML file msh_may18.html in a new web browser window that is 440 pixels wide and 280 pixels high. We have also included the JavaScript mouseOver code to provide a descriptive text a viewer moves the mouse over the link (see lesson 27a). The slideshow page is set to open by clicking either the icon of the projector or the hypertext link that is adjacent to the icon. Now you may realize that as we continue adding features that open new windows via JavaScript, some visitors to your web site may not be sure how they can easily return to the main page, as they tend to leave an array of windows that clutter up or completely cover their desktop. We can help out a little bit by adding a JavaScript button to close a window.
Check Your WorkCompare your web pages with this sample of how it should appear. If your pages are different from the sample or the hypertext links do not work correctly, review the text you entered in the text editor. Compare your work to the HTML of the samples (look for something like Source from your browser's View menu). ReviewReview topics for this lesson:
Independent PracticeAdd an animated GIF image to your own web pages. Try some of these resources to find images you can use:
More InformationIf you tire of viewing animations on a web page, you can freeze them by clicking the Stop button in your web browser. When you create your own GIF animation files, you have some options to control how many times it will loop through an animation sequence, so can prevent it from endlessly spinning, dancing, etc. And like static GIFs, you can make them act as hyperlinks like we learned in lesson 8e. If we found on the Cheeselover's Free Clip art site an animated gif of a dancing block of cheese, we could create a hypertext link to another site or HTML file by writing: <a href="http://www.cheeseanonymous.com/"><img src="dancing_cheese.gif" width=200 height=100 alt="animation of dancing cheese" border=0></a> For more information about GIF Animation, see Royal E. Frazier's GIF Animation on the WWW as well as the Web Developer's Virtual Library Coming Next....Viva Video! Movies in your web page! GO TO.... | Lesson Index | previous: "Multimedia in a Page" | next: "Multimedia: Movie Time" |
Writing HTML: Lesson 29a: Animate my GIF!
|