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 >
Wrap
Text File
|
1989-12-13
|
7KB
|
392 lines
head 2.5;
access ;
symbols pre-merge:2.0;
locks ; strict;
comment @ * @;
2.5
date 89.12.13.19.10.20; author joel; state Exp;
branches ;
next 2.4;
2.4
date 89.12.07.16.36.36; author joel; state Exp;
branches ;
next 2.3;
2.3
date 89.11.20.13.26.12; author joel; state Exp;
branches ;
next 2.2;
2.2
date 89.05.11.16.44.57; author joel; state Exp;
branches ;
next 2.1;
2.1
date 89.05.03.14.18.12; author joel; state Exp;
branches ;
next 2.0;
2.0
date 89.01.31.17.07.49; author erik; state Exp;
branches ;
next 1.2;
1.2
date 89.01.31.17.07.49; author joel; state Exp;
branches ;
next 1.1;
1.1
date 88.09.20.12.12.23; author walker; state Exp;
branches ;
next ;
desc
@fill trapezoids
@
2.5
log
@Added fill style stuff
@
text
@/*****************************************************************************
Copyright 1988, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************************/
#include "x11perf.h"
#include "bitmaps.h"
#define NUM_POINTS 4 /* 4 points to a trapezoid */
static XPoint *points;
static GC pgc;
int InitTrapezoids(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i, numPoints;
int rows;
int x, y;
int size, skew;
XPoint *curPoint;
pgc = xp->fggc;
size = p->special;
numPoints = (p->objects) * NUM_POINTS;
points = (XPoint *)malloc(numPoints * sizeof(XPoint));
curPoint = points;
x = size;
y = 0;
rows = 0;
skew = size;
for (i = 0; i != p->objects; i++, curPoint += NUM_POINTS) {
curPoint[0].x = x - skew;
curPoint[0].y = y;
curPoint[1].x = x - skew + size;
curPoint[1].y = y;
curPoint[2].x = x + skew;
curPoint[2].y = y + size;
curPoint[3].x = x + skew - size;
curPoint[3].y = y + size;
skew--;
if (skew < 0) skew = size;
y += size;
rows++;
if (y + size > HEIGHT || rows == MAXROWS) {
rows = 0;
y = 0;
x += 2 * size;
if (x + size > WIDTH) {
x = size;
}
}
}
SetFillStyle(xp, p);
return reps;
}
void DoTrapezoids(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i, j;
XPoint *curPoint;
for (i = 0; i != reps; i++) {
curPoint = points;
for (j = 0; j != p->objects; j++) {
XFillPolygon(xp->d, xp->w, pgc, curPoint, NUM_POINTS, Convex,
CoordModeOrigin);
curPoint += NUM_POINTS;
}
if (pgc == xp->bggc)
pgc = xp->fggc;
else
pgc = xp->bggc;
}
}
void EndTrapezoids(xp, p)
XParms xp;
Parms p;
{
free(points);
}
@
2.4
log
@Changed interface to p->reps
@
text
@d25 1
d77 2
@
2.3
log
@Declare pgc as static, so switch between fggc and bggc happens every time,
not just within one iteration of tests. (Helps make things look better on
slow machines, which may only run 1 iteration.)
@
text
@d30 1
a30 1
Bool InitTrapezoids(xp, p)
d33 1
d76 1
a76 1
return True;
d79 1
a79 1
void DoTrapezoids(xp, p)
d82 1
d87 1
a87 1
for (i = 0; i != p->reps; i++) {
@
2.2
log
@Parameters to all routines now (xp, p)
MAXROWS used in all routines
Junked most global communication variables
@
text
@d28 1
d40 2
a81 1
GC pgc;
a84 1
pgc = xp->fggc;
@
2.1
log
@Massive changes, I'm not going to go into details.
@
text
@d1 23
a27 2
static GC bggc, fggc;
static Window w;
d29 3
a31 3
Bool InitTrapezoids(d, p)
Display *d;
Parms p;
d33 5
a37 4
int i, numPoints;
int x, y;
int size, skew;
XPoint *curPoint;
d45 1
d47 2
a48 1
for (i = 0; i < p->objects; i++, curPoint += NUM_POINTS) {
d62 3
a64 1
if (y + size > HEIGHT) {
a71 1
CreatePerfStuff(d, 1, WIDTH, HEIGHT, &w, &bggc, &fggc);
d75 3
a77 3
void DoTrapezoids(d, p)
Display *d;
Parms p;
d79 3
a81 3
GC pgc;
int i, j;
XPoint *curPoint;
d83 2
a84 3
pgc = bggc;
for (i=0; i<p->reps; i++)
{
d86 2
a87 2
for (j=0; j < p->objects; j++) {
XFillPolygon(d, w, pgc, curPoint, NUM_POINTS, Convex,
d90 3
a92 3
}
if (pgc == bggc)
pgc = fggc;
d94 1
a94 1
pgc = bggc;
d98 3
a100 3
void EndTrapezoids(d, p)
Display *d;
Parms p;
a101 3
XDestroyWindow(d, w);
XFreeGC(d, bggc);
XFreeGC(d, fggc);
@
2.0
log
@version from /usr/src/pmax
@
text
@d3 1
a3 1
#define NUM_POINTS 4 /* 4 points to a trapezoid */
d6 1
a6 6
static Window w[4];
static XRectangle ws[3] = {
{100, 100, 200, 200},
{150, 150, 200, 200},
{200, 200, 200, 200}
};
d8 1
a8 1
void InitTraps(d, p)
d12 4
a15 1
int i, numPoints, j;
d17 2
a18 3
for (i = 0; i < 4; i++)
w[i] = None;
numPoints = (p->objects) * NUM_POINTS;
d20 25
a44 14
i = 0;
for (j = 0; j < p->objects; j++)
{
points[i].x = rand() % (WIDTH - 100);
points[i++].y = rand() % HEIGHT;
points[i].x = rand() % (WIDTH - 100);
points[i++].y = rand() % HEIGHT;
/* make the last 2 points correspond to the first 2 => trapezoid */
points[i].x = points[i-1].x + (rand() % (WIDTH - points[i-1].x));
points[i].y = points[i-1].y;
i++;
points[i].x = points[i-3].x + (rand() % (WIDTH - points[i-3].x));
points[i].y = points[i-3].y;
i++;
d46 2
a47 5
CreatePerfStuff(d, 1, WIDTH, HEIGHT, w, &bggc, &fggc);
for (i = 0; i < p->special; i++)
w[i+1] = CreatePerfWindow(
d, ws[i].x, ws[i].y, ws[i].width, ws[i].height);
d50 1
a50 1
void DoTraps(d, p)
d63 1
a63 1
XFillPolygon(d, w[0], pgc, curPoint, NUM_POINTS, Convex,
d74 1
a74 1
void EndTraps(d, p)
d78 1
a78 4
int i;
for (i = 0; i < 4; i++)
if (w[i] != None)
XDestroyWindow(d, w[i]);
@
1.2
log
@Added -fg -bg capabilities
@
text
@@
1.1
log
@Initial revision
@
text
@d5 1
a5 1
static GC whitegc, blackgc;
d38 1
a38 1
CreatePerfStuff(d, 1, WIDTH, HEIGHT, w, &whitegc, &blackgc);
d53 1
a53 1
pgc = whitegc;
d62 2
a63 2
if (pgc == whitegc)
pgc = blackgc;
d65 1
a65 1
pgc = whitegc;
d77 2
a78 2
XFreeGC(d, whitegc);
XFreeGC(d, blackgc);
@