home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / v / vpoint.zip / CAD3.C < prev    next >
C/C++ Source or Header  |  1993-02-06  |  81KB  |  3,482 lines

  1.  
  2. /*   -----------------------------------------------------------------------
  3.  
  4.      CAD?.C -- An interactive graphics drawing program.  Mainly a learning
  5.      exercise in Microsoft QuickC graphics functions.  Includes most of the
  6.      drawing functions available in large commercial paint programs, with
  7.      the notable exceptions of file saves and opens, and editing functions.
  8.      Portions of this program are copyright by John Clark Craig in
  9.      "Microsoft QuickC Programmers Toolbox" 1990.  These sections are
  10.      indicated below above the #include statements.  This is an organic
  11.      proccess, and some functions are incomplete.  All liability for the use
  12.      of this program is assumed by the user.  Suggestions or comments are
  13.      encouraged.
  14.  
  15.      Written by Arthur Dunphy Jr.  Winter 1992-93
  16.      80 Samoset Ave. #6, Hull, MA 02045
  17.      E-Mail: AJ@BU.EDU
  18.  
  19.      ----------------------------------------------------------------------*/
  20.  
  21. #include <conio.h>
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <graph.h>
  26. #include <time.h>
  27.  
  28. /* The following include files are copyright. The names are fairly
  29.    self-descriptive. See above. */
  30.  
  31. #include "sound.h"
  32. #include "mousefun.h"
  33. #include "getkey.h"
  34.  
  35. /* This file consists of graphics function definitions & constants.
  36.    The functions are defined in the file AJGFUN.C */
  37.  
  38. #include "ajgfun.h"
  39.  
  40. /* The following constants describe the upper left and lower right corners
  41.    of the rectangle composing the drawing area. */
  42.  
  43. #define X1  106
  44. #define Y1  45
  45. #define X2  632
  46. #define Y2  440
  47.  
  48. #define mx  (X1 + X2) / 2  /// Midpoints of the drawing area
  49. #define my  (Y1 + Y2) / 2
  50.  
  51. #define SIZE 22
  52. #define CX   275
  53. #define CY   vc.numypixels
  54.  
  55. #define NULL2 '\0'
  56. #define MAXIMAGESIZE 50000 /* Storage area allocation for graphics images.
  57.                   This appears to be the maximum allowed under
  58.                   the "Large" memory model I installed with the
  59.                   compiler, minus the overhead for other memory
  60.                   requirements. Suggestions are very welcome. */
  61. #define BOXSIZE 43
  62.  
  63. void    draw_screen( void );
  64. void    mouse_adjust( void );
  65. void    set_cad_logorg( void );
  66. int     select_style( int );
  67. void    draw_grid( void ) ;
  68. void    draw_menu( void );
  69. void    scroll_intro(void);
  70. void    remap_std_palette(void);
  71. void    cycle_palette(void);
  72. void    reset_vanish_pt(pixtype x, pixtype y);
  73. int     getcolor(pixtype);
  74. void    break_color( color_t cnum, short *red, short *blue, short *green );
  75.  
  76. boolean inXscreen( pixtype h, pixtype v );
  77. int     get_shape( pixtype h, pixtype v );
  78. void    draw_1stbox(void);
  79. boolean quit_prompt( short );
  80. void    helpbox(void);
  81. short   getbordercolor(void);
  82. int     remap_screen( short x1, short y1, short x2, short y2, short maptype );
  83. boolean draw_chars( pixtype x, pixtype y );
  84. boolean get_pos( pixtype *x1, pixtype *y1, pixtype *pos);
  85.  
  86. short   font_menu( void );
  87. short   fonttype( void );
  88. void    get_font_info( pixtype , pixtype );
  89. short   get_font_size(short);
  90. void    set_vector(void );
  91. void    get_vector(void );
  92. void    get_fillmask( void );
  93. void    remap_color( short col );
  94. void    draw_newbox( rect_s *, short, short, short, short );
  95. short   get_brush_shape( short oldshape );
  96. void    drawrect( boolean fill, rect_s *r );
  97. void    draw_star( pixtype, pixtype );
  98. void    draw_spray( pixtype, pixtype );
  99. void    draw_slash( pixtype x, pixtype y, short len);
  100. void    draw_backslash( pixtype x, pixtype y ,short len);
  101. void    draw_square(pixtype, pixtype,short);
  102. void    draw_ellipse(pixtype, pixtype, short);
  103. void    update_newbox(pixtype midx, pixtype midy, short shape );
  104. void    draw_paint2(pixtype x1, pixtype y1, short shape );
  105. void    draw_paint(pixtype x1, pixtype y1, short shape );
  106. void    cycle3( void );
  107. void    sqx( pixtype x, pixtype y );
  108. color_t custom_color(short palette_num );
  109. void    update_shapebox( short type );
  110. void    draw_arc( short );
  111.  
  112. int XSCREEN = 263;
  113. int YSCREEN = 193;
  114.  
  115. color_t c_array[16] = {
  116.             _BLACK, _BLUE, _GREEN, _CYAN, _RED, _MAGENTA, _BROWN,
  117.             _WHITE, _GRAY, _LIGHTBLUE, _LIGHTGREEN, _LIGHTCYAN,
  118.             _LIGHTRED, _LIGHTMAGENTA, _YELLOW, _BRIGHTWHITE};
  119. color_t c_array3[16] = {
  120.             _BLACK, _BLUE, _GREEN, _CYAN, _RED, _MAGENTA, _BROWN,
  121.             _WHITE, _GRAY, _LIGHTBLUE, _LIGHTGREEN, _LIGHTCYAN,
  122.             _LIGHTRED, _LIGHTMAGENTA, _YELLOW, _BRIGHTWHITE};
  123.  
  124.  
  125.  
  126. /* The following variables are global to the program. The reasons for
  127.    these are mainly because of memory management on the IBM PC, and
  128.    ease of use in many functions which depend on the same memory areas.*/
  129. char               temp[80];
  130. pixtype            MX = mx, MY = my;
  131. int                normal;         /// linestyle default
  132. int                menu_box[5][2];
  133. char _far          image[3000];/// array for _getimage() & _putimage()
  134.  
  135. char _far           randbox[1200];
  136. char _far           msgbox[50000];
  137. char _far           charbox[3000];
  138. short               size = 5;
  139. char                ipick = 1;
  140. boolean             fill_on = FALSE;
  141. short               bshape = 1, bsize = 10;
  142.  
  143. struct videoconfig vc;             /*  Since I change logical origin,
  144.                        video configuration & palette values
  145.                        in many different functions, the
  146.                        new values must be determined almost
  147.                        constantly. Making this struct global
  148.                        facillitates writing code. */
  149. boolean           clearscreen = FALSE;
  150. boolean           soundon = FALSE;
  151. boolean           warp_on = FALSE;
  152. boolean           mirror_on = TRUE;
  153. boolean           scroll_flag = TRUE;
  154.  
  155. unsigned char   pick[5][8];
  156.  
  157. short oldcolor = 1, border = 15;
  158. extern int r, g, b;
  159. boolean    c_used[16];
  160.  
  161. mtype = 1;
  162. unsigned long imagesize;
  163. short font1 = TRMN;
  164. short color = 12;
  165. short newcolor, c;
  166.  
  167. main()
  168. {
  169.    pixtype x, t;
  170.    pixtype x1, x2, y1, y2, oldx1, oldx2, oldy1, oldy2;
  171.    boolean esc_flag = FALSE;
  172.    char    temp[90];
  173.    mouse_t lb, rb, h, v, oldh = 0, oldv = 0;
  174.    struct _fontinfo    fi;
  175.  
  176.    int     type = 1, oldtype = 1, pixtemp;
  177.    int     xtextpos;
  178.  
  179.  
  180.   if ( UNABLETO _setvideomode( _MAXRESMODE ) )
  181.      {
  182.      _outtext(" This program requires at least VGA video capabilities. Sorry");
  183.      exit(1);
  184.      }
  185.   else
  186.      {
  187.      _outtext(" VGA card detected.\n ");
  188.      _getvideoconfig( &vc );
  189.      }
  190.  
  191.    if (  NOT regfonts2() )
  192.      {
  193.      _settextcolor(12);
  194.      _outtext(" \n Sorry, unable to register character font files.\n\
  195.            Try \\QC25\\BIN or \\WINDOWS\\SYSTEM if they are installed\n\
  196.            on your computer. Otherwise the *.FON files should be in\n\
  197.            the directory where you are running this program from.");
  198.      getch();
  199.      exit( 1 );
  200.      }
  201.      else
  202.      {
  203.        _outtext("Font information registered.\n");
  204.        _getfontinfo( &fi );
  205.        set_font( TRMN, 8 );
  206.      }
  207.  
  208.   if ( UNABLETO reset_mouse() )
  209.      {
  210.      _outtext(" This program requires a two-button MS compatible mouse. Sorry.");
  211.      _setvideomode( _DEFAULTMODE );
  212.      exit(1);
  213.      }
  214.   else
  215.      _outtext("Two-button mouse detected.");
  216.  
  217.   /* Seed the random number generator with the current time and set color
  218.      values so the program won't repeat the same starting colors. */
  219.   srand( (unsigned)time( NULL ) );
  220.  
  221.   r = rand() % 64 + 1;
  222.   g = rand() % 64 + 1;
  223.   b = rand() % 64 + 1;
  224.  
  225.  /* imagesize = _imagesize( X1 ,Y1 ,X2 ,Y2 );
  226.   sprintf( temp, "\nImage size of screen in Bytes = %u\nHit a Key", imagesize);
  227.   _outtext( temp );
  228.   getch();  */
  229.  
  230.   normal = _getlinestyle();
  231.  
  232.   for ( t = 0; t <= 15; t++)
  233.     c_used[t] = FALSE;
  234.  
  235.   note( 660, 3 );
  236.  
  237.   _clearscreen( _GCLEARSCREEN );
  238.   mouse_adjust();
  239.  /// mouse_setgcurs( &gcursor_hand );
  240.  
  241.   _setcolor(15);
  242.    draw_screen();
  243.    _setcolor( 12 );
  244.    set_font( TRMN, 8 );
  245.    scroll_intro();
  246.    set_cad_logorg();
  247.    mouse_show();
  248.   _setcolor( 9 );
  249.   font_menu();
  250.    _setlogorg( MX, MY );
  251.    while ( NOT esc_flag )
  252.       {
  253. loop_flag:
  254.       oldtype = type;
  255.       oldh = h;
  256.       oldv = v;
  257.  
  258.       mouse_status(&lb, &rb, &h, &v );
  259.       if ( (oldh NE h) OR (oldv NE v) )
  260.       {
  261.  
  262.      sprintf( temp, "(%d, %d)", h - MX, -(v - MY) );
  263.      _settextcolor(9);
  264.      _settextposition(vc.numtextrows - 1, 22 );
  265.      _outtext("             ");
  266.      _settextposition(vc.numtextrows - 1, 22 );
  267.      _outtext( temp );
  268.  
  269.      if ( h >= X1 AND v >= 50)
  270.        mouse_show();
  271.       }
  272.  
  273.       if ( kbhit() )
  274.     type = select_style( type );
  275.     oldtype = type;
  276.       if ((lb) AND ( h >= X1 ) AND ( v >= Y1 ) AND ( inXscreen( h, v ) ) )
  277.  
  278.     {
  279.       if (soundon)
  280.         {
  281.         oldcolor = _getcolor();
  282.         note( (oldcolor * 200) + rand() % 2000 , 1);
  283.         }
  284.  
  285.       /* Determine if any of the coordinates are out of the drawing
  286.          area. If they are, reset them to outer limit of any edges before
  287.          drawing the shape. */
  288.  
  289.       set_cad_logorg();
  290.  
  291.       mouse_hide();
  292.  
  293.       if (clearscreen)
  294.         {
  295.         _setlogorg(0,0);
  296.         _getvideoconfig(&vc);
  297.         oldcolor = _getcolor();
  298.         _setcolor(0);
  299.         _rectangle(_GFILLINTERIOR, X1, Y1, X2, Y2 );
  300.  
  301.         if (oldcolor == 0)
  302.           oldcolor = rand() % 15 + 1;
  303.           _setcolor( oldcolor );
  304.         set_cad_logorg();
  305.         }
  306.     else
  307.       {
  308.       x1 = h - MX;
  309.       y1 = v - MY;
  310.       x2 = -h + MX;
  311.       y2 = -v + MY;
  312.  
  313.       if ( x1 <= -XSCREEN )
  314.         x1 = -XSCREEN + 1;
  315.       if ( y1 <= -YSCREEN )
  316.         y1 = -YSCREEN;
  317.       if ( y2 >= YSCREEN )
  318.         y2 = YSCREEN + 1;
  319.       if ( x2 >= XSCREEN )
  320.         x2 = XSCREEN - 1;
  321.  
  322.       if ( x1 >= XSCREEN )
  323.         x1 = XSCREEN - 1;
  324.       if ( y1 >= YSCREEN )
  325.         y1 = YSCREEN;
  326.       if ( y2 <= -YSCREEN )
  327.         y2 = YSCREEN + 1;
  328.       if ( x2 <= -XSCREEN )
  329.         x2 = -XSCREEN + 1;
  330.  
  331.       set_cad_logorg();
  332.       c_used[ _getcolor() ] = TRUE;
  333.       switch (type)
  334.         {
  335.         case 2:
  336.            _ellipse(_GBORDER, x1, y1, x2, y2);
  337.            break;
  338.         case 100:
  339.            if (mtype)
  340.            type = remap_screen(x1,y1,x2,y2, mtype );
  341.            type = oldtype;
  342.            break;
  343.         case 1:
  344.            _rectangle( _GBORDER, x1, y1, x2, y2);
  345.            break;
  346.         case 4:
  347.             if (fill_on)
  348.               _setfillmask( pick[ ipick ] );
  349.             _ellipse( _GFILLINTERIOR, x1, y1, x2, y2);
  350.            if (fill_on)
  351.             _setfillmask(NULL);
  352.             break;
  353.         case 5:
  354.             if (fill_on)
  355.               _setfillmask( pick[ ipick ] );
  356.            _rectangle( _GFILLINTERIOR, x1, y1, x2, y2);
  357.            if (fill_on)
  358.             _setfillmask(NULL );
  359.             break;
  360.            case 99 :
  361.                 _setcolor(newcolor);
  362.                 if (fill_on)
  363.                  _setfillmask( pick[ ipick ] );
  364.                 _floodfill( x1, y1, border);
  365.                 if (fill_on)
  366.                  _setfillmask( NULL );
  367.                 type =  oldtype;
  368.                 break;
  369.         case 8:
  370.            draw_chars(h, v);
  371.            break;
  372.         case 666 :
  373.            draw_arc(1);
  374.            lb = FALSE;
  375.            break;
  376.         case 667 :
  377.            draw_arc(2);
  378.            lb = FALSE;
  379.            break;
  380.         case 6:
  381.            _moveto( x1, y1);
  382.            _lineto( 0, 0 );
  383.          if (mirror_on)
  384.            {
  385.            _moveto( -x1, y1);
  386.            _lineto( 0, 0 );
  387.            _moveto( x1, -y1);
  388.            _lineto( 0, 0 );
  389.            _moveto( -x1, -y1);
  390.            _lineto( 0, 0 );
  391.  
  392.             if (x1 < -197 )
  393.               x1 = -197;
  394.             if (x2 > 197 )
  395.               x2 = 197;
  396.             if (x2 < -197 )
  397.               x2 = -197;
  398.             if (x1 > 197 )
  399.               x1 = 197;
  400.  
  401.            _moveto( y1, x1);
  402.            _lineto( 0, 0 );
  403.            _moveto( -y1, x1);
  404.            _lineto( 0, 0 );
  405.            _moveto( y1, -x1);
  406.            _lineto( 0, 0 );
  407.            _moveto( -y1, -x1);
  408.            _lineto( 0, 0 );
  409.            }
  410.  
  411.            break;
  412.         case 25:
  413.           draw_paint2(x1, y1, bshape );
  414.           break;
  415.         case 111 :
  416.           sqx( x1, y1 );
  417.           break;
  418.         default:
  419.            break;
  420.         }
  421.       }
  422.       mouse_show();
  423.       mouse_condoff( 10, 50, X1 - 10, Y2 );
  424.     }
  425.  
  426.       if ( ( type == 11 ) AND ( h >= X1 ) AND ( v >= Y1 ))
  427.     {
  428.     MX = h;
  429.     MY = v;
  430.     reset_vanish_pt( h, v );
  431.     }
  432.  
  433.     if ( lb AND v > Y2 )
  434.        {
  435.        _setlogorg(0,0);
  436.        newcolor = getcolor(h);
  437.        if ( newcolor )
  438.          _setcolor( newcolor );
  439.  
  440.        }
  441.     else
  442.     if ( rb AND v > Y2 )
  443.        {
  444.        _setlogorg(0,0);
  445.        border = getbordercolor();
  446.        _setlogorg(0,0);
  447.        _setlinestyle(normal);
  448.        _rectangle( _GBORDER, X1, Y1, X2, Y2 );
  449.        _setcolor(newcolor);
  450.        set_cad_logorg();
  451.        }
  452.  
  453.  
  454.     if ( rb AND inXscreen( h, v ) )
  455.        reset_vanish_pt( h, v );
  456.  
  457.     if ( (rb OR lb) AND ( h < X1 ) AND ( v < 300 ) )
  458.       type = get_shape( h,v );
  459.  
  460.     if ( (lb OR rb) AND ( v < 34 ) AND ( h > 115) )
  461.        get_font_info(h, v);
  462.  
  463.     if ( lb AND (v < 34) AND (h > 15) AND (h < 115) )
  464.         get_fillmask();
  465.  
  466.     if ( type EQ 3 )
  467.       {
  468.       esc_flag = quit_prompt(oldtype);
  469.       type = oldtype;
  470.       }
  471.  
  472.     }
  473.  
  474.    _unregisterfonts();
  475.    _setvideomode( _DEFAULTMODE );
  476. }
  477.  
  478.  
  479. void draw_screen( void )
  480. /* This function draws the basic outline of the "work area" screen. */
  481. {
  482.    pixtype            x, y; /// x & y pixels available in current video mode.
  483.    color_t            color;
  484.    struct videoconfig vc;   /// Video Configuration info.(_MAXRESMODE) only
  485.    pixtype            mx1, my1; /* midpoints of the outside of the
  486.                    rectangle included in the drawing area. */
  487.    int                linestyle = _getlinestyle();
  488.    _getvideoconfig( &vc );
  489.    x = vc.numxpixels;
  490.    y = vc.numypixels;
  491.  
  492.    _rectangle( _GBORDER, 0, 0, x - 1, y - 1 );
  493.    _rectangle( _GBORDER, 8, 8, x - 8, 40 ) ;  /// 1
  494.    _rectangle( _GBORDER, (pixtype) (x / 6), 45, x - 8, y - 40 ) ; ///  2
  495.    _rectangle( _GBORDER, (pixtype) (x / 6), y - 35, x - 8, y - 8 ); /// 3
  496.    _rectangle( _GBORDER, 8, 45, (pixtype) (x / 6) - 8 , y - 8 );  /// 4
  497.  
  498.  
  499.    draw_menu();
  500.  
  501. /*   _setcolor(4);
  502.    _rectangle( _GFILLINTERIOR, 10, 50, X1 - 10, 110 );
  503.    _rectangle( _GFILLINTERIOR, 10, 115, X1 - 10, 175 );
  504.  
  505.    _setcolor(12);
  506.    _rectangle( _GBORDER, 10, 50, X1 - 10, 110 );
  507.    _rectangle( _GBORDER, 10, 115, X1 - 10, 175 );
  508.  
  509.    _setcolor( 15 );
  510.     _rectangle( _GBORDER, 30, 70, X1 - 30, 90 );
  511.     _ellipse( _GBORDER, 30, 130, X1 - 30, 155 );      */
  512.  
  513.    mx1 = (X2 + X1) / 2;
  514.    my1 = (Y2 + Y1) / 2;
  515.    _setcolor( 12 );
  516.    _setlinestyle( 1);
  517.    _moveto( mx1, Y1 );
  518.    _lineto( mx1, Y2 );
  519.    _moveto( X1, my1 );
  520.    _lineto( X2, my1 );
  521.    _setlinestyle( linestyle );
  522.  
  523. }
  524.  
  525.  
  526.  
  527. void mouse_adjust( void )
  528. {
  529.      mouse_sethorz( 10, X2 );
  530.      mouse_setvert( 10, vc.numypixels - 10 );
  531.      mouse_setpos( (X1 + X2) / 2, (Y1 + Y2) / 2 );
  532.    //  mouse_condoff( 10, 50, X1 - 10, Y2 );
  533.      mouse_setsensitivity( 70, 70, 70 );
  534. }
  535.  
  536. void set_cad_logorg( void )
  537.  
  538. {
  539.   /*   pixtype mx1 = (X1 + X2) / 2;
  540.      pixtype my1 = (Y1 + Y2) / 2;  */
  541.  
  542.      _setlogorg( MX, MY );
  543.      _getvideoconfig( &vc );
  544. }
  545.  
  546.  
  547. int select_style( int type1 )
  548. {
  549.  
  550.   int               oldstyle = type1;
  551.   unsigned          key;
  552.   int               type = type1, t;
  553.   unsigned short    linestyle = _getlinestyle();
  554.   short             c = _getcolor();
  555.  
  556.   key = getkey();
  557.   switch ( key )
  558.   {
  559.  
  560.      case 'l' :
  561.            _setlinestyle( normal );
  562.            break;
  563.      case 'h' :
  564.      case 'H' :
  565.      case KEY_F1 :
  566.            helpbox();
  567.            break;
  568.      case 'p' :          /// Single pixels
  569.            type = 25;
  570.            break;
  571.      case 'g' :
  572.         type = 7;
  573.         break;
  574.       case KEY_HOME :
  575.            fonttype();
  576.            break;
  577.  
  578.      case 'r' :
  579.            type = 1; /// rectangle
  580.            break;
  581.      case 'f' :
  582.         oldcolor = _getcolor();
  583.            type = 99;
  584.            break;
  585.      case 'e' :
  586.            type = 2; /// ellipse
  587.            break;
  588.      case 'E' :
  589.            type = 4; /// solid ellipse
  590.            break;
  591.      case 'R' :
  592.            type = 5; /// solid rectangle
  593.            break;
  594.      case 'L' :
  595.            type = 6;
  596.            break;
  597.      case 'x' : fonttype();
  598.         break;
  599.  
  600.      case KEY_LEFT :
  601.            if ( linestyle > 0 )
  602.          _setlinestyle( linestyle -= 3 );
  603.            break;
  604.      case KEY_RIGHT :
  605.            _setlinestyle( linestyle += 3);
  606.            break;
  607.      case KEY_ESCAPE :
  608.            type = 3; /// Bag Out
  609.            break;
  610.      case KEY_DELETE:  /// clear drawing box
  611.            for ( t = 0; t <= 15; t++)
  612.          c_used[t] = FALSE;
  613.            draw_grid();
  614.            set_cad_logorg();
  615.            mouse_setpos(mx,my);
  616.            MX = mx;
  617.            MY = my;
  618.            mouse_show();
  619.            break;
  620.      case KEY_F3 :
  621.            scroll_flag = !scroll_flag;
  622.            break;
  623.      case KEY_F2 :
  624.            _setlogorg(0,0);
  625.            scroll_intro();
  626.            set_cad_logorg();
  627.            break;
  628.      case KEY_F4 :
  629.         remap_std_palette();
  630.         break;
  631.      case KEY_F5 :
  632.         cycle_palette();
  633.         break;
  634.      case KEY_F9 :
  635.         clearscreen = NOT clearscreen;
  636.         break;
  637.      case KEY_F8 :
  638.         soundon = NOT soundon;
  639.         break;
  640.      case KEY_F6 :
  641.         mirror_on = NOT mirror_on;
  642.         break;
  643.      case KEY_ALT_F2 :
  644.         mtype = getmaptype();
  645.         type = 100;
  646.         break;
  647.      case KEY_ALT_F4 :
  648.         _setfillmask( pick[ ipick ] );
  649.         break;
  650.      case KEY_ALT_F5 :
  651.         _setfillmask( NULL );
  652.         break;
  653.      case KEY_ALT_F6 :
  654.         fill_on = NOT fill_on;
  655.         break;
  656.      case KEY_ALT_F1 :
  657.         mouse_hide();
  658.         get_fillmask();
  659.         break;
  660.      case KEY_ALT_F3 :
  661.         remap_color( newcolor );
  662.         break;
  663.      case KEY_ALT_F8 :
  664.         type = 111;
  665.         break;
  666.      case KEY_ALT_F10    :
  667.          bshape = get_brush_shape(bshape);
  668.          break;
  669.      case KEY_ALT_F9:
  670.          cycle3();
  671.          break;
  672.      case KEY_CTRL_F2 :
  673.          ///draw_arc();
  674.          type = 666;
  675.          break;
  676.      case KEY_CTRL_F3 :
  677.          ///draw_arc();
  678.          type = 667;
  679.          break;
  680.  
  681.  
  682.      default :
  683.            warble(1);
  684.            break;
  685.   }
  686.   update_shapebox( type );
  687.   _setcolor( c );
  688.   return( type );
  689. }
  690.  
  691. void draw_grid( void )
  692. {
  693.    pixtype mx1 = (X2 + X1) / 2;
  694.    pixtype my1 = (Y2 + Y1) / 2;
  695.    int     linestyle = _getlinestyle();
  696.    pixtype nx = ( int ) ( X2 - X1 ) / 8;
  697.    pixtype ny = ( int ) ( Y2 - Y1 ) / 8;
  698.    pixtype xpos, ypos;
  699.    pixtype i, j;
  700.    short c = _getcolor();
  701.  
  702.    mouse_hide();
  703.    _setlogorg(0, 0);
  704.    mouse_setpos(mx1, my1);
  705.    _setcolor( 0 );
  706.    _rectangle( _GFILLINTERIOR, X1, Y1, X2, Y2 );
  707.    _setcolor( border );
  708.    _setlinestyle(normal);
  709.    _rectangle( _GBORDER, X1, Y1, X2, Y2 );
  710.  
  711.  
  712.    _setcolor( 12 );
  713.    _setlinestyle( 1 );
  714.  
  715.    _moveto( mx1, Y1 );
  716.    _lineto( mx1, Y2 );
  717.    _moveto( X1, my1 );
  718.    _lineto( X2, my1 );
  719.    _setlinestyle( linestyle );
  720.    set_cad_logorg();
  721.    /// mouse_setpos(mx1, my1);
  722.    _setcolor( c );
  723.    mouse_show();
  724.    mouse_condoff( 10, 50, X1 - 10, Y2 );
  725. }
  726.  
  727. void draw_menu( void )
  728. {
  729.    short   color = 0, c = _getcolor();
  730.    int     x = 15, y = 265; /// x & y virtual screen positions
  731.    pixtype yrand, xrand;
  732.    short   i; /// index counter
  733.  
  734.    _setlogorg( 0, 0 );
  735.    _setcolor(8);
  736.  
  737.    _rectangle( _GFILLINTERIOR, 10, 50, 53, 93 );
  738.    _rectangle( _GFILLINTERIOR, 56, 50, X1 - 10, 93 );
  739.    _rectangle( _GFILLINTERIOR, 10, 98, 53, 141 );
  740.    _rectangle( _GFILLINTERIOR, 56, 98, X1 - 10, 141 );
  741.    _rectangle( _GFILLINTERIOR, 10, 146, 53, 189 );
  742.    _rectangle( _GFILLINTERIOR, 56, 146, X1 - 10, 189 );
  743.    _rectangle( _GFILLINTERIOR, 10, 194, 53, 237 );
  744.    _rectangle( _GFILLINTERIOR, 56, 194, X1 - 10, 237 );
  745.  
  746.    _setcolor(7);
  747.    _rectangle( _GBORDER, 10, 50, 53, 93 );
  748.    _rectangle( _GBORDER, 56, 50, X1 - 10, 93 );
  749.    _rectangle( _GBORDER, 10, 98, 53, 141 );
  750.    _rectangle( _GBORDER, 56, 98, X1 - 10, 141 );
  751.    _rectangle( _GBORDER, 10, 146, 53, 189 );
  752.    _rectangle( _GBORDER, 56, 146, X1 - 10, 189 );
  753.    _rectangle( _GBORDER, 10, 194, 53, 237 );
  754.    _rectangle( _GBORDER, 56, 194, X1 - 10, 237 );
  755.  
  756.    _setcolor( 15 );
  757.    _rectangle( _GBORDER, 20, 60, 43, 83 );           /// square box
  758.    _ellipse( _GBORDER, 66, 60, X1 - 20, 83 );        /// circle box
  759.    _moveto( 15, 103 );                               /// line box
  760.    _lineto( 48, 136 );
  761.    _moveto( 64, 106 );                               /// Character box
  762.    set_font( TRMN, 8 );
  763.    _outgtext("A");
  764.    _setcolor( c );
  765.    _rectangle( _GFILLINTERIOR, 20, 156, 43, 179 );   /// Solid rectangle
  766.    _ellipse(_GFILLINTERIOR, 66, 156, X1 - 20, 179 ); /// Solid ellipse
  767.  
  768.    _setcolor( 15 );                                  /// Quit flag
  769.    set_font( TRMN, 5 );
  770.    _moveto( 10, 205 );
  771.    _outgtext("Quit");
  772.                              /// Single pixels
  773.    for (i = 1; i < 50; i++ )
  774.      {
  775.      xrand = rand() % 33 + 60;
  776.      yrand = rand() % 33 + 201;
  777.      ///note( xrand, 1 );
  778.      _setpixel( xrand, yrand );
  779.      }
  780.      _getimage(54, 194, X1 - 10, 237, randbox );
  781.    draw_1stbox();
  782.  
  783.    ///  _rectangle( _GBORDER, (pixtype) (x / 6), y - 35, x - 8, y - 8 );
  784.      x = 275 ;
  785.      y = vc.numypixels - 31;
  786.  
  787.     /* Create the color bars */
  788.     for (color = 0; color <= 15; color++ )
  789.       {
  790.       _setcolor( color );
  791.       _moveto( x, y );
  792.       if ( color EQ 0 )
  793.      {
  794.      _setcolor( 15 );
  795.      _rectangle( _GBORDER, x - 1, y - 1, x + 20, y + 20 );
  796.      }
  797.       else
  798.  
  799.      _rectangle( _GFILLINTERIOR, x, y, x + 19, y + 19 );
  800.       x += 22;
  801.       }
  802.      _setcolor( 1 );
  803.      _rectangle( _GFILLINTERIOR, X1 + SIZE + 12, vc.numypixels - 31,\
  804.               X1 + SIZE + SIZE + 10, vc.numypixels - 11);
  805.      _rectangle( _GFILLINTERIOR, X1 + 5, vc.numypixels - 31, X1 + SIZE + 5, \
  806.                  vc.numypixels - 11);
  807. }
  808.  
  809.  
  810. void scroll_intro(void)
  811. {
  812.    int      i, x = 10, newx = 11, stop, len;
  813.    unsigned long color = 1, newcolor = 1;
  814.    int      type = 1;
  815.    int      randindx = 1;
  816.  
  817.     _setlogorg(0,0);
  818.     _getvideoconfig( &vc );
  819.     stop = vc.numxpixels / 2 - 45;
  820.  
  821.     _setcolor(0);
  822.     _rectangle( _GFILLINTERIOR, 8, 8, vc.numxpixels - 8, 40 ) ;  /// 1
  823.     _setcolor(15);
  824.     _rectangle( _GBORDER, 8, 8, vc.numxpixels - 8, 40 ) ;  /// 1
  825.  
  826.    _setcolor( 1 );
  827.    set_font( TRMN, 6 );
  828.    len = _getgtextextent(" Vanishing Point");
  829.    _moveto( 10 , 12 );
  830.    _outgtext(" Vanishing Point");
  831.    ///remap2(10, 12, len + 10, fi.pixheight + 12, 1 );
  832.    _getimage( 10, 12, \
  833.           10 + _getgtextextent(" Vanishing Point"), \
  834.           12 + fi.pixheight, image);
  835.  
  836.    while ( NOT kbhit())
  837.    {
  838.      if (newcolor == vc.numcolors)
  839.        newcolor = 1;
  840.      else
  841.        ++newcolor;
  842.  
  843.    for ( x = 10; x <= (vc.numxpixels - len - 18); x+= 5 )
  844.      {
  845.        _putimage( x, 12, image, _GPSET );
  846.  
  847.        _putimage( newx, 12, image, _GXOR );
  848.       newx += 5;
  849.  
  850.     color = get_color( &type, &r, &g, &b );
  851.        _remappalette((short)newcolor, color );
  852.      ///(long)c_array[newcolor] );
  853.        c_array[newcolor] = color;
  854.  
  855.        if (scroll_flag)
  856.      _remappalette(1, color );
  857.  
  858.        if ( kbhit() )
  859.       break;
  860.       }
  861.  
  862.     _setcolor(0);
  863.     _rectangle( _GFILLINTERIOR, 8, 8, vc.numxpixels - 8, 40 ) ;  /// 1
  864.     _setcolor(15);
  865.     _rectangle( _GBORDER, 8, 8, vc.numxpixels - 8, 40 ) ;  /// 1
  866.    _moveto( vc.numxpixels /  2 - 65 , 12 );
  867.     _putimage( stop, 12, image, _GPSET );
  868.    }
  869.    remap_std_palette();
  870.    font_menu(); /*****/
  871.    set_cad_logorg();
  872. }
  873.  
  874.  
  875. int getcolor( pixtype h)
  876. /* Returns the palette number of a color selected from the color menu at the
  877.    bottom of the screen.  Activated when the left mouse button is pressed in
  878.    the area over the color palette. */
  879. {
  880.        short       c;
  881.  
  882.        _setlogorg(0,0);
  883.        c = (short) (h - CX) / SIZE ;
  884.        _setcolor( c );
  885.        _rectangle( _GFILLINTERIOR, X1 + 5, vc.numypixels - 31, X1 + SIZE + 5, \
  886.                  vc.numypixels - 11);
  887.  
  888.        if ( c EQ 8 ) ///Gray Background case
  889.      {
  890.      _setcolor( 8 );
  891.      _rectangle( _GFILLINTERIOR, 20, 156, 43, 179 );   /// Solid rectangle
  892.      _ellipse(_GFILLINTERIOR, 66, 156, X1 - 20, 179 ); /// Solid ellipse
  893.      _setcolor(15);
  894.      _rectangle( _GBORDER, 20, 156, 43, 179 );   /// Solid rectangle
  895.      _ellipse(_GBORDER, 66, 156, X1 - 20, 179 ); /// Solid ellipse
  896.      }
  897.        else
  898.      {
  899.      _rectangle( _GFILLINTERIOR, 20, 156, 43, 179 );   /// Solid rectangle
  900.      _ellipse(_GFILLINTERIOR, 66, 156, X1 - 20, 179 ); /// Solid ellipse
  901.      }
  902.  
  903.        ///set_cad_logorg();
  904.        return( (h - CX) / SIZE );
  905. }
  906.  
  907. short getbordercolor(void)
  908. {
  909.    mouse_t     lb, rb, h, v;
  910.    short       c;
  911.  
  912.      mouse_status(&lb, &rb, &h, &v );
  913.      c = (short) (h - CX) / SIZE ;
  914.      _setcolor( c );
  915.      _rectangle( _GFILLINTERIOR, X1 + SIZE + 12, vc.numypixels - 31,\
  916.               X1 + SIZE + SIZE + 10, vc.numypixels - 11);
  917.      set_cad_logorg();
  918.      return( (h - CX) / SIZE );
  919. }
  920.  
  921.  
  922.  
  923. void remap_std_palette(void)
  924.  {
  925.  
  926. /*_remappalette(0, _BLACK);
  927. _remappalette(1, _BLUE);
  928. _remappalette(2, _GREEN);
  929. _remappalette(3, _CYAN);
  930. _remappalette(4, _RED);
  931. _remappalette(5, _MAGENTA);
  932. _remappalette(6, _BROWN);
  933. _remappalette(7, _WHITE);
  934. _remappalette(8, _GRAY);
  935. _remappalette(9, _LIGHTBLUE);
  936. _remappalette(10, _LIGHTGREEN);
  937. _remappalette(11, _LIGHTCYAN);
  938. _remappalette(12, _LIGHTRED);
  939. _remappalette(13, _LIGHTMAGENTA);
  940. _remappalette(14, _YELLOW);
  941. _remappalette(15, _BRIGHTWHITE);
  942. */
  943.  
  944. _remapallpalette( c_array3 );
  945.  
  946. }
  947.  
  948.  
  949. void cycle_palette(void)
  950. {
  951.     unsigned long color;
  952.     color_t      newcolor = 1;
  953.     boolean      esc_flag = FALSE;
  954.     short        r = 20, g = 30, b = 40, type = 1;
  955.     int          i;
  956.  
  957.  
  958.     while (NOT esc_flag)
  959.       {
  960.       for ( i = 1; i <= 5; i++ )
  961.     {
  962.     ///break_color( c_array[ i ], &r, &g, &b );
  963.     color = get_color( &type, &r, &g, &b );
  964.     _remappalette((short)newcolor, color);
  965.     if ( kbhit() )
  966.       {
  967.       esc_flag = TRUE;
  968.       break;
  969.       }
  970.     }
  971.       if (newcolor == vc.numcolors)
  972.     newcolor = 1;
  973.       else
  974.     ++newcolor;
  975.       if ( kbhit() )
  976.      esc_flag = TRUE;
  977.       }
  978. }
  979.  
  980.  
  981. void reset_vanish_pt(pixtype x, pixtype y)
  982. {
  983.   short c = _getcolor();
  984.  
  985.  mouse_hide();
  986.  note(x * y, 1);
  987.  _setlogorg(0,0);
  988. /* _getimage( X1 + 50, Y1 + 50, X2 - 50, Y2 - 50, screen);
  989.  _setcolor(0);
  990.  _rectangle(_GFILLINTERIOR, X1, Y1, X2, Y2 );
  991.   _putimage( X1 + 50, Y1 + 50, screen, _GXOR);    */
  992.  _setcolor(12);
  993.  _setlinestyle(1);
  994.  _moveto( x, Y1 );
  995.  _lineto( x, Y2 );
  996.  _moveto( X1, y );
  997.  _lineto( X2, y );
  998.  
  999.  _setlinestyle(normal);
  1000.  _setlogorg(x, y);
  1001.  _getvideoconfig( &vc );
  1002.  MX = x;
  1003.  MY = y;
  1004.  _setcolor( c );
  1005.  mouse_show();
  1006.  }
  1007.  
  1008. boolean inXscreen( pixtype h, pixtype v )
  1009. {
  1010.     _setlogorg(0,0);
  1011.     if ( ( h <= X1 ) OR ( h >= X2) OR \
  1012.          ( v <= Y1 ) OR ( v >= Y2 ) )
  1013.       {
  1014.       set_cad_logorg();
  1015.       return( FALSE );
  1016.       }
  1017.     else
  1018.       {
  1019.       set_cad_logorg();
  1020.       return( TRUE );
  1021.       }
  1022. }
  1023.  
  1024. int get_shape( pixtype h, pixtype v )
  1025. {
  1026.     int type = -1;
  1027.     pixtype  ypos, xpos;
  1028.     short    c = _getcolor();
  1029.  
  1030.     _getvideoconfig(&vc);
  1031.     ypos = vc.numypixels - 12;
  1032.     xpos = 12;
  1033.  
  1034.     if ( h > 10  AND v > 50 AND h < 53 AND v < 93 )
  1035.       type = 1; /// rectangle
  1036.     if ( h > 56  AND v > 50 AND h < (X1 - 10) AND v < 93 )
  1037.       type = 2; /// ellipse
  1038.     if ( h > 10  AND v > 98 AND h < 53 AND v < 142 )
  1039.       type = 6; /// line
  1040.     if ( h > 56  AND v > 98 AND h < ( X1 - 10 ) AND v < 142 )
  1041.       type = 8; /// Character
  1042.     if ( h > 10  AND v > 146 AND h < 53 AND v < 189 )
  1043.       type = 5; /// Solid rectangle
  1044.     if ( h > 56  AND v > 146 AND h < ( X1 - 10) AND v < 189 )
  1045.       type = 4; /// Solid ellipse
  1046.     if ( h > 10  AND v > 194 AND h < 53 AND v < 237 )
  1047.       type = 3; /// Quit flag
  1048.     if ( h > 56  AND v > 194 AND h < (X1 - 10) AND v < 237 )
  1049.       type = 25; /// Single pixels
  1050.  
  1051.     update_shapebox(type);
  1052.     _setcolor( c );
  1053.     return( type );
  1054. }
  1055.  
  1056.  
  1057. void draw_1stbox(void)
  1058. {
  1059.      pixtype xpos, ypos;
  1060.      short   c = _getcolor();
  1061.  
  1062.      ypos = vc.numypixels - 12;
  1063.      xpos = 12;
  1064.  
  1065.      _setlogorg( 0, 0 );
  1066.      _setcolor(8);
  1067.      _rectangle(_GFILLINTERIOR, xpos, ypos - 43, xpos + 43, ypos );
  1068.      _setcolor( 7 );
  1069.      _rectangle(_GBORDER, xpos, ypos - 43, xpos + 43, ypos );
  1070.      _setcolor(15);
  1071.      _rectangle( _GBORDER, xpos + 5, ypos - 38, xpos + 38, ypos - 5 );
  1072.      _setcolor( c );
  1073. }
  1074.  
  1075.  
  1076. boolean quit_prompt(short type )
  1077. {
  1078.      unsigned long key;
  1079.  
  1080.      _setlogorg(0,0);
  1081.      _getvideoconfig(&vc);
  1082.      _setfillmask( NULL );
  1083.       mouse_hide();
  1084.      _getimage( 200, 200, 600, 250, msgbox );
  1085.  
  1086.      _setcolor(7);
  1087.      _rectangle( _GFILLINTERIOR, 200, 200, 600, 250 );
  1088.      _setcolor(15);
  1089.      _rectangle( _GBORDER, 205, 205, 595, 245 );
  1090.  
  1091.      set_font( TRMN, 5 );
  1092.      _setcolor( 1 );
  1093.      _moveto( 215, 215 );
  1094.  
  1095.      _outgtext("You Loathsome Wretch. Press Y or N");
  1096.  
  1097.      update_shapebox( 3 );
  1098.  
  1099.      while ( 1 )
  1100.        {
  1101.        key = getch();
  1102.        if ( key EQ 'y' OR key EQ 'Y' )
  1103.      {
  1104.      _setbkcolor(_WHITE);
  1105.      siren(2);
  1106.      return( TRUE );
  1107.      }
  1108.        if ( key EQ 'n' OR key EQ 'N' )
  1109.      {
  1110.      _putimage( 200, 200, msgbox, _GPSET );
  1111.      update_shapebox( type );
  1112.      mouse_show();
  1113.      return( FALSE );
  1114.      }
  1115.        warble(1);
  1116.        }
  1117. }
  1118.  
  1119. void helpbox(void)
  1120. {
  1121.   short         c = _getcolor();
  1122.   short         row = 12, col = 22;
  1123.   unsigned long key;
  1124.   boolean       done = FALSE;
  1125.   boolean       shownext = FALSE;
  1126.  
  1127.   _setlogorg(0,0);
  1128.   _getvideoconfig( &vc );
  1129.   _getimage(150, 70, 355, 400, msgbox );
  1130.   _setcolor(0);
  1131.   _rectangle( _GFILLINTERIOR, 150, 70, 355, 400 );
  1132.   _setcolor(15);
  1133.   _rectangle( _GBORDER, 150, 70, 355, 400 );
  1134.  
  1135.  
  1136.   set_font(HELV, 6);
  1137.   _setcolor(12);
  1138.   _moveto( 163, 75);
  1139.   _outgtext("Commands Help");
  1140.   set_font( TRMN, 8 );
  1141.   _setcolor( 3 );
  1142.   _moveto( 205, 125 );
  1143.   _outgtext( "F Keys");
  1144.  
  1145.   _settextcolor( 1 );
  1146.   _settextposition( row++, col);
  1147.   _outtext("F1: This Help Menu");
  1148.   _settextposition( row++, col);
  1149.   _outtext("F2: Scroll Intro");
  1150.   _settextposition( row++, col);
  1151.   _outtext("F3: Stop Scroll Colors");
  1152.   _settextposition( row++, col);
  1153.   _outtext("F4: Reset Std Colors");
  1154.   _settextposition( row++, col);
  1155.   _outtext("F5: Cycle Colors");
  1156.   _settextposition( row++, col);
  1157.   _outtext("F6: Mirror On/Off");
  1158.   _settextposition( row++, col);
  1159.   _outtext("F7: Warp Shape On/Off");
  1160.   _settextposition( row++, col);
  1161.   _outtext("F8: Sound On/Off");
  1162.   _settextposition( row++, col);
  1163.   _outtext("F9: Clearscreen On/Off");
  1164.   _settextposition( row++, col);
  1165.   _outtext("F10: Clear Area");
  1166.  
  1167.  
  1168.  
  1169.   set_font( COUR, 4 );
  1170.   _setcolor(13);
  1171.   _moveto( 170, 365 );
  1172.   _outgtext("PGDN");
  1173.   _moveto(170 + _getgtextextent("PGDN") + 2, 365);
  1174.   _setcolor(5);
  1175.   _outgtext(" For More");
  1176.   _moveto( 170, 380 );
  1177.   _setcolor( 13 );
  1178.   _outgtext("END");
  1179.    _moveto(170 + _getgtextextent("END") + 2, 380);
  1180.    _setcolor(5);
  1181.   _outgtext(" To Return");
  1182.  
  1183.   while( NOT done )
  1184.     {
  1185.     key = getkey();
  1186.     switch ( key )
  1187.       {
  1188.       case KEY_PGDN :
  1189.              shownext = TRUE;
  1190.              done = TRUE;
  1191.              break;
  1192.       case KEY_ESCAPE:
  1193.       case KEY_END  :
  1194.              done = TRUE;
  1195.              break;
  1196.       default        :
  1197.              warble( 1 );
  1198.              break;
  1199.       }
  1200.     }
  1201.     if ( shownext )
  1202.       {
  1203.       _setcolor(0);
  1204.       _rectangle(_GFILLINTERIOR, 156, 95, 348, 348 );
  1205.       set_font( TRMN, 6 );
  1206.       _setcolor(3);
  1207.       _moveto( 165, 108 );
  1208.       _outgtext( "Mouse Functions");
  1209.  
  1210.   row = 10;
  1211.   col = 21;
  1212.   _settextcolor( 12 );
  1213.   _settextposition( row++, col);
  1214.   _outtext(" Clicking Left Button:");
  1215.   _settextcolor( 15 );
  1216.   _settextposition( row++, col);
  1217.   _outtext("Draws shapes within the");
  1218.   _settextposition( row++, col);
  1219.   _outtext("drawing area while");
  1220.   _settextposition( row++, col);
  1221.   _outtext("depressed");
  1222.  
  1223.   _settextcolor( 12 );
  1224.   _settextposition( row++, col);
  1225.   _outtext(" Clicking Right Button:");
  1226.   _settextcolor( 15 );
  1227.   _settextposition( row++, col);
  1228.   _outtext("Selects from color pal-");
  1229.   _settextposition( row++, col);
  1230.   _outtext("ette the active color.");
  1231.   _settextposition( row++, col);
  1232.   _outtext("Selects shapes at left");
  1233.   _settextposition( row++, col);
  1234.   _outtext("as the active shape.");
  1235.   _settextposition( row++, col);
  1236.   _outtext("Clicking anywhere within");
  1237.   _settextposition( row++, col);
  1238.   _outtext("drawing area resets the");
  1239.   _settextposition( row++, col);
  1240.   _outtext("Vanishing point to those");
  1241.   _settextposition( row++, col);
  1242.   _outtext("screen coordinates.");
  1243.  
  1244.   }
  1245.    done = FALSE;
  1246.    shownext = FALSE;
  1247.   while( NOT done )
  1248.     {
  1249.     key = getkey();
  1250.     switch ( key )
  1251.       {
  1252.       case KEY_PGDN :
  1253.       case KEY_DOWN :
  1254.              shownext = TRUE;
  1255.              done = TRUE;
  1256.              break;
  1257.       case KEY_ESCAPE:
  1258.       case KEY_END  :
  1259.              done = TRUE;
  1260.              break;
  1261.       default        :
  1262.              warble( 1 );
  1263.              break;
  1264.       }
  1265.     }
  1266.     if ( shownext )
  1267.       {
  1268.       _setcolor(0);
  1269.       _rectangle(_GFILLINTERIOR, 156, 95, 350, 395 );
  1270.       set_font( TRMN, 6 );
  1271.       _setcolor(3);
  1272.       _moveto( 155, 108 );
  1273.       _outgtext( "Keyboard Functions");
  1274.  
  1275.   row = 11;
  1276.   col = 22;
  1277.  
  1278.   _settextposition( row++, col);
  1279.   _settextcolor(12);
  1280.   _outtext("r   :");
  1281.   _settextcolor(15);
  1282.   _outtext(" Lined Rectangle");
  1283.   _settextposition( row++, col);
  1284.   _settextcolor(12);
  1285.   _outtext("R  :");
  1286.   _settextcolor(15);
  1287.   _outtext(" Filled Rectangle");
  1288.   _settextposition( row++, col);
  1289.   _settextcolor(12);
  1290.   _outtext("e  :");
  1291.   _settextcolor(15);
  1292.   _outtext(" Lined Ellipse");
  1293.   _settextposition( row++, col);
  1294.   _settextcolor(12);
  1295.   _outtext("E  :");
  1296.   _settextcolor(15);
  1297.   _outtext(" Solid Ellipse  ");
  1298.   _settextcolor(12);
  1299.    _settextposition( row++, col);
  1300.   _outtext("h  :");
  1301.   _settextcolor(15);
  1302.   _outtext(" This Help Menu");
  1303.   _settextcolor(12);
  1304.    _settextposition( row++, col);
  1305.   _outtext("p  :");
  1306.   _settextcolor(15);
  1307.   _outtext(" Individual Pixels");
  1308.  
  1309.   _settextposition( row++, col);
  1310.   _settextcolor(12);
  1311.   _outtext("<- :");
  1312.   _settextcolor(15);
  1313.   _outtext(" -- Linestyle");
  1314.   _settextposition( row++, col);
  1315.   _settextcolor(12);
  1316.   _outtext("-> :");
  1317.   _settextcolor(15);
  1318.   _outtext(" ++ Linestyle ");
  1319.   _settextposition( row++, col);
  1320.   _settextcolor(12);
  1321.   _outtext("L  :");
  1322.   _settextcolor(15);
  1323.   _outtext(" Reset Linestyle");
  1324.   _settextcolor(12);
  1325.    _settextposition( row++, col);
  1326.   _outtext("ESC:");
  1327.   _settextcolor(15);
  1328.   _outtext(" Exit Program");
  1329.   _settextcolor(12);
  1330.    _settextposition( row++, col);
  1331.   _outtext("DEL:");
  1332.   _settextcolor(15);
  1333.   _outtext(" Clear Box ");
  1334.  
  1335.  
  1336.   set_font( TRMN, 6 );
  1337.   _setcolor(1);
  1338.   _moveto( 180, 355);
  1339.   _outgtext("Press A Key");
  1340.   getch();
  1341.   }
  1342.   _putimage(150, 70, msgbox, _GPSET );
  1343.   hfree( msgbox );
  1344.   _setcolor( c );
  1345. }
  1346.  
  1347.  
  1348. short getmaptype( void )
  1349. {
  1350.    unsigned long key;
  1351.    boolean  done = FALSE;
  1352.    pixtype  x1, y1, x2, y2;
  1353.    short    maptype;
  1354.  
  1355.    x1 = y1 = 180;
  1356.    x2 = 600;
  1357.    y2 = 300;
  1358.  
  1359.    _setlogorg(0,0);
  1360.    _setbkcolor(0);
  1361.    mouse_hide();
  1362.    _getimage( x1, y1, x2, y2, msgbox);
  1363.  
  1364.     _setcolor(0);
  1365.     _rectangle(_GFILLINTERIOR, x1, y1, x2, y2);
  1366.     _setcolor(1);
  1367.     _rectangle(_GBORDER, x1, y1, x2, y2);
  1368.     _setcolor(9);
  1369.     _rectangle(_GBORDER, x1 + 5, y1 + 5, x2 - 5, y2 - 5);
  1370.  
  1371.    _settextposition(14, 26);
  1372.    _settextcolor(12);
  1373.    _outtext("Enter the type of remapping you want, range 1..4");
  1374.    _settextposition(16,26);
  1375.    _settextcolor(1);
  1376.    _outtext("           Press ESC to Return:");
  1377.    _settextposition(15,26);
  1378.    _settextcolor(14);
  1379.    _outtext("   Select area to remap with left mouse button");
  1380.  
  1381.    while (NOT done)
  1382.      {
  1383.      done = TRUE;
  1384.      key = getkey();
  1385.      switch (key)
  1386.        {
  1387.        case '1':
  1388.         maptype = 1;
  1389.         break;
  1390.        case '2':
  1391.          maptype = 2;
  1392.          break;
  1393.        case '3':
  1394.          maptype = 3;
  1395.          break;
  1396.        case '4':
  1397.          maptype = 4;
  1398.          break;
  1399.        case KEY_ESCAPE :
  1400.          maptype = -1;
  1401.          break;
  1402.        default :
  1403.          done = FALSE;
  1404.          warble(1);
  1405.          break;
  1406.        }
  1407.      }
  1408.  
  1409.    _putimage( x1, y1, msgbox, _GPSET);
  1410.    hfree(msgbox);
  1411.    set_cad_logorg();
  1412.    if ( fill_on )
  1413.      _setfillmask( pick[ipick] );
  1414.    mouse_show();
  1415.    return( maptype );
  1416. }
  1417.  
  1418.  
  1419.  
  1420. int remap_screen( short x1, short y1, short x2, short y2, short type )
  1421. {
  1422.  
  1423.      if ( type )
  1424.        remap2( x1, y1, x2, y2, type );
  1425.      return(1);
  1426. }
  1427.  
  1428.  
  1429. boolean draw_chars( pixtype x, pixtype y )
  1430. {
  1431.  
  1432.      char          str[90];
  1433.      short         slen, sht;  /// Length of string and grapics char height;
  1434.      short         i, pos = 0; /// index & current str pos
  1435.      char          c;
  1436.      unsigned long key;
  1437.      boolean done = FALSE, move = FALSE;
  1438.      mouse_t     lb, rb, h, v, oldh, oldv;
  1439.      short       c1, oldx = x, oldy = y;
  1440.      short       font;
  1441.      short       col = _getcolor();
  1442.  
  1443.  
  1444.     _getfontinfo( &fi );
  1445.      _setlogorg(0,0);
  1446.      sht = fi.pixheight - 1;
  1447.  
  1448.      _getimage( x-1, y-1, X2, y + sht, charbox);
  1449.  
  1450.      str[1] = NULL2 ;
  1451.       mouse_status( &lb, &rb, &oldh, &oldv );
  1452.      while ( NOT done )
  1453.        {
  1454.        oldx = x;
  1455.        oldy = y;
  1456.        mouse_show();
  1457.        mouse_status( &lb, &rb, &h, &v );
  1458.        if ( oldh != h OR oldv != v )
  1459.      {
  1460.      if (lb OR rb )
  1461.        {
  1462.        if ( ( h > X1) AND (v > Y1) AND (h < X2) AND (v < Y2))
  1463.        {
  1464.        x = h;
  1465.        y = v;
  1466.  
  1467.        _setcolor(0);
  1468.        _setpixel( oldx, oldy );
  1469.        _setpixel( oldx+1, oldy );
  1470.        _setpixel( oldx, oldy+1 );
  1471.        _setpixel( oldx-1, oldy );
  1472.        _setpixel( oldx, oldy-1 );
  1473.        pos = 0;
  1474.        str[1] = '\0';
  1475.        mouse_hide();
  1476.        _getimage( x-1, y-1, X2, y + sht, charbox);
  1477.        _setcolor( col );
  1478.        _setpixel( x, y );
  1479.        _setpixel( x+1, y );
  1480.        _setpixel( x, y+1 );
  1481.        _setpixel( x-1, y );
  1482.        _setpixel( x, y-1 );
  1483.        mouse_show();
  1484.        }
  1485.  
  1486.      else
  1487.      if ( (v < Y1) AND ( h > 20 ) )
  1488.        get_font_info( h, v );
  1489.  
  1490.      else
  1491.      if ( lb AND v > Y2 )
  1492.        {
  1493.        col = getcolor(h);
  1494.        if ( col >= 0 )
  1495.          _setcolor( col );
  1496.          _setlogorg(0,0);
  1497.        }
  1498.  
  1499.      else
  1500.      if ( rb AND v > Y2 )
  1501.        {
  1502.        border = getbordercolor();
  1503.        _setlogorg(0,0);
  1504.        }
  1505.      }
  1506.        }
  1507.  
  1508.  
  1509.      if ( kbhit() )
  1510.      {
  1511.      mouse_hide();
  1512.      key = getkey();
  1513.  
  1514.        switch (key)
  1515.       {
  1516.       case KEY_LEFT :
  1517.               x -= 5;
  1518.               move = TRUE;
  1519.               break;
  1520.       case KEY_RIGHT:
  1521.               x += 5;
  1522.               move = TRUE;
  1523.               break;
  1524.       case KEY_UP   :
  1525.               y -= 5;
  1526.               move = TRUE;
  1527.               break;
  1528.       case KEY_DOWN :
  1529.               y += 5;
  1530.               move = TRUE;
  1531.               break;
  1532.       case KEY_ESCAPE:
  1533.               done = TRUE;
  1534.               break;
  1535.       default       :
  1536.               break;
  1537.       }
  1538.        if ( move )
  1539.      {
  1540.      mouse_hide();
  1541.      _putimage( oldx-1, oldy-1, charbox, _GPSET );
  1542.      _moveto( oldx, oldy );
  1543.      _outgtext( str );
  1544.  
  1545.      _getimage( x-1, y-1, X2, y + sht, charbox);
  1546.      str[0] = '\0';
  1547.      pos = 0;
  1548.      move = FALSE;
  1549.      }
  1550.  
  1551.        else
  1552.        {
  1553.        mouse_show();
  1554.        str[pos] = key;
  1555.  
  1556.        if ( key EQ KEY_BACKSPACE OR key EQ KEY_DELETE)
  1557.      {
  1558.      str[pos + 2] = '\0';
  1559.      if ( pos >= 1 )
  1560.        {
  1561.        str[pos +1] = ' ';
  1562.        pos -= 2;
  1563.        }
  1564.      }
  1565.  
  1566.        str[pos + 1] = NULL2;
  1567.        slen = _getgtextextent(str);
  1568.        mouse_hide();
  1569.        _putimage( x-1, y-1, charbox, _GPSET );
  1570.        _moveto( x, y );
  1571.        _outgtext( str );
  1572.        pos += 1;
  1573.  
  1574.        if ( key EQ KEY_ENTER )
  1575.      {
  1576.      pos = 0;
  1577.      str[1] = '\0';
  1578.      y+= sht + 2;
  1579.      _getimage( x-1, y-1, X2 , y + sht, charbox);
  1580.      }
  1581.        }
  1582.      }
  1583.     }
  1584.    _setgtextvector(1,0);
  1585. }
  1586.  
  1587. short font_menu( void )
  1588.   {
  1589.    pixtype x1, y1, x2, y2;
  1590.    short   oldc = _getcolor();
  1591.  
  1592.     _setlogorg(0,0);
  1593.     _getvideoconfig(&vc);
  1594.     mouse_hide();
  1595.     _setgtextvector(1,0);
  1596.     _setcolor(0);
  1597.     _rectangle(_GFILLINTERIOR, 10, 10, 600, 36);
  1598.  
  1599.     set_font( HELV, 5);
  1600.  
  1601.  
  1602.    x1 = 125;
  1603.    y1 = 11;
  1604.    x2 = 225;
  1605.    y2 = 35;
  1606.  
  1607.   _setcolor(7);
  1608.   _rectangle(_GFILLINTERIOR, x1, y1, x2, y2);
  1609.   _setcolor(15);
  1610.   _rectangle(_GBORDER, x1, y1, x2, y2);
  1611.   _setcolor(15);
  1612.   _rectangle(_GBORDER, x1+ 2, y1+2, x2- 2, y2 - 2);
  1613.  
  1614.   _moveto( x1 + 26, y1 + 3);
  1615.   _setcolor(0);
  1616.   _outgtext("Fonts");
  1617.  
  1618.    x1 = 235;
  1619.    x2 = 335;
  1620.  
  1621.   _setcolor(7);
  1622.   _rectangle(_GFILLINTERIOR, x1, y1, x2, y2);
  1623.   _setcolor(15);
  1624.   _rectangle(_GBORDER, x1, y1, x2, y2);
  1625.   _setcolor(15);
  1626.   _rectangle(_GBORDER, x1+ 2, y1+2, x2- 2, y2 - 2);
  1627.   _moveto( x1 + 29, y1 + 3);
  1628.   _setcolor(0);
  1629.   _outgtext("Sizes");
  1630.  
  1631.  
  1632.    x1 = 345;
  1633.    x2 = 445;
  1634.  
  1635.   _setcolor(7);
  1636.   _rectangle(_GFILLINTERIOR, x1, y1, x2, y2);
  1637.   _setcolor(15);
  1638.   _rectangle(_GBORDER, x1, y1, x2, y2);
  1639.   _setcolor(15);
  1640.   _rectangle(_GBORDER, x1+ 2, y1+2, x2- 2, y2 - 2);
  1641.   _moveto( x1 + 20, y1 + 3);
  1642.   _setcolor(0);
  1643.   _outgtext("Vectors");
  1644.  
  1645.    x1 = 455;
  1646.    x2 = 555;
  1647.  
  1648.   _setcolor(7);
  1649.   _rectangle(_GFILLINTERIOR, x1, y1, x2, y2);
  1650.   _setcolor(15);
  1651.   _rectangle(_GBORDER, x1, y1, x2, y2);
  1652.   _setcolor(15);
  1653.   _rectangle(_GBORDER, x1+ 2, y1+2, x2- 2, y2 - 2);
  1654.   _moveto( x1 + 23, y1 + 3);
  1655.   _setcolor(0);
  1656.   _outgtext("Colors");
  1657.  
  1658.  
  1659.   x1 = 15;
  1660.   x2 = 115;
  1661.  
  1662.   _setcolor(7);
  1663.   _rectangle(_GFILLINTERIOR, x1, y1, x2, y2);
  1664.   _setcolor(15);
  1665.   _rectangle(_GBORDER, x1, y1, x2, y2);
  1666.   _setcolor(15);
  1667.   _rectangle(_GBORDER, x1+ 2, y1+2, x2- 2, y2 - 2);
  1668.   _moveto( x1 + 17, y1 + 3);
  1669.   _setcolor(0);
  1670.   _outgtext("Patterns");
  1671.  
  1672.  
  1673.   _setcolor(oldc);
  1674.   mouse_show();
  1675.   return(1);
  1676.  
  1677.   }
  1678.  
  1679. short fonttype( void )
  1680. {
  1681.  
  1682.   pixtype       p1, p2, q1, q2, porg, qorg;
  1683.   unsigned long key;
  1684.   boolean       nochoice = FALSE;
  1685.   short         f = 1;
  1686.  
  1687.   _setlogorg(0,0);
  1688.   _getvideoconfig(&vc);
  1689.   mouse_hide();
  1690.   _setgtextvector(1,0);
  1691.   p1 = porg = 125;
  1692.   q1 = qorg = 45;
  1693.   p2 = 325;
  1694.   q2 = 350;
  1695.  
  1696.   _getimage( p1, q1, p2, q2, msgbox );
  1697.  
  1698.   _setcolor( 7 );
  1699.   _rectangle(_GFILLINTERIOR, p1, q1, p2, q2);
  1700.   _setcolor(15);
  1701.   _rectangle(_GBORDER, p1, q1, p2, q2);
  1702.   _setcolor(12);
  1703.   _rectangle(_GBORDER, p1+ 2, q1 + 2, p2 - 2, q2 - 2);
  1704.  
  1705.  
  1706.   set_font( TRMN, 8 );
  1707.   _setcolor( 0 );
  1708.   _moveto( p1 + 15, q1 + 15 );
  1709.   _outgtext("Select A Font");
  1710.   _setcolor( 8 );
  1711.   _moveto( p1 + 14, q1 + 14);
  1712.   _outgtext("Select A Font");
  1713.  
  1714.  
  1715.   q1 += 40;
  1716.  
  1717.   set_font( COUR, 10 );
  1718.   _setcolor( 1 );
  1719.   _moveto( p1 + 50, q1 + 15 );
  1720.   _outgtext("Courier");
  1721.  
  1722.   set_font( HELV, 7 );
  1723.  _moveto( p1 + 20, q1 += (3 + fi.pixheight) );
  1724.   _outgtext("Helevatica");
  1725.  
  1726.   set_font( TRMN, 7 );
  1727.  _moveto( p1 + 10, q1 += (3 + fi.pixheight) );
  1728.   _outgtext("Times Roman");
  1729.  
  1730.   set_font( MOD, 7 );
  1731.  _moveto( p1 + 28, q1 += (3 + fi.pixheight) - 10);
  1732.   _outgtext("Modern");
  1733.  
  1734.   set_font( SCRP, 10 );
  1735.  _moveto( p1 + 13, q1 += (3 + fi.pixheight) - 17 );
  1736.   _outgtext("Script");
  1737.  
  1738.   set_font( ROM, 8 );
  1739.  _moveto( p1 + 20, q1 += (3 + fi.pixheight) );
  1740.   _outgtext("Roman");
  1741.  
  1742.   _setcolor(0);
  1743.   _rectangle(_GFILLINTERIOR, p1 + 5, q1 + 45, p2 - 5, q2 - 5 );
  1744.   _setcolor(11);
  1745.   _rectangle(_GBORDER, p1 + 5, q1 + 45, p2 - 5, q2 - 5 );
  1746.   _setcolor(4);
  1747.   _rectangle(_GBORDER, p1 + 8, q1 + 48, p2 - 8, q2 - 8 );
  1748.  
  1749.   _settextcolor(1);
  1750.   _settextposition( 19, 19 );
  1751.   _outtext("Enter the 1st Letter");
  1752.   _settextposition( 20, 19 );
  1753.   _outtext("of the font you want");
  1754.   _settextposition( 21, 19 );
  1755.   _outtext("    To Display");
  1756.  
  1757.  
  1758.   key = getkey();
  1759.   switch (key)
  1760.   {
  1761.     case 'c':
  1762.     case 'C':
  1763.           f = COUR;
  1764.           break;
  1765.     case 'h':
  1766.     case 'H':
  1767.           f = HELV;
  1768.           break;
  1769.     case 't':
  1770.     case 'T':
  1771.           f = TRMN;
  1772.           break;
  1773.     case 'm':
  1774.     case 'M':
  1775.           f = MOD;
  1776.           break;
  1777.     case 's':
  1778.     case 'S':
  1779.           f = SCRP;
  1780.           break;
  1781.     case 'r':
  1782.     case 'R':
  1783.           f = ROM;
  1784.           break;
  1785.     case KEY_ESCAPE:
  1786.           f = -1;
  1787.           break;
  1788.     default :
  1789.           note(765,1);
  1790.           break;
  1791.     }
  1792.   _putimage( porg, qorg, msgbox, _GPSET);
  1793.  
  1794.   mouse_show();
  1795.    hfree(msgbox);
  1796.    return( f );
  1797. }
  1798.  
  1799. void get_font_info( pixtype h, pixtype v)
  1800. {
  1801.  
  1802.     short v1 = 0, v2 = 0;
  1803.  
  1804.     if ( h > 235 AND h < 335)
  1805.       {
  1806.       size = get_font_size(size);
  1807.       set_font( font1, size );
  1808.       return;
  1809.       }
  1810.       else
  1811.     if ( h > 345 AND h < 445 )
  1812.       {
  1813.       get_vector();
  1814.       return;
  1815.       }
  1816.     else
  1817.     if (h > 125 AND h < 225 )
  1818.       {
  1819.       font1 = fonttype();
  1820.       if ( font1 > -1)
  1821.         set_font( font1, size );
  1822.       return;
  1823.       }
  1824.     return;
  1825. }
  1826.  
  1827. short get_font_size(short s)
  1828. {
  1829.     pixtype p1 = 235;
  1830.     pixtype q1 = Y1 + 5;
  1831.     pixtype p2 = 485;
  1832.     pixtype q2 = Y1 + 105;
  1833.     short   col = _getcolor();
  1834.     short   f = font1;
  1835.     unsigned long key;
  1836.     boolean done = FALSE;
  1837.     char    str1[20];
  1838.  
  1839.     _setlogorg(0,0);
  1840.     mouse_hide();
  1841.     _getimage(p1, q1, p2, q2, msgbox );
  1842.     _setcolor(1);
  1843.     _rectangle(_GFILLINTERIOR, p1 + 1, q1 + 1, p2 - 1, q2 -1);
  1844.     _setcolor(7);
  1845.     _rectangle(_GFILLINTERIOR, p1, q1, p2, q2);
  1846.  
  1847.     _setcolor(8);
  1848.     _rectangle(_GBORDER, p1+1, q1+1, p2-1, q2-1);
  1849.     _rectangle(_GBORDER, p1+2, q1+2, p2-2, q2-2);
  1850.     _setcolor(7);
  1851.     _rectangle(_GBORDER, p1+3, q1+3, p2-3, q2-3);
  1852.     _rectangle(_GBORDER, p1+4, q1+4, p2-4, q2-4);
  1853.  
  1854.     set_font( TRMN, 6 );
  1855.     _setcolor(0);
  1856.     _moveto( p1 + 25, q1 + 5 );
  1857.     _outgtext("    Select Font Size");
  1858.     _setcolor(15);
  1859.     _moveto( p1 + 24, q1 + 4 );
  1860.     _outgtext("    Select Font Size");
  1861.  
  1862.     _moveto( p1 + 2, q1 + 30 );
  1863.     _setcolor(1);
  1864.     _outgtext("      Choose a Size in");
  1865.     _moveto( p1 + 2, q1 + 45);
  1866.     _outgtext("        the range 1..9");
  1867.  
  1868.     _settextcolor(4);
  1869.     while (NOT done)
  1870.      {
  1871.      sprintf( str1, " Current Size: %d", s );
  1872.      _settextposition(9, 38);
  1873.      _outtext( str1 );
  1874.      key = getkey();
  1875.      switch (key)
  1876.       {
  1877.       case '1' :  s =1;
  1878.           break;
  1879.       case '2' :  s =2; break;
  1880.       case '3' :  s =3; break;
  1881.       case '4' :  s =4; break;
  1882.       case '5' :  s =5; break;
  1883.       case '6' :  s =6; break;
  1884.       case '7' :  s =7; break;
  1885.       case '8' :  s =8; break;
  1886.       case '9' :  s =9; break;
  1887.       case KEY_UP:
  1888.           if ( s < 9 )
  1889.             ++s;
  1890.           break;
  1891.       case KEY_DOWN:
  1892.           if ( s > 2 )
  1893.             --s;
  1894.           break;
  1895.       case KEY_ESCAPE:
  1896.       case KEY_ENTER :
  1897.           done = TRUE;
  1898.           break;
  1899.       default  :  note(500, 1 );
  1900.           break;
  1901.  
  1902.       }
  1903.      }
  1904.    _putimage(p1, q1, msgbox, _GPSET);
  1905.    _setcolor( col );
  1906.    mouse_show();
  1907.     return(s);
  1908.  
  1909. }
  1910. void get_fillmask( void )
  1911.  
  1912. {
  1913.    unsigned char   mask[8];
  1914.    ///unsigned char   pick[5][8];
  1915.    pixtype         p1, q1, p2, q2, r1, s1, r2, s2;
  1916.    pixtype         xpos, ypos, oldx;
  1917.    pixtype         boxsize = 70;
  1918.    boolean         done = FALSE, change = TRUE, null = FALSE;
  1919.    short           col = _getcolor();
  1920.    short           i, j, oldi; /// indexes
  1921.    unsigned short  key;
  1922.  
  1923.    p1 = X1 + 50;
  1924.    q1 = Y1 + 100;
  1925.    p2 = p1 + 400;
  1926.    q2 = Y1 + 300;
  1927.  
  1928.    _setlogorg(0,0);
  1929.    mouse_hide();
  1930.    _getimage( p1, q1, p2, q2, msgbox );
  1931.  
  1932.    _setfillmask( NULL );
  1933.    fill_on = TRUE;
  1934.    _setcolor(1);
  1935.    _rectangle(_GFILLINTERIOR, p1 ,q1, p2, q2 );
  1936.    _setcolor(9);
  1937.    _rectangle(_GFILLINTERIOR, p1 + 3, q1 + 3, p2 - 3, q2 - 3);
  1938.    _setcolor(11);
  1939.    _rectangle(_GFILLINTERIOR, p1 + 6, q1 + 6, p2 - 6, q2 - 6);
  1940.  
  1941.    r1 = p1 + 15;
  1942.    r2 = r1 + boxsize;
  1943.    s1 = q1 + 55 + boxsize;
  1944.    s2 = s1 + 25;
  1945.    _setcolor(0);
  1946.    _rectangle(_GFILLINTERIOR, r1, s1, r2, s2 );
  1947.    _setcolor(8);
  1948.    _rectangle(_GFILLINTERIOR, r1 + 3, s1 + 3, r2 - 3, s2 - 3 );
  1949.    _setcolor(7);
  1950.    _rectangle(_GFILLINTERIOR, r1 + 6, s1 + 6, r2 - 6, s2 - 6 );
  1951.    _setcolor(0);
  1952.    set_font( HELV, 5);
  1953.    _moveto( r1 + 13, s1 + 3 );
  1954.    _outgtext("More");
  1955.  
  1956.    s1 += 35;
  1957.    s2 += 35;
  1958.    _setcolor(0);
  1959.    _rectangle(_GFILLINTERIOR, r1, s1, r2, s2 );
  1960.    _setcolor(8);
  1961.    _rectangle(_GFILLINTERIOR, r1 + 3, s1 + 3, r2 - 3, s2 - 3 );
  1962.    _setcolor(7);
  1963.    _rectangle(_GFILLINTERIOR, r1 + 6, s1 + 6, r2 - 6, s2 - 6 );
  1964.    _setcolor(0);
  1965.    _moveto( r1 + 6, s1 + 3 );
  1966.    _outgtext("Default");
  1967.  
  1968.    r1 = r2 + 5;
  1969.    r2 = r1 + boxsize;
  1970.    _setcolor(0);
  1971.    _rectangle(_GFILLINTERIOR, r1, s1, r2, s2 );
  1972.    _setcolor(8);
  1973.    _rectangle(_GFILLINTERIOR, r1 + 3, s1 + 3, r2 - 3, s2 - 3 );
  1974.    _setcolor(7);
  1975.    _rectangle(_GFILLINTERIOR, r1 + 6, s1 + 6, r2 - 6, s2 - 6 );
  1976.    _setcolor(0);
  1977.    _moveto( r1 + 11, s1 + 3 );
  1978.    _outgtext("  OK");
  1979.  
  1980.    s1 -= 35;
  1981.    s2 -= 35;
  1982.    _setcolor(0);
  1983.    _rectangle(_GFILLINTERIOR, r1, s1, r2, s2 );
  1984.    _setcolor(8);
  1985.    _rectangle(_GFILLINTERIOR, r1 + 3, s1 + 3, r2 - 3, s2 - 3 );
  1986.    _setcolor(7);
  1987.    _rectangle(_GFILLINTERIOR, r1 + 6, s1 + 6, r2 - 6, s2 - 6 );
  1988.    _setcolor(0);
  1989.    _moveto( r1 + 13, s1 + 3 );
  1990.    _outgtext("Make");
  1991.  
  1992.    r1 = r2 + 5;
  1993.    r2 = r1 + boxsize;
  1994.    _setcolor(0);
  1995.    _rectangle(_GFILLINTERIOR, r1, s1, r2, s2 );
  1996.    _setcolor(8);
  1997.    _rectangle(_GFILLINTERIOR, r1 + 3, s1 + 3, r2 - 3, s2 - 3 );
  1998.    _setcolor(7);
  1999.    _rectangle(_GFILLINTERIOR, r1 + 6, s1 + 6, r2 - 6, s2 - 6 );
  2000.    _setcolor(0);
  2001.    _moveto( r1 + 6, s1 + 3 );
  2002.    _outgtext("Cancel");
  2003.  
  2004.  
  2005.    s1 += 35;
  2006.    s2 += 35;
  2007.    _setcolor(0);
  2008.    _rectangle(_GFILLINTERIOR, r1, s1, r2, s2 );
  2009.    _setcolor(8);
  2010.    _rectangle(_GFILLINTERIOR, r1 + 3, s1 + 3, r2 - 3, s2 - 3 );
  2011.    _setcolor(7);
  2012.    _rectangle(_GFILLINTERIOR, r1 + 6, s1 + 6, r2 - 6, s2 - 6 );
  2013.    _setcolor(0);
  2014.    _moveto( r1 + 11, s1 + 3 );
  2015.    _outgtext(" Help");
  2016.  
  2017.  
  2018.    set_font( TRMN, 8 );
  2019.    _moveto( p1 + 75, q1 + 15 );
  2020.    _setcolor(12);
  2021.    _outgtext("Select A Fill Pattern");
  2022.    _moveto( p1 + 74, q1 + 14 );
  2023.    _setcolor(4);
  2024.    _outgtext("Select A Fill Pattern");
  2025.  
  2026.    xpos = oldx = p1 + 15;
  2027.    ypos = q1 + 45;
  2028.  
  2029.    for ( i = 0; i < 5; i++ )
  2030.      {
  2031.       _setcolor(0);
  2032.       _rectangle(_GFILLINTERIOR, xpos, ypos, xpos + boxsize, ypos + boxsize );
  2033.       _setcolor(8);
  2034.       _rectangle(_GFILLINTERIOR, xpos + 3, ypos + 3, xpos + boxsize - 3, ypos + boxsize -3);
  2035.       _setcolor(col);
  2036.  
  2037.       for ( j = 0; j < 8; j++ )
  2038.      mask[j] =  pick[i][j] = (unsigned char)rand();
  2039.  
  2040.       _setfillmask( mask );
  2041.       _rectangle(_GFILLINTERIOR, xpos + 6, ypos + 6, xpos + boxsize - 6, ypos + boxsize -6);
  2042.       _setfillmask(NULL);
  2043.       xpos += boxsize + 5;
  2044.      }
  2045.  
  2046.    _setcolor(15);
  2047.    _rectangle(_GBORDER, oldx, ypos, oldx + boxsize, ypos + boxsize );
  2048.     _rectangle(_GBORDER ,oldx + 3, ypos + 3, oldx + boxsize - 3, ypos + boxsize - 3 );
  2049.  
  2050.    i = 0;
  2051.    mouse_show();
  2052.    while ( NOT done )
  2053.      {
  2054.      key = getkey();
  2055.      oldi = i;
  2056.      switch ( key )
  2057.        {
  2058.        case KEY_RIGHT :
  2059.             if ( i < 4 )
  2060.               ++i;
  2061.             else
  2062.               i = 0;
  2063.             break;
  2064.        case KEY_LEFT  :
  2065.             if ( i >= 1 )
  2066.               --i;
  2067.             else
  2068.               i = 4;
  2069.             break;
  2070.        case KEY_ENTER :
  2071.                done = TRUE;
  2072.                break;
  2073.        case KEY_HOME  :
  2074.                null = TRUE;
  2075.                break;
  2076.        case KEY_ESCAPE:
  2077.                _setcolor( col );
  2078.                fill_on = FALSE;
  2079.                _putimage(p1, q1, msgbox, _GPSET );
  2080.                _setfillmask( NULL );
  2081.             ///   mouse_setgcurs( &gcursor_hand );
  2082.                mouse_show();
  2083.                return;
  2084.        default        :
  2085.                note(660, 2);
  2086.                break;
  2087.        }
  2088.        mouse_hide();
  2089.        _setcolor( 0 );
  2090.        _setfillmask(NULL);
  2091.        _rectangle(_GFILLINTERIOR, p2 - 85, q2 - 80, p2 - 85 + boxsize , q2 - 80 + boxsize );
  2092.        if ( NOT null )
  2093.      _setfillmask( pick[i] );
  2094.        else
  2095.      _setfillmask( NULL );
  2096.        _setcolor(col);
  2097.        _rectangle(_GFILLINTERIOR, p2 - 85, q2 - 80, p2 - 85 + boxsize , q2 - 80 + boxsize );
  2098.        _setcolor(15);
  2099.        _rectangle(_GBORDER, p2 - 85, q2 - 80, p2 - 85 + boxsize , q2 - 80 + boxsize );
  2100.        _rectangle(_GBORDER, p2 - 83, q2 - 78, p2 - 87 + boxsize , q2 - 82 + boxsize );
  2101.        null = FALSE;
  2102.  
  2103.        ipick = i;
  2104.        oldi = xpos ;
  2105.  
  2106.      xpos = p1 + 15 + ( i * ( boxsize + 5) - 1) ;
  2107.  
  2108.      if ( NOT done )
  2109.        {
  2110.       _setcolor(15);
  2111.        _rectangle(_GBORDER, xpos, ypos, xpos + boxsize, ypos + boxsize );
  2112.     _rectangle(_GBORDER, xpos+ 3, ypos + 3, xpos + boxsize - 3, ypos + boxsize -3);
  2113.     xpos = p1 + 15 + ( ( i ) * ( boxsize + 5) );
  2114.        _setcolor(0);
  2115.        _rectangle(_GBORDER, oldi, ypos, oldi + boxsize, ypos + boxsize );
  2116.        _rectangle(_GBORDER, oldi + 3, ypos + 3, oldi + boxsize - 3, ypos + boxsize -3);
  2117.        oldi = xpos;
  2118.        }
  2119.       mouse_show();
  2120.      }
  2121.    _setcolor( col );
  2122.    mouse_hide();
  2123.    _putimage(p1, q1, msgbox, _GPSET );
  2124.    _setfillmask( NULL );
  2125.  ///  mouse_setgcurs( &gcursor_hand );
  2126.    mouse_show();
  2127.    return;
  2128. }
  2129.  
  2130.  
  2131. void get_vector(void )
  2132. {
  2133.  
  2134.     pixtype p1, q1, p2, q2;
  2135.     pixtype vx, vy;
  2136.     char    msg[7] = "Vector";
  2137.     char    xnum[4], ynum[4];
  2138.     char    str[50];
  2139.     short   col = _getcolor();
  2140.     pixtype xpos, ypos;
  2141.     boolean done = FALSE;
  2142.     short   xvect = 1, yvect = 0;
  2143.     short   xcol = 53 , ycol = 65, row = 20;
  2144.     unsigned long key;
  2145.     pixtype  cht; /// Character height
  2146.  
  2147.     p1 = 300;
  2148.     q1 = Y1 + 10;
  2149.     p2 = 600;
  2150.     q2 = Y1 + 310;
  2151.  
  2152.     mouse_hide();
  2153.     _getimage( p1, q1, p2, q2, msgbox );
  2154.  
  2155.     _setfillmask (NULL);
  2156.  
  2157.     _setcolor(15);
  2158.     _rectangle(_GFILLINTERIOR, p1, q1, p2, q2);
  2159.     _setcolor(0);
  2160.     _rectangle(_GFILLINTERIOR, p1+2, q1+2, p2-2, q2-2);
  2161.     _setcolor(8);
  2162.     _rectangle(_GFILLINTERIOR, p1 + 4, q1+4, p2-4, q2-4);
  2163.     _setcolor(7);
  2164.     _rectangle(_GFILLINTERIOR, p1 + 6, q1 + 6, p2 - 6, q2 - 6);
  2165.  
  2166.     _setgtextvector(1, 0);
  2167.     _moveto( p1 + 10, q1 + 10 );
  2168.     _setcolor(0);
  2169.     set_font( HELV, 7);
  2170.     _outgtext("Choose a Text Vector");
  2171.     _moveto( p1 + 9, q1 + 9 );
  2172.     _setcolor(8);
  2173.     _outgtext("Choose a Text Vector");
  2174.  
  2175.     _setcolor(1);
  2176.     _rectangle(_GFILLINTERIOR, p1 + 10, q2 - 100, p2 - 10, q2 - 10);
  2177.     _setcolor(9);
  2178.     _rectangle(_GFILLINTERIOR, p1+13, q2 - 97, p2-13, q2-13);
  2179.     _setcolor(11);
  2180.     _rectangle(_GFILLINTERIOR, p1 + 16, q2 - 94, p2-16, q2 - 16);
  2181.     _setcolor(0);
  2182.     _rectangle(_GFILLINTERIOR, p1 + 19, q2 - 91, p2-19, q2 - 19);
  2183.  
  2184.     _setcolor(1);
  2185.     _rectangle(_GFILLINTERIOR, p1 + 10, q1 + 35, p2 - 10, q2 - 105);
  2186.     _setcolor(9);
  2187.     _rectangle(_GFILLINTERIOR, p1+13, q1 + 38, p2-13, q2-108);
  2188.     _setcolor(11);
  2189.     _rectangle(_GFILLINTERIOR, p1 + 16, q1 + 41, p2-16, q2 - 111);
  2190.     _setcolor(0);
  2191.     _rectangle(_GFILLINTERIOR, p1 + 19, q1 + 44, p2-19, q2 - 114);
  2192.  
  2193.     _settextcolor(5);
  2194.     _settextposition(20,46);
  2195.     sprintf( str,"X Vector:%2d  Y Vector:%2d", xvect, yvect);
  2196.     _outtext(str);
  2197.  
  2198.     _setcolor(col);
  2199.     set_font(TRMN, 8 );
  2200.     xpos = p1 + ((p2 - p1)/2) - (_getgtextextent(msg) / 2) + 1;
  2201.     ypos = q1 + 100;
  2202.  
  2203.     _setgtextvector(xvect, yvect);
  2204.      _moveto(xpos, q1 + 100);
  2205.     _outgtext( msg );
  2206.     mouse_show();
  2207.  
  2208.     while ( NOT done )
  2209.       {
  2210.       key = getkey();
  2211.       switch (key)
  2212.         {
  2213.         case KEY_UP :
  2214.              if ( xvect < 1 )
  2215.                ++xvect;
  2216.              break;
  2217.         case KEY_DOWN :
  2218.              if ( xvect > -1 )
  2219.                --xvect;
  2220.              break;
  2221.         case KEY_LEFT :
  2222.              if ( yvect > -1 )
  2223.                --yvect;
  2224.              break;
  2225.         case KEY_RIGHT :
  2226.              if ( yvect < 1 )
  2227.                ++yvect;
  2228.              break;
  2229.         case KEY_HOME :
  2230.              xvect = 1;
  2231.              yvect = 0;
  2232.              break;
  2233.         case KEY_ENTER:
  2234.         case KEY_ESCAPE:
  2235.              done = TRUE;
  2236.              break;
  2237.         default :
  2238.              note(660, 2);
  2239.              break;
  2240.         }
  2241.       mouse_hide();
  2242.  
  2243.     _settextposition(20,46);
  2244.     sprintf( str,"X Vector: %2d  Y Vector: %2d", xvect, yvect);
  2245.     _outtext(str);
  2246.     _setcolor(1);
  2247.     _rectangle(_GFILLINTERIOR, p1 + 10, q1 + 35, p2 - 10, q2 - 110);
  2248.     _setcolor(9);
  2249.     _rectangle(_GFILLINTERIOR, p1+13, q1 + 38, p2-13, q2-113);
  2250.     _setcolor(11);
  2251.     _rectangle(_GFILLINTERIOR, p1 + 16, q1 + 41, p2-16, q2 - 116);
  2252.     _setcolor(0);
  2253.     _rectangle(_GFILLINTERIOR, p1 + 19, q1 + 44, p2-19, q2 - 119);
  2254.  
  2255.     _setcolor( col );
  2256.     mouse_show();
  2257.  
  2258.     if ( (xvect EQ 1) AND (yvect == -1) )
  2259.       {
  2260.       xpos = p1 + 45;
  2261.       ypos = q1 + 60;
  2262.       }
  2263.     else
  2264.     if ( (xvect EQ 1) AND (yvect == 1) )
  2265.       {
  2266.       xpos = p1 + 80;
  2267.       ypos = q2 - 40;
  2268.       }
  2269.     else
  2270.     if ( (xvect EQ 0) AND (yvect == -1) )
  2271.       {
  2272.       xpos = 450;
  2273.       ypos = q1 + 60;
  2274.       }
  2275.     else
  2276.     if ( (xvect EQ -1) AND (yvect == -1) )
  2277.       {
  2278.       xpos = p2 -40;
  2279.       ypos = q1 + 30;
  2280.       }
  2281.     else
  2282.     if ( (xvect EQ 0) AND (yvect == 1) )
  2283.       {
  2284.       xpos = 400;
  2285.       ypos = q2 - 135;
  2286.       }
  2287.     else
  2288.     if ( (xvect EQ -1) AND (yvect == 0 ) )
  2289.       {
  2290.       xpos = p2 - 35;
  2291.       ypos = Y1 + 150;
  2292.       }
  2293.  
  2294.     _setgtextvector(xvect, yvect);
  2295.  
  2296.     _moveto(xpos, ypos);
  2297.     _outgtext( msg );
  2298.     xpos = p1 + ((p2 - p1)/2) - (_getgtextextent(msg) / 2) + 1;
  2299.     ypos = q1 + 100;
  2300.  
  2301.     }
  2302.  
  2303.     _setcolor( col );
  2304.     mouse_hide();
  2305.     _putimage( p1, q1, msgbox, _GPSET );
  2306.     mouse_show();
  2307.     return;
  2308. }
  2309.  
  2310.  
  2311. void remap_color( short col )
  2312. {
  2313.  
  2314.    pixtype p1,q1,p2,q2;
  2315.    short   oldcolor = _getcolor();
  2316.    short   ht = 130, wd = 40, space = 12;
  2317.    short   rindx, gindx, bindx, i ;
  2318.    pixtype xpos, ypos;
  2319.    boolean done = FALSE, go = TRUE;
  2320.    color_t newcolor;
  2321.    short   row = 20, column = 31;
  2322.    short   oldc, current;
  2323.    unsigned long key;
  2324.    char     t[5];
  2325.  
  2326.    _setlogorg(0,0);
  2327.    mouse_hide();
  2328.  
  2329.    p1 = 200;
  2330.    q1 = 100;
  2331.    p2 = p1 + 200;
  2332.    q2 = q1 + 300;
  2333.  
  2334.    rindx = gindx = bindx = 32;
  2335.    r = g = b = 32;
  2336.    oldc = current = 1;
  2337.  
  2338.    _getimage( p1, q1, p2, q2, msgbox );
  2339.  
  2340.    _setcolor(15);
  2341.    _rectangle(_GFILLINTERIOR, p1, q1, p2, q2 );
  2342.    _setcolor(8);
  2343.    _rectangle(_GFILLINTERIOR, p1 + 5, q1 + 5, p2 - 5, q2 - 5 );
  2344.    _setcolor(7);
  2345.    _rectangle(_GFILLINTERIOR, p1 + 10, q1 + 10, p2 - 10, q2 - 10 );
  2346.    _setcolor(0);
  2347.    _rectangle(_GFILLINTERIOR, p1 + 15, q1 + 15, p2 - 15, q2 - 15 );
  2348.  
  2349.    newcolor = rgb( r, g, b );
  2350.    _remappalette(col, newcolor);
  2351.    _setcolor( col );
  2352.    _rectangle(_GFILLINTERIOR, p1 + 25, q2 - 60, p1 + 60, q2 - 25 );
  2353.    _setcolor(15);
  2354.     _rectangle(_GBORDER, p1 + 25, q2 - 60, p1 + 60, q2 - 25 );
  2355.  
  2356.  
  2357.  
  2358.    xpos = p1 + 28;
  2359.    ypos = q1 + 55;
  2360.    for ( i = 1; i <= 3; i++ )
  2361.      {
  2362.       _setcolor(15);
  2363.       _rectangle(_GBORDER, xpos, ypos, xpos + wd, ypos + ht );
  2364.       _rectangle(_GBORDER, xpos + 3, ypos + 3, xpos + wd - 3, ypos + ht -3);
  2365.        switch( i )
  2366.      {
  2367.      case 1 :
  2368.          _setcolor( 4 );
  2369.          _settextcolor( 4 );
  2370.          break;
  2371.      case 2 :
  2372.          _setcolor( 2 );
  2373.          _settextcolor( 2 );
  2374.          break;
  2375.      case 3 :
  2376.          _setcolor( 1 );
  2377.           _settextcolor( 1 );
  2378.          break;
  2379.      default:
  2380.          break;
  2381.      }
  2382. _rectangle(_GBORDER, xpos, ypos + ht + space, xpos + wd, ypos + ht + space + 25);
  2383. _settextposition( row, column );
  2384. _outtext("32");
  2385. column += 8 - i;
  2386.  
  2387. _rectangle(_GFILLINTERIOR, xpos + 10, ypos + ht - 15 - (r * 2), \
  2388.                xpos + wd - 10, ypos + ht - 8);
  2389.  
  2390.       xpos += wd + space;
  2391.      }
  2392.  
  2393.    _setcolor(12);
  2394.    set_font( TRMN, 6 );
  2395.    _moveto( p1 + 27, q1 + 20);
  2396.    _outgtext("Custom Colors");
  2397.    _setcolor(4);
  2398.    _moveto( p1 + 26, q1 + 19);
  2399.    _outgtext("Custom Colors");
  2400.  
  2401.    xpos = p1 + 28;
  2402.    ypos = q1 + 55;
  2403.    row = 20;
  2404.    while ( NOT done )
  2405.      {
  2406.       key = getkey_or_mouse();
  2407.       oldc = current;
  2408.       column = 31;
  2409.       switch( key )
  2410.     {
  2411.     case KEY_LEFT :
  2412.       if ( current == 1 )
  2413.         current = 3;
  2414.       else
  2415.         --current ;
  2416.       go = FALSE;
  2417.       break;
  2418.     case KEY_RIGHT :
  2419.       if ( current == 3 )
  2420.         current = 1;
  2421.       else
  2422.         ++current ;
  2423.       go = FALSE;
  2424.       break;
  2425.     case KEY_UP :
  2426.       if ( (current == 1) AND (r < 63) )
  2427.         ++r;
  2428.       else
  2429.       if ( (current == 2) AND (g < 63) )
  2430.         ++g;
  2431.       else
  2432.       if ( (current == 3) AND (b < 63) )
  2433.         ++b;
  2434.       go = TRUE;
  2435.       break;
  2436.     case KEY_DOWN :
  2437.       if ( (current == 1) AND (r > 1) )
  2438.         --r;
  2439.       else
  2440.       if ( (current == 2) AND (g > 1) )
  2441.         --g;
  2442.       else
  2443.       if ( (current == 3) AND (b > 1) )
  2444.         --b;
  2445.       go = TRUE;
  2446.       break;
  2447.     case KEY_ESCAPE:
  2448.     case KEY_ENTER :
  2449.       done = TRUE;
  2450.       break;
  2451.     default :
  2452.       note(777, 2);
  2453.       break;
  2454.     }
  2455.    newcolor = rgb( r, g, b );
  2456.    _remappalette(col, newcolor);
  2457.    _setcolor( col );
  2458.    _rectangle(_GFILLINTERIOR, p1 + 25, q2 - 60, p1 + 60, q2 - 25 );
  2459.    _setcolor(15);
  2460.     _rectangle(_GBORDER, p1 + 25, q2 - 60, p1 + 60, q2 - 25 );
  2461.  
  2462.    _setcolor(15);
  2463.    xpos = (p1 + 28) + ((oldc - 1) * (wd + space));
  2464.       oldc = current;
  2465.       _rectangle(_GBORDER, xpos, ypos, xpos + wd, ypos + ht );
  2466.      _rectangle(_GBORDER, xpos + 3, ypos + 3, xpos + wd - 3, ypos + ht -3);
  2467.  
  2468.     switch (current)
  2469.       {
  2470.       case 1: _setcolor(4);
  2471.           _settextcolor(4);
  2472.           break;
  2473.       case 2: _setcolor(2);
  2474.           _settextcolor(2);
  2475.           break;
  2476.       case 3: _setcolor(1);
  2477.           _settextcolor(1);
  2478.           break;
  2479.       default:
  2480.           break;
  2481.       }
  2482.  
  2483.      if (go)
  2484.      switch( current )
  2485.      {
  2486.        case 1 :
  2487.        _setcolor(0);
  2488.        _rectangle(_GFILLINTERIOR, xpos + 10, ypos + 10, \
  2489.                xpos + wd - 10, ypos + ht - 8);
  2490.        _settextcolor( 4 );
  2491.        sprintf( t, "%2d", (int)r );
  2492.        column = 31;
  2493.        _setcolor( 4 );
  2494.        _rectangle(_GFILLINTERIOR, xpos + 10, ypos + ht - 5 - (r * 2), \
  2495.                xpos + wd - 10, ypos + ht - 8);
  2496.      break;
  2497.  
  2498.        case 2 :
  2499.      _setcolor(0);
  2500.      _rectangle(_GFILLINTERIOR, xpos + 10, ypos + 10, \
  2501.                xpos + wd - 10, ypos + ht - 8);
  2502.      _settextcolor( 2 );
  2503.      sprintf( t, "%2d", (int)g );
  2504.      column = 38;
  2505.      _setcolor( 2 );
  2506.      _rectangle(_GFILLINTERIOR, xpos + 10, ypos + ht - 5 - (g * 2), \
  2507.                xpos + wd - 10, ypos + ht - 8);
  2508.      break;
  2509.  
  2510.        case 3 :
  2511.      _setcolor(0);
  2512.      _rectangle(_GFILLINTERIOR, xpos + 10, ypos + 10, \
  2513.                xpos + wd - 10, ypos + ht - 8);
  2514.      _settextcolor( 1 );
  2515.      sprintf( t, "%2d", (int)b );
  2516.      column = 44;
  2517.      _setcolor( 1 );
  2518.      _rectangle(_GFILLINTERIOR, xpos + 10, ypos + ht - 5 - (b * 2), \
  2519.                xpos + wd - 10, ypos + ht - 8);
  2520.      break;
  2521.      default:
  2522.          break;
  2523.      }
  2524.  
  2525.       xpos = (p1 + 28) + ((current - 1) * (wd + space));
  2526.       _rectangle(_GBORDER, xpos, ypos, xpos + wd, ypos + ht );
  2527.       _setcolor(15);
  2528.       _rectangle(_GBORDER, xpos + 3, ypos + 3, xpos + wd - 3, ypos + ht -3);
  2529.  
  2530.  _rectangle(_GBORDER, xpos, ypos + ht + space, xpos + wd, ypos + ht + space + 25);
  2531. _settextposition( row, column );
  2532. _outtext(t);
  2533.   }
  2534. _setcolor( oldcolor );
  2535. _putimage( p1, q1, msgbox, _GPSET );
  2536. }
  2537.  
  2538.  
  2539.  
  2540. void draw_newbox( rect_s *r, short c1, short c2, short c3, short c4 )
  2541. {
  2542.  
  2543.     pixtype  p1, p2, q1, q2;
  2544.     char     i, s = 2;
  2545.  
  2546.     p1 = r -> x1;
  2547.     q1 = r -> y1;
  2548.     p2 = r -> x2;
  2549.     q2 = r -> y2;
  2550.  
  2551.     _setcolor( c1 );
  2552.     drawrect(FILL, r );
  2553.  
  2554.     r -> x1 += s;
  2555.     r -> y1 += s;
  2556.     r -> x2 -= s;
  2557.     r -> y2 -= s;
  2558.     _setcolor( c2 );
  2559.     drawrect(FILL, r );
  2560.  
  2561.     r -> x1 += s;
  2562.     r -> y1 += s;
  2563.     r -> x2 -= s;
  2564.     r -> y2 -= s;
  2565.     _setcolor( c3 );
  2566.     drawrect(FILL, r );
  2567.  
  2568.     r -> x1 += s;
  2569.     r -> y1 += s;
  2570.     r -> x2 -= s;
  2571.     r -> y2 -= s;
  2572.     _setcolor( c4 );
  2573.     drawrect(FILL, r );
  2574. }
  2575.  
  2576. short get_brush_shape( short oldshape )
  2577. {
  2578.  
  2579.    rect_s     r;
  2580.    pixtype    p1, q1, p2, q2;
  2581.    short      c1 = 1, c2 = 9, c3 = 5, c4 = 13;
  2582.    short      boxsize = 60;
  2583.    boolean    done = FALSE;
  2584.    pixtype    xpos, ypos, space = 15;
  2585.    pixtype    midx, midy; /// Center of boxes
  2586.    short      i, j, oldi, oldj;
  2587.    pixtype    xloc[5], yloc[2];
  2588.    key_t      key;
  2589.    mouse_t    lb, rb, h, v;
  2590.    char       tempstr[80];
  2591.    boolean    mouse_on = FALSE;
  2592.    short      shape = oldshape;
  2593.    short      old_color = _getcolor();
  2594.    pixtype    newx, newy;
  2595.    boolean    size_change = FALSE;
  2596.  
  2597.    p1 = r.x1 = 175;
  2598.    q1 = r.y1 = 175;
  2599.    p2 = r.x2 = p1 + 400;
  2600.    q2 = r.y2 = q1 + 200;
  2601.  
  2602.    mouse_hide();
  2603.    _setlogorg(0,0);
  2604.    _getimage( p1, q1, p2, q2, msgbox );
  2605.  
  2606.    draw_newbox( &r, 15, 8, 7, 0);
  2607.  
  2608.    set_font( TRMN, 7 );
  2609.    _setcolor(12);
  2610.    _moveto( p1 + 15 + space, q1 + 16 );
  2611.    _outgtext("Select a Brush Shape");
  2612.     _setcolor(4);
  2613.    _moveto( p1 + 14 + space, q1 + 15 );
  2614.    _outgtext("Select a Brush Shape");
  2615.  
  2616.    xpos = p1 + 15 + space;
  2617.    ypos = q1 + 35 + space;
  2618.  
  2619.    for ( i = 1; i <= 2; i++ )
  2620.      {
  2621.      yloc[i] = ypos;
  2622.      for ( j = 1; j <= 5; j++ )
  2623.        {
  2624.     if ( NOT ( i EQ 1 AND j EQ 5 ))
  2625.       {
  2626.       if ( j EQ 5 )
  2627.         {
  2628.         r.x1 = newx = xpos + 10;
  2629.         r.y1 = newy = ypos;
  2630.         r.x2 = xpos + boxsize + 10;
  2631.         r.y2 = ypos + boxsize;
  2632.         draw_newbox( &r, 12, 4, 0, 0);
  2633.         }
  2634.       else
  2635.         {
  2636.         r.x1 = xpos;
  2637.         xloc[j] = xpos;
  2638.         r.y1 = ypos;
  2639.         r.x2 = xpos + boxsize;
  2640.         r.y2 = ypos + boxsize;
  2641.         draw_newbox( &r, 1, 9, 0, 0);
  2642.         xpos = r.x2 + space;
  2643.         }
  2644.       }
  2645.        /* else
  2646.     if ( i EQ 2 AND j EQ 5 )
  2647.       {
  2648.       r.x1 = newx = xpos + 10;
  2649.       r.y1 = newy = ypos;
  2650.       r.x2 = xpos + boxsize + 10;
  2651.       r.y2 = ypos + boxsize;
  2652.       draw_newbox( &r, 12, 4, 11, 0);
  2653.       }  */
  2654.        }
  2655.      ypos += boxsize + space - 5 ;
  2656.      xpos = p1 + 15 + space;
  2657.      }
  2658.      _setcolor(15);
  2659.  
  2660.      newx = newx + (boxsize / 2) - 1;
  2661.      newy = newy + (boxsize / 2) - 1;
  2662.      update_newbox( newx, newy, oldshape );
  2663.  
  2664.      midx = xloc[1] + (boxsize / 2 ) - 1;
  2665.      midy = yloc[1] + (boxsize / 2 ) - 1;
  2666.      draw_star( midx, midy );
  2667.  
  2668.      midx = xloc[2] + (boxsize / 2 ) - 1;
  2669.      draw_slash( midx, midy ,bsize);
  2670.      midx = xloc[3] + (boxsize / 2 ) - 1;
  2671.      draw_backslash( midx, midy, bsize );
  2672.      midx = xloc[4] + (boxsize / 2 ) - 1;
  2673.      draw_ellipse(midx,midy,bsize);
  2674.      midx = xloc[1] + (boxsize / 2 ) - 1;
  2675.      midy = yloc[2] + (boxsize / 2 ) - 1;
  2676.      draw_square(midx, midy, bsize);
  2677.  
  2678.      if (oldshape < 5)
  2679.        {
  2680.        i = oldshape;
  2681.        j = 1;
  2682.        }
  2683.      else
  2684.        {
  2685.        i = 1;
  2686.        j = 2;
  2687.        }
  2688.      xpos = xloc[i];
  2689.      ypos = yloc[j];
  2690.      r.x1 = xpos;
  2691.      r.y1 = ypos;
  2692.      r.x2 = xpos + boxsize;
  2693.      r.y2 = ypos + boxsize;
  2694.      _setcolor( 15 );
  2695.      drawrect(NOFILL, &r );
  2696.      mouse_status(&lb, &rb, &h, &v);
  2697.      mouse_show();
  2698.      while ( NOT done )
  2699.        {
  2700.     oldi = i;
  2701.     oldj = j;
  2702.     mouse_show();
  2703.     mouse_status(&lb, &rb, &h, &v);
  2704.     if (lb OR rb)
  2705.       {
  2706.       if ( (h > xloc[1] ) AND (h < ( xloc[4] + boxsize)) )
  2707.         if ( (v > yloc[1] ) AND (v < ( yloc[1] + boxsize)) )
  2708.       {
  2709.       j = 1;
  2710.       xpos = xloc[1];
  2711.       ypos = yloc[1];
  2712.       if ( v < ypos + boxsize )
  2713.         {
  2714.         if ( h < xpos + boxsize )
  2715.           i = 1;
  2716.         else
  2717.         if ( (h > xpos + boxsize + space) AND \
  2718.          (h < xpos + (boxsize + space) * 2 ) )
  2719.           i = 2;
  2720.         else
  2721.         if ( (h > xpos + (boxsize + space) * 2) AND \
  2722.          (h < xpos + (boxsize + space) * 3 ) )
  2723.           i = 3;
  2724.         else
  2725.         if ( (h > xpos + (boxsize + space) * 3) AND \
  2726.          (h < xpos + (boxsize + space) * 4 ) )
  2727.           i = 4;
  2728.         }
  2729.       }
  2730.       else
  2731.       if ( (v > yloc[2] ) AND (v < ( yloc[2] + boxsize)) )
  2732.       {
  2733.       j = 2;
  2734.       xpos = xloc[1];
  2735.       ypos = yloc[2];
  2736.       if ( v < ypos + boxsize )
  2737.         {
  2738.         if ( h < xpos + boxsize )
  2739.           i = 1;
  2740.         else
  2741.         if ( (h > xpos + boxsize + space) AND \
  2742.          (h < xpos + (boxsize + space) * 2 ) )
  2743.           i = 2;
  2744.         else
  2745.         if ( (h > xpos + (boxsize + space) * 2) AND \
  2746.          (h < xpos + (boxsize + space) * 3 ) )
  2747.           i = 3;
  2748.         else
  2749.         if ( (h > xpos + (boxsize + space) * 3) AND \
  2750.          (h < xpos + (boxsize + space) * 4 ) )
  2751.           i = 4;
  2752.         }
  2753.       }
  2754.  
  2755.     }
  2756.        if (kbhit())
  2757.     {
  2758.     key = getkey();
  2759.     /*** i = column j = row    ***/
  2760.       switch( key )
  2761.         {
  2762.         case KEY_UP   :
  2763.               if ( j EQ 1 )
  2764.                 j = 2;
  2765.               else
  2766.                 j = 1;
  2767.               break;
  2768.         case KEY_DOWN :
  2769.               if ( j EQ 2 )
  2770.                 j = 1;
  2771.               else
  2772.                 j = 2;
  2773.               break;
  2774.         case KEY_LEFT :
  2775.               if ( i EQ 1 )
  2776.                 i = 4;
  2777.               else
  2778.                 --i;
  2779.               break;
  2780.         case KEY_RIGHT:
  2781.               if ( i EQ 4 )
  2782.                 i = 1;
  2783.               else
  2784.                 ++i;
  2785.               break;
  2786.         case KEY_CTRL_RIGHT :
  2787.               if (bsize < 20)
  2788.                 {
  2789.                 ++bsize;
  2790.                 size_change = TRUE;
  2791.                 }
  2792.               else
  2793.                 note( 400, 3 );
  2794.               break;
  2795.         case KEY_CTRL_LEFT :
  2796.               if (bsize > 1)
  2797.                 {
  2798.                 --bsize;
  2799.                 size_change = TRUE;
  2800.                 }
  2801.               else
  2802.                 note( 400, 3 );
  2803.               break;
  2804.         case KEY_ESCAPE:
  2805.         case KEY_END :
  2806.               done = TRUE;
  2807.               i = 0;
  2808.               break;
  2809.         case KEY_ENTER:
  2810.               done = TRUE;
  2811.               break;
  2812.         default       :
  2813.               note( 200, 3 );
  2814.               break;
  2815.         }
  2816.       }
  2817.       if ( (oldi NE i) OR ( oldj NE j ) OR size_change)
  2818.         {
  2819.         xpos = xloc[oldi];
  2820.         ypos = yloc[oldj];
  2821.         r.x1 = xpos;
  2822.         r.y1 = ypos;
  2823.         r.x2 = xpos + boxsize;
  2824.         r.y2 = ypos + boxsize;
  2825.         _setcolor( c1 );
  2826.         mouse_hide();
  2827.         drawrect(NOFILL, &r );
  2828.  
  2829.         xpos = xloc[i];
  2830.         ypos = yloc[j];
  2831.         r.x1 = xpos;
  2832.         r.y1 = ypos;
  2833.         r.x2 = xpos + boxsize;
  2834.         r.y2 = ypos + boxsize;
  2835.         _setcolor( 15 );
  2836.         drawrect(NOFILL, &r );
  2837.         mouse_show();
  2838.         mouse_on = FALSE;
  2839.  
  2840.         shape = i + (j - 1) * 4;
  2841.         update_newbox(newx, newy, shape);
  2842.         size_change = FALSE;
  2843.         }
  2844.     }
  2845.      if (j EQ 1 AND i > 0 AND i <= 4)
  2846.        shape = i;
  2847.      else
  2848.      if (j EQ 2 AND i > 0 AND i <= 1)
  2849.        shape = i + 4;
  2850.      else
  2851.        shape = oldshape;
  2852.      mouse_hide();
  2853.      _putimage( p1, q1, msgbox, _GPSET );
  2854.      mouse_show();
  2855.      _setcolor(oldcolor);
  2856.      return( shape );
  2857. }
  2858.  
  2859.  
  2860. void drawrect( boolean fill, rect_s *r )
  2861. {
  2862.  
  2863.    if ( fill )
  2864.      _rectangle(_GFILLINTERIOR, r -> x1, r -> y1, r -> x2, r -> y2 );
  2865.    else
  2866.      _rectangle(_GBORDER, r -> x1, r -> y1, r -> x2, r -> y2 );
  2867.  
  2868. }
  2869.  
  2870. void draw_star( pixtype x, pixtype y )
  2871. {
  2872.      _setpixel( x, y );
  2873.      _setpixel( x+1, y );
  2874.      _setpixel( x, y+1 );
  2875.      _setpixel( x-1, y );
  2876.      _setpixel( x, y-1 );
  2877. }
  2878.  
  2879. void draw_spray( pixtype x, pixtype y )
  2880. {
  2881.     char  i, j;
  2882.  
  2883.     for ( i = -10; i <= 10; i++)
  2884.       {
  2885.       for ( j = -10; j <= 10; j++)
  2886.        {
  2887.        _setpixel( x + j, y);
  2888.        x += 1;
  2889.        }
  2890.     ///  _setpixel( x, j + i );
  2891.     ///  y += 1;
  2892.       }
  2893. }
  2894.  
  2895. void draw_slash( pixtype x, pixtype y , short len)
  2896. {
  2897.  
  2898.    short   i;
  2899.  
  2900.    for ( i = 0; i <= 2; ++i )
  2901.      {
  2902.      _moveto( x - len + i, y - len );
  2903.      _lineto( x + len + i, y + len  );
  2904.      }
  2905. }
  2906.  
  2907. void draw_backslash( pixtype x, pixtype y , short len)
  2908. {
  2909.  
  2910.    short   i;
  2911.  
  2912.    for ( i = 0; i <= 2; ++i )
  2913.      {
  2914.      _moveto( x + len + i, y - len );
  2915.      _lineto( x - len + i, y + len  );
  2916.      }
  2917. }
  2918.  
  2919.  
  2920. void draw_square(pixtype midx, pixtype midy, short size )
  2921. {
  2922.  
  2923.  _rectangle(_GFILLINTERIOR,midx - size,midy - size, midx + size, midy + size );
  2924. }
  2925.  
  2926. void draw_ellipse(pixtype midx, pixtype midy, short size )
  2927. {
  2928.  
  2929.  _ellipse(_GFILLINTERIOR,midx - size,midy - size, midx + size, midy + size );
  2930. }
  2931.  
  2932.  
  2933.  
  2934. void update_newbox(pixtype midx, pixtype midy, short shape )
  2935. {
  2936.  
  2937.   if ( shape > 5 )
  2938.     return;
  2939.  
  2940.   _setcolor(0);
  2941.   _rectangle(_GFILLINTERIOR, midx - 25, midy - 25, midx + 25, midy + 25);
  2942.   _setcolor(15);
  2943.   switch ( shape )
  2944.     {
  2945.     case 1 :
  2946.        draw_star( midx, midy );
  2947.        break;
  2948.     case 2 :
  2949.        draw_slash(midx, midy, bsize);
  2950.        break;
  2951.     case 3 :
  2952.        draw_backslash(midx, midy, bsize);
  2953.        break;
  2954.     case 4:
  2955.        draw_ellipse(midx, midy, bsize );
  2956.        break;
  2957.     case 5:
  2958.        draw_square( midx, midy, bsize);
  2959.        break;
  2960.     default:
  2961.        break;
  2962.     }
  2963. }
  2964. void draw_paint(pixtype midx, pixtype midy, short shape )
  2965. {
  2966.  
  2967.   if ( shape > 5 )
  2968.     return;
  2969.   switch ( shape )
  2970.     {
  2971.     case 1 :
  2972.        draw_star( midx, midy );
  2973.        break;
  2974.     case 2 :
  2975.        draw_slash(midx, midy, bsize);
  2976.        break;
  2977.     case 3 :
  2978.        draw_backslash(midx, midy, bsize);
  2979.        break;
  2980.     case 4:
  2981.        draw_ellipse(midx, midy, bsize );
  2982.        break;
  2983.     case 5:
  2984.        draw_square( midx, midy, bsize);
  2985.        break;
  2986.     default:
  2987.        break;
  2988.     }
  2989. }
  2990.  
  2991.  
  2992.  
  2993. void draw_paint2(pixtype x1, pixtype y1, short shape )
  2994. {
  2995.            pixtype pixtemp, oldx1, oldy1;
  2996.  
  2997.            draw_paint( x1, y1, shape );
  2998.            if ( mirror_on )
  2999.              {
  3000.              oldx1 = x1;
  3001.              oldy1 = y1;
  3002.  
  3003.              x1 = -x1;  // -y +x
  3004.              y1 = -y1;  // y, -x
  3005.              draw_paint( x1, y1, shape );
  3006.  
  3007.              x1 = -x1;
  3008.              draw_paint( x1, y1, shape );
  3009.  
  3010.              y1 = -y1;
  3011.              x1 = - x1; // y, -x
  3012.              draw_paint( x1, y1, shape );
  3013.  
  3014.              pixtemp = oldy1;
  3015.              y1 = oldx1;
  3016.              x1 = pixtemp;
  3017.  
  3018.             if ((y1 < -197 ) OR (-y1 > 197 ) OR \
  3019.             (-y1 < -197 )OR (y1 > 197 ))
  3020.               return;
  3021.  
  3022.             draw_paint( x1, y1, shape );
  3023.  
  3024.              x1 = -x1;
  3025.              y1 = -y1;
  3026.             draw_paint( x1, y1, shape );
  3027.  
  3028.              x1 = -x1;  // -y +x
  3029.             draw_paint( x1, y1, shape );
  3030.  
  3031.              y1 = -y1;
  3032.              x1 = -x1;  // y, -x
  3033.             draw_paint( x1, y1, shape );
  3034.              }
  3035. }
  3036.  
  3037.  
  3038. void break_color( color_t cnum, short *red, short *blue, short *green )
  3039. {
  3040.      *red = cnum % 64;
  3041.      *green =  (cnum >> 8L) % 64;
  3042.      *blue = cnum >> 16L;
  3043. }
  3044.  
  3045. color_t custom_color(short palette_num )
  3046. {
  3047.  
  3048.    boolean  done = FALSE;
  3049.    boolean  change = TRUE;
  3050.    short    red, green, blue; /// Amount of each element of color, 0..63
  3051.    rect_s   c_bar[3][4];      /// Boxes for color bars & text
  3052.    rect_s   r1;               /// Coordinates of whole message box
  3053.    pixtype  xpos, ypos, ht, wd, space;
  3054.    pixtype  p1,p2,q1,q2;
  3055.    short    i, j;  /// row / column indexes
  3056.    color_t  newcol;
  3057.    mouse_t  lb, rb, h, v;
  3058.    key_t    key;
  3059.    char     str[80];
  3060.    short    row, column;
  3061.  
  3062.    r1.x1 = p1 = 200;
  3063.    r1.y1 = q1 = 70;
  3064.    r1.x2 = p2 = p1 + 226;
  3065.    r1.y2 = q2 = q1 + 350;
  3066.  
  3067.    _getimage( p1, q1, p2, q2, msgbox );
  3068.  
  3069.    draw_newbox( &r1, 15,7,8,0 );
  3070.  
  3071.    set_font(TRMN, 7);
  3072.    _getvideoconfig( &vc);
  3073.  
  3074.    _setcolor(12);
  3075.    _moveto( p1 + 15, q1 + 12 );
  3076.    _outgtext("Custom Colors");
  3077.     _moveto( p1 + 14, q1 + 11 );
  3078.    _setcolor(4);
  3079.    _outgtext("Custom Colors");
  3080.  
  3081.    ht = 148; /// height & width of color bar boxes
  3082.    wd = 50;
  3083.    space = 12;
  3084.  
  3085.    ypos = q1 + 50;
  3086.    xpos = p1 + 22;
  3087.  
  3088.    /* Draw the original boxes to contain the color bars & text info &
  3089.       save the screen coordinates of each in the "c_bar" array */
  3090.    for (j = 1; j <= 3; j++)
  3091.      {
  3092.      for ( i = 1; i <= 2; i++)
  3093.       {
  3094.  
  3095.        if (i EQ 1)
  3096.      {
  3097.      c_bar[i][j].x1 = xpos;
  3098.      c_bar[i][j].y1 = ypos;
  3099.      c_bar[i][j].x2 = xpos + wd;
  3100.      c_bar[i][j].y2 = ypos + ht;
  3101.      draw_newbox( &c_bar[i][j], 15, 0, 15, 0 );
  3102.      }
  3103.        else
  3104.      {
  3105.      c_bar[i][j].x1 = xpos;
  3106.      c_bar[i][j].y1 = ypos + ht + space;
  3107.      c_bar[i][j].x2 = xpos + wd;
  3108.      c_bar[i][j].y2 = ypos + ht + space + 30;
  3109.      draw_newbox( &c_bar[i][j], 15, 0, 0, 0 );
  3110.      }
  3111.        }
  3112.        xpos += wd + space;
  3113.       }
  3114.  
  3115.    /* Determine the primary color values used in creating the given color: */
  3116.    break_color( _BRIGHTWHITE, &red, &green, &blue );
  3117.  
  3118.    /* Draw the color bars showing the breakdown of these values. */
  3119.    row = 19;
  3120.    column = 31;
  3121.    for ( j = 1; j <= 3; j++ )
  3122.      {
  3123.      ypos = c_bar[1][j].y2 - 5;
  3124.      xpos = c_bar[1][j].x1 + 7;
  3125.  
  3126.      switch( j )
  3127.        {
  3128.        case 1 :
  3129.      _setcolor( 4 );
  3130.      _rectangle(_GFILLINTERIOR, xpos, ypos, xpos + wd - 20, \
  3131.                     ypos - ( red * 2 ) - 1 );
  3132.      _settextcolor( 4 );
  3133.      sprintf(str,"%2d", red );
  3134.      _settextposition( row, column );
  3135.      _outtext( str );
  3136.      break;
  3137.        case 2 :
  3138.      _setcolor( 2 );
  3139.      _rectangle(_GFILLINTERIOR, xpos, ypos, xpos + wd - 20, \
  3140.                     ypos - ( green * 2 ) - 1 );
  3141.      sprintf(str,"%2d", green );
  3142.      _settextposition( row, column += 8 );
  3143.      _settextcolor( 2 );
  3144.      _outtext( str );
  3145.  
  3146.      break;
  3147.        case 3 :
  3148.      _setcolor( 1 );
  3149.      _rectangle(_GFILLINTERIOR, xpos, ypos, xpos + wd - 20, \
  3150.                     ypos - ( blue * 2 ) - 1 );
  3151.      sprintf(str,"%2d", blue );
  3152.      _settextposition( row, column += 8);
  3153.      _settextcolor( 1 );
  3154.      _outtext( str );
  3155.  
  3156.      break;
  3157.        default:
  3158.      break;
  3159.        }
  3160.      }
  3161.  
  3162.  
  3163.    getch();
  3164.    _putimage(p1, q1, msgbox, _GPSET );
  3165. }
  3166.  
  3167.  
  3168.  
  3169.  
  3170. void sqx( pixtype x, pixtype y )
  3171. {
  3172.    _moveto(x, y);
  3173.    _lineto(-y, x);
  3174.    _lineto(-x, -y);
  3175.    _lineto(y, -x);
  3176.    _lineto(x, y);
  3177.  
  3178. }
  3179.  
  3180. void cycle3( void )
  3181. {
  3182.    boolean  done = FALSE;
  3183.    short    pnum;
  3184.    short    red, green, blue;
  3185.    color_t  newc;
  3186.    short    color_pick;
  3187.    short    shift;
  3188.    char     str[80];
  3189.  
  3190.   while ( NOT done )
  3191.    {
  3192.    for ( pnum = 1; pnum <= 15; pnum++ )
  3193.      {
  3194.      if ( c_used[ pnum ] )
  3195.      {
  3196.      break_color( c_array[ pnum ], &red, &green, &blue );
  3197.      done = TRUE;
  3198.      done = FALSE;
  3199.      color_pick = rand() % 6 + 1;
  3200.      shift = rand() % 7;
  3201.      newc = RGB( red, green, blue );
  3202.      newc << shift;
  3203.      _remappalette( pnum, newc );
  3204.      c_array[ pnum ] = newc;
  3205.  
  3206.      ///if ( kbhit() )
  3207.        done = (getkey() == KEY_ESCAPE);
  3208.      if (done) break;
  3209.  
  3210.  
  3211.  
  3212.  
  3213.     /* switch( shift )
  3214.        {
  3215.        case 1:
  3216.      if ( red + shift <= 63 )
  3217.        red += shift;
  3218.      else
  3219.        red -= shift;
  3220.      break;
  3221.        case 2:
  3222.      if ( green + shift <= 63 )
  3223.        green += shift;
  3224.      else
  3225.        green -= shift;
  3226.      break;
  3227.        case 3:
  3228.      if ( blue + shift <= 63 )
  3229.        blue += shift;
  3230.      else
  3231.        blue -= shift;
  3232.      break;
  3233.        case 4:
  3234.      if ( red - shift >= 0 )
  3235.        red -= shift;
  3236.      else
  3237.        red += shift;
  3238.      break;
  3239.        case 5:
  3240.      if ( green - shift >= 0 )
  3241.        green -= shift;
  3242.      else
  3243.        green += shift;
  3244.      break;
  3245.        case 6:
  3246.      if ( blue - shift >= 0 )
  3247.        blue -= shift;
  3248.      else
  3249.        blue += shift;
  3250.      break;
  3251.        case 7:
  3252.      if ( red <= 63 )
  3253.        ++red;
  3254.       ///   else
  3255.      ///  --red;
  3256.      break;
  3257.        case 8:
  3258.      if ( green <= 63 )
  3259.        ++green;
  3260.        ///  else
  3261.       /// --green;
  3262.      break;
  3263.        case 9:
  3264.      if ( blue <= 63 )
  3265.        ++blue;
  3266.        ///  else
  3267.       /// --blue;
  3268.      break;
  3269.        case 10:
  3270.      if ( red >= 0 )
  3271.        --red;
  3272.      ///else
  3273.      ///  ++red;
  3274.      break;
  3275.        case 11:
  3276.      if ( green >= 0 )
  3277.        --green;
  3278.     /// else
  3279.        ///++green;
  3280.      break;
  3281.        case 12:
  3282.      if ( blue >= 0 )
  3283.        --blue;
  3284.        ///  else
  3285.       /// ++blue;
  3286.      break;
  3287.  
  3288.        default:
  3289.      break;
  3290.        }
  3291.  
  3292.  
  3293.      newc = rgb( red, green, blue );
  3294.      _remappalette( pnum, newc );
  3295.      c_array[ pnum ] = newc;  */
  3296.  
  3297.      }
  3298.      }
  3299.    }
  3300. }
  3301.  
  3302.  
  3303. void update_shapebox( short type )
  3304. {
  3305.     short xpos, ypos;
  3306.     short newtype = type;
  3307.     short c = _getcolor();
  3308.  
  3309.     ypos = vc.numypixels - 12;
  3310.     xpos = 12;
  3311.  
  3312.      _setlogorg( 0, 0 );
  3313.      _getvideoconfig( &vc );
  3314.      _setcolor(8);
  3315.      _rectangle(_GFILLINTERIOR, xpos, ypos - 43, xpos + 43, ypos );
  3316.      _setcolor( 7 );
  3317.      _rectangle(_GBORDER, xpos, ypos - 43, xpos + 43, ypos );
  3318.      _setcolor(15);
  3319.  
  3320.     switch ( type )
  3321.       {
  3322.       case 1 : /// square box
  3323.           _rectangle( _GBORDER, xpos + 5, ypos - 38, xpos + 38, ypos - 5 );
  3324.           break;
  3325.       case 2 : /// ellipse box
  3326.           _ellipse( _GBORDER, xpos + 5, ypos - 38, xpos + 38, ypos - 5 );
  3327.           break;
  3328.       case 5 : /// Solid rectangle
  3329.           _setcolor( c );
  3330.           if ( fill_on )
  3331.         _setfillmask( pick[ipick] );
  3332.           _rectangle(_GFILLINTERIOR, xpos + 5, ypos - 38, xpos + 38, ypos - 5 );
  3333.           if ( fill_on )
  3334.         _setfillmask( NULL );
  3335.           break;
  3336.       case 4 : /// Solid ellipse
  3337.           _setcolor( c );
  3338.           if ( fill_on )
  3339.         _setfillmask( pick[ipick] );
  3340.           _ellipse(_GFILLINTERIOR,xpos + 5, ypos - 38, xpos + 38, ypos - 5 );
  3341.           if ( fill_on )
  3342.         _setfillmask( NULL );
  3343.           break;
  3344.       case 6 : /// Line box
  3345.           _moveto( xpos + 5, ypos - 38 );
  3346.           _lineto( xpos + 38, ypos - 5 );
  3347.           break;
  3348.       case 8 :/// Character Box
  3349.           set_font( TRMN, 8 );
  3350.           _moveto( xpos + 10, ypos - 33 );
  3351.           _outgtext("A");
  3352.           break;
  3353.       case 3 :/// Quit Box
  3354.           set_font( HELV, 8 );
  3355.           _moveto( xpos + 13, ypos - 33 );
  3356.           _setcolor( 12 );
  3357.           _outgtext("?");
  3358.           set_font( TRMN, 5 );
  3359.           _moveto( xpos + 2, ypos - 33 );
  3360.           _setcolor( 15 );
  3361.           _outgtext("Quit");
  3362.  
  3363.           break;
  3364.       case 99:/// Fill Box
  3365.           set_font( TRMN, 7 );
  3366.           _moveto( xpos + 2, ypos - 33 );
  3367.           _outgtext("Fill");
  3368.           break;
  3369.       case 666:/// Arc Box
  3370.           set_font( TRMN, 5 );
  3371.           _moveto( xpos + 3, ypos - 33 );
  3372.           _outgtext("Arc");
  3373.           break;
  3374.       case 667:/// Pie Box
  3375.           set_font( TRMN, 7 );
  3376.           _moveto( xpos + 2, ypos - 33 );
  3377.           _outgtext("Pie");
  3378.           break;
  3379.       case 25 : /// Brush Box
  3380.           _putimage(12, vc.numypixels - 55, randbox, _GPSET );
  3381.           break;
  3382.  
  3383.       default:
  3384.           break;
  3385.       }
  3386. }
  3387.  
  3388. void draw_arc( short fill_type )
  3389. {
  3390.    pixtype xb, yb, xe, ye, p, q, pabs, qabs;
  3391.    mouse_t lb, rb, h, v, status;
  3392.    boolean done = FALSE;
  3393.    boolean done1 = FALSE;
  3394.    boolean done2 = FALSE;
  3395.    short   c = _getcolor();
  3396.    short   presses = 0;
  3397.    unsigned long     size;
  3398.    char    str[80];
  3399.  
  3400.    set_cad_logorg();
  3401.    _getvideoconfig( &vc );
  3402.    _setlinestyle( 4 );
  3403.    mouse_press( LBUTTON, &status, &presses, &h, &v );
  3404.  
  3405.    while( NOT done )
  3406.      {
  3407.      mouse_show();
  3408.      mouse_press( LBUTTON, &status, &presses, &h, &v );
  3409.      if ( presses > 0 )
  3410.        if ( NOT done1)
  3411.      {
  3412.      p = h - MX;
  3413.      q = v - MY;
  3414.      _setcolor( 7 );
  3415.      size = _imagesize( p, q, -p, -q );
  3416.      if ( size >= MAXIMAGESIZE )
  3417.        done1 = FALSE;
  3418.      else
  3419.        {
  3420.        if ( p > 0 )
  3421.          p = -p;
  3422.        if ( q > 0 )
  3423.          q = -q;
  3424.        mouse_hide();
  3425.        _getimage( p, q, -p, -q, msgbox );
  3426.        _rectangle( _GBORDER, p, q, -p, -q );
  3427.        _ellipse( _GBORDER, p, q, -p, -q );
  3428.        mouse_show();
  3429.        done1 = TRUE;
  3430.        }
  3431.      }
  3432.  
  3433.        else
  3434.        if ( NOT done2 )
  3435.      {
  3436.      xb = h - MX;
  3437.      yb = v - MY;
  3438.      _setcolor(12);
  3439.      draw_star( xb, yb );
  3440.      _moveto( xb, yb );
  3441.      _lineto( 0, 0 );
  3442.      done2 = TRUE;
  3443.      }
  3444.        else
  3445.      {
  3446.      xe = h - MX;
  3447.      ye = v - MY;
  3448.      _setcolor( c );
  3449.      done1 = FALSE;
  3450.      mouse_hide();
  3451.      _putimage( p, q, msgbox, _GPSET );
  3452.  
  3453.      if ( fill_type EQ 1 )
  3454.        _arc( p, q, -p, -q, xb, yb, xe, ye );
  3455.      else
  3456.        _pie( _GFILLINTERIOR, p, q, -p, -q, xb, yb, xe, ye );
  3457.  
  3458.      ///done1 = done2 = FALSE;
  3459.      mouse_show();
  3460.      done = TRUE;
  3461.      }
  3462.        if ( kbhit() )
  3463.      {
  3464.      if ( getch() EQ KEY_ESCAPE )
  3465.        {
  3466.        mouse_hide();
  3467.        _putimage( p, q, msgbox, _GPSET );
  3468.        mouse_show();
  3469.        done = TRUE;
  3470.        }
  3471.      else
  3472.        note( 440, 2 );
  3473.      }
  3474.       }
  3475.      _setlinestyle( normal );
  3476.      _setcolor( c );
  3477.      mouse_show();
  3478.  
  3479. }
  3480.  
  3481.  
  3482.