Å ?!!


So what's with all this Å business anyway ? I still haven't been able to figure out why anyone would want to christen an animation language Å ( pronounced Awe ). Maybe because they think it's one ( or two ) up on C, or perhaps they think the animations will fill us with awe at their programming expertise !! ( punny !!). But whatever the reason, we spent a whole day calling it "A with a dot on top ", until the documentation finally set us right.

This is the first in a whole line of recently released animation languages and being in the Alpha stage, it is presently a little buggy. The main downside to this language is that some of the concepts, namely object declarations, are a tad difficult to grasp at first, but once you've thoroughly familiarized yourself with the intricacies of awe, you'll start wondering how you ever managed without them. These concepts are, however, much easier to use than similar features in other animation languages.

On the plus side however, it's use of the C language syntax really smoothens out the learning curve. This decision on the part of the developers makes the language much easier to learn and recall. Indeed, it is intended to be "... an extension of a subset of C. ", whatever that means !! Unlike C however, Awe has no provision for pointers, only real arrays, which are boundary checked at run-time ( a feature similar to one present in Java ). This makes the language adequately secure for transfer over the Internet. The inclusion of boundary checking prevents access to illegal memory, discouraging malicious programming.

So now you want it too, huh ?!!

Interested ? Well then, scurry over to the Candle site on the Web and download it NOW !! It's preferable if you work out these programs, run them and see their output as you read our explanation. Or you can read through our tutorial and then download the software. It's your choice.

We've worked on a Pentium 66 with 16 MB Ram, a large hard disk, Windows95 and a 256 color display adapter. We don't know if it will work on anything less, but check it out.

A little more on Å

Awe is an interpreted animation language paired up with a browser named CandleWeb. It is marketed as, and I quote, " an interpreted language , particularly suited for making interactive graphics presentations " and it's quite good at it too. The creators have paid special attention to the usability and programmer-friendliness of this language and have wisely decided to stick to the old syntax of C, semicolons et al.

The languages main attraction is however, something that bears absolutely no resemblance to C, Object declarations.

What are objects ? ( hey ! you C++ programmers, keep your hands down ! ). No, we're not referring to classes and objects as in C++, but to real objects, as in Awe. The best way to understand objects is to see them in action and use them in your own programs, but here is a short overview.

Objects make the programmers work much easier. For example in Awe, if you want to draw a line, you give the program the line attributes ( length, thickness, color, etc. ) and the program does the rest. Quite different from C/C++ where the programmer does all the work. Objects handle almost everything in the following programs, all you have to do is change the variables. But remember, objects only work well when they have all the relevant data. Leave anything out and be prepared for some surprises !! Objects also make possible the existence of the functions input and output. These functions enable input or output to be carried out in one step, leading to smoother and faster animation. So instead of drawing ten boxes one after the other, output will store them in memory and dump them onto the screen in one go.

As mentioned earlier, the best way to understand objects is to see them in action. So lets.

Learning our ÅBC's....

int main ()
{ 
}
Look familiar ? But that's not C, it's Awe. The same main, the same braces, the same everything !! no wonder this language is easy to learn ! As you've guessed this program does absolutely nothing, but it doesn't error either, which is more that you can say about any other programs you've written !!

Save the program with the extension .awe and store it in a separate subdirectory. Run the CandleWeb browser and load the file. Run it. That's all !!

On to the next one.

main()
{
resizeWindow (200, 100);
}
Program number 2 resizes the browser window, to 200 X 100 ( pixels ). resizeWindow is one of the many built in functions of Awe and it is quite useful.

main()
{
setAnchor("http://www.candleweb.no ");
output;
}
This program sets an anchor to a particular site on the Web, in this case to the Candle Homepage. Notice that the site address is given as a string. Here we get our first taste of the output function. If output hadn't been present the anchor wouldn't have been set.

