summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/context/third/visualcounter/visualcounter.tex
blob: a5eb6fc4fb0f1415009870cb2b153f5a37d85803 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
\usemodule[documentation]
\usemodule[visualcounter]

\definevisualcounter
  [visualsection]
  [countdown]
  [n={\somenamedheadnumber{visualsection}{current}},
   last={\somenamedheadnumber{visualsection}{last}},
   maxtext={99},
   text={\headnumber[visualsection]},
   style=\ssbf,
  ]
  
\definehead[visualsection]
           [subsection]
           [numbercommand=\visualsectionnumber,
            numnberstyle=sansbold,
            textstyle=sansbold,
            page=yes]

\def\visualsectionnumber#1{\smash{\framed[location=middle,frame=off]{\usevisualcounter[text=#1]{visualsection}}}}

\startbuffer[visual]
\definevisualcounter
  [visualitem]
  [scratchmarks]
  [ counter=\getvalue{v_strc_itemgroups_counter},
    width=1.5bp,
    height=1.2ExHeight,
    distance=3bp]

\definesymbol[visual][\usevisualcounter{visualitem}]
\stopbuffer

\startbuffer[page]
\definevisualcounter
  [visualpage]
  [mayanumbers]
  [
    counter=userpage,
    maxwidth=\textwidth,
  ]

\stopbuffer

\startbuffer[pagenumber]
\setupfootertexts[\usevisualcounter{visualpage}]
\stopbuffer


\getbuffer[visual,page,pagenumber]

\startbuffer[brightred]
\definecolor[bright-red] [h=DE1B1B]
\definecolor[dull-black] [h=2B2B2B]
\definecolor[dull-yellow][h=E9E581]

\definepalet
   [brightred]
   [past=dull-black, active=bright-red, future=dull-yellow]
\stopbuffer

