Announcing the visualcounter module

It has been almost two years since I posted about the main idea of the visualcounter module. I am happy to announce the official release of the module. I have been using this module in my presentations for almost two years without any problems, so I believe that it is stable enough to be released.

At present, the module is available on github and it should be available through ConTeXt garden soon. Look at the documentation to see some of the features of the module (in particular, the "star rating" example based on Jim Hefferon’s article in the Practex Journal).

The module provides six counters. Two of these were created for proof of concept and are not well tested; the remaining four—scratchcounter, mayanumbers, markers, and countdown—are well tested and, hopefully, their interface will not change.

This was my first module that uses the ConTeXt namespace macros. If you peek into the module, you’ll notice that I only define one macro; everything else is handled by the ConTeXt namespace macro \definenamespace.

The other interesting feature of this module is that I use a separate metapost instance for displaying the counters. This avoids conflict with user definitions. For example, if a user decides to change the metapost definition of fill for whatever reason,

let fill = draw;

such a change will not affect the visual counter module!

Any feedback is appreciated.


Introducing the visual counter module

A typical document usually contains many contains many counters: page numbers, section numbers, enumerations, theorems, and so on. Displaying all these numbers gets boring quickly. Do you want to spice up the document a bit? Enter the visual counter module.

The idea is simple. Each counter already keeps track of its current and maximum value. So, we can just pass that information to MetaPost and display the counter in a visually attractive manner. For example, to display page numbers, I use:




The options are pretty self explanatory. counter sets the name of the counter that we want to display (the module figures out its current and maximum (last) value) The alternative selects the type of visual counter that you want to use. The \usevisualcounter macro displays the counter. Currently, I have only implemented two alternatives: countdown and pulseline. (Here is an example showing both of them). I plan to add others in the future. Suggestions are welcome!

At the moment, there is no documentation. I am still playing around with the API and the code is in a state of flux. Nonetheless, you can take a look in the tests directory to see a few examples of how things work. Stay tuned for more posts on this module.

I am also using the new name space code in the module. It is very very elegant. The entire module has just three macros (two of them are just for convenience). Everything else is just a matter of setting the values for different options. A big advantage of the name space code is that the macros to access the value of a particular option are fully expandable. This means that they can be used directly inside Metapost. No need to have an extra \setMPvariables to pass values to Metapost. Yipee!

Note: It appears that github is down at the moment. Hopefully, it will come back up soon.