Chapter 6. Drawing Graphics and Text
This chapter describes the routines used to draw lines, geometrical figures, and text. It also discusses the use of the pixmaps, images, and regions. You should be familiar with the use of the graphics context before attempting to use these routines.
Drawing with computers is a little like drawing by hand. Holding the pencil is not hard, but getting anything recognizable to appear on the page is a different matter. Similarly, drawing with X is quite easy, but designing what to draw and where can be a challenge. We can do little more in this chapter than tell you how to hold the pencil; the rest is up to you.
This chapter describes various techniques that have to do with drawing: drawing lines, rectangles, and arcs; using bitmaps; placing and drawing text; using regions; creating and using cursors; and using images.
The draw_text and
draw_graphics routines called in the
basicwin program in Chapter 3, are used as examples in this chapter.
Also described here are various versions of the
draw_box routine, which is called in the simple window
manager winman described in Chapter 16.
Note that, before you draw anything, you must set up a graphics
context to specify, at minimum, the foreground and background pixel values
for drawing and the font if you are drawing text. For monochrome
applications, you should set these values using the
BlackPixel() and WhitePixel() macros
described in Chapter 3. For color applications, you should use one of the color allocation ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access