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_triangles.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-12-12
|
7KB
|
386 lines
head 2.5;
access ;
symbols pre-merge:2.0;
locks ; strict;
comment @ * @;
2.5
date 89.12.12.17.33.31; author joel; state Exp;
branches ;
next 2.4;
2.4
date 89.12.07.16.36.50; author joel; state Exp;
branches ;
next 2.3;
2.3
date 89.11.20.13.26.23; author joel; state Exp;
branches ;
next 2.2;
2.2
date 89.05.11.16.45.08; author joel; state Exp;
branches ;
next 2.1;
2.1
date 89.05.03.14.18.18; author joel; state Exp;
branches ;
next 2.0;
2.0
date 89.01.31.17.08.02; author erik; state Exp;
branches ;
next 1.2;
1.2
date 89.01.31.17.08.02; author joel; state Exp;
branches ;
next 1.1;
1.1
date 88.09.20.12.29.08; author walker; state Exp;
branches ;
next ;
desc
@fill triangles
@
2.5
log
@Added call to fill style setting, for stipples, etc.
@
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 3 /* 3 points to a triangle */
static XPoint *points;
static GC pgc;
extern double sin();
extern double cos();
extern double sqrt();
#define PI 3.14159265357989
int InitTriangles(xp, p, reps)
XParms xp;
Parms p;
int reps;
{
int i, j, numPoints;
int rows;
int x, y;
int size, iradius;
double phi, radius, delta, phi2;
XPoint *curPoint;
pgc = xp->fggc;
size = p->special;
phi = 0.0;
radius = ((double) size) * sqrt(3.0)/2.0;
iradius = (int) (radius + 0.5);
delta = 2.0 * PI / ((double) NUM_POINTS);
numPoints = (p->objects) * NUM_POINTS;
points = (XPoint *)malloc(numPoints * sizeof(XPoint));
curPoint = points;
x = iradius;
y = iradius;
rows = 0;
for (i = 0; i != p->objects; i++) {
for (j = 0; j != NUM_POINTS; j++) {
phi2 = phi + ((double) j) * delta;
curPoint->x = (int) ((double)x + (radius * cos(phi2)) + 0.5);
curPoint->y = (int) ((double)y + (radius * sin(phi2)) + 0.5);
curPoint++;
}
phi += delta/10.0;
y += 2 * iradius;
rows++;
if (y + iradius > HEIGHT || rows == MAXROWS) {
rows = 0;
y = iradius;
x += 2 * iradius;
if (x + iradius > WIDTH) {
x = iradius;
}
}
}
SetFillStyle(xp, p);
return reps;
}
void DoTriangles(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 EndTriangles(xp, p)
XParms xp;
Parms p;
{
free(points);
}
@
2.4
log
@Changed interface to p->reps
@
text
@d25 1
d82 3
@
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
@d35 1
a35 1
Bool InitTriangles(xp, p)
d38 1
d81 1
a81 1
return True;
d84 1
a84 1
void DoTriangles(xp, p)
d87 1
d92 1
a92 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
d46 2
a86 1
GC pgc;
a89 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;
d34 3
a36 3
Bool InitTriangles(d, p)
Display *d;
Parms p;
d38 6
a43 5
int i, j, numPoints;
int x, y;
int size, iradius;
double phi, radius, delta, phi2;
XPoint *curPoint;
d48 1
a48 1
iradius = (int) radius + 1;
d56 4
a59 2
for (i = 0; i < p->objects; i++) {
for (j = 0; j < NUM_POINTS; j++) {
d67 3
a69 1
if (y + iradius >= HEIGHT) {
d72 1
a72 1
if (x + iradius >= WIDTH) {
a76 1
CreatePerfStuff(d, 1, WIDTH, HEIGHT, &w, &bggc, &fggc);
d80 3
a82 3
void DoTriangles(d, p)
Display *d;
Parms p;
d84 3
a86 3
GC pgc;
int i, j;
XPoint *curPoint;
d88 2
a89 3
pgc = bggc;
for (i=0; i<p->reps; i++)
{
d91 2
a92 2
for (j=0; j < p->objects; j++) {
XFillPolygon(d, w, pgc, curPoint, NUM_POINTS, Convex,
d95 3
a97 3
}
if (pgc == bggc)
pgc = fggc;
d99 1
a99 1
pgc = bggc;
d103 3
a105 3
void EndTriangles(d, p)
Display *d;
Parms p;
a106 3
XDestroyWindow(d, w);
XFreeGC(d, bggc);
XFreeGC(d, fggc);
@
2.0
log
@version from /usr/src/pmax
@
text
@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 6
a13 1
void InitTriangles(d, p)
d17 5
a21 1
int i, numPoints;
d23 6
a28 3
for (i = 0; i < 4; i++)
w[i] = None;
i = 0;
d31 19
a49 4
for (i = 0; i < numPoints; i++)
{
points[i].x = rand() % WIDTH;
points[i].y = rand() % HEIGHT;
d51 2
a52 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);
d68 1
a68 1
XFillPolygon(d, w[0], pgc, curPoint, NUM_POINTS, Convex,
d83 1
a83 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;
d29 1
a29 1
CreatePerfStuff(d, 1, WIDTH, HEIGHT, w, &whitegc, &blackgc);
d44 1
a44 1
pgc = whitegc;
d53 2
a54 2
if (pgc == whitegc)
pgc = blackgc;
d56 1
a56 1
pgc = whitegc;
d68 2
a69 2
XFreeGC(d, whitegc);
XFreeGC(d, blackgc);
@