File: FillRect.c

package info (click to toggle)
acm 5.0-19
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 7,852 kB
  • ctags: 4,792
  • sloc: ansic: 42,427; makefile: 706; cpp: 293; perl: 280; sh: 198
file content (47 lines) | stat: -rw-r--r-- 801 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

#include <Alib.h>

extern int MakeET(AWindow * w, Point * pts, int npts, ZInfo * zinfo);

void
FillRectangle(AWindow * w, int x, int y, int width, int height, ZInfo * zinfo)
{

	Point     pts[4];
	register int yextent, xextent;

/*
 *  (Minimally) clip the box.
 */

	xextent = x + width - 1;
	yextent = y + height - 1;

	if (x > w->clip.x2 || y > w->clip.y2 ||
		xextent < w->clip.x1 || yextent < w->clip.y1) {
		return;
	}
	if (x < w->clip.x1) {
		x = w->clip.x1;
	}
	if (y < w->clip.y1) {
		y = w->clip.y1;
	}
	if (xextent > w->clip.x2) {
		xextent = w->clip.x2;
	}
	if (yextent > w->clip.y2) {
		yextent = w->clip.y2;
	}

	pts[0].x = x;
	pts[0].y = y;
	pts[1].x = xextent;
	pts[1].y = y;
	pts[2].x = xextent;
	pts[2].y = yextent;
	pts[3].x = x;
	pts[3].y = yextent;

	MakeET(w, pts, 4, zinfo);
}