/usr/share/doc/libsx-dev/html/drawing.html is in libsx-dev 2.05-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 | <title> Drawing Functions </title>
<ul>
<li> <a href="#drawing"> Drawing Overview </a>
<li> <a href="drawing.html#fCD"> ClearDisplay </a>
<li> <a href="drawing.html#fDP"> DrawPixel </a>
<li> <a href="drawing.html#fDL"> DrawLine </a>
<li> <a href="drawing.html#fDPl"> DrawPolyline </a>
<li> <a href="drawing.html#fDFP"> DrawFilledPolygon </a>
<li> <a href="drawing.html#fDB"> DrawBox </a>
<li> <a href="drawing.html#fDFB"> DrawFilledBox </a>
<li> <a href="drawing.html#fDT"> DrawText </a>
<li> <a href="drawing.html#fDA"> DrawArc </a>
<li> <a href="drawing.html#fDFA"> DrawFilledArc </a>
<li> <a href="drawing.html#fDI"> DrawImage </a>
<li> <a href="drawing.html#fGDAS"> GetDrawAreaSize </a>
<li> <a href="drawing.html#fGI"> GetImage </a>
<li> <a href="drawing.html#fGP"> GetPixel </a>
<li> <a href="drawing.html#fSDA"> ScrollDrawArea </a>
<li> <a href="drawing.html#fSC"> SetColor </a>
<li> <a href="drawing.html#fSDA2"> SetDrawArea </a>
<li> <a href="drawing.html#fSDM"> SetDrawMode </a>
<li> <a href="drawing.html#fSLW"> SetLineWidth </a>
</ul>
<hr>
<p>
<h2> <a name="drawing"> Drawing Overview </a> </h2>
<p>
This file contains documentation about the routines that let you draw
in a drawing area.
<p>
The documentation for these functions is quite brief because they are
not all that complicated (how much can one really say about
<a href="drawing.html#fDL"> DrawLine() </a>
).
<p>
Keep in mind that for all the drawing functions, the top-left corner
of a drawing area is considered to be 0,0.
<p>
Also, all primitives are drawn in the current foreground color (set
either by
<a href="drawing.html#fSC"> SetColor() </a>
or
<a href="misc.html#fSFC"> SetFgColor() </a>.
Text is drawn with the current
foreground color and the background color. Line, arc, and box
primitives are drawn with the current line width (as set by
<a href="drawing.html#fSLW"> SetLineWidth() </a>
), and all primitives are drawn in the current draw mode
(set by
<a href="drawing.html#fSDM"> SetDrawMode() </a>
).
<hr>
<p>
<a name="fSDA2"> <b>
void SetDrawArea(Widget w);
</b> </a>
<p>
This sets the current drawing area to be that named by the Widget w.
If `w' is not a drawing area widget, nothing happens.
<p>
You need to call this function when you want to switch between
multiple drawing areas.
<p>
If you only have one drawing area you do not need to worry about this
function at all.
<p>
Any callbacks for a drawing area already have the current drawing area
set to be the one where the event happened (so it is not necessary to
call this function in a callback for a drawing area).
<hr>
<p>
<a name="fSC"> <b>
void SetColor(int color);
</b> </a>
<p>
This sets the foreground color to draw with in the current drawing
area (each drawing area has its own foreground color). The argument
"color" should be a valid color obtained with one of the color
functions (such as GetNamedColor() or GetRGBColor(), etc).
<p>
To some extent this function duplicates the SetFgColor() function, but
exists because it is faster than SetFgColor().
<p>
SEE ALSO :
<a href="misc.html#fSBC"> SetBgColor() </a>,
<a href="misc.html#fGFC"> GetFgColor() </a>,
<a href="misc.html#fSFC"> SetFgColor() </a>,
<a href="color.html#fGSC"> GetStandardColors() </a>
<hr>
<p>
<a name="fSLW"> <b>
void SetLineWidth(int width);
</b> </a>
<p>
This functions sets the width of lines drawn in the current drawing
area. Each drawing area has its own line width.
<p>
A width of zero is valid and tells the X server to draw lines as fast
as it possibly can, possibly being a little inaccurate. Larger
numbers of course draw wider lines.
<p>
SEE ALSO :
<a href="drawing.html#fSDM"> SetDrawMode() </a>,
<a href="font.html#fSWF"> SetWidgetFont() </a>,
<a href="misc.html#fSFC"> SetFgColor() </a>,
<a href="misc.html#fSBC"> SetBgColor() </a>
<hr>
<p>
<a name="fSDM"> <b>
void SetDrawMode(int mode);
</b> </a>
<p>
This function sets the drawing mode for the current drawing area. A
drawing mode is one of:
<p>
GXcopy, GXxor, GXinvert, GXor, GXclear, GXand, GXandReverse,
GXnoop, GXnor, GXequiv, GXinvert, GXorReverse, GXcopyInverted,
GXorInverted, GXnand, and GXset
<p>
Most of these are stupid/useless modes defined by X (so ignore them).
<p>
The primary mode is GXcopy (the default mode). This causes all
primitives to draw in the foreground color, overwriting any pixels
already drawn.
<p>
Libsx also defines a special mode: SANE_XOR. The SANE_XOR mode will
actually draw primitives in a true XOR mode so that you can draw
things like rubber-band boxes that the user stretches with the mouse.
You must use SANE_XOR if you want true XOR'ed primitives, GXxor will
definitely NOT work as you expect.
<p>
When you are done using SANE_XOR, you would normally call
<a href="drawing.html#fSDM"> SetDrawMode() </a>
with an argument of GXcopy to restore normal drawing.
<p>
SEE ALSO :
<a href="drawing.html#fSLW"> SetLineWidth() </a>,
<a href="font.html#fSWF"> SetWidgetFont() </a>,
<a href="misc.html#fSFC"> SetFgColor() </a>,
<a href="misc.html#fSBC"> SetBgColor() </a>
<hr>
<p>
<a name="fGDAS"> <b>
void GetDrawAreaSize(int *w, int *h);
</b> </a>
<p>
This is a convience function that returns the size of the current
drawing area. The window dimension are returned in the two variables.
It is important to note that "w" and "h" are POINTERS to integers, not
just regular integers.
<hr>
<p>
<a name="fCD"> <b>
void ClearDrawArea(void);
</b> </a>
<p>
This function completely clears the current drawing area and sets it
to the current background color (which may not be white).
<p>
Generally, when your redisplay callback is called, this is the first
thing want to do.
<p>
SEE ALSO :
<a href="drawing.html#fSDA2"> SetDrawArea() </a>,
<a href="misc.html#fGBC"> GetBgColor() </a>,
<a href="misc.html#fSBC"> SetBgColor() </a>
<hr>
<p>
<a name="fDP"> <b>
void DrawPixel(int x1, int y1);
</b> </a>
<p>
This function draws a point in the current foreground color at the
location x1, y1 in your current drawing area. The top left corner of
the drawing area is considered 0,0.
<p>
SEE ALSO :
<a href="drawing.html#fGP"> GetPixel() </a>,
<a href="drawing.html#fSC"> SetColor() </a>,
<a href="drawing.html#fSDA2"> SetDrawArea() </a>,
<a href="misc.html#fSBC"> SetBgColor() </a>,
<a href="misc.html#fSFC"> SetFgColor() </a>
<hr>
<p>
<a name="fGP"> <b>
int GetPixel(int x1, int y1);
</b> </a>
<p>
This function retrieves the pixel value at the location x1, y1 in the
current drawing area. The top left corner of the drawing area is
considered 0,0.
<p>
The pixel value returned to you will be between 0 and 255 (inclusive).
The value you get back should be treated as an index to a colormap.
To find out what actual color is displayed at that location, you
need to look up the color in the colormap (which you should be
maintaining as there is no way to get it after you've set it).
<p>
NOTE: This function is <b>NOT</b> very high performance. It has to call
<a href="drawing.html#fGI"> GetImage() </a>
to do the bulk of the work. This is unfortunate,
but unavoidable because X does not provide an easy way to read
individual pixels.
<p>
SEE ALSO :
<a href="drawing.html#fGI"> GetImage() </a>,
<a href="drawing.html#fSC"> SetColor() </a>,
<a href="drawing.html#fSDA2"> SetDrawArea() </a>,
<a href="misc.html#fSBC"> SetBgColor() </a>,
<a href="misc.html#fSFC"> SetFgColor() </a>
<hr>
<p>
<a name="fDL"> <b>
void DrawLine(int x1, int y1, int x2, int y2);
</b> </a>
<p>
This function draws a line from x1,y1 to x2,y2 in the current
foreground color in the current drawing area. The top left corner of
the drawing area is considered 0,0.
<p>
SEE ALSO :
<a href="drawing.html#fDPl"> DrawPolyline() </a>,
<a href="drawing.html#fDP"> DrawPixel() </a>,
<a href="drawing.html#fSC"> SetColor() </a>,
<a href="misc.html#fSBC"> SetBgColor() </a>,
<a href="misc.html#fSFC"> SetFgColor() </a>,
<a href="drawing.html#fSDA2"> SetDrawArea() </a>,
<hr>
<p>
<a name="fDPl"> <b>
void DrawPolyline(XPoint *points, int n);
</b> </a>
<p>
This function accepts an array of points and draws them as a connected
polyline on the display. The line is drawn in the current foreground
color in the current drawing area. The top left corner of the drawing
area is considered 0,0.
<p>
The `points' argument is an array of XPoint structures which are as
follows:
<p>
<pre>
typedef struct XPoint
{
short x,y;
}XPoint;
</pre>
<p>
You do not need to define this structure yourself. It is defined for
you already, it is just reprinted here so you can see what it is.
<p>
You should have an array of these structures with each entry holding a
vertex of the polyline.
<p>
SEE ALSO :
<a href="drawing.html#fDL"> DrawLine() </a>,
<a href="drawing.html#fDFP"> DrawFilledPolygon() </a>,
<a href="drawing.html#fSC"> SetColor() </a>,
<a href="drawing.html#fSDA2"> SetDrawArea() </a>,
<a href="misc.html#fSBC"> SetBgColor() </a>,
<a href="misc.html#fSFC"> SetFgColor() </a>
<hr>
<p>
<a name="fDFP"> <b>
void DrawFilledPolygon (XPoint *points, int n);
</b> </a>
<p>
This function takes an array of points and draws them as a filled
polygon on the display. The polygon is filled with the current
foreground color and is drawn in the current drawing area. The top
left corner of the drawing area is considered 0,0.
<p>
The `points' argument is an array of XPoint structures which are as
follows:
<p>
<pre>
typedef struct XPoint
{
short x,y;
}XPoint;
</pre>
<p>
You do not need to define this structure yourself. It is defined for
you already, it is just reprinted here so you can see what it is.
<p>
You should have an array of these structures with each entry holding a
vertex of the polygon to be filled.
<p>
SEE ALSO :
<a href="drawing.html#fDPl"> DrawPolyline() </a>,
<a href="drawing.html#fDB"> DrawBox() </a>,
<a href="drawing.html#fSC"> SetColor() </a>,
<a href="drawing.html#fSDA2"> SetDrawArea() </a>,
<a href="misc.html#fSBC"> SetBgColor() </a>,
<a href="misc.html#fSFC"> SetFgColor() </a>
<hr>
<p>
<a name="fDB"> <b>
void DrawBox(int x, int y, int width, int height);
</b> </a>
<p>
This function draws a rectangular box starting at x,y with a width and
height as specified. If you make the call: DrawBox(50,50, 75,75), you
will get a box that starts at position 50,50 and goes for 75 pixels in
the X and Y directions (i.e the other extreme of the box would be at
125,125). The box is drawn in the current foreground color in the
current drawing area. The top left corner of the drawing area is
considered 0,0.
<p>
If the width and height are negative, the box is still drawn properly.
<p>
SEE ALSO :
<a href="drawing.html#fDFB"> DrawFilledBox() </a>,
<a href="drawing.html#fDPl"> DrawPolyline() </a>,
<a href="drawing.html#fSC"> SetColor() </a>,
<a href="drawing.html#fSDA2"> SetDrawArea() </a>,
<a href="misc.html#fSBC"> SetBgColor() </a>,
<a href="misc.html#fSFC"> SetFgColor() </a>
<hr>
<p>
<a name="fDFB"> <b>
void DrawFilledBox(int x, int y, int width, int height);
</b> </a>
<p>
This function draws a filled rectangular box starting at x,y with a
width and height as specified. If you make the call:
DrawFilledBox(50,50, 75,75), you will get a filled box that starts at
position 50,50 and goes for 75 pixels in the X and Y directions (i.e
the other extreme of the box would be at 125,125). The box is filled
with the current foreground color in the current drawing area. The top
left corner of the drawing area is considered 0,0.
<p>
If the width and height are negative, the box is still drawn properly.
<p>
SEE ALSO :
<a href="drawing.html#fDB"> DrawBox() </a>,
<a href="drawing.html#fDFP"> DrawFilledPolygon() </a>,
<a href="drawing.html#fSC"> SetColor() </a>,
<a href="drawing.html#fSDA2"> SetDrawArea() </a>,
<a href="misc.html#fSBC"> SetBgColor() </a>,
<a href="misc.html#fSFC"> SetFgColor() </a>
<hr>
<p>
<a name="fDT"> <b>
void DrawText(char *string, int x, int y);
</b> </a>
<p>
This function prints the text string "string" starting at x,y. The
text is drawn in the current foreground color. The background of the
text is filled with current background color of the drawing area
widget. The top left of the drawing area is 0,0. The X,Y position
you specify is the bottom left corner of where the text is drawn.
<p>
SEE ALSO :
<a href="font.html#fGF"> GetFont() </a>,
<a href="font.html#fFH"> FontHeight() </a>,
<a href="font.html#fTW"> TextWidth() </a>,
<a href="drawing.html#fSC"> SetColor() </a>,
<a href="drawing.html#fSDA2"> SetDrawArea() </a>,
<a href="font.html#fSWF"> SetWidgetFont() </a>,
<a href="misc.html#fGBC"> GetBgColor() </a>,
<a href="misc.html#fSFC"> SetFgColor() </a>,
<a href="misc.html#fSBC"> SetBgColor() </a>
<hr>
<p>
<a name="fDA"> <b>
void DrawArc(int x, int y, int width, int height, int angle1, int angle2);
</b> </a>
<p>
This function draws an arc/ellipse from the location x,y that is
bounded by the box defined by the x,y, width and height. That is, the
arc/ellipse will always be contained in the box defined by the x,y
position and the width and height arguments. The X,Y arguments are
not the center of the arc/circle.
<p>
The arc begines at angle1 degrees and continues for angle2 degrees
around the circle. The arc is drawn in the current foreground color
in the current drawing area. The top left corner of the drawing area
is considered 0,0.
<p>
If you want a circle, you would specify angle1 as 0, and angle2 as
360.
<p>
If the width and height are negative, the arc is still drawn properly.
<p>
SEE ALSO :
<a href="drawing.html#fDPl"> DrawPolyline() </a>,
<a href="drawing.html#fSC"> SetColor() </a>,
<a href="drawing.html#fSDA2"> SetDrawArea() </a>,
<a href="misc.html#fSBC"> SetBgColor() </a>,
<a href="misc.html#fSFC"> SetFgColor() </a>
<hr>
<p>
<a name="fDFA"> <b>
void DrawFilledArc(int x, int y, int width, int height,
int angle1, int angle2);
</b> </a>
<p>
This function draws a filled arc/ellipse from the location x,y that is
bounded by the box defined by the x,y, width and height. That is, the
arc/ellipse will always be contained in the box defined by the x,y
position and the width and height arguments. The X,Y arguments are
not the center of the arc/circle.
<p>
The arc begines at angle1 degrees and continues for angle2 degrees
around the circle. The arc is filled with the current foreground
color in the current drawing area. The top left corner of the drawing
area is considered 0,0.
<p>
If you want a circle, you would specify angle1 as 0, and angle2 as
360.
<p>
If the width and height are negative, the arc is still drawn properly.
<p>
SEE ALSO :
<a href="drawing.html#fDA"> DrawArc() </a>,
<a href="drawing.html#fSC"> SetColor() </a>,
<a href="drawing.html#fSDA2"> SetDrawArea() </a>,
<a href="misc.html#fSBC"> SetBgColor() </a>,
<a href="misc.html#fSFC"> SetFgColor() </a>
<hr>
<p>
<a name="fDI"> <b>
void DrawImage(char *data, int x, int y, int width, int height);
</b> </a>
<p>
This function draws a bitmap image that has a width and height as
specified by the arguments. The image is drawn at location x,y in the
current drawing area. The "data" argument should point to at least
width*height bytes of data.
<p>
Each byte of the data is interpreted as a color value to draw the
corresponding pixel with.
<p>
Normally you would use this function when you have taken over the
colormap with GetAllColors() (so that you can be guaranteed certain
colors are in a given range). If you have not taken over the
colormap, you need to make sure that the bytes in the image data
contain valid values that you've allocated with the color allocation
functions (
<a href="color.html#fGNC"> GetNamedColor() </a>,
<a href="color.html#fGRGBC"> GetRGBColor() </a> or
<a href="color.html#fGPC"> GetPrivateColor() </a>
).
<p>
The top left corner of the drawing area is considered 0,0.
<p>
SEE ALSO :
<a href="drawing.html#fGI"> GetImage() </a>,
<a href="drawing.html#fSC"> SetColor() </a>,
<a href="drawing.html#fSDA2"> SetDrawArea() </a>,
<a href="color.html#fGAC"> GetAllColors() </a>
<hr>
<p>
<a name="fDB"><b>
void DrawBitmap(char *data, int x, int y, int width, int height);
</b></a>
<p>
This function draws a bitmap that has a width and height as specified
by the arguments. The bitmap is drawn at location x,y in the current
drawing area. The "data" argument should point to at least
width*height/8 bytes of data.
<p>
The difference between this function and DrawImage() is that the data
is an actual bitmap with 1 bit per pixel (versus 1 byte per pixel for
an Image).
<p>
Each byte of the data is interpreted as 8 pixels. If a bit in the
byte is on, the corresponding pixel is drawn in the foreground color.
If the bit is off, the corresponding color is drawn in the background
color.
<p>
Normally you would use this function on a monochrome display (though
it will still work on a color screen).
<p>
The top left corner of the drawing area is considered 0,0.
<p>
SEE ALSO :
<a href="drawing.html#fDI"> DrawImage() </a>,
<a href="drawing.html#fGI"> GetImage() </a>,
<a href="drawing.html#fSC"> SetColor() </a>,
<a href="drawing.html#fSDA2"> SetDrawArea() </a>
<hr>
<p>
<a name="fGI"> <b>
void GetImage(char *data, int x, int y, int width, int height);
</b> </a>
<p>
This function retrieves a bitmap image from your drawing area that
has a width and height as specified by the arguments. The image is
taken from the starting location x,y in the current drawing area. The
"data" argument should point to at least width*height bytes of data.
<p>
The area of memory pointed to by data will be filled with the 8-bit
pixel values of the current drawing area. Note that the pixel values
are not the actual color values. If you want the actual color values,
you'll need to know what the current colormap is (which you would know
if you've set the colormap) and then use the pixel values to index the
colormap.
<p>
The memory pointed to by data is packed with width*height bytes, with
no extra padding or filling. That is, the first width bytes
correspond to line 0, the next width bytes correspond to line 1 of the
image, etc.
<p>
It is important to keep in mind that if you plan to save the pixel
data in an image file, you need to also keep track of the colormap so
that you can save that as well. By themselves, the pixel values don't
correspond to any particular color.
<p>
A serious drawback of this function arises from the way X operates.
If the drawing area from which you are "getting" the image is obscured
by another window, that part of the bitmap will be empty. The only
way around this is to make sure that your window is in front of all
the others before you call GetImage(). This is a serious limitation,
but it's the way X operates.
<p>
The top left corner of the drawing area is considered 0,0. If you specify
a starting x,y and width,height dimensions that are larger than your
drawing area, you will get a BadMatch error and X will terminate your
program (so be careful).
<p>
SEE ALSO :
<a href="drawing.html#fDI"> DrawImage() </a>,
<a href="drawing.html#fSC"> SetColor() </a>,
<a href="drawing.html#fSDA2"> SetDrawArea() </a>,
<a href="color.html#fGAC"> GetAllColors() </a>
<hr>
<p>
<a name="fSDA"> <b>
void ScrollDrawArea(int dx, int dy, int x1,int y1, int x2, int y2);
</b> </a>
<p>
This function scrolls the box defined by (x1,y1) (x2,y2) by the
amounts dx and dy in the X and Y directions respectively. This means
that the box whose upper left corner is (x1,y1) and whose lower right
corner is (x2,y2) are scrolled by dx and dy pixels in X and Y.
<p>
A positive value for dx causes the drawing area to scroll its contents
to the left. That is, whatever is at the left edge gets pushed off
and the dx columns of pixels on the right hand side are cleared to the
background color. A negative value has the opposite effect.
<p>
A positive value for dy corresponds to scrolling upwards. That is,
whatever is at the top of the drawing area is pushed up by dy pixels
and the bottom dy rows of pixels are cleared to the background color.
A negative value has the opposite effect.
<p>
This function is useful for scrolling the drawing area to draw new
information (such as a text editor might do to scroll text up or
down).
<p>
The new area exposed by the scroll is filled with the current
background color of the drawing area.
<p>
SEE ALSO :
<a href="font.html#fSWF"> SetWidgetFont() </a>,
<a href="drawing.html#fSC"> SetColor() </a>
|