home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / contrib / libgrx / test / testpatt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-06  |  2.9 KB  |  88 lines

  1. /**
  2.  ** TESTPATT.C
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23. #include "test.h"
  24.  
  25. unsigned char mybits[] = { 0x88, 0x44, 0x22, 0x11 };
  26. GrBitmap mybitmap = { 0, 4, mybits };
  27.  
  28. GrPattern *p1;
  29. GrPattern *p2 = (GrPattern *)&mybitmap;
  30.  
  31. static void initpatterns(void)
  32. {
  33.     GrContext tmp,save;
  34.     GrFBoxColors bc;
  35.  
  36.     mybitmap.bmp_fgcolor = GrAllocColor(255,0,0);
  37.     mybitmap.bmp_bgcolor = GrNOCOLOR;
  38.  
  39.     GrCreateContext(20,20,NULL,&tmp);
  40.     GrSaveContext(&save);
  41.     GrSetContext(&tmp);
  42.     bc.fbx_intcolor = GrAllocColor(0,140,140);
  43.     bc.fbx_leftcolor = bc.fbx_topcolor = GrAllocColor(0,200,200);
  44.     bc.fbx_rightcolor = bc.fbx_bottomcolor = GrAllocColor(0,80,80);
  45.     GrFramedBox(2,2,17,17,2,&bc);
  46.     p1 = GrConvertToPixmap(&tmp);
  47.     GrSetContext(&save);
  48. }
  49.  
  50. void pbox(int x1,int y1,int x2,int y2,GrPattern *p)
  51. {
  52.     GrPatternFilledLine(x1,y1,x2,y1,p);
  53.     GrPatternFilledLine(x1,y2,x2,y2,p);
  54.     GrPatternFilledLine(x1,y1,x1,y2,p);
  55.     GrPatternFilledLine(x2,y1,x2,y2,p);
  56. }
  57.  
  58. void pat_drawing(int xpos,int ypos,int xsize,int ysize,GrPattern *p)
  59. {
  60.     int ii;
  61.  
  62.     GrPatternFilledLine(XP(10),YP(10),XP(40),YP(40),p);
  63.     GrPatternFilledLine(XP(40),YP(10),XP(10),YP(40),p);
  64.     GrPatternFilledLine(XP(35),YP(10),XP(65),YP(40),p);
  65.     GrPatternFilledLine(XP(35),YP(40),XP(65),YP(10),p);
  66.     GrPatternFilledLine(XP(70),YP(10),XP(90),YP(40),p);
  67.     GrPatternFilledLine(XP(70),YP(40),XP(90),YP(10),p);
  68.     for(ii = 0; ii < 5; ii++)
  69.         pbox(XP(70+2*ii),YP(10+3*ii),XP(90-2*ii),YP(40-3*ii),p);
  70.     GrPatternFilledBox(XP(10),YP(50),XP(60),YP(90),p);
  71.     for(ii = (XP(90) - XP(70)) * (YP(90) - YP(50)); --ii >= 0; ) {
  72.         int x = (int)XP((((random() >> 4) & 0x7fff) % 2000L) + 7000L) / 100L;
  73.         int y = (int)YP((((random() >> 4) & 0x7fff) % 4000L) + 5000L) / 100L;
  74.         GrPatternFilledPlot(x,y,p);
  75.     }
  76.     pbox(XP(70),YP(50),XP(90),YP(90),p);
  77. }
  78.  
  79. TESTFUNC(testpatt)
  80. {
  81.     initpatterns();
  82.     pat_drawing(0,0,GrSizeX(),GrSizeY(),p1);
  83.     getkey();
  84.     pat_drawing(0,0,GrSizeX(),GrSizeY(),p2);
  85.     getkey();
  86. }
  87.  
  88.