1 cfa37a7b 2004-04-10 devnull .TH DRAW 3
3 cfa37a7b 2004-04-10 devnull Image, draw, gendraw, drawreplxy, drawrepl,
4 cfa37a7b 2004-04-10 devnull replclipr, line, poly, fillpoly, bezier, bezspline, fillbezier, fillbezspline, ellipse,
5 cfa37a7b 2004-04-10 devnull fillellipse, arc, fillarc, icossin, icossin2, border, string, stringn,
6 cfa37a7b 2004-04-10 devnull runestring, runestringn, stringbg, stringnbg, runestringbg,
7 cfa37a7b 2004-04-10 devnull runestringnbg, _string, ARROW, drawsetdebug \- graphics functions
13 cfa37a7b 2004-04-10 devnull .SH SYNOPSIS
20 cfa37a7b 2004-04-10 devnull #include <u.h>
21 cfa37a7b 2004-04-10 devnull #include <libc.h>
22 cfa37a7b 2004-04-10 devnull #include <draw.h>
25 cfa37a7b 2004-04-10 devnull struct Image
27 cfa37a7b 2004-04-10 devnull Display *display; /* display holding data */
28 cfa37a7b 2004-04-10 devnull int id; /* id of system-held Image */
29 cfa37a7b 2004-04-10 devnull Rectangle r; /* rectangle in data area, local coords */
30 cfa37a7b 2004-04-10 devnull Rectangle clipr; /* clipping region */
31 cfa37a7b 2004-04-10 devnull ulong chan; /* pixel channel format descriptor */
32 cfa37a7b 2004-04-10 devnull int depth; /* number of bits per pixel */
33 cfa37a7b 2004-04-10 devnull int repl; /* flag: data replicates to tile clipr */
34 cfa37a7b 2004-04-10 devnull Screen *screen; /* 0 if not a window */
35 cfa37a7b 2004-04-10 devnull Image *next; /* next in list of windows */
38 cfa37a7b 2004-04-10 devnull typedef enum
40 cfa37a7b 2004-04-10 devnull /* Porter-Duff compositing operators */
41 cfa37a7b 2004-04-10 devnull Clear = 0,
43 cfa37a7b 2004-04-10 devnull SinD = 8,
44 cfa37a7b 2004-04-10 devnull DinS = 4,
45 cfa37a7b 2004-04-10 devnull SoutD = 2,
46 cfa37a7b 2004-04-10 devnull DoutS = 1,
48 cfa37a7b 2004-04-10 devnull S = SinD|SoutD,
49 cfa37a7b 2004-04-10 devnull SoverD = SinD|SoutD|DoutS,
50 cfa37a7b 2004-04-10 devnull SatopD = SinD|DoutS,
51 cfa37a7b 2004-04-10 devnull SxorD = SoutD|DoutS,
53 cfa37a7b 2004-04-10 devnull D = DinS|DoutS,
54 cfa37a7b 2004-04-10 devnull DoverS = DinS|DoutS|SoutD,
55 cfa37a7b 2004-04-10 devnull DatopS = DinS|SoutD,
56 cfa37a7b 2004-04-10 devnull DxorS = DoutS|SoutD, /* == SxorD */
58 cfa37a7b 2004-04-10 devnull Ncomp = 12,
59 cfa37a7b 2004-04-10 devnull } Drawop;
62 cfa37a7b 2004-04-10 devnull .ta +\w'\fL 'u +\w'\fL 'u +6n +4n
63 cfa37a7b 2004-04-10 devnull void draw(Image *dst, Rectangle r, Image *src,
64 cfa37a7b 2004-04-10 devnull Image *mask, Point p)
66 cfa37a7b 2004-04-10 devnull void drawop(Image *dst, Rectangle r, Image *src,
67 cfa37a7b 2004-04-10 devnull Image *mask, Point p, Drawop op)
69 cfa37a7b 2004-04-10 devnull void gendraw(Image *dst, Rectangle r, Image *src, Point sp,
70 cfa37a7b 2004-04-10 devnull Image *mask, Point mp)
72 cfa37a7b 2004-04-10 devnull void gendrawop(Image *dst, Rectangle r, Image *src, Point sp,
73 cfa37a7b 2004-04-10 devnull Image *mask, Point mp, Drawop op)
75 cfa37a7b 2004-04-10 devnull int drawreplxy(int min, int max, int x)
77 cfa37a7b 2004-04-10 devnull Point drawrepl(Rectangle r, Point p)
79 cfa37a7b 2004-04-10 devnull void replclipr(Image *i, int repl, Rectangle clipr)
81 cfa37a7b 2004-04-10 devnull void line(Image *dst, Point p0, Point p1, int end0, int end1,
82 cfa37a7b 2004-04-10 devnull int radius, Image *src, Point sp)
84 cfa37a7b 2004-04-10 devnull void lineop(Image *dst, Point p0, Point p1, int end0, int end1,
85 cfa37a7b 2004-04-10 devnull int radius, Image *src, Point sp, Drawop op)
87 cfa37a7b 2004-04-10 devnull void poly(Image *dst, Point *p, int np, int end0, int end1,
88 cfa37a7b 2004-04-10 devnull int radius, Image *src, Point sp)
90 cfa37a7b 2004-04-10 devnull void polyop(Image *dst, Point *p, int np, int end0, int end1,
91 cfa37a7b 2004-04-10 devnull int radius, Image *src, Point sp, Drawop op)
93 cfa37a7b 2004-04-10 devnull void fillpoly(Image *dst, Point *p, int np, int wind,
94 cfa37a7b 2004-04-10 devnull Image *src, Point sp)
96 cfa37a7b 2004-04-10 devnull void fillpolyop(Image *dst, Point *p, int np, int wind,
97 cfa37a7b 2004-04-10 devnull Image *src, Point sp, Drawop op)
99 cfa37a7b 2004-04-10 devnull int bezier(Image *dst, Point p0, Point p1, Point p2, Point p3,
100 cfa37a7b 2004-04-10 devnull int end0, int end1, int radius, Image *src, Point sp)
102 cfa37a7b 2004-04-10 devnull int bezierop(Image *dst, Point p0, Point p1, Point p2, Point p3,
103 cfa37a7b 2004-04-10 devnull int end0, int end1, int radius, Image *src, Point sp,
104 cfa37a7b 2004-04-10 devnull Drawop op)
106 cfa37a7b 2004-04-10 devnull int bezspline(Image *dst, Point *pt, int npt, int end0, int end1,
107 cfa37a7b 2004-04-10 devnull int radius, Image *src, Point sp)
109 cfa37a7b 2004-04-10 devnull int bezsplineop(Image *dst, Point *pt, int npt, int end0, int end1,
110 cfa37a7b 2004-04-10 devnull int radius, Image *src, Point sp, Drawop op)
112 cfa37a7b 2004-04-10 devnull int bezsplinepts(Point *pt, int npt, Point **pp)
114 cfa37a7b 2004-04-10 devnull int fillbezier(Image *dst, Point p0, Point p1, Point p2, Point p3,
115 cfa37a7b 2004-04-10 devnull int w, Image *src, Point sp)
117 cfa37a7b 2004-04-10 devnull int fillbezierop(Image *dst, Point p0, Point p1, Point p2, Point p3,
118 cfa37a7b 2004-04-10 devnull int w, Image *src, Point sp, Drawop op)
120 cfa37a7b 2004-04-10 devnull int fillbezspline(Image *dst, Point *pt, int npt, int w,
121 cfa37a7b 2004-04-10 devnull Image *src, Point sp)
123 cfa37a7b 2004-04-10 devnull int fillbezsplineop(Image *dst, Point *pt, int npt, int w,
124 cfa37a7b 2004-04-10 devnull Image *src, Point sp, Drawop op)
126 cfa37a7b 2004-04-10 devnull void ellipse(Image *dst, Point c, int a, int b, int thick,
127 cfa37a7b 2004-04-10 devnull Image *src, Point sp)
129 cfa37a7b 2004-04-10 devnull void ellipseop(Image *dst, Point c, int a, int b, int thick,
130 cfa37a7b 2004-04-10 devnull Image *src, Point sp, Drawop op)
132 cfa37a7b 2004-04-10 devnull void fillellipse(Image *dst, Point c, int a, int b,
133 cfa37a7b 2004-04-10 devnull Image *src, Point sp)
135 cfa37a7b 2004-04-10 devnull void fillellipseop(Image *dst, Point c, int a, int b,
136 cfa37a7b 2004-04-10 devnull Image *src, Point sp, Drawop op)
138 cfa37a7b 2004-04-10 devnull void arc(Image *dst, Point c, int a, int b, int thick,
139 cfa37a7b 2004-04-10 devnull Image *src, Point sp, int alpha, int phi)
141 cfa37a7b 2004-04-10 devnull void arcop(Image *dst, Point c, int a, int b, int thick,
142 cfa37a7b 2004-04-10 devnull Image *src, Point sp, int alpha, int phi, Drawop op)
144 cfa37a7b 2004-04-10 devnull void fillarc(Image *dst, Point c, int a, int b, Image *src,
145 cfa37a7b 2004-04-10 devnull Point sp, int alpha, int phi)
147 cfa37a7b 2004-04-10 devnull void fillarcop(Image *dst, Point c, int a, int b, Image *src,
148 cfa37a7b 2004-04-10 devnull Point sp, int alpha, int phi, Drawop op)
150 cfa37a7b 2004-04-10 devnull int icossin(int deg, int *cosp, int *sinp)
152 cfa37a7b 2004-04-10 devnull int icossin2(int x, int y, int *cosp, int *sinp)
154 cfa37a7b 2004-04-10 devnull void border(Image *dst, Rectangle r, int i, Image *color, Point sp)
157 cfa37a7b 2004-04-10 devnull Point string(Image *dst, Point p, Image *src, Point sp,
158 cfa37a7b 2004-04-10 devnull Font *f, char *s)
160 cfa37a7b 2004-04-10 devnull Point stringop(Image *dst, Point p, Image *src, Point sp,
161 cfa37a7b 2004-04-10 devnull Font *f, char *s, Drawop op)
163 cfa37a7b 2004-04-10 devnull Point stringn(Image *dst, Point p, Image *src, Point sp,
164 cfa37a7b 2004-04-10 devnull Font *f, char *s, int len)
166 cfa37a7b 2004-04-10 devnull Point stringnop(Image *dst, Point p, Image *src, Point sp,
167 cfa37a7b 2004-04-10 devnull Font *f, char *s, int len, Drawop op)
169 cfa37a7b 2004-04-10 devnull Point runestring(Image *dst, Point p, Image *src, Point sp,
170 cfa37a7b 2004-04-10 devnull Font *f, Rune *r)
172 cfa37a7b 2004-04-10 devnull Point runestringop(Image *dst, Point p, Image *src, Point sp,
173 cfa37a7b 2004-04-10 devnull Font *f, Rune *r, Drawop op)
175 cfa37a7b 2004-04-10 devnull Point runestringn(Image *dst, Point p, Image *src, Point sp,
176 cfa37a7b 2004-04-10 devnull Font *f, Rune *r, int len)
178 cfa37a7b 2004-04-10 devnull Point runestringnop(Image *dst, Point p, Image *src, Point sp,
179 cfa37a7b 2004-04-10 devnull Font *f, Rune *r, int len, Drawop op)
181 cfa37a7b 2004-04-10 devnull Point stringbg(Image *dst, Point p, Image *src, Point sp,
182 cfa37a7b 2004-04-10 devnull Font *f, char *s, Image *bg, Point bgp)
184 cfa37a7b 2004-04-10 devnull Point stringbgop(Image *dst, Point p, Image *src, Point sp,
185 cfa37a7b 2004-04-10 devnull Font *f, char *s, Image *bg, Point bgp, Drawop op)
187 cfa37a7b 2004-04-10 devnull Point stringnbg(Image *dst, Point p, Image *src, Point sp,
188 cfa37a7b 2004-04-10 devnull Font *f, char *s, int len, Image *bg, Point bgp)
190 cfa37a7b 2004-04-10 devnull Point stringnbgop(Image *dst, Point p, Image *src, Point sp,
191 cfa37a7b 2004-04-10 devnull Font *f, char *s, int len, Image *bg, Point bgp, Drawop op)
193 cfa37a7b 2004-04-10 devnull Point runestringbg(Image *dst, Point p, Image *src, Point sp,
194 cfa37a7b 2004-04-10 devnull Font *f, Rune *r, Image *bg, Point bgp)
196 cfa37a7b 2004-04-10 devnull Point runestringbgop(Image *dst, Point p, Image *src, Point sp,
197 cfa37a7b 2004-04-10 devnull Font *f, Rune *r, Image *bg, Point bgp, Drawop op)
199 cfa37a7b 2004-04-10 devnull Point runestringnbg(Image *dst, Point p, Image *src, Point sp,
200 cfa37a7b 2004-04-10 devnull Font *f, Rune *r, int len, Image *bg, Point bgp)
202 cfa37a7b 2004-04-10 devnull Point runestringnbgop(Image *dst, Point p, Image *src, Point sp,
203 cfa37a7b 2004-04-10 devnull Font *f, Rune *r, int len, Image *bg, Point bgp, Drawop op)
205 cfa37a7b 2004-04-10 devnull Point _string(Image *dst, Point p, Image *src,
206 cfa37a7b 2004-04-10 devnull Point sp, Font *f, char *s, Rune *r, int len,
207 cfa37a7b 2004-04-10 devnull Rectangle clipr, Image *bg, Point bgp, Drawop op)
209 cfa37a7b 2004-04-10 devnull void drawsetdebug(int on)
214 cfa37a7b 2004-04-10 devnull /* line ends */
215 cfa37a7b 2004-04-10 devnull Endsquare = 0,
216 cfa37a7b 2004-04-10 devnull Enddisc = 1,
217 cfa37a7b 2004-04-10 devnull Endarrow = 2,
218 cfa37a7b 2004-04-10 devnull Endmask = 0x1F
221 cfa37a7b 2004-04-10 devnull #define ARROW(a, b, c) (Endarrow|((a)<<5)|((b)<<14)|((c)<<23))
222 cfa37a7b 2004-04-10 devnull .SH DESCRIPTION
224 cfa37a7b 2004-04-10 devnull .B Image
225 cfa37a7b 2004-04-10 devnull type defines rectangular pictures and the methods to draw upon them;
226 cfa37a7b 2004-04-10 devnull it is also the building block for higher level objects such as
227 cfa37a7b 2004-04-10 devnull windows and fonts.
228 cfa37a7b 2004-04-10 devnull In particular, a window is represented as an
229 cfa37a7b 2004-04-10 devnull .BR Image ;
230 cfa37a7b 2004-04-10 devnull no special operators are needed to draw on a window.
234 cfa37a7b 2004-04-10 devnull The coordinates of the rectangle in the plane for which the
235 cfa37a7b 2004-04-10 devnull .B Image
236 cfa37a7b 2004-04-10 devnull has defined pixel values.
237 cfa37a7b 2004-04-10 devnull It should not be modified after the image is created.
239 cfa37a7b 2004-04-10 devnull .B clipr
240 cfa37a7b 2004-04-10 devnull The clipping rectangle: operations that read or write
241 cfa37a7b 2004-04-10 devnull the image will not access pixels outside
242 cfa37a7b 2004-04-10 devnull .BR clipr .
243 cfa37a7b 2004-04-10 devnull Frequently,
244 cfa37a7b 2004-04-10 devnull .B clipr
245 cfa37a7b 2004-04-10 devnull is the same as
247 cfa37a7b 2004-04-10 devnull but it may differ; see in particular the discussion of
248 cfa37a7b 2004-04-10 devnull .BR repl .
249 cfa37a7b 2004-04-10 devnull The clipping region may be modified dynamically using
250 cfa37a7b 2004-04-10 devnull .I replclipr
251 cfa37a7b 2004-04-10 devnull .RI ( q.v. ).
254 cfa37a7b 2004-04-10 devnull The pixel channel format descriptor, as described in
255 cfa37a7b 2004-04-10 devnull .IR image (6).
256 cfa37a7b 2004-04-10 devnull The value should not be modified after the image is created.
258 cfa37a7b 2004-04-10 devnull .B depth
260 cfa37a7b 2004-04-10 devnull number of bits per pixel in the picture;
261 cfa37a7b 2004-04-10 devnull it is identically
262 cfa37a7b 2004-04-10 devnull .B chantodepth(chan)
264 bf8a59fa 2004-04-11 devnull .IR graphics (3))
265 cfa37a7b 2004-04-10 devnull and is provided as a convenience.
266 cfa37a7b 2004-04-10 devnull The value should not be modified after the image is created.
269 cfa37a7b 2004-04-10 devnull A boolean value specifying whether the image is tiled to cover
270 cfa37a7b 2004-04-10 devnull the plane when used as a source for a drawing operation.
273 cfa37a7b 2004-04-10 devnull is zero, operations are restricted to the intersection of
276 cfa37a7b 2004-04-10 devnull .BR clipr .
281 cfa37a7b 2004-04-10 devnull defines the tile to be replicated and
282 cfa37a7b 2004-04-10 devnull .B clipr
283 cfa37a7b 2004-04-10 devnull defines the portion of the plane covered by the tiling, in other words,
285 cfa37a7b 2004-04-10 devnull is replicated to cover
286 cfa37a7b 2004-04-10 devnull .BR clipr ;
287 cfa37a7b 2004-04-10 devnull in such cases
290 cfa37a7b 2004-04-10 devnull .B clipr
291 cfa37a7b 2004-04-10 devnull are independent.
293 cfa37a7b 2004-04-10 devnull For example, a replicated image with
295 cfa37a7b 2004-04-10 devnull set to ((0,\ 0),\ (1,\ 1)) and
296 cfa37a7b 2004-04-10 devnull .B clipr
297 cfa37a7b 2004-04-10 devnull set to ((0,\ 0),\ (100,\ 100)),
298 cfa37a7b 2004-04-10 devnull with the single pixel of
300 cfa37a7b 2004-04-10 devnull set to blue,
301 cfa37a7b 2004-04-10 devnull behaves identically to an image with
304 cfa37a7b 2004-04-10 devnull .B clipr
305 cfa37a7b 2004-04-10 devnull both set to ((0,\ 0),\ (100,\ 100)) and all pixels set to blue.
306 cfa37a7b 2004-04-10 devnull However,
307 cfa37a7b 2004-04-10 devnull the first image requires far less memory.
308 cfa37a7b 2004-04-10 devnull The replication flag may be modified dynamically using
309 cfa37a7b 2004-04-10 devnull .I replclipr
310 cfa37a7b 2004-04-10 devnull .RI ( q.v. ).
312 cfa37a7b 2004-04-10 devnull Most of the drawing functions come in two forms:
313 cfa37a7b 2004-04-10 devnull a basic form, and an extended form that takes an extra
314 cfa37a7b 2004-04-10 devnull .B Drawop
315 cfa37a7b 2004-04-10 devnull to specify a Porter-Duff compositing operator to use.
316 cfa37a7b 2004-04-10 devnull The basic forms assume the operator is
317 cfa37a7b 2004-04-10 devnull .BR SoverD ,
318 cfa37a7b 2004-04-10 devnull which suffices for the vast majority of applications.
319 cfa37a7b 2004-04-10 devnull The extended forms are named by adding an
320 cfa37a7b 2004-04-10 devnull .RB - op
321 cfa37a7b 2004-04-10 devnull suffix to the basic form.
322 cfa37a7b 2004-04-10 devnull Only the basic forms are listed below.
324 cfa37a7b 2004-04-10 devnull .BI draw( dst\fP,\fP\ r\fP,\fP\ src\fP,\fP\ mask\fP,\fP\ p )
326 cfa37a7b 2004-04-10 devnull is the standard drawing function.
327 cfa37a7b 2004-04-10 devnull Only those pixels within the intersection of
328 cfa37a7b 2004-04-10 devnull .IB dst ->r
330 cfa37a7b 2004-04-10 devnull .IB dst ->clipr
331 cfa37a7b 2004-04-10 devnull will be affected;
334 cfa37a7b 2004-04-10 devnull .IB dst ->repl\fR.
335 cfa37a7b 2004-04-10 devnull The operation proceeds as follows
336 cfa37a7b 2004-04-10 devnull (this is a description of the behavior, not the implementation):
341 cfa37a7b 2004-04-10 devnull is set in
344 cfa37a7b 2004-04-10 devnull .IR mask ,
345 cfa37a7b 2004-04-10 devnull replicate their contents to fill
346 cfa37a7b 2004-04-10 devnull their clip rectangles.
348 cfa37a7b 2004-04-10 devnull Translate
354 cfa37a7b 2004-04-10 devnull is aligned with
355 cfa37a7b 2004-04-10 devnull .IB r .min\fR.
359 cfa37a7b 2004-04-10 devnull to the intersection of
362 cfa37a7b 2004-04-10 devnull .IB dst ->r\fR.
364 cfa37a7b 2004-04-10 devnull Intersect
367 cfa37a7b 2004-04-10 devnull .IB src ->clipr\fR.
369 cfa37a7b 2004-04-10 devnull .IB src ->repl
370 cfa37a7b 2004-04-10 devnull is false, also intersect
373 cfa37a7b 2004-04-10 devnull .IB src ->r\fR.
375 cfa37a7b 2004-04-10 devnull Intersect
378 cfa37a7b 2004-04-10 devnull .IB mask ->clipr\fR.
380 cfa37a7b 2004-04-10 devnull .IB mask ->repl
381 cfa37a7b 2004-04-10 devnull is false, also intersect
384 cfa37a7b 2004-04-10 devnull .IB mask ->r\fR.
386 cfa37a7b 2004-04-10 devnull For each location in
388 cfa37a7b 2004-04-10 devnull combine the
390 cfa37a7b 2004-04-10 devnull pixel with the
392 cfa37a7b 2004-04-10 devnull pixel using the alpha value
393 cfa37a7b 2004-04-10 devnull corresponding to the
398 cfa37a7b 2004-04-10 devnull has an explicit alpha channel, the alpha value
399 cfa37a7b 2004-04-10 devnull corresponding to the
401 cfa37a7b 2004-04-10 devnull pixel is simply that pixel's alpha channel.
402 cfa37a7b 2004-04-10 devnull Otherwise, the alpha value is the NTSC greyscale equivalent
403 cfa37a7b 2004-04-10 devnull of the color value, with white meaning opaque and black transparent.
404 cfa37a7b 2004-04-10 devnull In terms of the Porter-Duff compositing algebra,
406 cfa37a7b 2004-04-10 devnull replaces the
408 cfa37a7b 2004-04-10 devnull pixels with
409 cfa37a7b 2004-04-10 devnull .RI ( src
411 cfa37a7b 2004-04-10 devnull .IR mask )
413 cfa37a7b 2004-04-10 devnull .IR dst .
414 cfa37a7b 2004-04-10 devnull (In the extended form,
415 cfa37a7b 2004-04-10 devnull ``over'' is replaced by
416 cfa37a7b 2004-04-10 devnull .IR op ).
419 cfa37a7b 2004-04-10 devnull The various
420 cfa37a7b 2004-04-10 devnull pixel channel formats
421 cfa37a7b 2004-04-10 devnull involved need not be identical.
422 cfa37a7b 2004-04-10 devnull If the channels involved are smaller than 8-bits, they will
423 cfa37a7b 2004-04-10 devnull be promoted before the calculation by replicating the extant bits;
424 cfa37a7b 2004-04-10 devnull after the calculation, they will be truncated to their proper sizes.
426 cfa37a7b 2004-04-10 devnull \f5gendraw(\f2dst\fP, \f2r\fP, \f2src\fP, \f2p0\fP, \f2mask\fP, \f2p1\f5)\fP
427 cfa37a7b 2004-04-10 devnull Similar to
429 cfa37a7b 2004-04-10 devnull except that
430 cfa37a7b 2004-04-10 devnull .I gendraw
431 cfa37a7b 2004-04-10 devnull aligns the source and mask differently:
433 cfa37a7b 2004-04-10 devnull is aligned so
435 cfa37a7b 2004-04-10 devnull corresponds to
436 cfa37a7b 2004-04-10 devnull .IB r .min
439 cfa37a7b 2004-04-10 devnull is aligned so
441 cfa37a7b 2004-04-10 devnull corresponds to
442 cfa37a7b 2004-04-10 devnull .IB r .min .
443 cfa37a7b 2004-04-10 devnull For most purposes with simple masks and source images,
445 cfa37a7b 2004-04-10 devnull is sufficient, but
446 cfa37a7b 2004-04-10 devnull .B gendraw
447 cfa37a7b 2004-04-10 devnull is the general operator and the one all other drawing primitives are built upon.
449 cfa37a7b 2004-04-10 devnull .BI drawreplxy( min , max , x\f5)
452 cfa37a7b 2004-04-10 devnull to be in the half-open interval [\fImin\fP, \fImax\fP) by adding
453 cfa37a7b 2004-04-10 devnull or subtracting a multiple of \fImax-min\fP.
455 cfa37a7b 2004-04-10 devnull .BI drawrepl( r , p )
456 cfa37a7b 2004-04-10 devnull Clips the point \fIp\fP to be within the rectangle \fIr\fP
457 cfa37a7b 2004-04-10 devnull by translating the point horizontally by an integer multiple of rectangle width
458 cfa37a7b 2004-04-10 devnull and vertically by the height.
460 cfa37a7b 2004-04-10 devnull .BI replclipr( i , repl , clipr\f5)
461 cfa37a7b 2004-04-10 devnull Because the image data is stored on the server, local modifications to the
462 cfa37a7b 2004-04-10 devnull .B Image
463 cfa37a7b 2004-04-10 devnull data structure itself will have no effect.
464 cfa37a7b 2004-04-10 devnull .I Repclipr
465 cfa37a7b 2004-04-10 devnull modifies the local
466 cfa37a7b 2004-04-10 devnull .B Image
467 cfa37a7b 2004-04-10 devnull data structure's
470 cfa37a7b 2004-04-10 devnull .B clipr
471 cfa37a7b 2004-04-10 devnull fields, and notifies the server of their modification.
473 cfa37a7b 2004-04-10 devnull \f5line(\f2dst\fP, \f2p0\fP, \f2p1\fP, \f2end0\fP, \f2end1\fP, \f2thick\fP, \f2src\fP, \f2sp\fP)
475 cfa37a7b 2004-04-10 devnull draws in
477 cfa37a7b 2004-04-10 devnull a line of width
478 cfa37a7b 2004-04-10 devnull .RI 1+2* thick
479 cfa37a7b 2004-04-10 devnull pixels joining points
482 cfa37a7b 2004-04-10 devnull .IR p1 .
483 cfa37a7b 2004-04-10 devnull The line is drawn using pixels from the
485 cfa37a7b 2004-04-10 devnull image aligned so
487 cfa37a7b 2004-04-10 devnull in the source corresponds to
489 cfa37a7b 2004-04-10 devnull in the destination.
490 cfa37a7b 2004-04-10 devnull The line touches both
493 cfa37a7b 2004-04-10 devnull .IR p1 ,
498 cfa37a7b 2004-04-10 devnull specify how the ends of the line are drawn.
499 cfa37a7b 2004-04-10 devnull .B Endsquare
500 cfa37a7b 2004-04-10 devnull terminates the line perpendicularly to the direction of the line; a thick line with
501 cfa37a7b 2004-04-10 devnull .B Endsquare
502 cfa37a7b 2004-04-10 devnull on both ends will be a rectangle.
503 cfa37a7b 2004-04-10 devnull .B Enddisc
504 cfa37a7b 2004-04-10 devnull terminates the line by drawing a disc of diameter
505 cfa37a7b 2004-04-10 devnull .RI 1+2* thick
506 cfa37a7b 2004-04-10 devnull centered on the end point.
507 cfa37a7b 2004-04-10 devnull .B Endarrow
508 cfa37a7b 2004-04-10 devnull terminates the line with an arrowhead whose tip touches the endpoint.
510 cfa37a7b 2004-04-10 devnull The macro
511 cfa37a7b 2004-04-10 devnull .B ARROW
512 cfa37a7b 2004-04-10 devnull permits explicit control of the shape of the arrow.
513 cfa37a7b 2004-04-10 devnull If all three parameters are zero, it produces the default arrowhead,
514 cfa37a7b 2004-04-10 devnull otherwise,
516 cfa37a7b 2004-04-10 devnull sets the distance along line from end of the regular line to tip,
518 cfa37a7b 2004-04-10 devnull sets the distance along line from the barb to the tip,
521 cfa37a7b 2004-04-10 devnull sets the distance perpendicular to the line from edge of line to the tip of the barb,
522 cfa37a7b 2004-04-10 devnull all in pixels.
525 cfa37a7b 2004-04-10 devnull and the other geometrical operators are equivalent to calls to
526 cfa37a7b 2004-04-10 devnull .I gendraw
527 cfa37a7b 2004-04-10 devnull using a mask produced by the geometric procedure.
529 cfa37a7b 2004-04-10 devnull \f5poly(\f2dst\fP, \f2p\fP, \f2np\fP, \f2end0\fP, \f2end1\fP, \f2thick\fP, \f2src\fP, \f2sp\fP)
531 cfa37a7b 2004-04-10 devnull draws a general polygon; it
532 cfa37a7b 2004-04-10 devnull is conceptually equivalent to a series of calls to
534 cfa37a7b 2004-04-10 devnull joining adjacent points in the
535 cfa37a7b 2004-04-10 devnull array of
536 cfa37a7b 2004-04-10 devnull .B Points
538 cfa37a7b 2004-04-10 devnull which has
540 cfa37a7b 2004-04-10 devnull elements.
541 cfa37a7b 2004-04-10 devnull The ends of the polygon are specified as in
542 cfa37a7b 2004-04-10 devnull .IR line ;
543 cfa37a7b 2004-04-10 devnull interior lines are terminated with
544 cfa37a7b 2004-04-10 devnull .B Enddisc
545 cfa37a7b 2004-04-10 devnull to make smooth joins.
546 cfa37a7b 2004-04-10 devnull The source is aligned so
548 cfa37a7b 2004-04-10 devnull corresponds to
549 cfa37a7b 2004-04-10 devnull .IB p [0]\f1.
551 cfa37a7b 2004-04-10 devnull \f5fillpoly(\f2dst\fP, \f2p\fP, \f2np\fP, \f2wind\fP, \f2src\fP, \f2sp\fP)
552 cfa37a7b 2004-04-10 devnull .I Fillpoly
555 cfa37a7b 2004-04-10 devnull but fills in the resulting polygon rather than outlining it.
556 cfa37a7b 2004-04-10 devnull The source is aligned so
558 cfa37a7b 2004-04-10 devnull corresponds to
559 cfa37a7b 2004-04-10 devnull .IB p [0]\f1.
560 cfa37a7b 2004-04-10 devnull The winding rule parameter
562 cfa37a7b 2004-04-10 devnull resolves ambiguities about what to fill if the polygon is self-intersecting.
566 cfa37a7b 2004-04-10 devnull .BR ~0 ,
567 cfa37a7b 2004-04-10 devnull a pixel is inside the polygon if the polygon's winding number about the point
568 cfa37a7b 2004-04-10 devnull is non-zero.
573 cfa37a7b 2004-04-10 devnull a pixel is inside if the winding number is odd.
574 cfa37a7b 2004-04-10 devnull Complementary values (0 or ~1) cause outside pixels to be filled.
575 cfa37a7b 2004-04-10 devnull The meaning of other values is undefined.
576 cfa37a7b 2004-04-10 devnull The polygon is closed with a line if necessary.
578 cfa37a7b 2004-04-10 devnull \f5bezier(\f2dst\fP, \f2a\fP, \f2b\fP, \f2c\fP, \f2d\fP, \f2end0\fP, \f2end1\fP, \f2thick\fP, \f2src\fP, \f2sp\fP)
579 cfa37a7b 2004-04-10 devnull .I Bezier
580 cfa37a7b 2004-04-10 devnull draws the
581 cfa37a7b 2004-04-10 devnull cubic Bezier curve defined by
582 cfa37a7b 2004-04-10 devnull .B Points
588 cfa37a7b 2004-04-10 devnull The end styles are determined by
591 cfa37a7b 2004-04-10 devnull .IR end1 ;
592 cfa37a7b 2004-04-10 devnull the thickness of the curve is
593 cfa37a7b 2004-04-10 devnull .RI 1+2* thick .
594 cfa37a7b 2004-04-10 devnull The source is aligned so
598 cfa37a7b 2004-04-10 devnull corresponds to
601 cfa37a7b 2004-04-10 devnull .IR dst .
603 cfa37a7b 2004-04-10 devnull \f5bezspline(\f2dst\fP, \f2p\fP, \f2end0\fP, \f2end1\fP, \f2thick\fP, \f2src\fP, \f2sp\fP)
604 cfa37a7b 2004-04-10 devnull .I Bezspline
605 cfa37a7b 2004-04-10 devnull takes the same arguments as
607 cfa37a7b 2004-04-10 devnull but draws a quadratic B-spline (despite its name) rather than a polygon.
608 cfa37a7b 2004-04-10 devnull If the first and last points in
610 cfa37a7b 2004-04-10 devnull are equal, the spline has periodic end conditions.
612 cfa37a7b 2004-04-10 devnull \f5bezsplinepts(\f2pt\fP, \f2npt\fP, \f2pp\fP)
613 cfa37a7b 2004-04-10 devnull .I Bezsplinepts
614 cfa37a7b 2004-04-10 devnull returns in
616 cfa37a7b 2004-04-10 devnull a list of points making up the open polygon that
617 cfa37a7b 2004-04-10 devnull .I bezspline
618 cfa37a7b 2004-04-10 devnull would draw.
619 cfa37a7b 2004-04-10 devnull The caller is responsible for freeing
620 cfa37a7b 2004-04-10 devnull .IR *pp .
622 cfa37a7b 2004-04-10 devnull \f5fillbezier(\f2dst\fP, \f2a\fP, \f2b\fP, \f2c\fP, \f2d\fP, \f2wind\fP, \f2src\fP, \f2sp\fP)
623 cfa37a7b 2004-04-10 devnull .I Fillbezier
625 cfa37a7b 2004-04-10 devnull .I bezier
627 cfa37a7b 2004-04-10 devnull .I fillpoly
629 cfa37a7b 2004-04-10 devnull .IR poly .
631 cfa37a7b 2004-04-10 devnull \f5fillbezspline(\f2dst\fP, \f2p\fP, \f2wind\fP, \f2src\fP, \f2sp\fP)
632 cfa37a7b 2004-04-10 devnull .I Fillbezspline
634 cfa37a7b 2004-04-10 devnull .I fillpoly
635 cfa37a7b 2004-04-10 devnull but fills the quadratic B-spline rather than the polygon outlined by
637 cfa37a7b 2004-04-10 devnull The spline is closed with a line if necessary.
639 cfa37a7b 2004-04-10 devnull \f5ellipse(\f2dst\fP, \f2c\fP, \f2a\fP, \f2b\fP, \f2thick\fP, \f2src\fP, \f2sp\fP)
640 cfa37a7b 2004-04-10 devnull .I Ellipse
641 cfa37a7b 2004-04-10 devnull draws in
643 cfa37a7b 2004-04-10 devnull an ellipse centered on
645 cfa37a7b 2004-04-10 devnull with horizontal and vertical semiaxes
649 cfa37a7b 2004-04-10 devnull The source is aligned so
653 cfa37a7b 2004-04-10 devnull corresponds to
656 cfa37a7b 2004-04-10 devnull .IR dst .
657 cfa37a7b 2004-04-10 devnull The ellipse is drawn with thickness
658 cfa37a7b 2004-04-10 devnull .RI 1+2* thick .
660 cfa37a7b 2004-04-10 devnull \f5fillellipse(\f2dst\fP, \f2c\fP, \f2a\fP, \f2b\fP, \f2src\fP, \f2sp\fP)
661 cfa37a7b 2004-04-10 devnull .I Fillellipse
663 cfa37a7b 2004-04-10 devnull .I ellipse
664 cfa37a7b 2004-04-10 devnull but fills the ellipse rather than outlining it.
666 cfa37a7b 2004-04-10 devnull \f5arc(\f2dst\fP, \f2c\fP, \f2a\fP, \f2b\fP, \f2thick\fP, \f2src\fP, \f2sp\fP, \f2alpha\fP, \f2phi\fP)
669 cfa37a7b 2004-04-10 devnull .IR ellipse ,
670 cfa37a7b 2004-04-10 devnull but draws only that portion of the ellipse starting at angle
671 cfa37a7b 2004-04-10 devnull .I alpha
672 cfa37a7b 2004-04-10 devnull and extending through an angle of
673 cfa37a7b 2004-04-10 devnull .IR phi .
674 cfa37a7b 2004-04-10 devnull The angles are measured in degrees counterclockwise from the positive
678 cfa37a7b 2004-04-10 devnull \f5fillarc(\f2dst\fP, \f2c\fP, \f2a\fP, \f2b\fP, \f2src\fP, \f2sp\fP, \f2alpha\fP, \f2phi\fP)
679 cfa37a7b 2004-04-10 devnull .I Fillarc
681 cfa37a7b 2004-04-10 devnull .IR arc ,
682 cfa37a7b 2004-04-10 devnull but fills the sector with the source color.
684 cfa37a7b 2004-04-10 devnull \f5icossin(\f2deg\fP, \f2cosp\fP, \f2sinp\fP)
685 cfa37a7b 2004-04-10 devnull .I Icossin
686 cfa37a7b 2004-04-10 devnull stores in
687 cfa37a7b 2004-04-10 devnull .BI * cosp
689 cfa37a7b 2004-04-10 devnull .BI * sinp
690 cfa37a7b 2004-04-10 devnull scaled integers representing the cosine and sine of the angle
691 cfa37a7b 2004-04-10 devnull .IR deg ,
692 cfa37a7b 2004-04-10 devnull measured in integer degrees.
693 cfa37a7b 2004-04-10 devnull The values are scaled so cos(0) is 1024.
695 cfa37a7b 2004-04-10 devnull \f5icossin2(\f2x\fP, \f2y\fP, \f2cosp\fP, \f2sinp\fP)
696 cfa37a7b 2004-04-10 devnull .I Icossin2
697 cfa37a7b 2004-04-10 devnull is analogous to
698 cfa37a7b 2004-04-10 devnull .IR icossin,
699 cfa37a7b 2004-04-10 devnull with the angle represented not in degrees but implicitly by the point
700 cfa37a7b 2004-04-10 devnull .RI ( x , y ).
701 cfa37a7b 2004-04-10 devnull It is to
702 cfa37a7b 2004-04-10 devnull .I icossin
704 cfa37a7b 2004-04-10 devnull .B atan2
708 bf8a59fa 2004-04-11 devnull .IR sin (3)).
710 cfa37a7b 2004-04-10 devnull .BI border( dst\fP,\fP\ r\fP,\fP\ i\fP,\fP\ color\fP,\fP\ sp\fP)
711 cfa37a7b 2004-04-10 devnull .I Border
712 cfa37a7b 2004-04-10 devnull draws an outline of rectangle
714 cfa37a7b 2004-04-10 devnull in the specified
715 cfa37a7b 2004-04-10 devnull .IR color .
716 cfa37a7b 2004-04-10 devnull The outline has width
718 cfa37a7b 2004-04-10 devnull if positive, the border goes inside the rectangle; negative, outside.
719 cfa37a7b 2004-04-10 devnull The source is aligned so
721 cfa37a7b 2004-04-10 devnull corresponds to
722 cfa37a7b 2004-04-10 devnull .IB r .min .
724 cfa37a7b 2004-04-10 devnull .BI string( dst\fP,\fP\ p\fP,\fP\ src\fP,\fP\ sp\fP,\fP\ font\fP,\fP\ s )
725 cfa37a7b 2004-04-10 devnull .I String
726 cfa37a7b 2004-04-10 devnull draws in
728 cfa37a7b 2004-04-10 devnull characters specified by the string
731 cfa37a7b 2004-04-10 devnull .IR font ;
732 cfa37a7b 2004-04-10 devnull it is equivalent to a series of calls to
733 cfa37a7b 2004-04-10 devnull .I gendraw
734 cfa37a7b 2004-04-10 devnull using source
736 cfa37a7b 2004-04-10 devnull and masks determined by the character shapes.
737 cfa37a7b 2004-04-10 devnull The text is positioned with the left of the first character at
738 cfa37a7b 2004-04-10 devnull .IB p .x
739 cfa37a7b 2004-04-10 devnull and the top of the line of text at
740 cfa37a7b 2004-04-10 devnull .IB p .y\f1.
741 cfa37a7b 2004-04-10 devnull The source is positioned so
745 cfa37a7b 2004-04-10 devnull corresponds to
748 cfa37a7b 2004-04-10 devnull .IR dst .
749 cfa37a7b 2004-04-10 devnull .I String
750 cfa37a7b 2004-04-10 devnull returns a
751 cfa37a7b 2004-04-10 devnull .B Point
752 cfa37a7b 2004-04-10 devnull that is the position of the next character that would be drawn if the string were longer.
754 cfa37a7b 2004-04-10 devnull For characters with undefined
755 cfa37a7b 2004-04-10 devnull or zero-width images in the font, the character at font position 0 (NUL) is drawn.
757 cfa37a7b 2004-04-10 devnull The other string routines are variants of this basic form, and
758 cfa37a7b 2004-04-10 devnull have names that encode their variant behavior.
759 cfa37a7b 2004-04-10 devnull Routines whose names contain
761 cfa37a7b 2004-04-10 devnull accept a string of Runes rather than
762 cfa37a7b 2004-04-10 devnull .SM UTF\c
763 cfa37a7b 2004-04-10 devnull -encoded bytes.
764 cfa37a7b 2004-04-10 devnull Routines ending in
766 cfa37a7b 2004-04-10 devnull accept an argument,
768 cfa37a7b 2004-04-10 devnull that defines the number of characters to draw rather than accepting a NUL-terminated
770 cfa37a7b 2004-04-10 devnull Routines containing
772 cfa37a7b 2004-04-10 devnull draw the background behind the characters in the specified color
773 cfa37a7b 2004-04-10 devnull .RI ( bg )
775 cfa37a7b 2004-04-10 devnull alignment
776 cfa37a7b 2004-04-10 devnull .RI ( bgp );
777 cfa37a7b 2004-04-10 devnull normally the text is drawn leaving the background intact.
779 cfa37a7b 2004-04-10 devnull The routine
780 cfa37a7b 2004-04-10 devnull .I _string
781 cfa37a7b 2004-04-10 devnull captures all this behavior into a single operator. Whether it draws a
784 cfa37a7b 2004-04-10 devnull or Rune string depends on whether
788 cfa37a7b 2004-04-10 devnull is null (the string length is always determined by
789 cfa37a7b 2004-04-10 devnull .IR len ).
792 cfa37a7b 2004-04-10 devnull is non-null, it is used as a background color.
794 cfa37a7b 2004-04-10 devnull .I clipr
795 cfa37a7b 2004-04-10 devnull argument allows further management of clipping when drawing the string;
796 cfa37a7b 2004-04-10 devnull it is intersected with the usual clipping rectangles to further limit the extent of the text.
798 cfa37a7b 2004-04-10 devnull .BI drawsetdebug( on )
799 cfa37a7b 2004-04-10 devnull Turns on or off debugging output (usually
800 cfa37a7b 2004-04-10 devnull to a serial line) according to whether
802 cfa37a7b 2004-04-10 devnull is non-zero.
803 cfa37a7b 2004-04-10 devnull .SH SOURCE
804 b5fdffee 2004-04-19 devnull .B /usr/local/plan9/src/libdraw
805 cfa37a7b 2004-04-10 devnull .SH SEE ALSO
806 bf8a59fa 2004-04-11 devnull .IR graphics (3),
807 bf8a59fa 2004-04-11 devnull .IR stringsize (3),
808 cfa37a7b 2004-04-10 devnull .IR color (6),
809 cfa37a7b 2004-04-10 devnull .IR utf (6),
810 bf8a59fa 2004-04-11 devnull .IR addpt (3)
812 cfa37a7b 2004-04-10 devnull T. Porter, T. Duff.
813 cfa37a7b 2004-04-10 devnull ``Compositing Digital Images'',
814 cfa37a7b 2004-04-10 devnull .I "Computer Graphics
815 cfa37a7b 2004-04-10 devnull (Proc. SIGGRAPH), 18:3, pp. 253-259, 1984.
816 cfa37a7b 2004-04-10 devnull .SH DIAGNOSTICS
817 cfa37a7b 2004-04-10 devnull These routines call the graphics error function on fatal errors.
818 cfa37a7b 2004-04-10 devnull .SH BUGS
819 cfa37a7b 2004-04-10 devnull Anti-aliased characters can be drawn by defining a font
820 cfa37a7b 2004-04-10 devnull with multiple bits per pixel, but there are
821 cfa37a7b 2004-04-10 devnull no anti-aliasing geometric primitives.