|
|
1.1 root 1: .TH BOX 3R "630 MTG"
2: .XE "box()"
3: .SH NAME
4: box \- draw a Rectangle
5: .SH SYNOPSIS
6: .ft B
7: #include <dmd.h>
8: .sp
9: void box (bp, r, f)
10: .br
11: Bitmap \(**bp;
12: .br
13: Rectangle r;
14: .br
15: Code f;
16: .SH DESCRIPTION
17: The
18: .I box
19: function
20: draws the Rectangle
21: .I r
22: in the Bitmap
23: .I bp
24: using function Code
25: .IR f .
26: The coordinates of the corner point of the Rectangle
27: .I r
28: are decremented by one
29: before the outline is drawn so that abutting
30: Rectangles do not have common edges.
31: .SH EXAMPLE
32: The following subroutine can be used to draw a rectangle in the window and
33: have its position follow mouse movement.
34: .PP
35: .RS
36: .ft CM
37: .nf
38: .S -4
39: #include <dmd.h>
40:
41: int request();
42: int wait();
43: Rectangle raddp();
44: void box();
45: int eqpt();
46:
47: trackRect(tr)
48: Rectangle tr;
49: {
50: Rectangle r;
51: Point p,q;
52: int half_height, half_width;
53:
54: half_width = (tr.corner.x - tr.origin.x)/2;
55: half_height = (tr.corner.y - tr.origin.y)/2;
56: request (MOUSE);
57: while (!button1())
58: wait(MOUSE);
59: q = mouse.xy;
60: /*
61: * position the rectangle with mouse position
62: * in the middle
63: */
64: r = raddp (tr, Pt(q.x - half_width,
65: q.y - half_height));
66: box (&display, r, F_XOR);
67: do {
68: /*
69: * NOTE: This do-while loop does not give up
70: * the CPU for other processes to run.
71: */
72: p = mouse.xy;
73: if (!eqpt(p, q)){
74: /* allow update of mouse and video refresh */
75: nap(2);
76: box (&display, r, F_XOR);
77: r = raddp (tr, Pt(p.x - half_width,
78: p.y - half_height));
79: nap(2);
80: box (&display, r, F_XOR);
81: q = p;
82: }
83: } while( bttn(1) );
84: }\fR
85: .fi
86: .ft R
87: .RE
88: .S +4
89: .SH SEE ALSO
90: structures(3R).
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.