ASCII-animations

Here is a template you can copy and paste into a text document. (Please note that I did not write the JavaScript. I copied the script from an unknown artist's Javascript animation and hope that that person doesn't mind my broadcasting it about.) Many thanks to miK for altering the line endings so that it can be viewed on most platforms.

I have just been doing some reading about JavaScript. Apparently some bozos have decided that <script language="JavaScript"> is deprecated. They prefer script type="text/javascript" language="javascript"> now. I have altered the template to reflect that change.

<html>
<head>
<title>your title here</title>
</head>
<body bgcolor="#fff6e9" text="#660000" link="#3366cc" alink="llizard" 
vlink="#333399" onload="tick()">

<b>bird singing</b> --ejm98

<script type="text/javascript" language="javascript">
<!-- hide from older browsers
    var agt=navigator.userAgent.toLowerCase();
    if (agt.indexOf("mac") != -1) { var a="\r"; } else { var a="\n"; }
    var max=0;
    function tlist(){ max=tlist.arguments.length;
        for(i=0;i<max;i++) this[i]=tlist.arguments[i];
    }

    tl = new tlist(

" "+a+
"  \<\") "+a+
"   ( \>\\ "+a+
"    \" \\\\ "+a+
"       \\  ejm"+a,

"              "+a+
"  \>\")       "+a+
"   ( \>\\     "+a+
"    \" \\\\   "+a+
"       \\  ejm"+a

    );
    var x=0;
    function tick() {
        document.f.t.value=tl[x];
        x++; if(x==max) x=0;
        //if(confirm('continue?'))
            setTimeout("tick()",70);
    }
    // end-->

</script>

<form name="f" action="self"><textarea name="t" rows="6" cols="15">
</textarea> </form>

<p><b>to <a
href="https://llizardakaejm.wordpress.com/gallery/ascii-animations/">
llizard's Javascript ASCII-animations</a></b></p>

</body>
</html>

The body bgcolors (background), text and link colours can be changed to any you like. Consult a colour chart for hexadecimal numbers.

Erase the above birds and insert your frames there. All frames must have the same number of lines. (If your drawing extends to 8 lines tall, all of the drawings must be 8 lines tall.) There are the two frames of the singing bird to show you what it looks like. Each line must begin with a " (quotation mark). Each line except the last line of all frames must end with "+a+ (quotationmark, plus sign, lowercase a, plus sign). The last line of each frame except the last frame must end with a "+a, (quotation mark, plus sign, lowercase a, comma). The last line of the last frame must end with a "+a (quotation mark, plus sign, lowercase a)

N.B. There is no comma at the end of the last frame.

Another important thing, any \ (backslash) in your drawing must be preceded by another \ (backslash) or you will have weird jumps in your animation. The same goes for any " (quotation mark) in the drawing. And apparently, for some people, you must do the same with any < and > (lessthan and greaterthan) and possible the + (plus sign). Precede each of them with a \ (backslash).

Here is how one of the frame pictures of the bird appears:

                        <")
                        ( >\
                         " \\
                            \      ejm

This is how the frame would look when your animation was done:


                     " "+a+
                     "  \<\")"+a+
                     "   ( \>\\"+a+
                     "    \" \\\\"+a+
                     "       \\  ejm"+a,

The number after the words "tick()" will adjust the speed.

setTimeout("tick()",70);

Change the number to see what happens.

The numbers in this next part will adjust the size of the frame when you are viewing the animation.

rows="6" cols="17">

The rows is the number of lines in each frame and the cols is the width of the frame.

It's a good idea to add a blank line at the top of your drawing so that you won't have unsightly scrollbar things (tantalizing people into thinking there is more to be seen) at the sides of the window of your animation. The blank line looks like " "+a+ (quotation mark, spacebar, quotation mark, plus sign, a, plus sign) You must have a space between the quotation mark and the end of the line or you will get a weird box and a jump in your animation. And then you should add 2 to the number in the "ROW" section. ie: If your original drawing is 5 lines tall, in your animation, it will be 7 lines tall.

Save your animation as an .html to view it. You label the animation "youranimationtitle.html" Remember, Javascript animations can only be viewed with Netscape 3, Opera 3.2b2 and Microsoft Explorer 4 (or higher) that have the Javascript enabled. They DON'T work at all in MSIE 3 because the font is proportional instead of fixed width.

                     \ 
                      \,^^%---
                      <\/  \ See? It's easy when you know how....
                      >
                      >^^
                     /| 
ejm                  | \

I hope these instructions were detailed enough and/or not too detailed and that you can now go nuts making your own animations. Have fun and be forewarned; it's really time consuming.

But just in case you'd like some more detail, please go to part 2 of this lesson to learn about optimizing your animation. With this scripting, you can only have one ASCII-animation per page. But go to part 3 of this lesson to learn how to put more than one animation on a page.

When you have made your Javascript ASCII-animation, please tell people about it. Put your animation onto your website and post the URL in the newsgroup alt.ascii-art.animation. Generally, Javascript ASCII-animations have a LOT of text so take up a tremendous amount of room (not to mention the distortion) in the newsgroup. Please do not post your whole animation there.

To first part of animation lesson
To second part of animation lesson
To third part of animation lesson
To fourth part of animation lesson
To fifth part of animation lesson
To sixth part of animation lesson