\def\showcounter[#1]%
    {\startmiddlealigned
      \startcombination[#1]
        {\usevisualcounter[n=3, last=12]{dummy}}{3 out of 12}
        {\usevisualcounter[n=4, last=12]{dummy}}{4 out of 12}
        {\usevisualcounter[n=5, last=12]{dummy}}{5 out of 12}
        {\usevisualcounter[n=6, last=12]{dummy}}{6 out of 12}
      \stopcombination
    \stopmiddlealigned}

\starttext


\title {The \command{visualcounter} module \\ Aditya Mahajan \\ \currentdate}

\starttyping
\usemodule[visualcounter]
\stoptyping

\startitemize[visual, broad, packed, columns, two]
  \item Find \TEX\ documents to be too boring?
  \item Voilà, the \command{visualcounter} module!
  \item Make your presentations stand out.
  \item Turn any counter into a picture.
\stopitemize

\page

The above effect was achieved by first defining a \command{visualitem} counter
and a symbol \command{visual} that uses that counter:

\typebuffer[visual]

and then using the symbol \command{visual} in an itemization:

\starttyping
\startitemize[visual, ...]
    \item ...
    \item ...
\stopitemize
\stoptyping

\page

Notice the counter used for page numbering? That was achieved by first defining
a \command{visualpage} counter:

\typebuffer[page]

and setting it as the footer text:

\typebuffer[pagenumber]

\page

The above examples show the basic usage of the modules. The module provides two
commands: \type{\definevisualcounter} to define a visual counter

\starttyping
\definevisualcounter
    [...]     % [[\comment{name of the counter}]]
    [...]     % [[\comment{optional name of the parent counter} ]]
    [
     ...=..., % [[\comment{key-value settings} ]]
    ]
\stoptyping

and \type{\usevisualcounter} to use an already defined counter

\starttyping
\usevisualcounter
  [...=...] % [[\comment{key-value settings}]]
  {...}     % [[\comment{name of the counter}]]
\stoptyping

\section {So, how do I use this?}

Visual counters are defined and used in two ways:
\startitemize[visual, broad, joinedup]
  \item Using a low level interface that explicitly sets the current values of
    the counter, last count, the \METAPOST\ graphic that draws the counter, and
    the color palette. 
  \item Using higher-level interfaces built on top of the low-level interface
    that allows you to specify a \emph{structure counter} like those used for
    page numbering, itemizations, descriptions, etc.
\stopitemize

\page

\subsection {The low-level interface}

To begin with, lets not worry about how to define \METAPOST\ graphics that draw
the counter. The module provides a predefined set of \command{visualcounter}s,
and, for now, we'll just use those: the \command{scratchmarks}  counter. Details
on defining new counters are explained later.

\startbuffer[scratchmarks]
\usevisualcounter[n=6, last=12]{scratchmarks}
\stopbuffer

Suppose that I want to show that I am on page 6 out of 12 pages:

\startmiddlealigned
  \getbuffer[scratchmarks]
\stopmiddlealigned

which uses a predefined counter \command{scratchmarks} and was typed as follows:

\typebuffer[scratchmarks]

The counter may be made smaller

\startbuffer[smaller]
\setupvisualcounter[scratchmarks]
                   [width=1pt, height=8pt, distance=2pt]
\stopbuffer

\startmiddlealigned
  \getbuffer[smaller,scratchmarks]
\stopmiddlealigned

or may use a different color palette

\startbuffer[palette]
\setupvisualcounter[scratchmarks][palette=brightred]
\stopbuffer

\startmiddlealigned
  \getbuffer[brightred,palette,scratchmarks]
\stopmiddlealigned

\page

These settings are changed using \command{\setupvisualcounter}. In particular, to
get a small counter, use: 

\typebuffer[smaller]

and to change the color palette, use:

\typebuffer[palette]

where the \type{brightred} palette was defined as

\typebuffer[brightred]

\subsection {The high-level interface}

The high level interface is useful to display a \CONTEXT{} counter. Rather than
manually setting the value of \options{n}, \options{last}, \options{text}, and
\options{maxtext} (the last two are used only by a few counters), simply set the
value of a \options{counter} and the other values are automatically generated.
As an example, recall the set up for displaying the page numbers in the footer:

\typebuffer[page]

In the above example, \command{userpage} is the name of the counter that keeps
track of the user page number.

\page

A list of some commonly used \CONTEXT{} counters is given below:

\startbuffer[internal] counter=\getvalue{v_strc_itemgroups_counter},
\stopbuffer


\starttabulate[|l|l|]
  \NC Page numbers \NC \type{userpage} \NC \NR
  \NC Item group numbers 
      \NC \type{\v_strc_itemgroups_counter}\footnote[internal]
          {Macros names with underscore are internal \CONTEXT{} macros, and generally are
          not meant to be used in user code. The easiest way to set the value of
          \options{counter} to \options{\v_strc_itemgroups_counter} is to use:
          \typebuffer[internal]} \NC \NR
  \NC Enumeration number\NC name of the enumeration \NC \NR
\stoptabulate


\section {Changing the color of counters}

All counters use three colors: \command{past} to display past counters,
\command{active} to display current counter, and \command{future} to display
future counters. To change the color scheme, first define a new color palette
(which is misspelled in \CONTEXT{} is \command{colorpalet}):

\starttyping
  \definecolorpalet
      [...], % [[\comment{Name of the color palette}]]
      [
        past=..., % [[\comment{any previously defined \CONTEXT{} color}]]
      active=..., % [[\comment{any previously defined \CONTEXT{} color}]]
      future=..., % [[\comment{any previously defined \CONTEXT{} color}]]
      ]
\stoptyping

\page

and then set the color palette of a particular counter either using

\starttyping
  \definevisualcounter
      [...]     % [[\comment{name of the counter}]]
      [...]     % [[\comment{optional name of the parent counter} ]]
      [
        ...,
        palette=..., % [[\comment{name of a previously defined} \options{colorpalet}]]
        ...
      ]
\stoptyping

or using

\starttyping
  \setupvisualcounter
      [...]     % [[\comment{name of the counter}]]
      [
        ...,
        palette=..., % [[\comment{name of a previously defined} \options{colorpalet}]]
        ...
      ]
\stoptyping

\section {Changing the size of the counters}

All predefined counters have tunable parameters (such as \options{width},
\options{height}, and \options{distance}) that change the size of the counter.
The default sizes are given in terms of \options{EmWidth} or \options{ExHeight};
so they adapt to the size of the surrounding text. 

\section {Changing the style of text displayed in the counters}

Some visual counters (currently, only the \command{countdown} counter) also
display text. The style of this text may be set using:


\starttyping
  \setupvisualcounter
      [...]     % [[\comment{name of the counter}]]
      [
        ...,
        style=..., %[[ \comment{any valid \CONTEXT{} style}]]
        color=..., %[[ \comment{any valid \CONTEXT{} color}]]
        ...
      ]
\stoptyping

Note that changing the font size in the \options{style} affects the value of
\options{EmWidth} and \options{ExHeight} and therefore also scales the counter
appropriately. If this is not desirable, then you also need to set the size of
the counter in dimensions that are independent of bodyfontsize.

\section {Predefined counters}

The \command{visualcounter} module provides the following predefined counters:

\startnarrower
\placelist[visualsection][criterium=local, alternative=f]
\stopnarrower

\page

\visualsection {The \command{scratchmarks} counter}

The \command{scratchmarks} counter is inspired by the \command{fuzzycount}
counter that is part of the \CONTEXT's metapost library \command{txt}. The output
looks as follows:

\definevisualcounter
  [dummy]
  [scratchmarks]

\showcounter[4]

\blank[2*big]

The \command{scratchmarks} counter has the following tunable parameters:
\startitemize[packed, joinedup]
  \item \options{width} (default \options{3bp}): the width of each stroke
  \item \options{height} (default \options{3ExHeight}): 
    the length of the marker (and strictly speaking, not
    the height; the real height is $\options{height}×\sin(\options{angle})$).
  \item \options{distance} (default \options{0.5EmWidth}):
    the distance between two successive markers. The
    distance is measured from the middle of one marker to the middle of the
    other (that is, it does not take the width of the stroke into account).
  \item \options{angle} (default \options{75}): the angle of the forward
    markers. The angle of the backward marker is \command{-angle}.
    Only angles between \options{-90} and \options{90} give proper output. 
\stopitemize

\page

For example, the output with \options{width=1.5bp, angle=45} is:

{\setupvisualcounter[dummy][width=1.5bp, angle=45]\showcounter[4]}

\blank[2*big]

An angle less than \options{0} changes the direction of the stroke. 
For example the output with \options{width=1.5bp, angle=-45} is:

{\setupvisualcounter[dummy][width=1.5bp, angle=-45]\showcounter[4]}


\visualsection {The \command{mayanumbers} counter}

The \command{mayanumbers} counter is inspired by the Mayan numbering system that I saw in the
documentary \quotation{Breaking the Maya code}. It counter does not strictly
follow the Mayan numbering system. The Mayan numbering system is written
vertically; the output of this counter is horizontal which makes it more useful
for displaying page numbers in presentations.

\definevisualcounter
  [dummy]
  [mayanumbers]

\showcounter[2*2]

\blank[2*big]

The shape of the small and the large markers is as follows:

\startmiddlealigned
  \startcombination[2]
    {\usevisualcounter[n=1,last=5,width=3EmWidth, height=3ExHeight]{dummy}}
    {The shape of the small marker}
    {\usevisualcounter[n=5,last=5,width=3EmWidth, height=3ExHeight]{dummy}}
    {The shape of the large marker}
  \stopcombination
\stopmiddlealigned

\page

The \command{scratchmarks} counter has the following tunable parameters:
\startitemize[packed, joinedup]
  \item \options{width} (default value \options{1EmWidth}): The width of the
    small marker. 
  \item \options{height} (default value \options{1ExHeight}): The height of the
    markers.
  \item \options{distance} (default value \options{width/4}): The distance
    between two small markers. The distance between each group of four small
    counters is \command{2*distance}.
\stopitemize

\blank[2*big]

For example, to get an output that is half the default size, use 
the options \goodbreak \options{width=0.5EmWidth, height=0.5ExHeight}.

{\setupvisualcounter[dummy][width=0.5EmWidth, height=0.5ExHeight]\showcounter[4]}

% {\setupvisualcounter[dummy][style=\tfxx]\showcounter[4]}

\visualsection {The \command{countdown} counter}

This counter is inspired by the spinning wheel on the iPhone and on Google
images.

\definevisualcounter
  [dummy]
  [countdown]

\startmiddlealigned
  \startcombination[4]
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=3, last=12]{dummy}}}{3 out of 12}
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=4, last=12]{dummy}}}{4 out of 12}
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=5, last=12]{dummy}}}{5 out of 12}
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=6, last=12]{dummy}}}{6 out of 12}
  \stopcombination
