Re: Graphical Bar Code?

From: Mathew Earle Reuther (graymere@zipcon.net)
Date: 07/26/02


On Thu, 25 Jul 2002, Daniel A. Koepke wrote:
> Why not just:

 <code snipped, lines I modified quoted>

>   char *bar(char *buf, int M, int per)
>     int len = MIN(M - 1, per / 10);
>   #define SBAR(b,v,m) bar((b), sizeof(b), PERC((v), (m)))

Lines I modified:

   char *bar(char *buf, int M, int per, int scale)
     int len = MIN(M - 1, per / scale);
   #define SBAR(b,v,m,s) bar((b), sizeof(b), PERC((v), (m)), (s))

This allows you to set the number of percentage points in a mark on your
bar.  Works quite well, so you can set it to what you need for any given
bar you're making.  Say you want one where 4% = a mark (this means you'll
have a 25 mark bar), you set it to 4.  Now you want one where 10% is a
mark, set it to 10 and you get a 10 mark bar.  Great for when you want to
use the function for multiple purposes.

Another thing you could do is change the barChar to just a char and have
it passed as well.  That way you can control what mark is showing up in
different bars.  Say you want to us 'H' for hit points and 'M' for mana
so they're clearer, or whatever you want.

Much thanks to the other two guys who sent code, I ended up going with
DAK's because it was relatively easy to modify for what I wanted, though
the other two each had something worthwhile for me to learn from, so they
were surely not wasted efforts.

-Mathew

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT