< ] [ GCL Home ] [ CGI Tutorial ] [ Home ] [ > ]

The Graphic Counter Language, Page 4

Again, let us compare what we have with what we are after:

Adding a Frame

GCL contains a frame keyword, which determines what kind of frame, if any, the counter shoud have. It is always followed by one of the following keywords: none, popup, button, defaultbutton, or shadow.

frame none tells GCL not to draw any kind of frame. This is the default, which we have seen so far.

The next three frame types are derived from my button creator. See that page for details.

Finally, frame shadow is my original design. It looks like frame popup but has a deeper shadow. This is what I have been using in marble.gcl. Our next step, then, is to add this line:

frame shadow

Here is what the counter looks like now:

Specifying Background Color

By default, GCL uses white for the background. As you can see, this is best suited for counters with no frame. We change the color by adding this line:

bkg 204 204 51

This is the same color I used when creating the button which I used as the background for the digits.

The numeric values are of the red, green, and blue component respectively. Each can range from 0 - 255.

Padding

This is not too bad. But the frame is a bit too close to the digits. With GCL we can add some padding. We will use the pad keyword. If we follow it by an integer, we determine how many pixels to add to each of the four sides:

pad 5

That is good for our purposes. However, if we wanted to, we could define the padding for each side differently. We would insert top, bottom, left, or right after the pad keyword. For example:

pad top 5
pad left 7
pad right 6
pad bottom 3

Adding a Tile

We are almost done. The only thing missing is the “frosting” in the background. I created it in Corel Paint as a 64-pixel-by-64-pixel GIF graphic. I filled the background with black, and used the “spray can” to add white sprinkles. I saved it as marble.gif, then used giftrans to make the black background transparent.

Then I added the following line:

#+ "/usr/pix/marble.gif" gif

Actually, I added it not at the end of the file, but after the #, line. It does not matter where you add it. I just like to keep the file list together.

Here, then, is the complete source code for marble.gcl:

#!/usr/bin/gcl
#0 "/usr/pix/n0.gif" gif
#1 "/usr/pix/n1.gif" gif
#2 "/usr/pix/n2.gif" gif
#3 "/usr/pix/n3.gif" gif
#4 "/usr/pix/n4.gif" gif
#5 "/usr/pix/n5.gif" gif
#6 "/usr/pix/n6.gif" gif
#7 "/usr/pix/n7.gif" gif
#8 "/usr/pix/n8.gif" gif
#9 "/usr/pix/n9.gif" gif
#, "/usr/pix/ncomma.gif" gif
#+ "/usr/pix/marble.gif" gif
align digits bottom
align commas bottom -15
kern 5
frame shadow
bkg 204 204 51
pad 5

We have created an original counter in just 19 lines of GCL code.

There are other keywords in GCL. Our next example (next page) shows how to add a head and a tail.

Copyright © 1999 G. Adam Stanislav
All rights reserved

Below is the finished counter. Hit the reload button to see it change. Then click on the counter to go to next page.

< ] [ GCL Home ] [ CGI Tutorial ] [ Home ] [ > ]