\stopmiddlealigned

\blank[2*big]

The \command{countdown} counter may also be used with a text display of the
counter.

\startmiddlealigned
  \startcombination[4]
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=3, text=3, last=12]{dummy}}}{3 out of 12}
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=4, text=4, last=12]{dummy}}}{4 out of 12}
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=5, text=5, last=12]{dummy}}}{5 out of 12}
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=6, text=6, last=12]{dummy}}}{6 out of 12}
  \stopcombination
\stopmiddlealigned

\blank[2*big]

The example below shows how the counter changes when the number of steps are
increased.

\startmiddlealigned
  \startcombination[4]
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=13, last=24]{dummy}}}{13 out of 24}
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=14, last=36]{dummy}}}{14 out of 36}
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=25, last=48]{dummy}}}{25 out of 48}
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=36, last=60]{dummy}}}{36 out of 60}
  \stopcombination
\stopmiddlealigned

\page

The \command{countdown} counter has the following tunable parameters:
\startitemize[packed, joinedup]
  \item \options{width} (default value \options{1EmWidth}) and \options{height}
    (default value \options{1ExHeight}): The maximum of these two determine the
    difference between the inner and outer diameter of the ring.

  \item \options{text} (not set by default): The text to be displayed in the
    middle of the counter.

  \item \options{maxtext} (not set by default): The diameter of the inner circle
    is equal to \options{1.5} times the maximum of the width and the height of
    \options{maxtext}.

  \item \options{distance} (default value \options{3EmWidth}): 
    The distance between the consecutive markers along the circumference of the
    outer circle is equal to \options{distance/last}. 
