|
|
1.1 root 1: /*
2: * $Source: /u1/X/libis/RCS/draw.c,v $
3: * $Header: draw.c,v 1.1 86/11/17 14:33:49 swick Rel $
4: */
5:
6: #ifndef lint
7: static char *rcsid_draw_c = "$Header: draw.c,v 1.1 86/11/17 14:33:49 swick Rel $";
8: #endif lint
9:
10: #include "is-copyright.h"
11:
12: /* draw.c Draw lines, curves, and polygons on the screen
13: *
14: * DrawCurve Draw a generalized line/polygon/combination
15: *
16: * Copyright (c) 1986, Integrated Solutions, Inc.
17: */
18:
19: /*
20: * ToDo:
21: * Dash/Pattern
22: * Curves
23: */
24:
25: #include "Xis.h"
26:
27: #define imin(i,j) ((i)<(j)?(i):(j))
28: #define imax(i,j) ((i)>(j)?(i):(j))
29:
30: static
31: Draw_Solid(srcpix, xbase, ybase, func, vertcount, verts, clipcount, clips, zmask, bwidth, bheight)
32: int srcpix; /* Pixel value to write */
33: int xbase, ybase; /* Origin of curve */
34: int func; /* Opcode */
35: int vertcount; /* Length of Vertex array */
36: Vertex *verts; /* Vertices */
37: int clipcount; /* Length of clip array */
38: CLIP *clips; /* clipping rectangles */
39: int zmask; /* plane mask */
40: int bwidth, bheight;/* brush width and height */
41: {
42: PIXMAP *fillpix;
43: extern PIXMAP *MakePixmap();
44:
45: fillpix = MakePixmap((BITMAP *)NULL, srcpix, 0);
46: do { /* for each clipping region */
47: register int xp, yp;
48: register Vertex *v = verts;
49: register int vc = vertcount;
50:
51: do { /* for each vertex */
52: register xo = xp, yo = yp;
53: /* first vertex is always VertexDontDraw and !VertexRelative */
54: /* xo,yo do not matter and xp,yp get initialized first time */
55:
56: if (v->flags & VertexRelative) {
57: xp += v->x;
58: yp += v->y;
59: } else {
60: xp = v->x + xbase;
61: yp = v->y + ybase;
62: }
63: /* XXX - ignore VertexCurved for now */
64: /* XXX - ignore VertexDrawLastPoint for now */
65: if (!(v->flags & VertexDontDraw)) {
66: CLIP bounds;
67:
68: /* bounding rectangle of two points */
69: bounds.top = imin(yo, yp);
70: bounds.left = imin(xo, xp);
71: bounds.width = imax(xo, xp) + bwidth - bounds.left;
72: bounds.height = imax(yo, yp) + bheight - bounds.top;
73:
74: if (Overlap(bounds, clips[clipcount-1])) {
75: /* vector at least partly visible */
76: CLIP i;
77: i = Intersection(clips[clipcount-1], bounds);
78: CheckCursor(i);
79: if ((xo == xp) || (yo == yp)) {
80: /* horizontal or vertical vector */
81: GIP_RasterOp((unsigned char)func,
82: fillpix, 0, 0,
83: &ScreenPixmap, i.left, i.top,
84: (BITMAP *)0, 0, 0,
85: i.width, i.height, zmask);
86: } else {
87: /* non-horizontal and non-vertical vector */
88: GIP_Vector((unsigned char)func,
89: fillpix, 0, 0,
90: &ScreenPixmap, xo, yo, xp, yp,
91: i.left, i.top, i.left+i.width-1, i.top+i.height-1,
92: bwidth, bheight, zmask);
93: }
94: }
95: }
96: v++;
97: } while (--vc > 0);
98: } while (--clipcount > 0);
99: if (!--fillpix->refcnt)
100: FreePixmap (fillpix);
101: RestoreCursor();
102: }
103:
104: DrawCurve(verts, vertcount, xbase, ybase, srcpix, altpix, mode,
105: bwidth, bheight, pat, patlen, patmul, clips, clipcount, func, zmask)
106: Vertex *verts;
107: int vertcount, xbase, ybase, srcpix, altpix, mode, bwidth, bheight;
108: int pat, patlen, patmul, clipcount, func, zmask;
109: CLIP *clips;
110: {
111:
112: #ifdef DEBUG
113: if (debug & D_DrawCurve)
114: printf("DrawCurve(verts=0x%x, vertcount=%d, xbase=%d, ybase=%d,\n srcpix=%d, altpix=%d, mode=%d, bwidth=%d, bheight=%d\n pat=%d, patlen=%d, patmul=%d\n clips=0x%x, clipcount=%d, func=%d, zmask=0x%04x)\n",
115: verts, vertcount, xbase, ybase, srcpix, altpix, mode, bwidth, bheight,
116: pat, patlen, patmul, clips, clipcount, func, zmask);
117: #endif DEBUG
118:
119: switch (mode) { /* XXX - ignores dash/pattern for now */
120: case DrawSolidLine:
121: Draw_Solid(srcpix, xbase, ybase, func, vertcount, verts,
122: clipcount, clips, zmask, bwidth, bheight);
123: break;
124: case DrawDashedLine:
125: Draw_Solid(srcpix, xbase, ybase, func, vertcount, verts,
126: clipcount, clips, zmask, bwidth, bheight);
127: break;
128: case DrawPatternedLine:
129: Draw_Solid(srcpix, xbase, ybase, func, vertcount, verts,
130: clipcount, clips, zmask, bwidth, bheight);
131: break;
132: }
133: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.