home *** CD-ROM | disk | FTP | other *** search
- #include "eg_proto.h"
-
-
- /* keyboard defines */
-
- #define RETURN 13
- #define ESCAPE 27
- #define HOME -71
- #define CURUP -72
- #define END -79
- #define CURDN -80
-
- /* default colors */
- int color[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
-
- int max_x,max_y,max_colors; /* max colors and sizes */
- int dev,grafx_mode; /* device and graphics mode */
- int forg,back; /* foreground and background colors */
- int mouse; /* store whether mouse available */
- char str[20][70],*s[20]; /* strings for windows */
- int cga_pal; /* CGA Palette */
-
- #ifdef __TURBOC__ /* defined by Turbo C compiler */
- int _stklen = 10000; /* increase default stack size to 10000 */
- #endif
-
- main()
- {
- unsigned char banks; /* banks for Video 7 Card */
- int i,key,reconfig,x,y; /* work variables */
- int selection; /* selection from EG_SMENU */
- struct egstatus stat; /* EG status structure */
- int shadow,clear; /* colors for menu shadow and clear screen */
- int t_forg,t_back; /* title foregraound and background for EG_SMENU */
- char cardtype[23]; /* string for card type */
- char font[20]; /* font for menus */
- char selecs[15][80]; /* array of strings for menus */
- char *sels[15];
-
- cga_pal = 0;
-
- dev = device_query(); /* check graphics card */
- i = check_vid7(&banks); /* check for Video-7 card */
-
- if (i){ /* if Video 7 */
- dev = 5; /* use 1024x768x16 */
- if (banks > 1){
- dev = 6;
- grafx_mode = 101;
- }
- else /* use 800x600x16 */
- grafx_mode = 98;
- strcpy(cardtype,"Video 7 Extended VGA");
- }
- else{
- if (dev & 16){ /* VGA adapter */
- dev = 2;
- grafx_mode = 18;
- strcpy(cardtype,"VGA");
- }
- else{
- if (dev & 4){ /* EGA adapter */
- dev = 1;
- i = ega_mem(); /* check amount of available memory */
- grafx_mode = 16;
- strcpy(cardtype,"EGA");
- }
- else{
- if (dev & 64){ /* Hercules adapter */
- dev = 3;
- grafx_mode = 20;
- strcpy(cardtype,"Hercules");
- }
- else{ /* CGA Adpater */
- dev = 0;
- grafx_mode = 4;
- cga_pal = 3;
- strcpy(cardtype,"CGA");
- }
- }
- }
- }
-
- /* set up defaults */
-
- forg = 1; back = 15; shadow = 3; clear = 11;
- selection = 0; t_forg = 15; t_back = 4;
-
-
- /* devices are as follows :
- CGA - 0
- EGA - 1
- VGA - 2
- HERC - 3
- PARADISE - 4
- VIDEO 7 - 5 ( 800 x 600)
- VIDEO 7 - 6 (1024 x 768)
- IBM 8514 - 7 (1024 x 768)
- */
-
-
- switch(dev){
- case 0 : setibm(); initgraf(grafx_mode,0,0);
- for (i = 1; i < 16; i++) /* set up colors */
- color[i] = 1;
- strcpy(font,"micprint.sms");
- x = y = 50; cga_pal = 2;
- forg = 3; back = 2; shadow = -1;
- t_forg = 1; t_back = 2;
- clear = 0; color[4] = 0;
- break;
- case 1 : setega(); initgraf(grafx_mode,0,0);
- /* load up logo */
- strcpy(font,"sbo.sms");
- x = y = 140;
- break;
- case 2 : setvga(); initgraf(grafx_mode,0,0);
- /* load up logo */
- strcpy(font,"sbo.sms");
- x = y = 140;
- break;
- case 3 : setherc(1); initgraf(grafx_mode,0,0);
- /* load up logo */
- for (i = 1; i < 16; i++)
- color[i] = 1;
- t_forg = 1; t_back = 1;
- strcpy(font,"sbo.sms");
- x = y = 130; forg = 0; back = 1;
- shadow = -1; grafx_mode = 20;
- clear = 1; color[4] = 0;
- break;
- case 5 : /* Use VGA logo here */
- case 6 : setvga(); initgraf(18,0,0);
- /* load up logo */
- strcpy(font,"sbo.sms");
- x = y = 140;
- break;
-
- }
-
- eg_status(&stat); /* get status */
-
- /* set up max colors and sizes */
-
- max_x = stat.x_res-1;
- max_y = stat.y_res-1;
- max_colors = stat.avail_colors;
-
- /* init and load fonts */
-
- fontinit();
- font_load(0,font);
-
- /* Use mouse if available */
-
- if (m_instal() == -1 && dev < 4){
- mouse = 1;
- m_curon();
- m_curtyp(0);
- }
-
- clearscr(clear); /* clear the screen */
-
- /* set up strings for window function */
-
- strcpy(str[0],"You appear to have a");
- strcpy(str[1]," ");
- strcpy(str[2],cardtype);
- strcpy(str[3]," ");
- strcpy(str[4],"card in your computer");
- strcpy(str[5]," ");
- strcpy(str[6],"Enter 1 to reconfigure or");
- strcpy(str[7]," ");
- strcpy(str[8],"0 to run the demo in this mode :");
- for (i = 0; i < 9; i++)
- s[i] = str[i];
-
- switch(dev){
- case 0 : eg_window(4,0,"ibmrom",200,75,9,s,1,0,1);
- break;
- case 1 : eg_window(4,0,"sbo.sms",200,75,9,s,4,15,1);
- break;
- case 2 : eg_window(4,0,"sbo.sms",200,75,9,s,4,15,1);
- break;
- case 3 : eg_window(4,0,"sbo.sms",200,75,9,s,1,0,1);
- break;
- case 4 : eg_window(4,0,"sbo.sms",200,75,9,s,4,15,1);
- break;
- case 5 :
- case 6 : eg_window(4,0,"sbo.sms",200,75,9,s,4,15,1);
- break;
- }
- /* call our function to get a key without echo to screen */
-
- esgetkey(&reconfig);
-
- /* if key = '1', put a menu up to make a card selection */
-
- if (reconfig == 49){
- clearscr(clear);
- strcpy(selecs[0],"IBM CGA CARD");
- strcpy(selecs[1],"IBM EGA CARD");
- strcpy(selecs[2],"IBM VGA CARD");
- strcpy(selecs[3],"Hercules CARD");
- strcpy(selecs[4],"Paradise Professional Card");
- strcpy(selecs[5],"Video 7 Extended VGA Card");
- strcpy(selecs[6],"IBM 8514");
- for (i = 0; i < 7; i++)
- sels[i] = selecs[i];
- i = eg_smenu(0,7,sels,x,y,forg,back,shadow,4,1,"Select A Device",t_forg,t_back);
- if (i != -1)
- dev = i;
- switch(dev){
- case 0 : grafx_mode = 4; break;
- case 1 : grafx_mode = 16; break;
- case 2 : grafx_mode = 18; break;
- case 3 : grafx_mode = 20; break;
- case 4 : grafx_mode = 88; break;
- case 5 : grafx_mode = 98; break;
- case 6 : dev = 7; grafx_mode = 8514; break;
- case -1: break;
- }
- }
-
- /* reset colors */
-
- for (i = 0; i < 16; i++)
- color[i] = i;
-
- /* reset colors */
- forg = 1; back = 15; shadow = 3; clear = 11;
-
- switch(dev){
- case 0 : setibm();
- for (i = 1; i < 16; i++)
- color[i] = 1;
- strcpy(font,"micprint.sms");
- x = y = 2; cga_pal = 2; forg = 3; back = 2;
- shadow = -1; clear = 0; color[4] = 0;
- break;
- case 1 : setega(); strcpy(font,"sbo.sms"); x = y = 40; break;
- case 2 : setvga(); strcpy(font,"sbo.sms"); x = y = 40; break;
- case 3 : setherc(1);
- for (i = 1; i < 16; i++)
- color[i] = 1;
- strcpy(font,"sbo.sms");
- x = y = 30; forg = 0; back = 1; shadow = -1;
- grafx_mode = 20; clear = 1; color[4] = 0; break;
- case 4 : set_pvga(); strcpy(font,"sbo.sms"); x = y = 30; mouse = 0; break;
- case 5 : set_vid7(); strcpy(font,"sbo.sms"); x = y = 40; mouse = 0; break;
- case 6 : set_vid7(); strcpy(font,"roman3.sms"); x = y = 40; mouse = 0; break;
- case 7 : set8514(); strcpy(font,"roman3.sms"); x = y = 40; mouse = 0; break;
- }
- fontquit(); /* unload fonts */
-
- /* set up labels */
-
- hatch_init();
-
- /* set up menu choices */
-
- strcpy(selecs[0],"Lines");
- strcpy(selecs[1],"Arcs and circles");
- strcpy(selecs[2],"Rectangles");
- strcpy(selecs[3],"Bit mapped fonts");
- strcpy(selecs[4],"Vector fonts");
- strcpy(selecs[5],"2-D graphs");
- strcpy(selecs[6],"3-D bars");
- strcpy(selecs[7],"3-D pies");
- strcpy(selecs[8],"Animation");
- strcpy(selecs[9],"EXIT");
-
- for (i = 0; i < 10; i++)
- sels[i] = selecs[i];
-
- initgraf(grafx_mode,cga_pal,0);
- eg_status(&stat);
-
- max_x = stat.x_res-1;
- max_y = stat.y_res-1;
- max_colors = stat.avail_colors;
-
- selection = 0;
- if (m_instal() == -1 && dev < 4)
- mouse = 1;
-
- /* loop through till exit */
-
- while (selection != 10){
- clearscr(clear);
-
- /* display menu directions */
- strcpy(str[0],"Use the UP and DOWN arrow keys");
- strcpy(str[1],"or the mouse cursor to highlight");
- strcpy(str[2],"any selection in the menu.");
- strcpy(str[3],"HOME and END keys will bring you");
- strcpy(str[4],"to the top and bottom of the menu.");
- strcpy(str[5]," ");
- strcpy(str[6],"Hit RETURN or the left mouse button");
- strcpy(str[7],"to make a selection.");
- for (i = 0; i < 8; i++)
- s[i] = str[i];
-
- worldon(0);
- switch(dev){
- case 0 : strcpy(str[0],"Use the up and");
- strcpy(str[1],"down arrow keys");
- strcpy(str[2],"or the mouse");
- strcpy(str[3],"to move the");
- strcpy(str[4],"cursor thru the");
- strcpy(str[5],"menu. Home and");
- strcpy(str[6],"end keys will");
- strcpy(str[7],"bring you to");
- strcpy(str[8],"the top and");
- strcpy(str[9],"bottom of the");
- strcpy(str[10],"menu.");
- strcpy(str[11]," ");
- strcpy(str[12],"Hit return or");
- strcpy(str[13],"the left mouse");
- strcpy(str[14],"button to make");
- strcpy(str[15],"a selection.");
- for (i = 0; i < 16; i++)
- s[i] = str[i];
- eg_window(0,0,"ibmrom",190,35,16,s,3,1,0);
- break;
- case 1 : eg_window(4,0,"ega8x14",315,75,8,s,4,15,0);
- if (font_load(0,"roman3.sms")){
- initgraf(3,0,0);
- printf("Fonts not In Current Directory!!!\n");
- printf("Demo Cancelled!!!\n");
- exit(1);
- }
- fhatsay(0,"Essential",1,400,250);
- fhatsay(0," Graphics",1,400,280);
- fhatsay(0," Demo",1,400,310);
- font_unload(0);
- break;
- case 2 : eg_window(4,0,"vga8x16",150,300,8,s,4,15,0);
- if (font_load(0,"roman3.sms")){
- initgraf(3,0,0);
- printf("Fonts not In Current Directory!!!\n");
- printf("Demo Cancelled!!!\n");
- exit(1);
- }
- fhatsay(0,"Essential",1,375,100);
- fhatsay(0," Graphics",1,375,140);
- fhatsay(0," Demo",1,375,180);
- font_unload(0);
- break;
- case 3 : eg_window(4,0,"ibmrom",350,75,8,s,1,0,0); break;
- case 4 : strcpy(str[0],"Use the UP and DOWN arrow keys");
- strcpy(str[1],"to highlight any selection");
- strcpy(str[2],"in the menu.");
- strcpy(str[3],"HOME and END keys will bring you");
- strcpy(str[4],"to the top and bottom of the menu.");
- strcpy(str[5]," ");
- strcpy(str[6],"Hit RETURN to make a selection.");
- for (i = 0; i < 7; i++)
- s[i] = str[i];
- eg_window(4,0,"sbo.sms",210,450,7,s,4,15,0);
- if (font_load(0,"roman3.sms")){
- initgraf(3,0,0);
- printf("Fonts not In Current Directory!!!\n");
- printf("Demo Cancelled!!!\n");
- exit(1);
- }
- fhatsay(0,"Essential",1,575,150);
- fhatsay(0," Graphics",1,575,190);
- fhatsay(0," Demo",1,575,230);
- font_unload(0);
- break;
- case 5 : strcpy(str[0],"Use the UP and DOWN arrow keys");
- strcpy(str[1],"to highlight any selection");
- strcpy(str[2],"in the menu.");
- strcpy(str[3],"HOME and END keys will bring you");
- strcpy(str[4],"to the top and bottom of the menu.");
- strcpy(str[5]," ");
- strcpy(str[6],"Hit RETURN to make a selection.");
- for (i = 0; i < 7; i++)
- s[i] = str[i];
- eg_window(2,0,"sbo.sms",210,450,7,s,4,15,0);
- if (font_load(0,"roman3.sms")){
- initgraf(3,0,0);
- printf("Fonts not In Current Directory!!!\n");
- printf("Demo Cancelled!!!\n");
- exit(1);
- }
- fhatsay(0,"Essential",1,575,150);
- fhatsay(0," Graphics",1,575,190);
- fhatsay(0," Demo",1,575,230);
- font_unload(0);
- break;
- case 6 :
- case 7 :
- strcpy(str[0],"Use the UP and DOWN arrow keys");
- strcpy(str[1],"to highlight any selection");
- strcpy(str[2],"in the menu.");
- strcpy(str[3],"HOME and END keys will bring you");
- strcpy(str[4],"to the top and bottom of the menu.");
- strcpy(str[5]," ");
- strcpy(str[6],"Hit RETURN to make a selection.");
- for (i = 0; i < 7; i++)
- s[i] = str[i];
- eg_window(4,0,"roman3.sms",90,530,7,s,4,15,0);
- if (font_load(0,"roman3.sms")){
- initgraf(3,0,0);
- printf("Fonts not In Current Directory!!!\n");
- printf("Demo Cancelled!!!\n");
- exit(1);
- }
- fhatsay(0,"Essential",1,775,150);
- fhatsay(0," Graphics",1,775,190);
- fhatsay(0," Demo",1,775,230);
- font_unload(0);
- break;
- }
- fontinit();
- font_load(0,font);
- if (mouse){
- m_curon();
- m_curtyp(0);
- }
- selection = eg_smenu(0,10,sels,x,y,forg,back,shadow,4,0,"",0,0);
- if (mouse)
- m_curoff();
- fontquit();
-
- /* call the appropiate demo function */
- switch(selection){
- case -1 : initgraf(3,0,0);
- exit(0);
- case 0 : dots_and_lines(); break;
- case 1 : arcs_and_circles(); break;
- case 2 : rectangles(); break;
- case 3 : bit_mapped_fonts(); break;
- case 4 : vector_fonts(); break;
- case 5 : two_d_grafs(); break;
- case 6 : three_d_bars(); break;
- case 7 : three_d_pies(); break;
- case 8 : animation(); break;
- case 9 : initgraf(3,0,0);
- exit(0);
- }
- }
- }
-
- /* draw some dot and line patterns */
-
- dots_and_lines(){
-
- int key;
- int j,k,l,m,jump,max;
- int x,y,color,inc;
- int xinc,yinc,moveinc;
- int xo,yo,i,startx,starty;
-
- /* set up the window */
-
- strcpy(str[0],"Essential Graphics' low level");
- strcpy(str[1],"functions are the fastest around.");
- strcpy(str[2],"So if speed is a prime factor in");
- strcpy(str[3],"your graphics, check us out !!!");
- strcpy(str[4]," ");
- strcpy(str[5],"Hit any key to continue.");
- for (i = 0; i < 6; i++)
- s[i] = str[i];
-
- clearscr(0);
-
- switch(dev){
- case 0 : eg_window(4,1,"ibmrom",200,75,6,s,1,0,1);
- break;
- case 1 : eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
- break;
- case 2 : eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
- break;
- case 3 : eg_window(4,1,"sbo.sms",200,75,6,s,1,0,1);
- break;
- case 4 : eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
- break;
- case 5 : eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
- break;
- case 6 :
- case 7 : eg_window(4,1,"roman3.sms",200,75,6,s,4,15,1);
- break;
- }
- clearscr(0);
-
- /* set up defaults */
-
- moveinc = 0; inc = 5; startx = max_x/4; starty = max_y/5;
- switch(dev){
- case 0 : xinc = 5; yinc = 3; break;
- case 1 : xinc = 7; yinc = 5; break;
- case 2 : xinc = 7; yinc = 7; break;
- case 3 : xinc = 7; yinc = 5; break;
- case 4 :
- case 5 :
- case 6 :
- case 7 : xinc = 12; yinc = 9; break;
- }
-
- for (color = 1; color < 16; color++,moveinc += inc){
- if (inkey(&k) != -1) break;
- if (moveinc > max_x || moveinc > max_y) moveinc = 0;
- for (x = startx+moveinc; x < max_x-startx-moveinc; x += xinc){
- eg_line(max_x/2,max_y/2,x,starty+moveinc,color%max_colors);
- if (inkey(&k) != -1) break;
- }
- for (y = starty+moveinc; y < max_y-starty-moveinc; y += yinc){
- eg_line(max_x/2,max_y/2,max_x-startx-moveinc,y,color%max_colors);
- if (inkey(&k) != -1) break;
- }
- for (x = max_x-startx-moveinc; x > startx+moveinc; x -= xinc){
- eg_line(max_x/2,max_y/2,x,max_y-starty-moveinc,color%max_colors);
- if (inkey(&k) != -1) break;
- }
- for (y = max_y-starty-moveinc; y > starty+moveinc; y -= yinc){
- eg_line(max_x/2,max_y/2,startx+moveinc,y,color%max_colors);
- if (inkey(&k) != -1) break;
- }
- }
-
- /* set up defaults */
- moveinc = 35; inc = 0; y = max_y-1; x = 0;
- clearscr(0);
- for (color = 1; color < 16; color++,moveinc += 20){
- if (inkey(&k) != -1) break;
- if (moveinc > max_x || moveinc > max_y) moveinc = 35;
- for (x = 0; x < max_x; x += xinc){
- eg_line(max_x/2,max_y/2,x,0+moveinc,color%max_colors);
- if (inkey(&k) != -1) break;
- }
- for (y = 0; y < max_y; y += yinc){
- eg_line(max_x/2,max_y/2,max_x-1-moveinc,y,color%max_colors);
- if (inkey(&k) != -1) break;
- }
- for (x = max_x-1; x >= 0; x -= xinc){
- eg_line(max_x/2,max_y/2,x,max_y-1-moveinc,color%max_colors);
- if (inkey(&k) != -1) break;
- }
- for (y = max_y-1; y >= 0; y -= yinc){
- eg_line(max_x/2,max_y/2,0+moveinc,y,color%max_colors);
- if (inkey(&k) != -1) break;
- }
- }
-
- /* set up the window */
-
- strcpy(str[0],"Hit Return at any time");
- strcpy(str[1],"to move to the next");
- strcpy(str[2],"screen.");
- for (i = 0; i < 3; i++)
- s[i] = str[i];
-
- switch(dev){
- case 0 : eg_window(4,1,"ibmrom",200,75,3,s,3,2,1);
- break;
- case 1 : eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
- break;
- case 2 : eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
- break;
- case 3 : eg_window(4,1,"sbo.sms",200,75,3,s,1,0,1);
- break;
- case 4 : eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
- break;
- case 5 : eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
- break;
- case 6 :
- case 7 : eg_window(4,1,"roman3.sms",200,75,3,s,4,15,1);
- break;
- }
- }
-
-
- arcs_and_circles(){
-
- int key;
- int radius;
- int x,y,i;
-
- hatch_init();
-
- /* set up the window */
-
- strcpy(str[0],"Arcs and circles can be drawn in");
- strcpy(str[1],"any color, size or angle. Hatch");
- strcpy(str[2],"styles or solids may be used");
- strcpy(str[3],"to fill the arcs.");
- strcpy(str[4]," ");
- strcpy(str[5],"Hit any key to continue.");
- strcpy(str[6],"or change screens.");
- for (i = 0; i < 7; i++)
- s[i] = str[i];
-
- clearscr(0);
- switch(dev){
- case 0 : eg_window(4,1,"ibmrom",200,75,7,s,1,0,1);
- break;
- case 1 : eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
- break;
- case 2 : eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
- break;
- case 3 : eg_window(4,1,"sbo.sms",200,75,7,s,1,0,1);
- break;
- case 4 : eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
- break;
- case 5 : eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
- break;
- case 6 :
- case 7 : eg_window(4,1,"roman3.sms",200,75,7,s,4,15,1);
- break;
- }
-
- radius = max_y/20; x = max_x - max_x/7; y = max_y - max_y/7;
-
- clearscr(0);
- while (inkey(&key) == -1){
- eg_arc(rand()%x+(radius+10),rand()%y+(radius+10),1+rand()%radius,rand()%max_colors,rand()%180,180+(rand()%180),rand()%2,-1);
- eg_circle(rand()%x+(radius+10),rand()%y+(radius+10),1+rand()%radius,rand()%max_colors,rand()%2);
- }
- clearscr(0);
- while (inkey(&key) == -1)
- eg_arc(rand()%x+(radius+10),rand()%y+(radius+10),1+rand()%radius,rand()%max_colors,rand()%180,180+(rand()%180),0,rand()%4);
- }
-
-
-
- rectangles(){
-
- int x,y,i,key,c;
- int xsize,ysize;
-
- xsize = max_x/5; ysize = max_y/5;
-
- hatch_init();
- /* set up the window */
- strcpy(str[0],"Rectangles and boxes can be drawn");
- strcpy(str[1],"in any color or size.");
- strcpy(str[2],"Hatch styles or solids may");
- strcpy(str[3],"be used for filling.");
- strcpy(str[4]," ");
- strcpy(str[5],"Hit any key to continue.");
- strcpy(str[6],"or change screens.");
- for (i = 0; i < 7; i++)
- s[i] = str[i];
-
- clearscr(0);
- switch(dev){
- case 0 : eg_window(4,1,"ibmrom",200,75,7,s,3,2,1);
- break;
- case 1 : eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
- break;
- case 2 : eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
- break;
- case 3 : eg_window(4,1,"sbo.sms",200,75,7,s,1,0,1);
- break;
- case 4 : eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
- break;
- case 5 : eg_window(4,1,"sbo.sms",200,75,7,s,4,15,1);
- break;
- case 6 :
- case 7 : eg_window(4,1,"roman3.sms",200,75,7,s,4,15,1);
- break;
- }
-
- clearscr(0);
- while(inkey(&key) == -1){
- x = rand()%(max_x-xsize);
- y = rand()%(max_y-ysize);
- eg_rectangle(x,y,x+rand()%xsize,y+rand()%ysize,rand()%max_colors,0,-1);
- }
- clearscr(0);
- while(inkey(&key) == -1){
- x = rand()%(max_x-xsize);
- y = rand()%(max_y-ysize);
- eg_rectangle(x,y,x+rand()%xsize,y+rand()%ysize,rand()%max_colors,1,-1);
- }
- clearscr(0);
- while(inkey(&key) == -1){
- x = rand()%(max_x-xsize);
- y = rand()%(max_y-ysize);
- eg_rectangle(x,y,x+rand()%xsize,y+rand()%ysize,rand()%max_colors,rand()%2,rand()%4);
- }
- }
-
- bit_mapped_fonts()
- {
- char chr,strgpt[10];
- int x_loc,y_loc,font,x,y,key,pixels,i;
- int c,h,ch,lf,vsize,hsize,baseline;
-
- fontinit();
- /* load up all fonts */
- if (font_load(0,"ibmrom")){
- printf("Error loading fonts!!!\n");
- exit(0);
- }
- if (font_load(1,"sbo.sms")){
- printf("Error loading fonts!!!\n");
- exit(0);
- }
- if (dev != 3){
- if (font_load(2,"ega8x14")){
- printf("Error loading fonts!!!\n");
- exit(0);
- }
- }
- else{
- if (font_load(2,"mono.sms")){
- printf("Error loading fonts!!!\n");
- exit(0);
- }
- }
- if (font_load(3,"roman3.sms")){
- printf("Error loading fonts!!!\n");
- exit(0);
- }
- if (font_load(4,"moon.sms")){
- printf("Error loading fonts!!!\n");
- exit(0);
- }
- if (font_load(5,"sboi.sms")){
- printf("Error loading fonts!!!\n");
- exit(0);
- }
- if (font_load(6,"script1.sms")){
- printf("Error loading fonts!!!\n");
- exit(0);
- }
-
- clipsize(0,0,max_x,max_y+1);
- clipon();
-
- /* set up the window */
- strcpy(str[0],"Essential Graphic's comes complete");
- strcpy(str[1],"with 10 bit mapped fonts. Hundreds");
- strcpy(str[2],"more are also available thru third");
- strcpy(str[3],"party vendors.");
- strcpy(str[4]," ");
- strcpy(str[5],"Hit any key to change screens.");
- strcpy(str[6]," ");
- strcpy(str[7],"Let's look at some !");
- for (i = 0; i < 8; i++)
- s[i] = str[i];
-
- clearscr(color[0]);
- switch(dev){
- case 0 : eg_window(3,1,"ibmrom",200,75,8,s,2,3,1);
- color[4] = 2; color[15] = 3;
- break;
- case 1 : eg_window(4,1,"sbo.sms",200,75,8,s,15,1,1);
- break;
- case 2 : eg_window(4,1,"sbo.sms",200,75,8,s,15,1,1);
- break;
- case 3 : eg_window(4,1,"sbo.sms",200,75,8,s,1,0,1);
- break;
- case 4 : eg_window(4,1,"sbo.sms",200,75,8,s,15,1,1);
- break;
- case 5 : eg_window(4,1,"sbo.sms",200,75,8,s,15,1,1);
- break;
- case 6 :
- case 7 : eg_window(4,1,"roman3.sms",200,75,8,s,4,15,1);
- break;
- }
-
- clearscr(color[4]);
- /* display random font strings */
- while (inkey(&key) == -1){
- x_loc = rand()%max_x;
- y_loc = rand()%max_y;
- font = rand()%7;
- if (font != 4)
- pixels = fontpixn(font,"A graphics text string.",0,23);
- else
- pixels = fontpixn(font,"Large text string.",0,18);
-
- font_info(font,&c,&h,&ch,&lf,&vsize,&hsize,&baseline);
-
- if (pixels+x_loc >= max_x) x_loc = max_x - pixels;
- if (vsize+y_loc >= max_y) y_loc = max_y - vsize;
- if (y_loc -vsize <= 0) y_loc = 0 + vsize;
-
- if (font != 4){
- fhatsay(font,"A graphics text string.",color[15],x_loc,y_loc);
- syspause(0,0,0,20);
- }
- else{
- fhatsay(font,"Large text string.",color[15],x_loc,y_loc);
- syspause(0,0,0,20);
- }
-
- if (font != 4){
- fhatsay(font,"A graphics text string.",color[4],x_loc,y_loc);
- syspause(0,0,0,20);
- }
- else{
- fhatsay(font,"Large text string.",color[4],x_loc,y_loc);
- syspause(0,0,0,20);
- }
- }
-
- /* display a full screen of all font characters */
-
- for (font = 0; font < 7; font++){
- clearscr(color[4]);
- font_info(font,&c,&h,&ch,&lf,&vsize,&hsize,&baseline);
- chr = 33;
- for (y_loc = vsize*2; y_loc <= max_y; y_loc += vsize+5){
- fcurloc(hsize,y_loc); x = hsize;
- while (x+hsize < max_x){
- fcurch(font,chr,0,color[15],0);
- fcurget(&x,&y);
- chr++;
- if (chr >= 100) chr = 33;
- }
- }
- strcpy(str[0],"Font size = ");
- egitoa(strgpt,hsize);
- strcat(str[0],strgpt);
- strcat(str[0]," x ");
- egitoa(strgpt,vsize);
- strcat(str[0],strgpt);
- strcpy(str[1]," ");
- strcpy(str[2],"Hit Return at any time");
- strcpy(str[3],"to move to the next");
- strcpy(str[4],"screen.");
- for (i = 0; i < 5; i++)
- s[i] = str[i];
-
- switch(dev){
- case 0 : eg_window(4,1,"ibmrom",200,75,5,s,3,1,1);
- break;
- case 1 : eg_window(4,1,"sbo.sms",200,75,5,s,15,1,1);
- break;
- case 2 : eg_window(4,1,"sbo.sms",200,75,5,s,15,1,1);
- break;
- case 3 : eg_window(4,1,"sbo.sms",200,75,5,s,1,0,1);
- break;
- case 4 : eg_window(4,1,"sbo.sms",200,75,5,s,15,1,1);
- break;
- case 5 : eg_window(4,1,"sbo.sms",200,75,5,s,15,1,1);
- break;
- case 6 :
- case 7 : eg_window(4,1,"roman3.sms",200,75,5,s,15,1,1);
- break;
- }
- }
- fontquit();
- }
-
- vector_fonts()
- {
- int recs,j,i,col,row,descender,w,h,base_line,desc;
- double size,start;
- char ptr[1000],t[80],font[80];
- struct vfont *fk;
- int height,width;
- double f,ff;
- char strgpt[20];
-
- /* load up a font */
- fk = vfontld("s2ur.vec",&j);
- if (j < 0){
- printf("\r\nvfontld return:%d\r\n",j);
- exit(0);
- }
-
- /* set up scaling factor */
-
- start = .8;
- switch(dev){
- case 0 : start = .35; break;
- case 4 :
- case 5 :
- case 6 :
- case 7 : start = 1.0; break;
- }
-
- strcpy(str[0],"Essential Graphic's comes complete");
- strcpy(str[1],"with 10 vector based fonts. Unlike");
- strcpy(str[2],"bit mapped fonts, these fonts are");
- strcpy(str[3],"scalable and rotatable.");
- strcpy(str[4]," ");
- strcpy(str[5],"Let's look at some !");
- for (i = 0; i < 6; i++)
- s[i] = str[i];
-
- clearscr(0);
- switch(dev){
- case 0 : eg_window(2,1,"ibmrom",200,75,6,s,3,2,1);
- color[15] = 3; color[14] = 2;
- break;
- case 1 : eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
- break;
- case 2 : eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
- break;
- case 3 : eg_window(4,1,"sbo.sms",200,75,6,s,1,0,1);
- break;
- case 4 : eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
- break;
- case 5 : eg_window(4,1,"sbo.sms",200,75,6,s,4,15,1);
- break;
- case 6 :
- case 7 : eg_window(4,1,"roman3.sms",200,75,6,s,4,15,1);
- break;
- }
-
- descender = j = 0;
- recs = vfchset(fk,ptr);
- while(j < recs){
- vfchinf(fk,ptr[j],&w,&h,&base_line);
- if (base_line > descender)
- descender = base_line;
- j++;
- }
- desc = descender;
-
- sprintf(t,"==>%%.%ds<==\r\n",recs);
- for (size = (double)start; size <= (double)start*3.0; size += (double)start){
- descender = desc;
- vfscale(fk,(double)size);
- f = descender * size + .5;
- descender = f;
- f = fk->maxhigh * size + .5;
- height = f;
- f = fk->maxwidth * size + .5;
- width = f;
- j = 0;
- while(j < recs){
- row = height + 1;
- clearscr(0);
- while(j < recs){
- col = 10;
- eg_line(0,row,max_x-1,row,color[14]);
- while(j < recs){
- i = vfontch(fk,ptr[j],col,row,color[15],0,&col,&row);
- if (i == -1){
- initgraf(3,0,0);
- printf("return error of %d on vfontch\r\n",i);
- exit(0);
- }
- ++j;
- if(col+width+1 > max_x-1) break;
- }
- row += height + 1 + descender;
- if(row + descender > max_y-1) break;
- }
- putch(7);
-
- strcpy(str[0],"Scaled size = ");
- sprintf(strgpt,"%1.3f\n",size);
- strgpt[strlen(strgpt)-1] = '\0';
- strcat(str[0],strgpt);
- strcpy(str[1]," ");
- strcpy(str[2],"Hit Return at any time");
- strcpy(str[3],"to move to the next");
- strcpy(str[4],"screen.");
- for (i = 0; i < 5; i++)
- s[i] = str[i];
-
- switch(dev){
- case 0 : eg_window(4,1,"ibmrom",200,75,5,s,3,2,1);
- break;
- case 1 : eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
- break;
- case 2 : eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
- break;
- case 3 : eg_window(4,1,"sbo.sms",200,75,5,s,1,0,1);
- break;
- case 4 : eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
- break;
- case 5 : eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
- break;
- case 6 :
- case 7 : eg_window(4,1,"roman3.sms",200,75,5,s,4,15,1);
- break;
- }
- }
- }
-
- /* rotate a string */
-
- clearscr(0);
- strcpy(ptr,"ABCDE");
- eg_line(max_x/2,max_y/2-10,max_x/2,max_y/2+10,color[14]);
- eg_line(max_x/2-20,max_y/2,max_x/2+20,max_y/2,color[14]);
- for (size = (double)start; size <= (double)start*4.0; size += (double)start){
- vfscale(fk,(double)size);
- for(j = 0; j < 360; j += 60){
- if (dev ==3)
- vfsprtc(fk,ptr,max_x/2,max_y/2,1,j);
- else
- vfsprtc(fk,ptr,max_x/2,max_y/2,rand()%(max_colors-1)+1,j);
- }
- }
- vfontuld(fk);
- strcpy(str[0],"Hit Return at any time");
- strcpy(str[1],"to move to the next");
- strcpy(str[2],"screen.");
- for (i = 0; i < 3; i++)
- s[i] = str[i];
-
- switch(dev){
- case 0 : eg_window(4,1,"ibmrom",200,75,3,s,3,2,1);
- break;
- case 1 : eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
- break;
- case 2 : eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
- break;
- case 3 : eg_window(4,1,"sbo.sms",200,75,3,s,1,0,1);
- break;
- case 4 : eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
- break;
- case 5 : eg_window(4,1,"sbo.sms",200,75,3,s,4,15,1);
- break;
- case 6 :
- case 7 : eg_window(4,1,"roman3.sms",200,75,3,s,4,15,1);
- break;
- }
- }
-
-
- two_d_grafs()
- {
- int pts1[20],pts2[20],pts3[20],pts4[20]; /* arrays of points */
- int j,i,key,graph,w;
- int numpts; /* number of points to graph */
- int scatter[50][2]; /* array of scatter points */
- int hilow[20][3]; /* array of hi-low-close points */
- int stack[20][3]; /* array of stack bar points */
- char colors[10]; /* colors */
- char labels[20][30],*l[20]; /* labels */
- char title[50]; /* title string */
- char x_descrip_label[20]; /* description labels */
- char y_descrip_label[20];
- GRAPH_INFO gg; /* structures for graphs */
- EG_AXIS x_axis,y_axis;
-
- /* symbol functions */
- extern int symbol_x();
- extern int symbol_box();
- extern int symbol_circle();
- extern int symbol_star();
- extern int symbol_tri();
- extern int symbol_plus();
- extern int symbol_diamd();
-
- /* initialize data for the graphs */
-
- pts1[0] = 10; pts1[1] = 7; pts1[2] = 80; pts1[3] = 70; pts1[4] = 60;
- pts1[5] = 50; pts1[6] = 6; pts1[7] = 99; pts1[8] = 65; pts1[9] = 60;
- pts1[10] = 60; pts1[11] = 44; pts1[12] = 3; pts1[13] = 10;
- pts1[14] = 44; pts1[15] = 11;
-
- pts2[0] = 5; pts2[1] = 11; pts2[2] = 20; pts2[3] = 30;
- pts2[4] = 40; pts2[5] = 40; pts2[6] = 60; pts2[7] = 65;
- pts2[8] = 70; pts2[9] = 80; pts2[10] = 81; pts2[11] = 85;
- pts2[12] = 90; pts2[13] = 93; pts2[14] = 94; pts2[15] = 97;
-
- pts3[0] = 12; pts3[1] = 44; pts3[2] = 32; pts3[3] = 45;
- pts3[4] = 65; pts3[5] = 70; pts3[6] = 75; pts3[7] = 80;
- pts3[8] = 70; pts3[9] = 60; pts3[10] = 51; pts3[11] = 45;
- pts3[12] = 30; pts3[13] = 23; pts3[14] = 14; pts3[15] = 7;
-
- pts4[0] = 80; pts4[1] = 80; pts4[2] = 70; pts4[3] = 70;
- pts4[4] = 60; pts4[5] = 60; pts4[6] = 50; pts4[7] = 50;
- pts4[8] = 40; pts4[9] = 30; pts4[10] = 20; pts4[11] = 75;
-
- stack[0][0] = 30; stack[0][1] = 20; stack[0][2] = 10;
- stack[1][0] = 60; stack[1][1] = 20; stack[1][2] = 10;
- stack[2][0] = 10; stack[2][1] = 8; stack[2][2] = 6;
- stack[3][0] = 60; stack[3][1] = 40; stack[3][2] = 8;
- stack[4][0] = 15; stack[4][1] = 40; stack[4][2] = 20;
- stack[5][0] = 30; stack[5][1] = 45; stack[5][2] = 22;
- stack[6][0] = 11; stack[6][1] = 22; stack[6][2] = 33;
- stack[7][0] = 10; stack[7][1] = 68; stack[7][2] = 6;
- stack[8][0] = 20; stack[8][1] = 40; stack[8][2] = 20;
- stack[9][0] = 30; stack[9][1] = 30; stack[9][2] = 30;
- stack[10][0] = 10; stack[10][1] = 10; stack[10][2] = 5;
- stack[11][0] = 70; stack[11][1] = 11; stack[11][2] = 15;
-
- hilow[0][0] = 30; hilow[0][1] = 20; hilow[0][2] = 30;
- hilow[1][0] = 90; hilow[1][1] = 50; hilow[1][2] = 70;
- hilow[2][0] = 10; hilow[2][1] = 8; hilow[2][2] = 9;
- hilow[3][0] = 90; hilow[3][1] = 40; hilow[3][2] = 50;
- hilow[4][0] = 100; hilow[4][1] = 10; hilow[4][2] = 20;
- hilow[5][0] = 90; hilow[5][1] = 45; hilow[5][2] = 62;
- hilow[6][0] = 54; hilow[6][1] = 24; hilow[6][2] = 34;
- hilow[7][0] = 97; hilow[7][1] = 68; hilow[7][2] = 76;
- hilow[8][0] = 70; hilow[8][1] = 40; hilow[8][2] = 60;
- hilow[9][0] = 60; hilow[9][1] = 40; hilow[9][2] = 50;
- hilow[10][0] = 90; hilow[10][1] = 10; hilow[10][2] = 20;
- hilow[11][0] = 40; hilow[11][1] = 12; hilow[11][2] = 30;
- hilow[12][0] = 50; hilow[12][1] = 34; hilow[12][2] = 41;
- hilow[13][0] = 75; hilow[13][1] = 56; hilow[13][2] = 63;
- hilow[14][0] = 33; hilow[14][1] = 5; hilow[14][2] = 21;
- hilow[15][0] = 106; hilow[15][1] = 40; hilow[15][2] = 70;
- hilow[16][0] = 87; hilow[16][1] = 34; hilow[16][2] = 50;
- hilow[17][0] = 21; hilow[17][1] = 12; hilow[17][2] = 17;
- hilow[18][0] = 44; hilow[18][1] = 23; hilow[18][2] = 31;
- hilow[19][0] = 56; hilow[19][1] = 10; hilow[19][2] = 34;
-
- /* set up labels, small for CGA */
-
- if (dev > 1){
- strcpy(labels[0],"January"); strcpy(labels[1],"February");
- strcpy(labels[2],"March"); strcpy(labels[3],"April");
- strcpy(labels[4],"May"); strcpy(labels[5],"June");
- strcpy(labels[6],"July"); strcpy(labels[7],"August");
- strcpy(labels[8],"September");strcpy(labels[9],"October");
- strcpy(labels[10],"November");strcpy(labels[11],"December");
- strcpy(labels[12],"January"); strcpy(labels[13],"February");
- strcpy(labels[14],"March");
- }
- else{
- strcpy(labels[0],"Jan"); strcpy(labels[1],"Feb");
- strcpy(labels[2],"Mar"); strcpy(labels[3],"Apr");
- strcpy(labels[4],"May"); strcpy(labels[5],"Jun");
- strcpy(labels[6],"Jul"); strcpy(labels[7],"Aug");
- strcpy(labels[8],"Sep"); strcpy(labels[9],"Oct");
- strcpy(labels[10],"Nov"); strcpy(labels[11],"Dec");
- strcpy(labels[12],"Jan"); strcpy(labels[13],"Feb");
- strcpy(labels[14],"Mar");
- }
-
- /* init for fonts */
-
- fontinit();
-
- /* font for axis labels */
- if (font_load(0,"ibmrom")){
- printf("IBMROM font not available !!!\n");
- exit(0);
- }
- if (font_load(1,"vga8x16")){
- printf("VGA8X16 font not available !!!\n");
- exit(0);
- }
- if (font_load(2,"roman3.sms")){
- printf("ROMAN3.ESI font not available !!!\n");
- exit(0);
- }
- if (font_load(3,"ega8x14")){
- printf("ega8x14 font not available !!!\n");
- exit(0);
- }
- if (font_load(4,"sbo.sms")){
- printf("SBO.ESI font not available !!!\n");
- exit(0);
- }
- if (font_load(5,"micprint.sms")){
- printf("IBMROM font not available !!!\n");
- exit(0);
- }
-
- font_change(0,-1,-1,-1,0,-1); /* change the font spacing */
-
- /* set up general graph info */
-
- gg.title_loc = TOP; /* title at top */
- gg.bar_mid_value = -1;
- gg.bar_type = 0; /* default bar type to 0 */
- gg.frame_back = color[7]; /* frame background is color 7 */
- gg.frame_color = color[15]; /* frame color is color 15 */
- gg.frame_width = 1;
- gg.frame_style = 0xffff;
- gg.title_gap = -1;
- x_axis.axis_gap = -1;
- y_axis.axis_gap = -1;
- gg.line_width = 3;
- gg.title_color = color[15];
- gg.symbol_fill = 1; /* default to filled symbols */
- gg.symbol_size = -1;
- gg.item_color = color[1];
- gg.symbol_color = color[2];
- numpts = 12; /* number of points = 12 */
-
- /* set up Axis description labels */
-
- strcpy(x_descrip_label,"Months For 1989");
- strcpy(y_descrip_label,"Gross Profits");
-
- /* set up X axis */
-
- x_axis.label_type = MANUAL_SET;
- x_axis.axis_width = 1;
- x_axis.axis_style = 0xffff;
- x_axis.label_color = color[15];
- x_axis.descrip_color = color[4];
- x_axis.grid_color = color[1];
- x_axis.tick_gap = -1;
- x_axis.tick_size = -1;
- x_axis.grid_width = 1;
- x_axis.num_labels = 12;
- x_axis.num_grids = 11;
- x_axis.grid_style = 0xffff;
- x_axis.num_ticks = 11;
- x_axis.tick_color = color[15];
-
- /* set up Y axis */
-
- y_axis.label_type = AUTO_SET;
- y_axis.axis_width = 1;
- y_axis.axis_style = 0xffff;
- y_axis.label_color = color[14];
- y_axis.descrip_color = color[1];
- y_axis.grid_color = color[2];
- y_axis.tick_gap = -1;
- y_axis.tick_size = -1;
- y_axis.grid_width = 1;
- y_axis.grid_style = 0xffff;
- y_axis.num_labels = 11;
- y_axis.num_grids = 10;
- y_axis.num_ticks = 10;
- y_axis.tick_color = color[15];
-
- /* set up label pointers */
-
- for (i = 0; i < numpts; i++)
- l[i] = labels[i];
- x_axis.labels = l;
- y_axis.labels = l;
-
- /* graph 9 items */
-
- for (graph = 0; graph < 9; graph++){
- clearscr(0);
-
- gg.line_graph_type = LINE_AND_SYMBOL;
-
- /* set up pointers to labels */
- x_axis.descrip_label = x_descrip_label;
- y_axis.descrip_label = y_descrip_label;
- gg.title_label = title;
-
- /* set up items specific to cards */
-
- switch(dev){
- case 0 : color[4] = 2; color[5] = 3; color[15] = 3;
- color[9] = 1; color[10] = 2; color[11] = 3;
- color[13] = 2;
- x_axis.grid_color = gg.title_color = 3;
- x_axis.label_color = x_axis.tick_color = 3;
- y_axis.label_color = y_axis.tick_color = 3;
- x_axis.descrip_color = y_axis.descrip_color = 3;
- gg.frame_back = color[0];
- gg.frame_color = 3;
- x_axis.grid_color = y_axis.grid_color = color[3];
- /* use the ibmrom font for labels */
- x_axis.descrip_font = y_axis.descrip_font = 0;
- x_axis.axis_font = y_axis.axis_font = 5;
- gg.title_font = 0;
- x_axis.axis_font = 0; y_axis.axis_font = 0;
- gg.line_width = 1;
- gg.title_color = color[3];
- gg.item_color = color[2]; gg.symbol_color = color[3];
- color_hatch();
- break;
- case 1 : color_hatch();
- x_axis.descrip_font = y_axis.descrip_font = 0;
- x_axis.axis_font = y_axis.axis_font = 4;
- /* use the rman3.sms font for the title */
- gg.title_font = 2;
- gg.bar_mid_width = 2;
- break;
- case 2 : gg.bar_mid_width = 3;
- color_hatch();
- x_axis.descrip_font = y_axis.descrip_font = 4;
- x_axis.axis_font = y_axis.axis_font = 1;
- gg.title_font = 2;
- break;
- case 3 : color[1] = color[2] = color[3] = color[4] = color[5] = 1;
- x_axis.descrip_color = x_axis.tick_color = color[1];
- y_axis.descrip_color = y_axis.tick_color = color[1];
- x_axis.label_color = y_axis.label_color = color[1];
- gg.frame_back = color[0];
- gg.frame_color = color[1];
- x_axis.grid_color = y_axis.grid_color = color[1];
- x_axis.descrip_font = y_axis.descrip_font = 4;
- x_axis.axis_font = y_axis.axis_font = 0;
- gg.title_font = 2;
- gg.line_width = 1;
- gg.title_color = x_axis.tick_color = color[1];
- y_axis.tick_color = color[1];
- gg.item_color = gg.symbol_color = color[1];
- mono_hatch();
- gg.bar_mid_width = 3;
- break;
- case 4 : gg.line_width = 5;
- gg.bar_mid_width = 5;
- x_axis.descrip_font = y_axis.descrip_font = 4;
- x_axis.axis_font = y_axis.axis_font = 1;
- /* use the rman3.sms font for the title */
- gg.title_font = 2;
- color_hatch();
- break;
- case 5 : gg.line_width = 5;
- gg.bar_mid_width = 5;
- x_axis.descrip_font = y_axis.descrip_font = 4;
- x_axis.axis_font = y_axis.axis_font = 1;
- gg.title_font = 2;
- color_hatch();
- break;
- case 6 :
- case 7 : gg.line_width = 6;
- x_axis.descrip_font = y_axis.descrip_font = 4;
- x_axis.axis_font = y_axis.axis_font = 1;
- /* use the rman3.sms font for the title */
- gg.title_font = 2;
- gg.bar_mid_width = 5;
- color_hatch();
- break;
- }
-
- /* use the whole screen as a viewport */
-
- setview(0,0,max_x,max_y);
-
- /* draw a graph */
-
- switch(graph){
- case 0 : gg.graph_type = LINE_GRAPH;
- gg.line_style = 0xffff;
- gg.adjust_edges = 0;
- x_axis.low = 0; x_axis.high = numpts;
- y_axis.low = 0; y_axis.high = 110;
- gg.line_width = -1;
- gg.frame_type = FULL_FRAME;
- strcpy(title,"Non-Centered Line Graph");
- gg.item_color = color[2]; gg.symbol_color = color[15];
- set_graf_symbol(symbol_circle);
- eg_graph(numpts,pts1,WHOLE_GRAPH,gg,x_axis,y_axis);
- gg.item_color = color[3]; gg.symbol_color = color[15];
- set_graf_symbol(symbol_tri);
- eg_graph(numpts,pts2,DATA_ONLY,gg,x_axis,y_axis);
- gg.item_color = color[4]; gg.symbol_color = color[15];
- set_graf_symbol(symbol_box);
- eg_graph(numpts,pts3,DATA_ONLY,gg,x_axis,y_axis);
- gg.item_color = color[5]; gg.symbol_color = color[15];
- set_graf_symbol(symbol_diamd);
- eg_graph(numpts,pts4,DATA_ONLY,gg,x_axis,y_axis);
- twod_win(200,75);
- break;
- case 1 : gg.graph_type = LINE_GRAPH; gg.adjust_edges = 1;
- gg.line_style = 0xffff;
- gg.line_width = 3;
- x_axis.low = 0; x_axis.high = numpts;
- y_axis.low = 0; y_axis.high = 110;
- gg.frame_type = HALF_FRAME;
- strcpy(title,"Centered Line Graph");
- gg.item_color = color[2]; gg.symbol_color = color[15];
- set_graf_symbol(symbol_x);
- eg_graph(numpts,pts1,WHOLE_GRAPH,gg,x_axis,y_axis);
- gg.item_color = color[3]; gg.symbol_color = color[15];
- set_graf_symbol(symbol_star);
- eg_graph(numpts,pts2,DATA_ONLY,gg,x_axis,y_axis);
- gg.item_color = color[4]; gg.symbol_color = color[15];
- set_graf_symbol(symbol_plus);
- eg_graph(numpts,pts3,DATA_ONLY,gg,x_axis,y_axis);
- gg.item_color = color[5]; gg.symbol_color = color[15];
- set_graf_symbol(symbol_diamd);
- eg_graph(numpts,pts4,DATA_ONLY,gg,x_axis,y_axis);
- twod_win(200,75);
- break;
- case 2 : gg.graph_type = SCATTER_GRAPH;
- x_axis.label_type = 0;
- y_axis.label_type = 0;
- x_axis.label_type = AUTO_SET;
- y_axis.label_type = AUTO_SET;
- x_axis.low = 0; x_axis.high = 1000;
- y_axis.low = 0; y_axis.high = 2000;
- gg.adjust_edges = 0;
- gg.symbol_color = color[4];
- numpts = 50;
- gg.symbol_size = max_y / 30;
- set_graf_symbol(symbol_star);
- gg.frame_type = FULL_FRAME;
- x_axis.num_labels = 21;
- y_axis.num_labels = 11;
- x_axis.num_grids = 20; y_axis.num_grids = 10;
- x_axis.num_ticks = 20; y_axis.num_ticks = 10;
- for (i = 0; i < 50; i++){
- scatter[i][0] = rand()%(x_axis.high-x_axis.low);
- scatter[i][1] = rand()%(y_axis.high-y_axis.low);
- }
- strcpy(x_descrip_label,"Amount of Carbon");
- strcpy(y_descrip_label,"Amount of Silsymbol");
- strcpy(title,"Scatter Graph");
- eg_graph(numpts,scatter,WHOLE_GRAPH,gg,x_axis,y_axis);
- numpts = 12;
- x_axis.label_type = 1;
- y_axis.label_type = 1;
- twod_win(200,75);
- gg.symbol_size = -1;
- break;
- case 3 : gg.graph_type = HI_LOW_GRAPH;
- gg.frame_type = HALF_FRAME;
- x_axis.label_type = MANUAL_SET;
- y_axis.label_type = AUTO_SET;
- gg.adjust_edges = 1;
- numpts = 20;
- if (!dev || dev ==3)
- gg.line_width = 3;
- gg.item_color = color[15];
- gg.symbol_color = color[13];
- x_axis.low = 0; x_axis.high = numpts;
- y_axis.low = 0; y_axis.high = 110;
- x_axis.num_labels = 12; /* 10 x axis labels */
- y_axis.num_labels = 11; /* 11 x axis labels */
- /* same for grids and ticks per axis */
- x_axis.num_grids = 19; y_axis.num_grids = 10;
- x_axis.num_ticks = 0; y_axis.num_ticks = 20;
- strcpy(title,"Hi-Low-Close Graph");
- strcpy(x_descrip_label,"Acme Stock");
- strcpy(y_descrip_label,"Stock Range");
- eg_graph(numpts,hilow,WHOLE_GRAPH,gg,x_axis,y_axis);
- twod_win(200,75);
- break;
- case 4 : gg.graph_type = BAR_GRAPH; gg.bar_type = VERT_BARS;
- numpts = 12;
- gg.series_bars = 1;
- gg.num_series = 0;
- gg.bar_mid_width = -1;
- x_axis.num_labels = 12; /* 12 x axis labels */
- y_axis.num_labels = 11; /* 11 y axis labels */
- x_axis.num_grids = 11; y_axis.num_grids = 10;
- x_axis.num_ticks = 11; y_axis.num_ticks = 10;
- x_axis.low = 0; x_axis.high = numpts;
- y_axis.low = 0; y_axis.high = 110;
- gg.frame_type = FULL_FRAME;
- strcpy(x_descrip_label,"Months For 1989");
- strcpy(y_descrip_label,"Gross Profits");
- strcpy(title,"Vertical Bar Graph");
- gg.item_color = color[2];
- eg_graph(numpts,pts3,WHOLE_GRAPH,gg,x_axis,y_axis);
- twod_win(200,75);
- gg.series_bars = 3;
- gg.num_series = 0;
- gg.item_color = color[12];
- eg_graph(numpts,pts3,WHOLE_GRAPH,gg,x_axis,y_axis);
- gg.item_color = color[11];
- gg.num_series = 1;
- eg_graph(numpts,pts2,DATA_ONLY,gg,x_axis,y_axis);
- gg.item_color = color[14];
- gg.num_series = 2;
- eg_graph(numpts,pts1,DATA_ONLY,gg,x_axis,y_axis);
- twod_win(200,75);
- break;
- case 5 : gg.graph_type = BAR_GRAPH; gg.bar_type = HORZ_BARS;
- x_axis.low = 0; x_axis.high = 110;
- y_axis.low = 0; y_axis.high = numpts;
- x_axis.label_type = AUTO_SET;
- y_axis.label_type = MANUAL_SET;
- gg.frame_type = HALF_FRAME;
- y_axis.num_labels = 12; x_axis.num_labels = 11;
- y_axis.num_grids = 11; x_axis.num_grids = 10;
- y_axis.num_ticks = 11; x_axis.num_ticks = 10;
- strcpy(y_descrip_label,"Months For 1989");
- strcpy(x_descrip_label,"Gross Profits");
- strcpy(title,"Horizontal Bar Graph");
- gg.series_bars = 1;
- gg.num_series = 0;
- gg.item_color = color[5];
- eg_graph(numpts,pts3,WHOLE_GRAPH,gg,x_axis,y_axis);
- twod_win(200,75);
- gg.series_bars = 3;
- gg.num_series = 0;
- gg.item_color = color[12];
- eg_graph(numpts,pts3,WHOLE_GRAPH,gg,x_axis,y_axis);
- gg.item_color = color[11];
- gg.num_series = 1;
- eg_graph(numpts,pts2,DATA_ONLY,gg,x_axis,y_axis);
- gg.item_color = color[14];
- gg.num_series = 2;
- eg_graph(numpts,pts1,DATA_ONLY,gg,x_axis,y_axis);
- twod_win(200,75);
- break;
- case 6 : gg.graph_type = STACK_BAR_GRAPH; gg.bar_type = VERT_BARS;
- x_axis.low = 0; x_axis.high = numpts;
- y_axis.low = 0; y_axis.high = 110;
- x_axis.num_labels = 12; /* 10 x axis labels */
- y_axis.num_labels = 11; /* 11 x axis labels */
- x_axis.num_grids = 11; y_axis.num_grids = 10;
- x_axis.num_ticks = 11; y_axis.num_ticks = 10;
- x_axis.label_type = MANUAL_SET;
- y_axis.label_type = AUTO_SET;
- gg.frame_type = FULL_FRAME;
- numpts = 12;
- strcpy(title,"Vertical Stack Bar Graph");
- gg.stack_bars = 3;
- colors[0] = color[4]; colors[1] = color[15]; colors[2] = color[1];
- gg.stack_colors = colors;
- eg_graph(numpts,stack,WHOLE_GRAPH,gg,x_axis,y_axis);
- twod_win(200,75);
- break;
- case 7 : gg.graph_type = STACK_BAR_GRAPH; gg.bar_type = HORZ_BARS;
- x_axis.low = 0; x_axis.high = 110;
- y_axis.low = 0; y_axis.high = numpts;
- y_axis.label_type = MANUAL_SET;
- x_axis.label_type = AUTO_SET;
- gg.frame_type = HALF_FRAME;
- y_axis.num_labels = 12;
- x_axis.num_labels = 11;
- y_axis.num_grids = 11; x_axis.num_grids = 10;
- y_axis.num_ticks = 11; x_axis.num_ticks = 10;
- strcpy(y_descrip_label,"Months For 1989");
- strcpy(x_descrip_label,"Gross Profits");
- strcpy(title,"Horizontal Stack Bar Graph");
- gg.stack_bars = 3;
- colors[0] = color[4]; colors[1] = color[15]; colors[2] = color[1];
- gg.stack_colors = colors;
- eg_graph(numpts,stack,WHOLE_GRAPH,gg,x_axis,y_axis);
- twod_win(200,75);
- break;
- case 8 : gg.graph_type = BAR_GRAPH; gg.bar_type = VERT_BARS;
- x_axis.low = 0; x_axis.high = numpts;
- y_axis.low = 0; y_axis.high = 110;
- gg.frame_type = HALF_FRAME;
- gg.bar_mid_width = 3;
- gg.series_bars = 1;
- gg.num_series = 0;
- x_axis.label_type = MANUAL_SET;
- y_axis.label_type = AUTO_SET;
- gg.bar_mid_color = color[15];
- x_axis.num_labels = 12; /* 10 x axis labels */
- y_axis.num_labels = 11; /* 11 x axis labels */
- x_axis.num_grids = 11; y_axis.num_grids = 10;
- x_axis.num_ticks = 11; y_axis.num_ticks = 10;
- strcpy(title,"Above / Below Bar Graph");
- gg.bar_mid_value = 50;
- gg.item_color = color[10];
- eg_graph(numpts,pts3,WHOLE_GRAPH,gg,x_axis,y_axis);
- twod_win(200,75);
- break;
- }
- }
- clipoff();
- if (color[4] == 1)
- color[4] = 0;
- fontquit();
- }
-
-
- /* do some 3-D charting */
-
- three_d_bars(){
-
- sphr_crd rela_obj; /* theta, phi, rho and sd */
- struct vfont *vfn1; /* font to use for cga */
- int font; /* font for the title */
- int basetype,bar_bott;
- double barval[12]; /* for cubebar, pyramid and octahdrn */
- int i,j;
- /* for the labels */
- char lab0[1][80],lab1[1][80],lab2[3][80],lab3[4][80];
- char lab4[7][20],lab5[7][20];
- char title[4][80];
- char *lab0_p[1],*lab1_p[1],*lab2_p[3],*lab3_p[4],*lab4_p[7],*lab5_p[7];
- char l[3][80]; /* for the legend */
- char *label[3]; /* for the legend */
- stack_cr stackc[3]; /* for the stack bar's color */
- double stack[12][3]; /* check number of bars in the stack */
- double base_unit_size,height;
- int bar_area;
- int bar_segs = 1;
-
- stackc[0].leftc = color[9];
- stackc[0].rightc = color[1];
- stackc[1].leftc = color[10];
- stackc[1].rightc = color[2];
- stackc[2].leftc = color[11];
- stackc[2].rightc = color[3];
-
- /* assign Title labels */
-
- strcpy(title[0],"3-D Bar Chart");
- strcpy(title[1],"3-D Pyramid Chart");
- strcpy(title[2],"3-D Octahedron Chart");
- strcpy(title[3],"3-D Stack Bar Chart");
-
- /* assign value to Base labels */
-
- strcpy(lab0[0],"WIDGETS");
- lab0_p[0] = lab0[0];
- strcpy(lab1[0],"QUARTERS");
- lab1_p[0] = lab1[0];
-
- /* assign value to XY left labels */
-
- strcpy(lab2[0],"1986");
- strcpy(lab2[1],"1987");
- strcpy(lab2[2],"1988");
- for (i=0; i<3; ++i)
- lab2_p[i]=lab2[i];
-
- /* assign value to XY right labels */
-
- strcpy(lab3[0],"JAN-MAR");
- strcpy(lab3[1],"APR-JUN");
- strcpy(lab3[2],"JUL-SEP");
- strcpy(lab3[3],"OCT-DEC");
- for (i=0; i<4; ++i)
- lab3_p[i]=lab3[i];
-
-
- bar_area = 2;
- basetype = 0; /* square base type */
-
- /* assign the value to each bar */
-
- barval[0] = 300.0; barval[1] = 200.0;
- barval[2] = 100.0; barval[3] = 220.0;
- barval[4] = 150.0; barval[5] = 120.0;
- barval[6] = 180.0; barval[7] = 90.0;
- barval[8] = 80.0; barval[9] = 80.0;
- barval[10] = 190.0; barval[11] = 100.0;
-
- /* assign the value to each bar in the stack */
-
- stack[0][0] = 50.0; stack[0][1] = 100.0; stack[0][2] = 230.0;
- stack[1][0] = 30.0; stack[1][1] = 160.0; stack[1][2] = 190.0;
- stack[2][0] = 40.0; stack[2][1] = 100.0; stack[2][2] = 200.0;
- stack[3][0] = 70.0; stack[3][1] = 100.0; stack[3][2] = 130.0;
- stack[4][0] = 30.0; stack[4][1] = 40.0; stack[4][2] = 180.0;
- stack[5][0] = 10.0; stack[5][1] = 70.0; stack[5][2] = 190.0;
- stack[6][0] = 20.0; stack[6][1] = 60.0; stack[6][2] = 190.0;
- stack[7][0] = 50.0; stack[7][1] = 70.0; stack[7][2] = 180.0;
- stack[8][0] = 20.0; stack[8][1] = 40.0; stack[8][2] = 200.0;
- stack[9][0] = 40.0; stack[9][1] = 90.0; stack[9][2] = 120.0;
- stack[10][0] = 20.0; stack[10][1] = 100.0; stack[10][2] = 170.0;
- stack[11][0] = 60.0; stack[11][1] = 70.0; stack[11][2] = 150.0;
-
- /* set the value for the legend */
-
- strcpy(l[0],"first year");
- strcpy(l[1],"second year");
- strcpy(l[2],"third year");
- for (i = 0; i< 3; ++i)
- label[i] = l[i];
-
- /* load the bit map font */
-
- fontinit();
- if (font_load(0,"ibmrom")){
- printf("Error loading ibmrom\n");
- exit(0);
- }
- if (font_load(1,"sbo.sms")){
- printf("Error loading sbo.sms\n");
- exit(0);
- }
- if (font_load(2,"roman3.sms")){
- printf("Error loading roman3.sms\n");
- exit(0);
- }
-
- /* load the vector font */
-
- vfn1 = (struct vfont *)vfontld("K0UR.VEC",&j);
- if (j < 0){
- printf("\r\nvfontld return:%d\r\n",j);
- exit(0);
- }
-
- clearscr(0);
- strcpy(str[0],"Explode your data on screen in 3-D.");
- strcpy(str[1],"Essential Graphics has 3-D bar, pyramid,");
- strcpy(str[2],"octahedrens and stack bar graphs ready to go.");
- strcpy(str[3]," ");
- strcpy(str[4],"Let's chart !");
- for (i = 0; i < 5; i++)
- s[i] = str[i];
-
- clearscr(0);
- switch(dev){
- case 0 : max_x = 639; initgraf(6,0,0);
- eg_window(4,1,"ibmrom",200,75,5,s,3,2,1);
- break;
- case 1 : eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
- break;
- case 2 : eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
- break;
- case 3 : eg_window(4,1,"sbo.sms",200,75,5,s,1,0,1);
- break;
- case 4 : eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
- break;
- case 5 :
- case 6 :
- case 7 : eg_window(4,1,"sbo.sms",200,75,5,s,4,15,1);
- break;
- }
-
- rela_obj.theta = 45L;
- rela_obj.phi = 50L;
- rela_obj.rho = 1000L;
- rela_obj.sd = 500L;
-
- font = 2;
- switch(dev){
- case 0 : color[6] = 0;
- base_unit_size = 70.0;
- height = 70.0;
- font = 1;
- stackc[0].leftc = stackc[0].rightc = 0;
- stackc[1].leftc = stackc[1].rightc = 0;
- stackc[2].leftc = stackc[2].rightc = 0;
- mono_hatch();
- break;
- case 1 : base_unit_size = 90.0;
- height = 110.0;
- color_hatch();
- break;
- case 2 : base_unit_size = 90.0;
- height = 110.0;
- color_hatch();
- break;
- case 3 : color[6] = 0;
- base_unit_size = 80.0;
- height = 90.0;
- font = 1;
- stackc[0].leftc = stackc[0].rightc = 0;
- stackc[1].leftc = stackc[1].rightc = 0;
- stackc[2].leftc = stackc[2].rightc = 0;
- mono_hatch();
- break;
- case 4 :
- case 5 :
- case 6 :
- case 7 : base_unit_size = 200.0;
- height = 100.0;
- color_hatch();
- break;
- }
-
- /* set the viewport and world */
-
- setview(0,0,max_x,max_y);
- setworld(0,0,max_x,max_y);
-
- strcpy(str[0],"Hit Return at any time");
- strcpy(str[1],"to move to the next");
- strcpy(str[2],"screen.");
- for (i = 0; i < 3; i++)
- s[i] = str[i];
-
- clearscr(0);
-
- for (i = 0; i < 4; i++){
-
- strcpy(lab4[0],"200");
- strcpy(lab4[1],"800");
- for (j=0; j<7; ++j)
- lab4_p[j]=lab4[j];
- strcpy(lab5[0],"200");
- strcpy(lab5[1],"800");
- for (j=0; j<7; ++j)
- lab5_p[j]=lab5[j];
-
- td_bar_set(0,4,3,bar_segs,stackc);
-
- /* using the default to set base */
-
- td_base_dim((double)-1,base_unit_size,(double)-1);
- td_base_height(height);
-
- /* using the default to set middle plane */
-
- td_midplane(-1,-1,-1.0);
-
- /* Set the bar and frame colors */
- if (dev == 0 || dev == 3){
- td_frame_color(0,1,0);
- td_bar_color(1,1,0,0);
- }
- else{
- td_frame_color(color[6],color[15],color[6]);
- }
- clearscr(0);
- worldon(1);
- if (i == 3)
- bar_segs = 3;
-
- /* set up the labels */
-
- td_bar_label(BASE_LEFT,color[14],lab0_p,vfn1,1,0);
- td_bar_label(BASE_RIGHT,color[14],lab1_p,vfn1,1,0);
- td_bar_label(XY_PLANE_LEFT,color[15],lab2_p,vfn1,3,0);
- td_bar_label(XY_PLANE_RIGHT,color[15],lab3_p,vfn1,4,0);
- td_bar_label(XZ_PLANE,color[15],lab4_p,vfn1,7,1);
- td_bar_label(YZ_PLANE,color[15],lab5_p,vfn1,7,1);
-
-
- /* call td_bar_set() to set the attribute of the bar chart */
-
- td_bar_set(i,4,3,bar_segs,stackc);
-
- /* put the legend */
-
- if (dev)
- switch(i){
- case 0 : td_legend(3,BOT_CENTER,label,color[15],color[15],
- SINGLE_BORDER,0,vfn1);
- break;
- case 1 : td_legend(3,BOT_LEFT_VERT,label,color[15],color[15],
- DOUBLE_BORDER,0,vfn1);
- break;
- case 2 : td_legend(3,BOT_RIGHT_VERT,label,color[15],color[15],
- SINGLE_BORDER,0,vfn1);
- break;
- case 3 : td_legend(3,BOT_LEFT_HORZ,label,color[15],color[15],
- DOUBLE_BORDER,0,vfn1);
- break;
- }
-
- /* put the title */
-
- td_title(TOP,title[i],color[15],font,vfn1);
-
-
- /* call td_chart() to draw the bar chart */
-
- if (i == 3)
- td_chart(300.0,0.0,basetype,bar_area,rela_obj,HALF_FRAME,stack);
- else
- td_chart(300.0,0.0,basetype,bar_area,rela_obj,HALF_FRAME,barval);
-
- switch(dev){
- case 0 : eg_window(4,1,"ibmrom",5,25,3,s,1,0,0);
- break;
- case 1 : eg_window(4,1,"sbo.sms",5,25,3,s,4,15,0);
- break;
- case 2 : eg_window(4,1,"sbo.sms",10,60,3,s,4,15,0);
- break;
- case 3 : eg_window(4,1,"sbo.sms",10,60,3,s,1,0,0);
- break;
- case 4 : eg_window(4,1,"sbo.sms",10,60,3,s,4,15,0);
- break;
- case 5 :
- case 6 :
- case 7 : eg_window(4,1,"sbo.sms",100,200,6,s,4,15,0);
- break;
- }
- clearscr(0);
- }
- if (!dev){
- max_x = 319; initgraf(4,cga_pal,0);
- }
-
- /* free the memory */
- vfontuld(vfn1);
- worldon(0);
- fontquit();
- }
-
- three_d_pies()
- {
- int val[13],i,j;
- int explode,offset,width;
- int radius,x0,y0,num,den;
- int linec,labelc,border_color;
- struct vfont *vfn; /* font to use */
- int title_font,xy_label_font;
- char title[5][80];
-
- for (i = 0; i < 13; i++)
- val[i] = i+1;
-
- setaspec(10,25);
- explode = 0; offset = 40;
- num = 10; den = 25;
- /* assign Title labels */
-
- strcpy(title[0],"3-D Exploded Pie Chart");
- strcpy(title[1],"Labels Inside and Out");
- strcpy(title[2],"Labels Outside Only");
- strcpy(title[3],"Legend for Labels");
-
- title_font = 2;
- xy_label_font = 1;
-
- clearscr(0);
- strcpy(str[0],"Charts are as easy as pie with");
- strcpy(str[1],"Essential Graphics 3-D pie charts.");
- strcpy(str[2]," ");
- strcpy(str[3],"Let's chart !");
- for (i = 0; i < 4; i++)
- s[i] = str[i];
-
- clearscr(0);
- switch(dev){
- case 0 : num = 1; den = 3;
- eg_window(4,1,"ibmrom",20,150,4,s,1,0,1);
- break;
- case 1 : eg_window(4,1,"sbo.sms",20,300,4,s,4,15,1);
- break;
- case 2 : eg_window(4,1,"sbo.sms",50,400,4,s,4,15,1);
- break;
- case 3 : eg_window(4,1,"sbo.sms",20,250,4,s,1,0,1);
- break;
- case 4 : eg_window(4,1,"sbo.sms",100,700,4,s,4,15,1);
- break;
- case 5 : eg_window(4,1,"sbo.sms",100,300,4,s,4,15,1);
- break;
- case 6 :
- case 7 : eg_window(4,1,"sbo.sms",100,300,4,s,4,15,1);
- break;
- }
-
- setview(0,0,max_x,max_y);
- setworld(0,0,max_x,max_y);
- switch(dev){
- case 0 : offset = 20;
- for (i = 1; i < 7; i++)
- color[i] = 1;
- title_font = 1;
- xy_label_font = 3;
- linec = labelc = border_color = 2;
- x0 = 160; y0 = 100; radius = 100;
- for (i = 1; i < 16; i++)
- color[i] = 1;
- width = 25;
- cga_hatch();
- break;
- case 1 : x0 = 320; y0 = 150; radius = 125;
- width = 40;
- color_hatch();
- linec = labelc = border_color = color[15];
- break;
- case 2 : x0 = 300; y0 = 200; radius = 140;
- width = 60;
- linec = labelc = border_color = color[15];
- color_hatch();
- break;
- case 3 : for (i = 1; i < 16; i++)
- color[i] = 1;
- x0 = 350; y0 = 175; radius = 125;
- linec = labelc = border_color = color[1];
- width = 40;
- mono_hatch();
- break;
- case 4 : x0 = 320; y0 = 200; radius = 160;
- width = 60;
- linec = labelc = border_color = color[15];
- color_hatch();
- break;
- case 5 : x0 = 400; y0 = 300; radius = 220;
- width = 80;
- linec = labelc = border_color = color[15];
- color_hatch();
- break;
- case 6 :
- case 7 : x0 = 500; y0 = 300; radius = 250;
- width = 80;
- linec = labelc = border_color = color[15];
- color_hatch();
- break;
- }
- clearscr(0);
-
-
- /* load the bit map font */
-
- fontinit();
- if (font_load(0,"ibmrom")){
- printf("Error loading ibmrom\n");
- exit(0);
- }
- if (font_load(1,"sbo.sms")){
- printf("Error loading sbo.sms\n");
- exit(0);
- }
- if (font_load(2,"roman3.sms")){
- printf("Error loading roman3.sms\n");
- exit(0);
- }
- if (font_load(3,"micprint.sms")){
- printf("Error loading roman3.sms\n");
- exit(0);
- }
-
- /* set aspect ratio */
- setaspec(num,den);
-
- strcpy(str[0],"Hit Return at any time");
- strcpy(str[1],"to move to the next");
- strcpy(str[2],"screen.");
- for (i = 0; i < 3; i++)
- s[i] = str[i];
-
- for (i = 1; i < 4; i++){
- clearscr(0);
- worldon(1);
- if (!dev){
- if (i == 3)
- td_pie_legend(BOT_LEFT_VERT,SINGLE_BORDER);
- td_pie_set(4,xy_label_font,i,width,linec,labelc);
- td_title(TOP,title[i],color[15],title_font,0);
- td_pie_slice(0,color[1],1,"1st");
- td_pie_slice(1,color[2],2,"2nd");
- td_pie_slice(2,color[3],3,"3rd");
- td_pie_slice(3,color[4],4,"4th");
- }
- else{
- if (i == 3){
- j = td_pie_set(8,xy_label_font,i,width,linec,labelc);
- td_title(TOP,title[i],color[15],title_font,0);
- td_pie_slice(0,color[1],1,"JAN 1989");
- td_pie_slice(1,color[2],2,"FEB 1989");
- td_pie_slice(2,color[3],3,"MAR 1989");
- td_pie_slice(3,color[4],4,"APR 1989");
- td_pie_slice(4,color[5],5,"MAY 1989");
- td_pie_slice(5,color[6],6,"JUN 1989");
- td_pie_slice(6,color[7],7,"JUL 1989");
- td_pie_slice(7,color[8],8,"AUG 1989");
- }
- else{
- td_pie_set(6,xy_label_font,i,width,linec,labelc);
- td_title(TOP,title[i],color[15],title_font,0);
- td_pie_legend(BOT_LEFT_VERT,DOUBLE_BORDER);
- td_pie_slice(0,color[1],1,"JAN 1989");
- td_pie_slice(1,color[2],2,"FEB 1989");
- td_pie_slice(2,color[3],3,"MAR 1989");
- td_pie_slice(3,color[4],4,"APR 1989");
- td_pie_slice(4,color[5],5,"MAY 1989");
- td_pie_slice(5,color[6],6,"JUN 1989");
- }
- }
- j = td_pie(x0,y0,radius,explode,border_color,0,val);
- switch(dev){
- case 0 : eg_window(4,1,"ibmrom",20,135,3,s,1,0,0);
- break;
- case 1 : eg_window(4,1,"sbo.sms",20,275,3,s,4,15,0);
- break;
- case 2 : eg_window(4,1,"sbo.sms",50,400,3,s,4,15,0);
- break;
- case 3 : eg_window(4,1,"sbo.sms",20,350,3,s,1,0,0);
- break;
- case 4 : eg_window(4,1,"sbo.sms",100,500,3,s,4,15,0);
- break;
- case 5 : eg_window(4,1,"sbo.sms",200,500,3,s,4,15,0);
- break;
- case 6 :
- case 7 : eg_window(4,1,"sbo.sms",200,600,6,s,4,15,0);
- break;
- }
- }
- /* explode some slices */
- setview(0,0,max_x,max_y);
- setworld(0,0,max_x,max_y);
- worldon(1);
- clearscr(0);
- if (!dev){
- td_pie_set(4,xy_label_font,2,width,linec,labelc);
- /* put the title */
- td_title(TOP,title[0],color[15],title_font,0);
- td_pie_slice(0,color[1],1,"1st");
- td_pie_slice(1,color[2],2,"2nd");
- td_pie_slice(2,color[3],3,"3rd");
- td_pie_slice(3,color[4],4,"4th");
- td_pie(x0,y0,radius,1,border_color,offset,val);
- }
- else{
- td_pie_set(6,xy_label_font,2,width,linec,labelc);
- /* put the title */
- td_title(TOP,title[0],color[15],title_font,0);
- td_pie_slice(0,color[1],1,"JAN-FEB");
- td_pie_slice(1,color[2],2,"MAR-APR");
- td_pie_slice(2,color[3],3,"MAY-JUN");
- td_pie_slice(3,color[4],4,"JUL-AUG");
- td_pie_slice(4,color[5],5,"SEP-OCT");
- td_pie_slice(5,color[6],6,"NOV-DEC");
- td_pie(x0,y0,radius,9,border_color,offset,val);
- }
- switch(dev){
- case 0 : eg_window(4,1,"ibmrom",20,50,3,s,3,2,0);
- break;
- case 1 : eg_window(4,1,"sbo.sms",20,60,3,s,4,15,0);
- break;
- case 2 : eg_window(4,1,"sbo.sms",50,60,3,s,4,15,0);
- break;
- case 3 : eg_window(4,1,"sbo.sms",20,50,3,s,1,0,0);
- break;
- case 4 : eg_window(4,1,"sbo.sms",100,50,3,s,4,15,0);
- break;
- case 5 : eg_window(4,1,"sbo.sms",100,70,3,s,4,15,0);
- break;
- case 6 :
- case 7 : eg_window(4,1,"sbo.sms",100,50,3,s,4,15,0);
- break;
- }
- fontquit();
- worldon(0);
- setview(0,0,max_x,max_y);
- setworld(0,0,max_x,max_y);
- clipoff();
- }
-
- /* use PC Paintbrush files for animation */
-
- animation()
- {
-
- int k,i;
-
- clearscr(0);
- strcpy(str[0],"This portion will only");
- strcpy(str[1]," ");
- strcpy(str[2],"run in EGA or VGA Mode");
- strcpy(str[3]," ");
- strcpy(str[4],"Hit return to start and");
- strcpy(str[5]," ");
- strcpy(str[6],"stop animation");
-
- for (i = 0; i < 7; i++)
- s[i] = str[i];
-
- switch(dev){
- case 0 : eg_window(4,1,"ibmrom",20,50,7,s,3,2,1);
- break;
- case 1 : eg_window(4,1,"sbo.sms",20,60,7,s,4,15,1);
- break;
- case 2 : eg_window(4,1,"sbo.sms",50,60,7,s,4,15,1);
- break;
- case 3 : eg_window(4,1,"sbo.sms",20,50,7,s,1,0,1);
- break;
- case 4 : eg_window(4,1,"sbo.sms",100,50,7,s,4,15,1);
- break;
- case 5 : eg_window(4,1,"sbo.sms",100,50,7,s,4,15,1);
- break;
- case 6 :
- case 7 : eg_window(4,1,"sbo.sms",100,70,7,s,4,15,1);
- break;
- }
-
- /* only if EGA or VGA */
-
- if (dev == 2 || dev == 1){
- clearscr(0);
- /* loop thru the horse motion */
- while(1){
- if (inkey(&k) != -1)
- break;
- pcc_load("h1.pcc",240,150);
- pcc_load("h2.pcc",240,150);
- pcc_load("h3.pcc",240,150);
- pcc_load("h4.pcc",240,150);
- pcc_load("h5.pcc",240,150);
- pcc_load("h6.pcc",240,150);
- pcc_load("h7.pcc",240,150);
- pcc_load("h8.pcc",240,150);
- pcc_load("h9.pcc",240,150);
- pcc_load("h10.pcc",240,150);
- pcc_load("h11.pcc",240,150);
- }
- }
- }
-
-
- /* put a window on the screen with text */
-
- eg_window(horz_pad,wait,font,startx,starty,lines,str,forg,back,center)
- int horz_pad; /* number of characters to pad window */
- int wait; /* 0 - no keystroke wait, 1 - wait for keystroke */
- char *font; /* font to load */
- int startx,starty; /* starting locs */
- int lines; /* number of text lines */
- char *str[]; /* text strings */
- int forg,back; /* colors */
- int center; /* 1 - center box, 0 - no center */
- {
-
- int i,j,border,l,size;
- int w_height,w_width,largest;
- int c,h,ch,lf,vsize,hsize,baseline;
-
- worldon(0);
- clipoff();
- if (font_load(7,font)){
- initgraf(3,0,0);
- printf("Fonts not In Current Directory!!!\n");
- printf("Demo Cancelled!!!\n");
- exit(1);
- }
- font_info(7,&c,&h,&ch,&lf,&vsize,&hsize,&baseline);
-
- largest = 0;
- for (i = 0; i < lines; i++){
- size = fontpixn(7,str[i],0,strlen(str[i]));
- if (size > largest)
- largest = size;
- }
-
- w_width = largest+(hsize*horz_pad);
- w_height = vsize*(lines+2);
-
- if (center){
- startx = (max_x - w_width)/2;
- starty = (max_y - w_height)/2;
- }
-
- border = 5;
- eg_rectangle(startx,starty,startx+w_width+border,starty+w_height+border,back,1,-1);
-
- for (i = 0; i < border; i++,starty++,startx++,border--)
- eg_rectangle(startx,starty,startx+w_width+1+border-i,
- starty+w_height+border-i,forg,0,-1);
-
- for (i = 0,j = 1; i < lines; i++,j++){
- size = fontpixn(7,str[i],0,strlen(str[i]));
- fhatsay(7,str[i],forg,startx+(w_width-size)/2,starty+j*vsize+vsize/2);
- }
- if (wait)
- esgetkey(&i);
- font_unload(7);
- }
-
-
- /* quick call to eg_window from twod_graphs */
-
- twod_win(x,y)
- int x,y;
- {
-
- switch(dev){
- case 0 : eg_window(4,1,"ibmrom",20,20,3,s,3,2,0);
- break;
- case 1 : eg_window(4,1,"sbo.sms",x,y,3,s,15,1,0);
- break;
- case 2 : eg_window(4,1,"sbo.sms",x,y,3,s,15,1,0);
- break;
- case 3 : eg_window(4,1,"sbo.sms",x,y,3,s,1,0,0);
- break;
- case 4 : eg_window(4,1,"sbo.sms",x,y,3,s,15,1,0);
- break;
- case 5 : eg_window(4,1,"sbo.sms",200,100,3,s,15,1,0);
- break;
- case 6 :
- case 7 : eg_window(4,1,"sbo.sms",200,100,3,s,15,1,1);
- break;
- }
- }
-
-
- /* function for a vertical menu */
-
- eg_smenu(font,num_choices,choices,startx,starty,forg_color,back_color,
- shadow_color,cell_pad,do_title,title,t_forg,t_back)
-
- int font; /* font to write text with */
- int num_choices; /* number of choices in the menu */
- char *choices[]; /* array to selections or choices */
- int startx,starty; /* location to start menu */
- int forg_color; /* foreground color (text) */
- int back_color; /* background color */
- int shadow_color; /* shadow color */
- int cell_pad; /* space to add between text and cell border */
- int do_title; /* 0 - no | 1 - Yes */
- char *title; /* title string */
- int t_forg; /* foreground color (text) */
- int t_back; /* background color */
- {
- int topy,boty; /* top and bottom of selection cell */
- int pixels[15];
- int startfntx[15];
- int startfnty[15];
- int c,h,ch,lf,x;
- int vsize,hsize,baseline;
- int menu_width,menu_height; /* height and width of the menu */
- int shadowx,shadowy; /* location to draw shadow */
- int curlen,maxlen;
- int max_strlen;
- int mouse_x,mouse_y;
- int key,size;
- int fontnum;
- int i,j,k,y,y2,l;
- struct egstatus stat; /* graphic status */
- int border_size; /* border width */
- int cell_height; /* heigh of a menu selection cell */
- int bl,br;
-
-
- /* turn off while drawing */
- if (mouse)
- m_curoff();
-
- eg_status(&stat);
-
- border_size = 5;
-
- /* get the font info */
-
- font_info(font,&c,&h,&ch,&lf,&vsize,&hsize,&baseline);
- cell_height = vsize + cell_pad + (vsize-baseline);
-
- clipoff();
- max_strlen = 0;
-
- /* get max string length */
-
- for (i = 0; i < num_choices; i++){
- curlen = fontpixn(font,choices[i],0,strlen(choices[i]));
- if (curlen > max_strlen)
- max_strlen = curlen;
- }
-
- /* get the menu length and height */
-
- menu_width = max_strlen+(hsize*4);
- menu_height = cell_height*num_choices+num_choices;
-
- shadowx = shadowy = cell_height;
-
- if (shadowx > startx)
- shadowx = startx;
-
- if (shadowy > starty)
- shadowy = starty;
-
- if (startx+menu_width > stat.x_res)
- return(-2);
-
- if (starty+menu_height > stat.y_res)
- return(-3);
-
- /* put up the menu shadow */
-
- if (shadow_color != -1)
- eg_rectangle(startx-shadowx,starty+shadowy,startx+menu_width-shadowx,
- starty+menu_height+shadowy+border_size,shadow_color,1,-1);
-
- /* draw the menu border */
-
- for (i = 0; i < border_size; i++,starty++,startx++,border_size--)
- eg_rectangle(startx,starty,startx+menu_width+1+border_size-i,
- starty+menu_height+border_size-i,forg_color,0,-1);
-
- if (do_title){
- eg_rectangle(startx,starty-(vsize+4),startx+menu_width+1+border_size-i,
- starty,t_back,1,-1);
- eg_rectangle(startx,starty-(vsize+4),startx+menu_width+1+border_size-i,
- starty,t_forg,0,-1);
- i = fontpixn(font,title,0,strlen(title));
- x = startx + ((menu_width - i)/2);
- fhatsay(font,title,t_forg,x,starty-4);
- }
-
- /* put up the menu background */
-
- eg_rectangle(startx,starty,startx+menu_width,starty+menu_height,back_color,1,-1);
-
-
- /* put up the cell seperation lines */
-
- size = menu_height / num_choices;
- for (i = 0, y = starty; i <= num_choices; i++, y += size)
- eg_line(startx,y,startx+menu_width,y,forg_color);
-
-
- /* fill in the cells */
-
- y = starty + size;
- for (i = 0,j = 1; i < num_choices; i++,j++, y += size){
- pixels[i] = fontpixn(font,choices[i],0,strlen(choices[i]));
- startfntx[i] = startx + ((menu_width - pixels[i])/2);
- startfnty[i] = y-(cell_height-vsize)/2-cell_pad/2;
- fhatsay(font,choices[i],forg_color,startfntx[i],startfnty[i]);
- }
-
- i = 0; y = 1;
- eg_rectangle(startx,starty,startx+menu_width,starty+cell_height,forg_color,1,-1);
- fhatsay(font,choices[i],back_color,startfntx[i],startfnty[i]);
- if (mouse){
- m_setcur(startx+menu_width/2,(starty+y*vsize)-1);
- m_curon();
- }
-
- i = 0;
- topy = starty+(i*cell_height)+i+1;
- boty = topy+cell_height-1;
-
- while (1){
- j = inkey(&key);
- /* if key hit */
- if (j != -1){
- if (j == 1)
- key = -key;
- if (key == ESCAPE)
- return(-1);
- if (key == CURUP || key == CURDN || key == HOME || key == END){
- if (mouse) m_curoff();
- eg_rectangle(startx,topy,startx+menu_width,boty,back_color,1,-1);
- fhatsay(font,choices[i],forg_color,startfntx[i],startfnty[i]);
- }
- switch(key){
- case CURUP : if (i > 0)
- i--;
- else
- i = num_choices-1;
- break;
- case CURDN : if (i < num_choices-1)
- i++;
- else
- i = 0;
- break;
- case HOME : i = 0; break;
- case END : i = num_choices-1; break;
- case RETURN : return(i);
- }
- y = i+1;
- topy = starty+(i*cell_height)+i+1;
- boty = topy+cell_height-1;
- eg_rectangle(startx,topy,startx+menu_width,boty,forg_color,1,-1);
- fhatsay(font,choices[i],back_color,startfntx[i],startfnty[i]);
- if (mouse){
- m_setcur(startx+menu_width/2,(starty+y*cell_height)-1);
- m_curon();
- }
- }
- if (!mouse)
- continue;
- /* else check mouse position */
- m_posbut(&mouse_x,&mouse_y,&bl,&br);
- if (mouse_x >= startx && mouse_x <= startx+menu_width){
- size = menu_height / num_choices;
- for (l = 0, y2 = starty; l < num_choices; l++, y2 += size){
- if (mouse_y >= y2 && mouse_y < y2 + size && l != i){
- m_curoff();
- /* turn old choice off */
- eg_rectangle(startx,topy,startx+menu_width,boty,back_color,1,-1);
- fhatsay(font,choices[i],forg_color,startfntx[i],startfnty[i]);
- i = l;
- topy = starty+(i*cell_height)+i+1;
- boty = topy+cell_height-1;
- /* highlight new choice */
- eg_rectangle(startx,topy,startx+menu_width,boty,forg_color,1,-1);
- fhatsay(font,choices[l],back_color,startfntx[l],startfnty[l]);
- m_curon();
- }
- /* if left button hit return */
- if (bl == 1){
- return(i);
- }
- }
- }
- }
- }
-
- /* set up default hatch styles */
-
- hatch_init()
- {
-
- htinit(); /* initialize hatch definition space */
- htdefind(0,0,5); /* 2 pixels of background */
- htdefind(1,1,5); /* 2 pixels of color 1 */
- htdefind(2,2,5); /* 2 pixels of color 2 */
- htdefind(3,3,5); /* 2 pixels of color 3 */
- htdefind(4,4,5); /* 2 pixels of background */
- htdefind(5,5,5); /* 2 pixels of color 1 */
- htdefind(6,6,5); /* 2 pixels of color 2 */
- htdefind(7,7,5); /* 2 pixels of color 3 */
- htdefind(8,8,5); /* 2 pixels of background */
- htdefind(9,9,5); /* 2 pixels of color 1 */
- htdefind(10,10,5); /* 2 pixels of color 2 */
- htdefind(11,11,5); /* 2 pixels of color 3 */
- htdefind(12,12,5); /* 2 pixels of color 3 */
- htdefind(13,13,5); /* 2 pixels of color 3 */
- htdefind(14,14,5); /* 2 pixels of color 3 */
- htdefind(15,15,5); /* 2 pixels of color 3 */
-
- htdefstl(0,2,4,2,3,0,9); /* style 0 = solid color 1 */
- htdefstl(1,2,3,4,15,1); /* style 1 = solid color 2 */
- htdefstl(2,2,4,1,0,5,3); /* style 3 = horizontal stripes of color */
- htdefstl(3,2,3,11,14,13); /* style 3 = horizontal stripes of color */
-
- }
-
-