\stopitemize

\blank[2*big]

For example, to get a continuous circle set \options{distance=0pt}:

\startmiddlealigned
  \setupvisualcounter[dummy][distance=0cm]
  \startcombination[4]
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=13, last=24]{dummy}}}{13 out of 24}
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=14, last=36]{dummy}}}{14 out of 36}
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=25, last=48]{dummy}}}{25 out of 48}
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=36, last=60]{dummy}}}{36 out of 60}
  \stopcombination
\stopmiddlealigned

When the high level interface is used, i.e., when the option
\options{counter=...} is set, the value of \options{text} is the converted value of the
counter, and the value of \options{maxtext} is the converted value of last
counter.

\visualsection {The \command{markers} counter}

The \command{markers} counter is inspired by the section markers displayed by
the \LATEX{} \options{beamer} package. This module comes in two shapes: the
default shape is circle

\definevisualcounter
  [dummy]
  [markers]

\showcounter[1*4]

\page

The alternative shape is a square, which is selected using

\starttyping
  \setupvisualcounter
      [...]     % [[\comment{name of the counter}]]
      [
        ...
        mpsetups=[[\options{visualcounter::markers:square}]],
        ...
      ]
\stoptyping

{\setupvisualcounter[dummy][mpsetups=visualcounter::markers:square]\showcounter[1*4]}

\page

The \options{visualcounter::markers:square} is a predefined alternative shape.
Before discussing how to define a new shape, lets look at the tunable parameters
of the \command{markers} counter:
\startitemize[packed, joinedup]
  \item \options{width} (default value \options{1EmWidth}): The width of the
    each marker.

  \item \options{distance} (default value \options{width/4}): The edge to edge
    distance between successive markers.

  \item \options{mpsetups} (default value \options{visualcounter::markers:circle}): 
    A \command{useMPgraphic} that determines the shape and the display of the
    markers. The module comes with three predefined shapes,
    \options{visualcounter::markers:circle}, \goodbreak
    \options{visualcounter::markers:square}, and
    \options{visualcounter::markers:star}.
\stopitemize

To define a new shape, you have to create a \command{useMPgraphic} that defines
three \METAPOST{} macros:

\startitemize[packed, joinedup]
  \item \options{show_past_marker(expr shift)}
  \item \options{show_active_marker(expr shift)}
  \item \options{show_future_marker(expr shift)}
\stopitemize

The argument to these macros is the shift calculated based on their position.
The macros are responsible for using the shift amount either for horizontal
shift  or for vertical shift, and coloring the markers with appropriate colors.
The three colors from the color palette are available as \options{past_color},
\options{active_color}, \options{future_color}.

\page

\startbuffer[star-definition]
\startuseMPgraphic{visualcounter::markers:star}
% [[\comment{Copied from http://tug.org/pracjourn/2012-1/hefferon.html}]]
def fullstar = 
  hide (
    z0  = origin; 
    z1  = (x0, 0.5); 
    z2  = ((z1 - z0) rotated (  360/5)) + z0 ;
    z3  = ((z1 - z0) rotated (2*360/5)) + z0 ;
    z4  = ((z1 - z0) rotated (3*360/5)) + z0 ; 
    z5  = ((z1 - z0) rotated (4*360/5)) + z0 ;
    z6  = whatever[z1, z3] = whatever[z2, z5];
    z7  = whatever[z1, z3] = whatever[z2, z4];
    z8  = whatever[z2, z4] = whatever[z3, z5];
    z9  = whatever[z1, z4] = whatever[z3, z5];
    z10 = whatever[z1, z4] = whatever[z2, z5];
  ) 
  (z1 -- z6 -- z2 -- z7 -- z3 -- z8 -- z4 
      -- z9 -- z5 -- z10 -- cycle)
enddef;

def show_star(expr shift, fill_color) = 
  newpath p;
  p := fullstar xyscaled(width, width) shifted (shift, 0);

  fill p withcolor fill_color;
  draw p withcolor 0.5*fill_color;
enddef;

def show_past_marker(expr shift) = 
    show_star(shift, past_color);
  enddef;

def show_active_marker(expr shift) = 
    show_star(shift, active_color);
enddef;

def show_future_marker(expr shift) = 
    show_star(shift, future_color);
enddef;
\stopuseMPgraphic
\stopbuffer

\startbuffer[star-counter]
\definevisualcounter
  [stars]
  [markers]
  [mpsetups=visualcounter::markers:star, % [[\comment{use "star" marker}]]
   width=1.5EmWidth,
   distance=0.25EmWidth,
   palette=star-colors, % [[\comment{defined elsewhere}]]
   last=5, % [[\comment{rating out of 5}]]
  ]
\stopbuffer

\definepalet
  [star-colors]
  [active=orange,
     past=orange,
   future=gray]

\getbuffer[star-definition, star-counter]

As an example, lets consider a new visual counter that displays a
\quotation{star rating}: 

\startmiddlealigned
  \startcombination[3]
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=1]{stars}}}{1 out of 5}
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=3]{stars}}}{3 out of 5}
    {\framed[frame=off,width=0.2\textwidth]{\usevisualcounter[n=5]{stars}}}{5 out of 5}
  \stopcombination
\stopmiddlealigned

For better visual effect, I have also changed the color palette to one that uses
same color for \options{past} and \options{current} markers. Note
that the above alternative is available as the
\options{visualcounter::markers:star} option to \options{mpsetups}. The following
description is just to explain how to define a new marker.

\page

To create such a counter, first create a \command{useMPgraphic} as follows (I
could have used any name instead of \options{visualcounter::markers:star}):

\adaptlayout[lines=+2]

\typebuffer[star-definition]

\page

Next, define a new \command{visaulcounter} that inherits from \command{markers}
but uses a different \options{mpsetups}:

\typebuffer[star-counter]

\startbuffer[star-example]
\usevisualcounter[n=4]{stars}
\stopbuffer

To use this counter, type:

\typebuffer[star-example]

which gives: \framed[frame=off,location=lohi]{\getbuffer[star-example]}



\visualsection {The \command{progressbar} counter}

The \command{progressbar} counter is based on a question on TeX.SE. This counter
is not yet finalized. I am still working on the interface to change the shape of
the progress bar, and perhaps add some shading.

\definevisualcounter
  [dummy]
  [progressbar]

\showcounter[1*4]


\visualsection {The \command{pulseline} counter}

The \command{pulseline} counter is based on the heart pulses shown in a heart
rate measurement device. This counter is not yet finalized.

\definevisualcounter
  [dummy]
  [pulseline]

\definepalet
  [green]
  [past=darkgreen,
   active=darkgreen,
   future=darkgreen]

{\setupvisualcounter[dummy][rulethickness=2bp,palette=green]\showcounter[2*2]}

% \section[sec:new-counters]{How to define new counters}
% 
% The name of the \command{useMPgraphic} must start with \options{visualcounter::}
% (note the double \options{::}), so that the graphic uses the
% \options{visualcounter} MP instance.


\stoptext