main()
{
textobj points=((20,30)),outtext="How very interesting ! ",color=0xFF0000 ;
output;
}
Finally you get to see your first Object ! textobj ( Text Object ) is an object that, quite obviously, displays text out on the screen. The function points ( in double brackets ) sets where exactly on the screen the text should be displayed. Outtext contains the string that has to be displayed and color sets the color of that string. The color is given in this format, 0XRRGGBB. So the text you see will be tinted deep red. Here again we need the function output to display anything on the screen.

int main ()
{ 
box points = ((0, 0), (100, 200)), fill = 1, color = 0x4444FF;
output;
}
Now, in program number 4, it's time to create some graphics ! So okay, a box isn't much, but it's only a start ! Here we use the object box, to show ( what else ?! ) a box on the screen. points contains two sets of coordinates, the first one represents the upper left hand corner of the box and the second one, the lower right hand corner. fill is equal to one, signifying that the box should be filled with color, if it was zero, the box would appear as an outline. As before, color sets the color of the object.

You can add another function to the box object line, texture. Type in texture = 1 after the fill function and check out the results ! Also try out other value for the texture, other than one.

main()
{
image points=((0,0), (0,0)), image = "active.gif";
output;
}
In this program we tackle our first image. We use the image object and set up the image as we want it to appear on screen. As before points sets the position of the image on the screen. The first group of coordinates set the upper left hand corner position of the image and the second pair set the size of the image. We've made the second pair equal to 0,0. This will make the image appear as large as it originally was. Change the coordinates and the bitmap will be automatically stretched or shrunk to fit the designated area. The function image contains ( in double inverted commas ), the image to be displayed. You can replace the file name we've given with the name of any of your .gif or .jpg images.

main()
{
 image points=((0, 0), (0, 0)), level = 2, image = "active.gif";
 image points=((0, 0), (0, 0)), level = 1, image = "big.jpg";
 output;
}
If we had two images to be displayed at the same time and at the same place, you would use the function level, to decide who appears over who. In our program, the image active,gif will appear over the left hand corner of the image big.jpg . This means that a higher level picture will be displayed in full and on top of, an image with a lower level value. This means that we can now superimpose an image over another.

Try changing both the levels to 2. When you do this, each image will be displayed, but the next image will overwrite the previous one, if placed at the same position.

int main ()
{
  int red = 0x884444;
  box
  points = ((5, 5), (694, 44)), fill = 1, color = red;
  output;
}
This program is pretty much the same as the earlier box drawing program, only this time, a variable is used. ( WOW !!) Here the variable red represents the color of the box. Simple

Now keep in mind that Awe has only three types of variables, ints, floats and text. ints and floats are used to hold numeric values and text is used to hold string constants.

int main ()
{ 
 int x=0;
 image points=((x,x), (100, 100)),image = "active.gif";
 while (1) 
 {
 x = x +1;
 output;
 wait( 50 );
 }
}
Now the programs start getting a little more complicated and a lot more fun. In this program we initialize the variable x to zero. We set the image to active,gif and the image points to the variable x and the image size to 100,100. Then we go ahead and start an infinite loop by setting while to true ( otherwise known as 1 ). As the loop proceeds, we increment, or increase by one, the value of x. After the function object, which displays the image on the screen, we wait for half a second and then again increment the value of x. As the loop inexorably continues, the value of x will keep increasing. As the value of x increases, the image's point coordinates also change, making the .gif walk diagonally across the screen until it disappears below the window.

This is a concrete example of the utility of objects. Instead of a few lines of code, we could have had a hundred. All we have to change are the variables and nothing else, the output function takes care of everything. As you've probably noticed, most Awe programs have executable code down at the bottom, with all the rules up at the top.

Now you'll realize why we kept harping about the usefulness of objects. Try doing the same thing in C++ and measure both the file size and the litres of sweat you lose.

