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

The Graphic Counter Language, Page 3

While we have created a fully functional counter already, we can improve it in several ways. Let us compare what we have with what we are after:

Adding a Comma

We need another graphic, one with the picture of a comma. This is simple to make, just create it in any bitmap editor. I used Corel Paint again. I created a picture of a black comma on white background. I used an older version of Corel Paint which did not let me make the background transparent. So I used giftrans to turn the white background transparent.

I named the comma graphic ncomma.gif and added the following to marble.gcl:

#, "/usr/pix/ncomma.gif" gif

Here is what the counter looks like now:

Aligning the Counter

Well, we got a comma in it, all right, but it seems misplaced. By default, GCL will align the digits and the commas in the middle. This does not work well for our example.

Letís change the alignment by adding two more lines:

align digits bottom
align commas bottom

This looks better. But it would be nice if we could move the comma down by about 15 pixels, wouldnít it. Something like this:

Luckily, this is quite simple with GCL. We just need to change that last line to:

align commas bottom -15


Letís add one more line before moving on to the next topic. GCL allows you to kern the digits and the commas. That means you can move them appart:

kern 5

Incidentally, the kern value may be negative. This will make the digits and commas overlap. It is useful with odd shaped digits.

Although we do not need it for our example, we can also kern the digits and the commas separately. For example:

kern digits 8
kern commas 4

Our full source code now looks like this:

#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
align digits bottom
align commas bottom -15
kern 5

Copyright © 1999 G. Adam Stanislav
All rights reserved

Again, below is the counter we have created so far. Hit the reload button to see it change. Then click on the counter to get to page 4.

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