|
|
1.1 ! root 1: .TH CIRCLE 3L "630 MTG" ! 2: .XE "circle()" ! 3: .XE "disc()" ! 4: .XE "discture()" ! 5: .XE "arc()" ! 6: .SH NAME ! 7: circle, disc, discture, arc \- circle routines ! 8: .SH SYNOPSIS ! 9: .B #include <dmd.h> ! 10: .sp ! 11: \f3void circle (b, p, r, f)\f1 ! 12: .sp ! 13: .B void disc (b, p, r, f) ! 14: .sp ! 15: \f3void discture (b, p, r, t, f)\f1 ! 16: .sp ! 17: \f3void arc (b, p, p1, p2, f)\f1 ! 18: .sp ! 19: .B Bitmap \(**b; ! 20: .br ! 21: .B Point p, p1, p2; ! 22: .br ! 23: .B int r; ! 24: .br ! 25: .B Texture16 \(**t; ! 26: .br ! 27: .B Code f; ! 28: .SH DESCRIPTION ! 29: The ! 30: .I circle ! 31: function ! 32: draws the best approximate circle of radius ! 33: .I r ! 34: centered at Point ! 35: .I p ! 36: in the Bitmap ! 37: .I b ! 38: with Code ! 39: .IR f . ! 40: The circle is guaranteed to be symmetrical about the horizontal, ! 41: vertical, and diagonal axes. ! 42: .PP ! 43: The ! 44: .I disc ! 45: function ! 46: draws a disc of radius ! 47: .I r ! 48: centered at Point ! 49: .I p ! 50: in the Bitmap ! 51: .I b ! 52: with Code ! 53: .IR f . ! 54: A disc is a circle which has been completely filled. ! 55: .PP ! 56: The ! 57: .I discture ! 58: function ! 59: draws a disc of radius ! 60: .I r ! 61: centered at Point ! 62: .I p ! 63: in the Bitmap ! 64: .I b ! 65: using the Texture16 ! 66: .I t ! 67: with Code ! 68: .IR f . ! 69: The ! 70: .I discture ! 71: function ! 72: is similar to ! 73: the ! 74: .I disc ! 75: function ! 76: except it allows one to specify a pattern to fill the disc. ! 77: .PP ! 78: The ! 79: .I arc ! 80: function ! 81: draws a circular arc centered on ! 82: .IR p , ! 83: traveling counter-clockwise from ! 84: .I p1 ! 85: to the point on the circle closest to ! 86: .IR p2 . ! 87: .SH EXAMPLE ! 88: The following routine draws a ``smiling face'' in the display Bitmap ! 89: with center specified by clicking button 1. ! 90: .PP ! 91: .RS 3 ! 92: .ft CM ! 93: .nf ! 94: .S -4 ! 95: #include <dmd.h> ! 96: ! 97: ! 98: main() ! 99: { ! 100: int radius; ! 101: extern Texture16 T_darkgrey; ! 102: Point s; ! 103: ! 104: request(MOUSE); ! 105: wait(MOUSE); ! 106: bttns(1); ! 107: ! 108: s = mouse.xy; ! 109: radius = 50; ! 110: ! 111: /* smiling will draw the face. The nose will be ! 112: * placed wherever the mouse is clicked in ! 113: * the window. ! 114: */ ! 115: ! 116: smiling(&display, s, radius, &T_darkgrey, F_XOR); ! 117: ! 118: request(KBD); ! 119: wait(KBD); ! 120: } ! 121: ! 122: ! 123: smiling(b, c, rad, t, f) ! 124: Bitmap *b; ! 125: Point c; ! 126: int rad; ! 127: Texture16 *t; ! 128: Code f; ! 129: { ! 130: int mino, e; /* offsets for placing */ ! 131: /* eyes, nose and mouth */ ! 132: int enrad; /* radius of eyes and nose */ ! 133: ! 134: mino = rad/2; ! 135: e = rad/3; ! 136: enrad = e/3; ! 137: circle (b, c, rad, f); /* face outline */ ! 138: disc (b, Pt(c.x-e, c.y-mino), ! 139: enrad, f); /* left eye */ ! 140: disc (b, Pt(c.x+e, c.y-mino), ! 141: enrad, f); /* right eye */ ! 142: discture (b, c, enrad, t, f); /* nose */ ! 143: arc (b, c, Pt(c.x-mino, c.y+mino), ! 144: Pt(c.x+mino, c.y+mino),f); ! 145: /* mouth */ ! 146: } ! 147: .fi ! 148: .ft R ! 149: .RE ! 150: .S +4 ! 151: .SH SEE ALSO ! 152: ellipse(3L), jcircle(3L), jellipse(3L), texture(3R).
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.