home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / x / x11p-13.zip / RCS / do_traps.c,v < prev    next >
Text File  |  1989-12-13  |  7KB  |  392 lines

  1. head     2.5;
  2. access   ;
  3. symbols  pre-merge:2.0;
  4. locks    ; strict;
  5. comment  @ * @;
  6.  
  7.  
  8. 2.5
  9. date     89.12.13.19.10.20;  author joel;  state Exp;
  10. branches ;
  11. next     2.4;
  12.  
  13. 2.4
  14. date     89.12.07.16.36.36;  author joel;  state Exp;
  15. branches ;
  16. next     2.3;
  17.  
  18. 2.3
  19. date     89.11.20.13.26.12;  author joel;  state Exp;
  20. branches ;
  21. next     2.2;
  22.  
  23. 2.2
  24. date     89.05.11.16.44.57;  author joel;  state Exp;
  25. branches ;
  26. next     2.1;
  27.  
  28. 2.1
  29. date     89.05.03.14.18.12;  author joel;  state Exp;
  30. branches ;
  31. next     2.0;
  32.  
  33. 2.0
  34. date     89.01.31.17.07.49;  author erik;  state Exp;
  35. branches ;
  36. next     1.2;
  37.  
  38. 1.2
  39. date     89.01.31.17.07.49;  author joel;  state Exp;
  40. branches ;
  41. next     1.1;
  42.  
  43. 1.1
  44. date     88.09.20.12.12.23;  author walker;  state Exp;
  45. branches ;
  46. next     ;
  47.  
  48.  
  49. desc
  50. @fill trapezoids
  51. @
  52.  
  53.  
  54. 2.5
  55. log
  56. @Added fill style stuff
  57. @
  58. text
  59. @/*****************************************************************************
  60. Copyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
  61.  
  62.                         All Rights Reserved
  63.  
  64. Permission to use, copy, modify, and distribute this software and its 
  65. documentation for any purpose and without fee is hereby granted, 
  66. provided that the above copyright notice appear in all copies and that
  67. both that copyright notice and this permission notice appear in 
  68. supporting documentation, and that the name of Digital not be
  69. used in advertising or publicity pertaining to distribution of the
  70. software without specific, written prior permission.  
  71.  
  72. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  73. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  74. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  75. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  76. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  77. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  78. SOFTWARE.
  79.  
  80. ******************************************************************************/
  81.  
  82. #include "x11perf.h"
  83. #include "bitmaps.h"
  84.  
  85. #define NUM_POINTS 4   /* 4 points to a trapezoid */
  86. static XPoint *points;
  87. static GC      pgc;
  88.  
  89. int InitTrapezoids(xp, p, reps)
  90.     XParms  xp;
  91.     Parms   p;
  92.     int     reps;
  93. {
  94.     int     i, numPoints;
  95.     int     rows;
  96.     int     x, y;
  97.     int     size, skew;
  98.     XPoint  *curPoint;
  99.  
  100.     pgc = xp->fggc;
  101.  
  102.     size = p->special;
  103.     numPoints = (p->objects) * NUM_POINTS;  
  104.     points = (XPoint *)malloc(numPoints * sizeof(XPoint));
  105.     curPoint = points;
  106.     x = size;
  107.     y = 0;
  108.     rows = 0;
  109.     skew = size;
  110.  
  111.     for (i = 0; i != p->objects; i++, curPoint += NUM_POINTS) {
  112.     curPoint[0].x = x - skew;
  113.     curPoint[0].y = y;
  114.     curPoint[1].x = x - skew + size;
  115.     curPoint[1].y = y;
  116.     curPoint[2].x = x + skew;
  117.     curPoint[2].y = y + size;
  118.     curPoint[3].x = x + skew - size;
  119.     curPoint[3].y = y + size;
  120.  
  121.     skew--;
  122.     if (skew < 0) skew = size;
  123.  
  124.     y += size;
  125.     rows++;
  126.     if (y + size > HEIGHT || rows == MAXROWS) {
  127.         rows = 0;
  128.         y = 0;
  129.         x += 2 * size;
  130.         if (x + size > WIDTH) {
  131.         x = size;
  132.         }
  133.     }
  134.     }
  135.  
  136.     SetFillStyle(xp, p);
  137.     return reps;
  138. }
  139.  
  140. void DoTrapezoids(xp, p, reps)
  141.     XParms  xp;
  142.     Parms   p;
  143.     int     reps;
  144. {
  145.     int     i, j;
  146.     XPoint  *curPoint;
  147.  
  148.     for (i = 0; i != reps; i++) {
  149.         curPoint = points;
  150.         for (j = 0; j != p->objects; j++) {
  151.             XFillPolygon(xp->d, xp->w, pgc, curPoint, NUM_POINTS, Convex, 
  152.              CoordModeOrigin);
  153.             curPoint += NUM_POINTS;
  154.     }
  155.         if (pgc == xp->bggc)
  156.             pgc = xp->fggc;
  157.         else
  158.             pgc = xp->bggc;
  159.     }
  160. }
  161.  
  162. void EndTrapezoids(xp, p)
  163.     XParms  xp;
  164.     Parms   p;
  165. {
  166.     free(points);
  167. }
  168.  
  169. @
  170.  
  171.  
  172. 2.4
  173. log
  174. @Changed interface to p->reps
  175. @
  176. text
  177. @d25 1
  178. d77 2
  179. @
  180.  
  181.  
  182. 2.3
  183. log
  184. @Declare pgc as static, so switch between fggc and bggc happens every time,
  185. not just within one iteration of tests.  (Helps make things look better on
  186. slow machines, which may only run 1 iteration.)
  187. @
  188. text
  189. @d30 1
  190. a30 1
  191. Bool InitTrapezoids(xp, p)
  192. d33 1
  193. d76 1
  194. a76 1
  195.     return True;
  196. d79 1
  197. a79 1
  198. void DoTrapezoids(xp, p)
  199. d82 1
  200. d87 1
  201. a87 1
  202.     for (i = 0; i != p->reps; i++) {
  203. @
  204.  
  205.  
  206. 2.2
  207. log
  208. @Parameters to all routines now (xp, p)
  209. MAXROWS used in all routines
  210. Junked most global communication variables
  211. @
  212. text
  213. @d28 1
  214. d40 2
  215. a81 1
  216.     GC      pgc;
  217. a84 1
  218.     pgc = xp->fggc;
  219. @
  220.  
  221.  
  222. 2.1
  223. log
  224. @Massive changes, I'm not going to go into details.
  225. @
  226. text
  227. @d1 23
  228. a27 2
  229. static GC bggc, fggc;
  230. static Window w;
  231. d29 3
  232. a31 3
  233. Bool InitTrapezoids(d, p)
  234.     Display *d;
  235.     Parms p;
  236. d33 5
  237. a37 4
  238.     int i, numPoints;
  239.     int x, y;
  240.     int size, skew;
  241.     XPoint *curPoint;
  242. d45 1
  243. d47 2
  244. a48 1
  245.     for (i = 0; i < p->objects; i++, curPoint += NUM_POINTS) {
  246. d62 3
  247. a64 1
  248.     if (y + size > HEIGHT) {
  249. a71 1
  250.     CreatePerfStuff(d, 1, WIDTH, HEIGHT, &w, &bggc, &fggc);
  251. d75 3
  252. a77 3
  253. void DoTrapezoids(d, p)
  254.     Display *d;
  255.     Parms p;
  256. d79 3
  257. a81 3
  258.     GC pgc;
  259.     int i, j;
  260.     XPoint *curPoint;
  261. d83 2
  262. a84 3
  263.     pgc = bggc;
  264.     for (i=0; i<p->reps; i++)
  265.     {
  266. d86 2
  267. a87 2
  268.         for (j=0; j < p->objects; j++) {
  269.             XFillPolygon(d, w, pgc, curPoint, NUM_POINTS, Convex, 
  270. d90 3
  271. a92 3
  272.       }
  273.         if (pgc == bggc)
  274.             pgc = fggc;
  275. d94 1
  276. a94 1
  277.             pgc = bggc;
  278. d98 3
  279. a100 3
  280. void EndTrapezoids(d, p)
  281.     Display *d;
  282.     Parms p;
  283. a101 3
  284.     XDestroyWindow(d, w);
  285.     XFreeGC(d, bggc);
  286.     XFreeGC(d, fggc);
  287. @
  288.  
  289.  
  290. 2.0
  291. log
  292. @version from /usr/src/pmax
  293. @
  294. text
  295. @d3 1
  296. a3 1
  297. #define NUM_POINTS 4  /* 4 points to a trapezoid */
  298. d6 1
  299. a6 6
  300. static Window w[4];
  301. static XRectangle ws[3] = {
  302.     {100, 100, 200, 200},
  303.     {150, 150, 200, 200},
  304.     {200, 200, 200, 200}
  305.   };
  306. d8 1
  307. a8 1
  308. void InitTraps(d, p)
  309. d12 4
  310. a15 1
  311.     int i, numPoints, j;
  312. d17 2
  313. a18 3
  314.     for (i = 0; i < 4; i++)
  315.     w[i] = None;
  316.     numPoints = (p->objects) * NUM_POINTS;
  317. d20 25
  318. a44 14
  319.     i = 0;
  320.     for (j = 0; j < p->objects; j++)
  321.     {    
  322.         points[i].x = rand() % (WIDTH - 100);
  323.         points[i++].y = rand() % HEIGHT;
  324.         points[i].x = rand() % (WIDTH - 100);
  325.         points[i++].y = rand() % HEIGHT;
  326.         /* make the last 2 points correspond to the first 2 => trapezoid */
  327.         points[i].x = points[i-1].x + (rand() % (WIDTH - points[i-1].x));
  328.         points[i].y = points[i-1].y;
  329.         i++;
  330.         points[i].x = points[i-3].x + (rand() % (WIDTH - points[i-3].x));
  331.         points[i].y = points[i-3].y;
  332.         i++;
  333. d46 2
  334. a47 5
  335.     CreatePerfStuff(d, 1, WIDTH, HEIGHT, w, &bggc, &fggc);
  336.     for (i = 0; i < p->special; i++)
  337.     w[i+1] = CreatePerfWindow(
  338.         d, ws[i].x, ws[i].y, ws[i].width, ws[i].height);
  339.     
  340. d50 1
  341. a50 1
  342. void DoTraps(d, p)
  343. d63 1
  344. a63 1
  345.             XFillPolygon(d, w[0], pgc, curPoint, NUM_POINTS, Convex, 
  346. d74 1
  347. a74 1
  348. void EndTraps(d, p)
  349. d78 1
  350. a78 4
  351.     int i;
  352.     for (i = 0; i < 4; i++)
  353.     if (w[i] != None)
  354.         XDestroyWindow(d, w[i]);
  355. @
  356.  
  357.  
  358. 1.2
  359. log
  360. @Added -fg -bg capabilities
  361. @
  362. text
  363. @@
  364.  
  365.  
  366. 1.1
  367. log
  368. @Initial revision
  369. @
  370. text
  371. @d5 1
  372. a5 1
  373. static GC whitegc, blackgc;
  374. d38 1
  375. a38 1
  376.     CreatePerfStuff(d, 1, WIDTH, HEIGHT, w, &whitegc, &blackgc);
  377. d53 1
  378. a53 1
  379.     pgc = whitegc;
  380. d62 2
  381. a63 2
  382.         if (pgc == whitegc)
  383.             pgc = blackgc;
  384. d65 1
  385. a65 1
  386.             pgc = whitegc;
  387. d77 2
  388. a78 2
  389.     XFreeGC(d, whitegc);
  390.     XFreeGC(d, blackgc);
  391. @
  392.