| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Bars anyone ? |
21 Aug 96 08:53, Frank Adam wrote to All:
> This is one cute way of making a progress bar and handling sequential
> data, probably the least recommended way too, as it's rather hungry :-)
Here's another - have fun! :-)
/*
* Written by Andrew Clarke in December 1994 and updated for VidMgr
* compatibility in August 1996. Released to the public domain.
*/
#include
#include
#include "vidmgr.h"
void progress_bar(char x, char y, char width, char attr, double range,
double n)
{
double percent;
char buf[250];
memset(buf, '\0', sizeof buf);
vm_clearbox(x, y, x + width - 1, y);
percent = floor((n / range) * (width * 2));
if (percent == 1.0)
{
vm_xputch(x, y, attr, '\xDD');
}
else if (percent > 1.0)
{
if (fmod(percent, 2.0) != 0.0) /* odd number */
{
memset(buf, '\xDB', floor((percent - 1.0) / 2.0));
strcat(buf, "\xDD");
}
else /* even number */
{
memset(buf, '\xDB', floor(percent / 2.0));
}
vm_xputs(x, y, attr, buf);
}
}
void draw_window(char x1, char y1, char x2, char y2, char attr, char shadattr,
char *style, int has_shadow)
{
if (has_shadow)
{
vm_attrib(x1 + 2, y1 + 1, x2 + 2, y2 + 1, shadattr);
}
vm_paintclearbox(x1, y1, x2, y2, attr);
vm_frame(x1 + 3, y1 + 1, x2 - 3, y2 - 1, attr, style);
}
int main(void)
{
int i;
vm_init();
draw_window(20, 8, 59, 16, vm_mkcolor(BLACK, LIGHTGRAY),
vm_mkcolor(LIGHTGRAY, BLACK), vm_frame_double, 1);
vm_attrib(25, 11, 54, 11, vm_mkcolor(LIGHTGRAY, BLACK));
for (i = 0; i <= 88; i += 2)
{
progress_bar(25, 11, 30, vm_mkcolor(LIGHTBLUE, BLACK), 88.0, (double) i);
}
vm_done();
return 0;
}
--- Msged/2 4.00
* Origin: Blizzard of Ozz, Melbourne, Australia (3:635/727.4{at}fidonet)SEEN-BY: 50/99 620/243 623/630 632/349 635/503 544 727 728 711/401 409 410 SEEN-BY: 711/413 430 808 809 932 934 712/515 713/888 714/906 800/1 @PATH: 635/727 544 50/99 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.