![]() Volume 9, Issue 2 Articles Tricks of the Trade In and Out Trott's Corner New Products New Publications Calendar News Bulletins New Resources Classifieds Download This Issue Editorial Policy Staff Submissions Subscriptions Advertising Back Issues Contact Information |
Tricks of the Trade
Generating Barcodes We encounter a wide range of barcodes nearly every day. At www.barcodeman.com/info/c39_1.php one can find a number of barcode specifications. In one popular code--Code 39--each character is made up of 9 bars, alternating black and white, 3 of which are wider than the others. A single character therefore consists of 5 black bars and 4 white bars. The ratio of the bar widths, The Code 39 barcode symbology supports 43 characters plus *, which is used as a delimiter or start/stop character. Note that the alphabetic characters are all upper case. Here is the bar width configuration table. A zero corresponds to a narrow bar and a one to a wide bar.
Corresponding to a single character, the following code generates a sequence of rectangles of alternating black and white color (via MapIndexed and Mod) according to the bar width configuration table.
The position of each successive rectangle is computed using FoldList (computing a cumulative sum starting from pos). Since the alphabetic characters are all upper case, lowercase input is converted using ToUpperCase. The replacement rule Adding 1 for the intercharacter gap, the total width of a character is
Here is the barcode of Mathematica in Code 39.
By adding catch all code for missing characters, we can display such characters as a "graphical error."
For example, # and ^ are not in Code 39 and are shown in red.
|
||||||||
About Mathematica | Download Mathematica Player Copyright © 2004 Wolfram Media, Inc. All rights reserved. |