int main ()
{ 
 int x, y, on;
 window points = ((x,y), (x+130,y+150)), active = on, sb=0;
 image points=((0, 0), (0, 0)), level = -1, sb = 0, image = "active.gif";
 endwindow;
 while (1) {
 x = random( 4 , 660 );
 y = random( 50 , 460 );
 on = 1;
 output;
 wait( 50 );
 }
}
This is a program that bears more than a passing resemblance to the logoflas.awe demo program that comes along when you download the development package. We've just shortened and simplified that program to help you understand it better. Here we initialize three variable, x, y and on. Using the object window, we create a small window on the screen, whose location is variable and size is fixed. active is equal to on , where on is equal to 1. active makes the present window active. sb is short for SaveBackground, if it is set to zero, the background is not refreshed when another image is drawn ( i.e. If you redraw a box three times on the screen, one after the other, the old boxes do not disappear. ). The image points sets the image inside the window we've just created. Here level is equal to -1, but this is not necessary and sb is set off. The name of the image to be displayed is also given. Notice that after setting the window attributes, we have to type in endwindow. The absence of this statement makes the program error.

Again we enter an infinite loop and using the random function assign random values to the variable x and y, in the specified ranges. After a wait of .5 seconds, the images is displayed on the screen repeatedly and in random positions.

Neato !!!

main()
{
 inputarea points = ((1,1),(640,400)), translation = ("q" ; return 1 ; ) ;
 while (1) 
 {
 input;
 output; 	
 }
}
In this program, the input area has been set to include the whole screen. So when you type in 'q' while the program is running, the return statement will return 1, terminating the program. The while loop waits an infinite amount of time for your input. Simple really.

The inputarea represents user input. Using it you can receive input from your user. You can also use it to cut up your screen into various segments, with different things happening when they are stimulated.

More on translation coming right up !!

main()
{
int a=1; int b = 2
image points = ((0,0), (0,0)), level =b, sb = 0, image = "active.gif"
image points = ((0,0), (0,0)), level =a, sb = 0, image = "big,jpg"
inputarea points = ((1,1), (640,400))
translation = {Button1 : { a = 2; b = 1;}, Button3 : { a = 1; b = 2; }, "q" : return 1 ; ) ;
 while (1)
{
input;
output;
}
}
This program uses the variables a and b to flip the images every time the right or left mouse button is pressed. The variables a and b are initialized to 1 and 2 respectively. inputarea is set to cover the whole screen and pressing q, quits. In translation, the Button1 stands for the left mouse button and Button3 represents the right mouse button. When the buttons are clicked the image levels change and the images flip. translation helps us decide what to do each time we receive user input, like right now, we are using it to trap the mouse buttons.

If I'm forced to explain the while loop again, I'll explode !!


main()
{
int x=1, y = 2
image points = ((x,y), (0,0)), level =-1, sb = 0, image = "active.gif"
inputarea points = ((1,1), (640,400))
translation = {Button1 : { mousePos (x,y);}, "q" : return 1 ; ) ;
while (1)
{
input;
output;
}
}

This program is very similar to its predecessor and I won't insult your intelligence ( and tire my fingers ) by explaining the nitty gritty of these program to you again. In short, we use the function mousePos to determine the position of the mouse pointer every time it is clicked. We then set the image points to these coordinates. So every time you click your mouse, the image moves.

Confession Time....

We gained most of our learned and educated insight into the workings of Awe by doing the simplest thing, reading the documentation. We also understood the workings of the programs by examining the demos so thoughtfully provided by the developers. We suggest you follow in out our footsteps and download the manual too.

And another thing, the reason the number of programs given is small is because, one, it's so simple you can figure it all out yourself and two, we're to lazy to give you any more, so there !!


The above tutorial is a joint effort of

Mr. Vijay Mukhi
Mr. Arsalan Zaidi


Vijay Mukhi's Computer Institute

VMCI, B-13, Everest Building, Tardeo, Mumbai 400 034, India
e-mail : vmukhi@giasbm01.vsnl.net.in
http://www.vijaymukhi.com

Tel : 91-22-496 4335 /6/7/9
Fax : 91-22-307 28 59