1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3 "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
4 <chapter id='Graphics_Context_Functions'>
5 <title>Graphics Context Functions</title>
8 A number of resources are used when performing graphics operations in X. Most information
9 about performing graphics (for example, foreground color, background color, line style, and so
10 on) is stored in resources called graphics contexts (GCs). Most graphics operations (see chapter
11 8) take a GC as an argument. Although in theory the X protocol permits sharing of GCs between
12 applications, it is expected that applications will use their own GCs when performing operations.
13 Sharing of GCs is highly discouraged because the library may cache GC state.
16 Graphics operations can be performed to either windows or pixmaps, which collectively are
17 called drawables. Each drawable exists on a single screen. A GC is created for a specific screen
18 and drawable depth and can only be used with drawables of matching screen and depth.
21 This chapter discusses how to:
24 <listitem><para>Manipulate graphics context/state</para></listitem>
25 <listitem><para>Use graphics context convenience functions</para></listitem>
28 <sect1 id='Manipulating_Graphics_ContextState'>
29 <title>Manipulating Graphics Context/State</title>
31 <!-- (SN Manipulating Graphics Context/State -->
35 Most attributes of graphics operations are stored in GCs.
36 These include line width, line style, plane mask, foreground, background,
37 tile, stipple, clipping region, end style, join style, and so on.
38 Graphics operations (for example, drawing lines) use these values
39 to determine the actual drawing operation.
40 Extensions to X may add additional components to GCs.
41 The contents of a GC are private to Xlib.
45 Xlib implements a write-back cache for all elements of a GC that are not
46 resource IDs to allow Xlib to implement the transparent coalescing of changes
50 <xref linkend='XSetForeground' xrefstyle='select: title'/>
51 of a GC followed by a call to
52 <xref linkend='XSetLineAttributes' xrefstyle='select: title'/>
53 results in only a single-change GC protocol request to the server.
54 GCs are neither expected nor encouraged to be shared between client
55 applications, so this write-back caching should present no problems.
56 Applications cannot share GCs without external synchronization.
58 sharing GCs between applications is highly discouraged.
62 To set an attribute of a GC,
63 set the appropriate member of the
64 <structname>XGCValues</structname>
65 structure and OR in the corresponding value bitmask in your subsequent calls to
66 <xref linkend='XCreateGC' xrefstyle='select: title'/>.
67 The symbols for the value mask bits and the
68 <structname>XGCValues</structname>
74 <literallayout class="monospaced">
75 /* GC attribute value mask bits */
77 #define GCFunction (1L<<0)
78 #define GCPlaneMask (1L<<1)
79 #define GCForeground (1L<<2)
80 #define GCBackground (1L<<3)
81 #define GCLineWidth (1L<<4)
82 #define GCLineStyle (1L<<5)
83 #define GCCapStyle (1L<<6)
84 #define GCJoinStyle (1L<<7)
85 #define GCFillStyle (1L<<8)
86 #define GCFillRule (1L<<9)
87 #define GCTile (1L<<10)
88 #define GCStipple (1L<<11)
89 #define GCTileStipXOrigin (1L<<12)
90 #define GCTileStipYOrigin (1L<<13)
91 #define GCFont (1L<<14)
92 #define GCSubwindowMode (1L<<15)
93 #define GCGraphicsExposures (1L<<16)
94 #define GCClipXOrigin (1L<<17)
95 #define GCClipYOrigin (1L<<18)
96 #define GCClipMask (1L<<19)
97 #define GCDashOffset (1L<<20)
98 #define GCDashList (1L<<21)
99 #define GCArcMode (1L<<22)
102 <literallayout class="monospaced">
108 int function; /* logical operation */
109 unsigned long plane_mask; /* plane mask */
110 unsigned long foreground; /* foreground pixel */
111 unsigned long background; /* background pixel */
112 int line_width; /* line width (in pixels) */
113 int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */
114 int cap_style; /* CapNotLast, CapButt, CapRound, CapProjecting */
115 int join_style; /* JoinMiter, JoinRound, JoinBevel */
116 int fill_style; /* FillSolid, FillTiled, FillStippled FillOpaqueStippled*/
117 int fill_rule; /* EvenOddRule, WindingRule */
118 int arc_mode; /* ArcChord, ArcPieSlice */
119 Pixmap tile; /* tile pixmap for tiling operations */
120 Pixmap stipple; /* stipple 1 plane pixmap for stippling */
121 int ts_x_origin; /* offset for tile or stipple operations */
123 Font font; /* default text font for text operations */
124 int subwindow_mode; /* ClipByChildren, IncludeInferiors */
125 Bool graphics_exposures; /* boolean, should exposures be generated */
126 int clip_x_origin; /* origin for clipping */
128 Pixmap clip_mask; /* bitmap clipping; other calls for rects */
129 int dash_offset; /* patterned/dashed line information */
137 The default GC values are:
139 <informaltable frame='topbot'>
140 <?dbfo keep-together="auto" ?>
141 <tgroup cols='2' align='left' colsep='0' rowsep='0'>
142 <colspec colname='c1' colwidth='1.0*'/>
143 <colspec colname='c2' colwidth='1.0*'/>
146 <entry>Component</entry>
147 <entry>Default</entry>
152 <entry>function</entry>
153 <entry><symbol>GXcopy</symbol></entry>
156 <entry>plane_mask</entry>
157 <entry>All ones</entry>
160 <entry>foreground</entry>
164 <entry>background</entry>
168 <entry>line_width</entry>
172 <entry>line_style</entry>
173 <entry><symbol>LineSolid</symbol></entry>
176 <entry>cap_style</entry>
177 <entry><symbol>CapButt</symbol></entry>
180 <entry>join_style</entry>
181 <entry><symbol>JoinMiter</symbol></entry>
184 <entry>fill_style</entry>
185 <entry><symbol>FillSolid</symbol></entry>
188 <entry>fill_rule</entry>
189 <entry><symbol>EvenOddRule</symbol></entry>
192 <entry>arc_mode</entry>
193 <entry><symbol>ArcPieSlice</symbol></entry>
198 <para>Pixmap of unspecified size filled with foreground pixel</para>
199 <para>(that is, client specified pixel if any, else 0)</para>
200 <para>(subsequent changes to foreground do not affect this pixmap)</para>
204 <entry>stipple</entry>
205 <entry>Pixmap of unspecified size filled with ones</entry>
208 <entry>ts_x_origin</entry>
212 <entry>ts_y_origin</entry>
217 <entry><implementation dependent></entry>
220 <entry>subwindow_mode</entry>
221 <entry><symbol>ClipByChildren</symbol></entry>
224 <entry>graphics_exposures</entry>
225 <entry><symbol>True</symbol></entry>
228 <entry>clip_x_origin</entry>
232 <entry>clip_y_origin</entry>
236 <entry>clip_mask</entry>
237 <entry><symbol>None</symbol></entry>
240 <entry>dash_offset</entry>
244 <entry>dashes</entry>
245 <entry>4 (that is, the list [4, 4])</entry>
253 Note that foreground and background are not set to any values likely
254 to be useful in a window.
259 <indexterm significance="preferred"><primary>Display Functions</primary></indexterm>
260 <indexterm significance="preferred"><primary>Source</primary></indexterm>
261 <indexterm significance="preferred"><primary>Destination</primary></indexterm>
262 The function attributes of a GC are used when you update a section of
263 a drawable (the destination) with bits from somewhere else (the source).
264 The function in a GC defines how the new destination bits are to be
265 computed from the source bits and the old destination bits.
266 <symbol>GXcopy</symbol>
267 is typically the most useful because it will work on a color display,
268 but special applications may use other functions,
269 particularly in concert with particular planes of a color display.
270 The 16 GC functions, defined in
271 <filename class="headerfile"><X11/X.h></filename>,
272 <indexterm type="file"><primary><filename class="headerfile">X11/X.h</filename></primary></indexterm>
273 <indexterm><primary>Files</primary><secondary><filename class="headerfile"><X11/X.h></filename></secondary></indexterm>
274 <indexterm><primary>Headers</primary><secondary><filename class="headerfile"><X11/X.h></filename></secondary></indexterm>
277 <!-- .\" are listed in Table 5-1 along with the -->
278 <!-- .\"the associated hexadecimal code -->
279 <!-- .\" and operation. -->
281 <!-- .\"Display Functions -->
282 <informaltable frame='topbot'>
283 <?dbfo keep-together="auto" ?>
284 <tgroup cols='3' align='left' colsep='0' rowsep='0'>
285 <colspec colname='c1' colwidth='1.0*'/>
286 <colspec colname='c2' colwidth='1.0*'/>
287 <colspec colname='c3' colwidth='1.0*'/>
290 <entry>Function Name</entry>
292 <entry>Operation</entry>
297 <entry><symbol>GXclear</symbol></entry>
302 <entry><symbol>GXand</symbol></entry>
304 <entry>src AND dst</entry>
307 <entry><symbol>GXandReverse</symbol></entry>
309 <entry>src AND NOT dst</entry>
312 <entry><symbol>GXcopy</symbol></entry>
317 <entry><symbol>GXandInverted</symbol></entry>
319 <entry>(NOT src) AND dst</entry>
322 <entry><symbol>GXnoop</symbol></entry>
327 <entry><symbol>GXxor</symbol></entry>
329 <entry>src XOR dst</entry>
332 <entry><symbol>GXor</symbol></entry>
334 <entry>src OR dst</entry>
337 <entry><symbol>GXnor</symbol></entry>
339 <entry>(NOT src) AND (NOT dst)</entry>
342 <entry><symbol>GXequiv</symbol></entry>
344 <entry>(NOT src) XOR dst</entry>
347 <entry><symbol>GXinvert</symbol></entry>
349 <entry>NOT dst</entry>
352 <entry><symbol>GXorReverse</symbol></entry>
354 <entry>src OR (NOT dst)</entry>
357 <entry><symbol>GXcopyInverted</symbol></entry>
359 <entry>NOT src</entry>
362 <entry><symbol>GXorInverted</symbol></entry>
364 <entry>(NOT src) OR dst</entry>
367 <entry><symbol>GXnand</symbol></entry>
369 <entry>(NOT src) OR (NOT dst)</entry>
372 <entry><symbol>GXset</symbol></entry>
382 Many graphics operations depend on either pixel values or planes in a GC.
383 <indexterm><primary>Pixel value</primary></indexterm>
384 The planes attribute is of type long, and it specifies which planes of the
385 destination are to be modified, one bit per plane.
386 <indexterm><primary>Plane</primary><secondary>mask</secondary></indexterm>
387 A monochrome display has only one plane and
388 will be the least significant bit of the word.
389 As planes are added to the display hardware, they will occupy more
390 significant bits in the plane mask.
394 In graphics operations, given a source and destination pixel,
395 the result is computed bitwise on corresponding bits of the pixels.
396 That is, a Boolean operation is performed in each bit plane.
397 The plane_mask restricts the operation to a subset of planes.
399 <symbol>AllPlanes</symbol>
400 can be used to refer to all planes of the screen simultaneously.
401 The result is computed by the following:
405 <literallayout class="monospaced">
406 ((src FUNC dst) AND plane-mask) OR (dst AND (NOT plane-mask))
411 Range checking is not performed on the values for foreground,
412 background, or plane_mask.
413 They are simply truncated to the appropriate
415 The line-width is measured in pixels and either can be greater than or equal to
416 one (wide line) or can be the special value zero (thin line).
420 Wide lines are drawn centered on the path described by the graphics request.
421 Unless otherwise specified by the join-style or cap-style,
422 the bounding box of a wide line with endpoints [x1, y1], [x2, y2] and
423 width w is a rectangle with vertices at the following real coordinates:
427 <literallayout class="monospaced">
428 <!-- .TA .5i 2.5i -->
429 <!-- .ta .5i 2.5i -->
430 [x1-(w*sn/2), y1+(w*cs/2)], [x1+(w*sn/2), y1-(w*cs/2)],
431 [x2-(w*sn/2), y2+(w*cs/2)], [x2+(w*sn/2), y2-(w*cs/2)]
436 Here sn is the sine of the angle of the line,
437 and cs is the cosine of the angle of the line.
438 A pixel is part of the line and so is drawn
439 if the center of the pixel is fully inside the bounding box
440 (which is viewed as having infinitely thin edges).
441 If the center of the pixel is exactly on the bounding box,
442 it is part of the line if and only if the interior is immediately to its right
443 (x increasing direction).
444 Pixels with centers on a horizontal edge are a special case and are part of
445 the line if and only if the interior or the boundary is immediately below
446 (y increasing direction) and the interior or the boundary is immediately
447 to the right (x increasing direction).
451 Thin lines (zero line-width) are one-pixel-wide lines drawn using an
452 unspecified, device-dependent algorithm.
453 There are only two constraints on this algorithm.
458 If a line is drawn unclipped from [x1,y1] to [x2,y2] and
459 if another line is drawn unclipped from [x1+dx,y1+dy] to [x2+dx,y2+dy],
460 a point [x,y] is touched by drawing the first line
461 if and only if the point [x+dx,y+dy] is touched by drawing the second line.
466 The effective set of points comprising a line cannot be affected by clipping.
467 That is, a point is touched in a clipped line if and only if the point
468 lies inside the clipping region and the point would be touched
469 by the line when drawn unclipped.
475 A wide line drawn from [x1,y1] to [x2,y2] always draws the same pixels
476 as a wide line drawn from [x2,y2] to [x1,y1], not counting cap-style
478 It is recommended that this property be true for thin lines,
479 but this is not required.
480 A line-width of zero may differ from a line-width of one in which pixels are
482 This permits the use of many manufacturers' line drawing hardware,
483 which may run many times faster than the more precisely specified
489 drawing a thin line will be faster than drawing a wide line of width one.
490 However, because of their different drawing algorithms,
491 thin lines may not mix well aesthetically with wide lines.
492 If it is desirable to obtain precise and uniform results across all displays,
493 a client should always use a line-width of one rather than a line-width of zero.
497 The line-style defines which sections of a line are drawn:
502 <term><symbol>LineSolid</symbol></term>
504 <para>The full path of the line is drawn.</para>
508 <term><symbol>LineDoubleDash</symbol></term>
511 The full path of the line is drawn,
512 but the even dashes are filled differently
513 from the odd dashes (see fill-style) with <!-- xref -->
514 <symbol>CapButt</symbol>
515 style used where even and odd dashes meet.
520 <term><symbol>LineOnOffDash</symbol></term>
523 Only the even dashes are drawn,
524 and cap-style applies to
525 all internal ends of the individual dashes,
527 <symbol>CapNotLast</symbol>
529 <symbol>CapButt</symbol>.
535 The cap-style defines how the endpoints of a path are drawn:
540 <term><symbol>CapNotLast</symbol></term>
543 This is equivalent to
544 <symbol>CapButt</symbol>
545 except that for a line-width of zero the final endpoint is not drawn.
551 <term><symbol>CapButt</symbol></term>
554 The line is square at the endpoint (perpendicular to the slope of the line)
555 with no projection beyond.
560 <term><symbol>CapRound</symbol></term>
563 The line has a circular arc with the diameter equal to the line-width,
564 centered on the endpoint.
565 (This is equivalent to
566 <symbol>CapButt</symbol>
567 for line-width of zero).
572 <term><symbol>CapProjecting</symbol></term>
575 The line is square at the end, but the path continues beyond the endpoint
576 for a distance equal to half the line-width.
577 (This is equivalent to
578 <symbol>CapButt</symbol>
579 for line-width of zero).
586 The join-style defines how corners are drawn for wide lines:
591 <term><symbol>JoinMiter</symbol></term>
594 The outer edges of two lines extend to meet at an angle.
595 However, if the angle is less than 11 degrees,
597 <symbol>JoinBevel</symbol>
598 join-style is used instead.
603 <term><symbol>JoinRound</symbol></term>
606 The corner is a circular arc with the diameter equal to the line-width,
607 centered on the joinpoint.
612 <term><symbol>JoinBevel</symbol></term>
616 <symbol>CapButt</symbol>
617 endpoint styles with the triangular notch filled.
626 For a line with coincident endpoints (x1=x2, y1=y2),
627 when the cap-style is applied to both endpoints,
628 the semantics depends on the line-width and the cap-style:
631 <informaltable frame='none'>
632 <?dbfo keep-together="always" ?>
633 <tgroup cols='3' align='left' colsep='0' rowsep='0'>
634 <colspec colname='c1' colwidth='1.0*'/>
635 <colspec colname='c2' colwidth='1.0*'/>
636 <colspec colname='c3' colwidth='3.0*'/>
639 <entry><symbol>CapNotLast</symbol></entry>
641 <entry>The results are device dependent,
642 but the desired effect is that nothing is drawn.</entry>
645 <entry><symbol>CapButt</symbol></entry>
647 <entry>The results are device dependent,
648 but the desired effect is that a single pixel is drawn.</entry>
651 <entry><symbol>CapRound</symbol></entry>
653 <entry>The results are the same as for
654 <symbol>CapButt</symbol> /thin.</entry>
657 <entry><symbol>CapProjecting</symbol></entry>
659 <entry>The results are the same as for
660 <symbol>CapButt</symbol> /thin.</entry>
663 <entry><symbol>CapButt</symbol></entry>
665 <entry>Nothing is drawn.</entry>
668 <entry><symbol>CapRound</symbol></entry>
670 <entry>The closed path is a circle, centered at the endpoint, and
671 with the diameter equal to the line-width.</entry>
674 <entry><symbol>CapProjecting</symbol></entry>
676 <entry>The closed path is a square, aligned with the coordinate axes, centered at the
677 endpoint, and with the sides equal to the line-width.</entry>
685 For a line with coincident endpoints (x1=x2, y1=y2),
686 when the join-style is applied at one or both endpoints,
687 the effect is as if the line was removed from the overall path.
688 However, if the total path consists of or is reduced to a single point joined
689 with itself, the effect is the same as when the cap-style is applied at both
694 The tile/stipple represents an infinite two-dimensional plane,
695 with the tile/stipple replicated in all dimensions.
696 When that plane is superimposed on the drawable
697 for use in a graphics operation, the upper-left corner
698 of some instance of the tile/stipple is at the coordinates within
699 the drawable specified by the tile/stipple origin.
700 The tile/stipple and clip origins are interpreted relative to the
701 origin of whatever destination drawable is specified in a graphics
703 The tile pixmap must have the same root and depth as the GC,
705 <errorname>BadMatch</errorname>
707 The stipple pixmap must have depth one and must have the same root as the
709 <errorname>BadMatch</errorname>
711 For stipple operations where the fill-style is
712 <symbol>FillStippled</symbol>
714 <symbol>FillOpaqueStippled</symbol>,
715 the stipple pattern is tiled in a
716 single plane and acts as an additional clip mask to be ANDed with the clip-mask.
717 Although some sizes may be faster to use than others,
718 any size pixmap can be used for tiling or stippling.
723 The fill-style defines the contents of the source for line, text, and
725 For all text and fill requests (for example,
726 <xref linkend='XDrawText' xrefstyle='select: title'/>,
727 <xref linkend='XDrawText16' xrefstyle='select: title'/>,
728 <xref linkend='XFillRectangle' xrefstyle='select: title'/>,
729 <xref linkend='XFillPolygon' xrefstyle='select: title'/>,
731 <xref linkend='XFillArc' xrefstyle='select: title'/>);
734 <symbol>LineSolid</symbol>
736 <xref linkend='XDrawLine' xrefstyle='select: title'/>,
737 <xref linkend='XDrawSegments' xrefstyle='select: title'/>,
738 <xref linkend='XDrawRectangle' xrefstyle='select: title'/>,
739 <xref linkend='XDrawArc' xrefstyle='select: title'/>);
740 and for the even dashes for line requests with line-style
741 <symbol>LineOnOffDash</symbol>
743 <symbol>LineDoubleDash</symbol>,
747 <informaltable frame='none'>
748 <?dbfo keep-together="always" ?>
749 <tgroup cols='2' align='left' colsep='0' rowsep='0'>
750 <colspec colname='c1' colwidth='1.0*'/>
751 <colspec colname='c2' colwidth='2.0*'/>
754 <entry><symbol>FillSolid</symbol></entry>
755 <entry>Foreground</entry>
758 <entry><symbol>FillTiled</symbol></entry>
762 <entry><symbol>FillOpaqueStippled</symbol></entry>
763 <entry>A tile with the same width and height as stipple,
764 but with background everywhere stipple has a zero
765 and with foreground everywhere stipple has a one</entry>
768 <entry><symbol>FillStippled</symbol></entry>
769 <entry>Foreground masked by stipple</entry>
777 When drawing lines with line-style
778 <symbol>LineDoubleDash</symbol>,
779 the odd dashes are controlled by the fill-style in the following manner:
782 <informaltable frame='none'>
783 <?dbfo keep-together="always" ?>
784 <tgroup cols='2' align='left' colsep='0' rowsep='0'>
785 <colspec colname='c1' colwidth='1.0*'/>
786 <colspec colname='c2' colwidth='2.0*'/>
789 <entry><symbol>FillSolid</symbol></entry>
790 <entry>Background</entry>
793 <entry><symbol>FillTiled</symbol></entry>
794 <entry>Same as for even dashes</entry>
797 <entry><symbol>FillOpaqueStippled</symbol></entry>
798 <entry>Same as for even dashes</entry>
801 <entry><symbol>FillStippled</symbol></entry>
802 <entry>Background masked by stipple</entry>
810 Storing a pixmap in a GC might or might not result in a copy
812 If the pixmap is later used as the destination for a graphics request,
813 the change might or might not be reflected in the GC.
814 If the pixmap is used simultaneously in a graphics request both as
815 a destination and as a tile or stipple,
816 the results are undefined.
820 For optimum performance,
821 you should draw as much as possible with the same GC
822 (without changing its components).
823 The costs of changing GC components relative to using different GCs
824 depend on the display hardware and the server implementation.
825 It is quite likely that some amount of GC information will be
826 cached in display hardware and that such hardware can only cache a small number
831 The dashes value is actually a simplified form of the
832 more general patterns that can be set with
833 <xref linkend='XSetDashes' xrefstyle='select: title'/>.
835 value of N is equivalent to specifying the two-element list [N, N] in
836 <xref linkend='XSetDashes' xrefstyle='select: title'/>.
837 The value must be nonzero,
839 <errorname>BadValue</errorname>
844 The clip-mask restricts writes to the destination drawable.
845 If the clip-mask is set to a pixmap,
846 it must have depth one and have the same root as the GC,
848 <errorname>BadMatch</errorname>
850 If clip-mask is set to
851 <symbol>None</symbol>,
852 the pixels are always drawn regardless of the clip origin.
853 The clip-mask also can be set by calling the
854 <xref linkend='XSetClipRectangles' xrefstyle='select: title'/>
856 <xref linkend='XSetRegion' xrefstyle='select: title'/>
858 Only pixels where the clip-mask has a bit set to 1 are drawn.
859 Pixels are not drawn outside the area covered by the clip-mask
860 or where the clip-mask has a bit set to 0.
861 The clip-mask affects all graphics requests.
862 The clip-mask does not clip sources.
863 The clip-mask origin is interpreted relative to the origin of whatever
864 destination drawable is specified in a graphics request.
868 You can set the subwindow-mode to
869 <symbol>ClipByChildren</symbol>
871 <symbol>IncludeInferiors</symbol>.
873 <symbol>ClipByChildren</symbol>,
874 both source and destination windows are
875 additionally clipped by all viewable
876 <symbol>InputOutput</symbol>
879 <symbol>IncludeInferiors</symbol>,
880 neither source nor destination window is clipped by inferiors.
881 This will result in including subwindow contents in the source
882 and drawing through subwindow boundaries of the destination.
884 <symbol>IncludeInferiors</symbol>
885 on a window of one depth with mapped
886 inferiors of differing depth is not illegal, but the semantics are
887 undefined by the core protocol.
891 The fill-rule defines what pixels are inside (drawn) for
893 <xref linkend='XFillPolygon' xrefstyle='select: title'/>
894 requests and can be set to
895 <symbol>EvenOddRule</symbol>
897 <symbol>WindingRule</symbol>.
899 <symbol>EvenOddRule</symbol>,
901 an infinite ray with the point as origin crosses the path an odd number
904 <symbol>WindingRule</symbol>,
905 a point is inside if an infinite ray with the
906 point as origin crosses an unequal number of clockwise and
907 counterclockwise directed path segments.
908 A clockwise directed path segment is one that crosses the ray from left to
909 right as observed from the point.
910 A counterclockwise segment is one that crosses the ray from right to left
911 as observed from the point.
912 The case where a directed line segment is coincident with the ray is
913 uninteresting because you can simply choose a different ray that is not
914 coincident with a segment.
919 <symbol>EvenOddRule</symbol>
921 <symbol>WindingRule</symbol>,
922 a point is infinitely small,
923 and the path is an infinitely thin line.
924 A pixel is inside if the center point of the pixel is inside
925 and the center point is not on the boundary.
926 If the center point is on the boundary,
927 the pixel is inside if and only if the polygon interior is immediately to
928 its right (x increasing direction).
929 Pixels with centers on a horizontal edge are a special case
930 and are inside if and only if the polygon interior is immediately below
931 (y increasing direction).
935 The arc-mode controls filling in the
936 <xref linkend='XFillArcs' xrefstyle='select: title'/>
937 function and can be set to
938 <symbol>ArcPieSlice</symbol>
940 <symbol>ArcChord</symbol>.
942 <symbol>ArcPieSlice</symbol>,
943 the arcs are pie-slice filled.
945 <symbol>ArcChord</symbol>,
946 the arcs are chord filled.
950 The graphics-exposure flag controls
951 <symbol>GraphicsExpose</symbol>
954 <xref linkend='XCopyArea' xrefstyle='select: title'/>
956 <xref linkend='XCopyPlane' xrefstyle='select: title'/>
957 requests (and any similar requests defined by extensions).
962 To create a new GC that is usable on a given screen with a
963 depth of drawable, use
964 <xref linkend='XCreateGC' xrefstyle='select: title'/>.
966 <indexterm><primary>Graphics context</primary><secondary>initializing</secondary></indexterm>
967 <indexterm significance="preferred"><primary>XCreateGC</primary></indexterm>
969 <funcsynopsis id='XCreateGC'>
971 <funcdef>GC <function>XCreateGC</function></funcdef>
972 <paramdef>Display <parameter> *display</parameter></paramdef>
973 <paramdef>Drawable<parameter> d</parameter></paramdef>
974 <paramdef>unsignedlong<parameter> valuemask</parameter></paramdef>
975 <paramdef>XGCValues *<parameter>values</parameter></paramdef>
982 <emphasis remap='I'>display</emphasis>
986 Specifies the connection to the X server.
992 <emphasis remap='I'>d</emphasis>
996 Specifies the drawable.
997 <!-- .ds Vm set using the information in the specified values structure -->
1003 <emphasis remap='I'>valuemask</emphasis>
1007 Specifies which components in the GC are to be (Vm.
1008 This argument is the bitwise inclusive OR of zero or more of the valid
1009 GC component mask bits.
1015 <emphasis remap='I'>values</emphasis>
1019 Specifies any values as specified by the valuemask.
1028 <xref linkend='XCreateGC' xrefstyle='select: title'/>
1029 function creates a graphics context and returns a GC.
1030 The GC can be used with any destination drawable having the same root
1031 and depth as the specified drawable.
1032 Use with other drawables results in a
1033 <errorname>BadMatch</errorname>
1038 <xref linkend='XCreateGC' xrefstyle='select: title'/>
1040 <errorname>BadAlloc</errorname>,
1041 <errorname>BadDrawable</errorname>,
1042 <errorname>BadFont</errorname>,
1043 <errorname>BadMatch</errorname>,
1044 <errorname>BadPixmap</errorname>,
1046 <errorname>BadValue</errorname>
1052 To copy components from a source GC to a destination GC, use
1053 <xref linkend='XCopyGC' xrefstyle='select: title'/>.
1055 <indexterm significance="preferred"><primary>XCopyGC</primary></indexterm>
1057 <funcsynopsis id='XCopyGC'>
1059 <funcdef><function>XCopyGC</function></funcdef>
1060 <paramdef>Display<parameter> *display</parameter></paramdef>
1061 <paramdef>GCsrc,<parameter> dest</parameter></paramdef>
1062 <paramdef>unsignedlong<parameter> valuemask</parameter></paramdef>
1069 <emphasis remap='I'>display</emphasis>
1073 Specifies the connection to the X server.
1079 <emphasis remap='I'>src</emphasis>
1083 Specifies the components of the source GC.
1084 <!-- .ds Vm copied to the destination GC -->
1090 <emphasis remap='I'>valuemask</emphasis>
1094 Specifies which components in the GC are to be (Vm.
1095 This argument is the bitwise inclusive OR of zero or more of the valid
1096 GC component mask bits.
1102 <emphasis remap='I'>dest</emphasis>
1106 Specifies the destination GC.
1115 <xref linkend='XCopyGC' xrefstyle='select: title'/>
1116 function copies the specified components from the source GC
1117 to the destination GC.
1118 The source and destination GCs must have the same root and depth,
1120 <errorname>BadMatch</errorname>
1122 The valuemask specifies which component to copy, as for
1123 <xref linkend='XCreateGC' xrefstyle='select: title'/>.
1127 <xref linkend='XCopyGC' xrefstyle='select: title'/>
1129 <errorname>BadAlloc</errorname>,
1130 <errorname>BadGC</errorname>,
1132 <errorname>BadMatch</errorname>
1138 To change the components in a given GC, use
1139 <xref linkend='XChangeGC' xrefstyle='select: title'/>.
1141 <indexterm significance="preferred"><primary>XChangeGC</primary></indexterm>
1143 <funcsynopsis id='XChangeGC'>
1145 <funcdef><function>XChangeGC</function></funcdef>
1146 <paramdef>Display<parameter> *display</parameter></paramdef>
1147 <paramdef>GC<parameter> gc</parameter></paramdef>
1148 <paramdef>unsignedlong<parameter> valuemask</parameter></paramdef>
1149 <paramdef>XGCValues<parameter> *values</parameter></paramdef>
1156 <emphasis remap='I'>display</emphasis>
1160 Specifies the connection to the X server.
1166 <emphasis remap='I'>gc</emphasis>
1171 <!-- .ds Vm changed using information in the specified values structure -->
1177 <emphasis remap='I'>valuemask</emphasis>
1181 Specifies which components in the GC are to be (Vm.
1182 This argument is the bitwise inclusive OR of zero or more of the valid
1183 GC component mask bits.
1189 <emphasis remap='I'>values</emphasis>
1193 Specifies any values as specified by the valuemask.
1202 <xref linkend='XChangeGC' xrefstyle='select: title'/>
1203 function changes the components specified by valuemask for
1205 The values argument contains the values to be set.
1206 The values and restrictions are the same as for
1207 <xref linkend='XCreateGC' xrefstyle='select: title'/>.
1208 Changing the clip-mask overrides any previous
1209 <xref linkend='XSetClipRectangles' xrefstyle='select: title'/>
1210 request on the context.
1211 Changing the dash-offset or dash-list
1212 overrides any previous
1213 <xref linkend='XSetDashes' xrefstyle='select: title'/>
1214 request on the context.
1215 The order in which components are verified and altered is server dependent.
1216 If an error is generated, a subset of the components may have been altered.
1220 <xref linkend='XChangeGC' xrefstyle='select: title'/>
1222 <errorname>BadAlloc</errorname>,
1223 <errorname>BadFont</errorname>,
1224 <errorname>BadGC</errorname>,
1225 <errorname>BadMatch</errorname>,
1226 <errorname>BadPixmap</errorname>,
1228 <errorname>BadValue</errorname>
1234 To obtain components of a given GC, use
1235 <xref linkend='XGetGCValues' xrefstyle='select: title'/>.
1237 <indexterm significance="preferred"><primary>XGetGCValues</primary></indexterm>
1239 <funcsynopsis id='XGetGCValues'>
1241 <funcdef>Status <function>XGetGCValues</function></funcdef>
1242 <paramdef>Display<parameter> *display</parameter></paramdef>
1243 <paramdef>GC<parameter> gc</parameter></paramdef>
1244 <paramdef>unsignedlong<parameter> valuemask</parameter></paramdef>
1245 <paramdef>XGCValues<parameter> *values_return</parameter></paramdef>
1252 <emphasis remap='I'>display</emphasis>
1256 Specifies the connection to the X server.
1262 <emphasis remap='I'>gc</emphasis>
1267 <!-- .ds Vm returned in the values_return argument -->
1273 <emphasis remap='I'>valuemask</emphasis>
1277 Specifies which components in the GC are to be (Vm.
1278 This argument is the bitwise inclusive OR of zero or more of the valid
1279 GC component mask bits.
1285 <emphasis remap='I'>values_return</emphasis>
1289 Returns the GC values in the specified
1290 <structname>XGCValues</structname>
1300 <xref linkend='XGetGCValues' xrefstyle='select: title'/>
1301 function returns the components specified by valuemask for the specified GC.
1302 If the valuemask contains a valid set of GC mask bits
1303 (<symbol>GCFunction</symbol>,
1304 <symbol>GCPlaneMask</symbol>,
1305 <symbol>GCForeground</symbol>,
1306 <symbol>GCBackground</symbol>,
1307 <symbol>GCLineWidth</symbol>,
1308 <symbol>GCLineStyle</symbol>,
1309 <symbol>GCCapStyle</symbol>,
1310 <symbol>GCJoinStyle</symbol>,
1311 <symbol>GCFillStyle</symbol>,
1312 <symbol>GCFillRule</symbol>,
1313 <symbol>GCTile</symbol>,
1314 <symbol>GCStipple</symbol>,
1315 <symbol>GCTileStipXOrigin</symbol>,
1316 <symbol>GCTileStipYOrigin</symbol>,
1317 <symbol>GCFont</symbol>,
1318 <symbol>GCSubwindowMode</symbol>,
1319 <symbol>GCGraphicsExposures</symbol>,
1320 <symbol>GCClipXOrigin</symbol>,
1321 <symbol>GCClipYOrigin</symbol>,
1322 <symbol>GCDashOffset</symbol>,
1324 <symbol>GCArcMode</symbol>)
1325 and no error occurs,
1326 <xref linkend='XGetGCValues' xrefstyle='select: title'/>
1327 sets the requested components in values_return and returns a nonzero status.
1328 Otherwise, it returns a zero status.
1329 Note that the clip-mask and dash-list (represented by the
1330 <symbol>GCClipMask</symbol>
1332 <symbol>GCDashList</symbol>
1333 bits, respectively, in the valuemask)
1334 cannot be requested.
1335 Also note that an invalid resource ID (with one or more of the three
1336 most significant bits set to 1) will be returned for
1337 <symbol>GCFont</symbol>,
1338 <symbol>GCTile</symbol>,
1340 <symbol>GCStipple</symbol>
1341 if the component has never been explicitly set by the client.
1346 To free a given GC, use
1347 <xref linkend='XFreeGC' xrefstyle='select: title'/>.
1349 <indexterm significance="preferred"><primary>XFreeGC</primary></indexterm>
1351 <funcsynopsis id='XFreeGC'>
1353 <funcdef><function>XFreeGC</function></funcdef>
1354 <paramdef>Display<parameter> *display</parameter></paramdef>
1355 <paramdef>GC<parameter> gc</parameter></paramdef>
1362 <emphasis remap='I'>display</emphasis>
1366 Specifies the connection to the X server.
1372 <emphasis remap='I'>gc</emphasis>
1385 <xref linkend='XFreeGC' xrefstyle='select: title'/>
1386 function destroys the specified GC as well as all the associated storage.
1390 <xref linkend='XFreeGC' xrefstyle='select: title'/>
1392 <errorname>BadGC</errorname>
1399 <type>GContext</type>
1400 resource ID for a given GC, use
1401 <xref linkend='XGContextFromGC' xrefstyle='select: title'/>.
1403 <indexterm significance="preferred"><primary>XGContextFromGC</primary></indexterm>
1405 <funcsynopsis id='XGContextFromGC'>
1407 <funcdef>GContext <function>XGContextFromGC</function></funcdef>
1408 <paramdef>GC<parameter> gc</parameter></paramdef>
1412 <!-- .ds Gc for which you want the resource ID -->
1416 <emphasis remap='I'>gc</emphasis>
1420 Specifies the GC (Gc.
1429 Xlib usually defers sending changes to the components of a GC to the server
1430 until a graphics function is actually called with that GC.
1431 This permits batching of component changes into a single server request.
1432 In some circumstances, however, it may be necessary for the client
1433 to explicitly force sending the changes to the server.
1434 An example might be when a protocol extension uses the GC indirectly,
1435 in such a way that the extension interface cannot know what GC will be used.
1436 To force sending GC component changes, use
1437 <xref linkend='XFlushGC' xrefstyle='select: title'/>.
1439 <indexterm significance="preferred"><primary>XFlushGC</primary></indexterm>
1441 <funcsynopsis id='XFlushGC'>
1443 <funcdef>void <function>XFlushGC</function></funcdef>
1444 <paramdef>Display<parameter> *display</parameter></paramdef>
1445 <paramdef>GC<parameter> gc</parameter></paramdef>
1452 <emphasis remap='I'>display</emphasis>
1456 Specifies the connection to the X server.
1462 <emphasis remap='I'>gc</emphasis>
1476 <sect1 id="Using_Graphics_Context_Convenience_Routines">
1477 <title>Using Graphics Context Convenience Routines</title>
1479 <!-- (SN Using Graphics Context Convenience Routines -->
1483 This section discusses how to set the:
1488 Foreground, background, plane mask, or function components
1493 Line attributes and dashes components
1498 Fill style and fill rule components
1503 Fill tile and stipple components
1513 Clip region component
1518 Arc mode, subwindow mode, and graphics exposure components
1522 <sect2 id="Setting_the_Foreground_Background_Function_or_Plane_Mask">
1523 <title>Setting the Foreground, Background, Function, or Plane Mask</title>
1525 <!-- (SN Setting the Foreground, Background, Function, or Plane Mask -->
1529 To set the foreground, background, plane mask, and function components
1531 <xref linkend='XSetState' xrefstyle='select: title'/>.
1533 <indexterm significance="preferred"><primary>XSetState</primary></indexterm>
1535 <funcsynopsis id='XSetState'>
1537 <funcdef><function>XSetState</function></funcdef>
1538 <paramdef>Display<parameter> *display</parameter></paramdef>
1539 <paramdef>GC<parameter> gc</parameter></paramdef>
1540 <paramdef>unsignedlongforeground,<parameter> background</parameter></paramdef>
1541 <paramdef>int<parameter> function</parameter></paramdef>
1542 <paramdef>unsignedlong<parameter> plane_mask</parameter></paramdef>
1549 <emphasis remap='I'>display</emphasis>
1553 Specifies the connection to the X server.
1559 <emphasis remap='I'>gc</emphasis>
1569 <emphasis remap='I'>foreground</emphasis>
1573 Specifies the foreground you want to set for the specified GC.
1579 <emphasis remap='I'>background</emphasis>
1583 Specifies the background you want to set for the specified GC.
1589 <emphasis remap='I'>function</emphasis>
1593 Specifies the function you want to set for the specified GC.
1599 <emphasis remap='I'>plane_mask</emphasis>
1603 Specifies the plane mask.
1604 <!-- .\" *** JIM: NEED MORE INFO FOR THIS. *** -->
1612 <xref linkend='XSetState' xrefstyle='select: title'/>
1614 <errorname>BadAlloc</errorname>,
1615 <errorname>BadGC</errorname>,
1617 <errorname>BadValue</errorname>
1623 To set the foreground of a given GC, use
1624 <xref linkend='XSetForeground' xrefstyle='select: title'/>.
1626 <indexterm significance="preferred"><primary>XSetForeground</primary></indexterm>
1628 <funcsynopsis id='XSetForeground'>
1630 <funcdef><function>XSetForeground</function></funcdef>
1631 <paramdef>Display<parameter> *display</parameter></paramdef>
1632 <paramdef>GC<parameter> gc</parameter></paramdef>
1633 <paramdef>unsignedlong<parameter> foreground</parameter></paramdef>
1640 <emphasis remap='I'>display</emphasis>
1644 Specifies the connection to the X server.
1650 <emphasis remap='I'>gc</emphasis>
1660 <emphasis remap='I'>foreground</emphasis>
1664 Specifies the foreground you want to set for the specified GC.
1672 <xref linkend='XSetForeground' xrefstyle='select: title'/>
1674 <errorname>BadAlloc</errorname>
1676 <errorname>BadGC</errorname>
1682 To set the background of a given GC, use
1683 <xref linkend='XSetBackground' xrefstyle='select: title'/>.
1685 <indexterm significance="preferred"><primary>XSetBackground</primary></indexterm>
1687 <funcsynopsis id='XSetBackground'>
1689 <funcdef><function>XSetBackground</function></funcdef>
1690 <paramdef>Display<parameter> *display</parameter></paramdef>
1691 <paramdef>GC<parameter> gc</parameter></paramdef>
1692 <paramdef>unsignedlong<parameter> background</parameter></paramdef>
1699 <emphasis remap='I'>display</emphasis>
1703 Specifies the connection to the X server.
1709 <emphasis remap='I'>gc</emphasis>
1719 <emphasis remap='I'>background</emphasis>
1723 Specifies the background you want to set for the specified GC.
1731 <xref linkend='XSetBackground' xrefstyle='select: title'/>
1733 <errorname>BadAlloc</errorname>
1735 <errorname>BadGC</errorname>
1741 To set the display function in a given GC, use
1742 <xref linkend='XSetFunction' xrefstyle='select: title'/>.
1744 <indexterm significance="preferred"><primary>XSetFunction</primary></indexterm>
1746 <funcsynopsis id='XSetFunction'>
1748 <funcdef><function>XSetFunction</function></funcdef>
1749 <paramdef>Display<parameter> *display</parameter></paramdef>
1750 <paramdef>GC<parameter> gc</parameter></paramdef>
1751 <paramdef>int<parameter> function</parameter></paramdef>
1758 <emphasis remap='I'>display</emphasis>
1762 Specifies the connection to the X server.
1768 <emphasis remap='I'>gc</emphasis>
1778 <emphasis remap='I'>function</emphasis>
1782 Specifies the function you want to set for the specified GC.
1790 <xref linkend='XSetFunction' xrefstyle='select: title'/>
1792 <errorname>BadAlloc</errorname>,
1793 <errorname>BadGC</errorname>,
1795 <errorname>BadValue</errorname>
1801 To set the plane mask of a given GC, use
1802 <xref linkend='XSetPlaneMask' xrefstyle='select: title'/>.
1804 <indexterm significance="preferred"><primary>XSetPlaneMask</primary></indexterm>
1806 <funcsynopsis id='XSetPlaneMask'>
1808 <funcdef><function>XSetPlaneMask</function></funcdef>
1809 <paramdef>Display<parameter> *display</parameter></paramdef>
1810 <paramdef>GC<parameter> gc</parameter></paramdef>
1811 <paramdef>unsignedlong<parameter> plane_mask</parameter></paramdef>
1818 <emphasis remap='I'>display</emphasis>
1822 Specifies the connection to the X server.
1828 <emphasis remap='I'>gc</emphasis>
1838 <emphasis remap='I'>plane_mask</emphasis>
1842 Specifies the plane mask.
1843 <!-- .\" *** JIM: NEED MORE INFO FOR THIS. *** -->
1851 <xref linkend='XSetPlaneMask' xrefstyle='select: title'/>
1853 <errorname>BadAlloc</errorname>
1855 <errorname>BadGC</errorname>
1859 <sect2 id="Setting_the_Line_Attributes_and_Dashes">
1860 <title>Setting the Line Attributes and Dashes</title>
1862 <!-- (SN Setting the Line Attributes and Dashes -->
1866 To set the line drawing components of a given GC, use
1867 <xref linkend='XSetLineAttributes' xrefstyle='select: title'/>.
1869 <indexterm significance="preferred"><primary>XSetLineAttributes</primary></indexterm>
1871 <funcsynopsis id='XSetLineAttributes'>
1873 <funcdef><function>XSetLineAttributes</function></funcdef>
1874 <paramdef>Display<parameter> *display</parameter></paramdef>
1875 <paramdef>GC<parameter> gc</parameter></paramdef>
1876 <paramdef>unsignedint<parameter> line_width</parameter></paramdef>
1877 <paramdef>int<parameter> line_style</parameter></paramdef>
1878 <paramdef>int<parameter> cap_style</parameter></paramdef>
1879 <paramdef>int<parameter> join_style</parameter></paramdef>
1886 <emphasis remap='I'>display</emphasis>
1890 Specifies the connection to the X server.
1896 <emphasis remap='I'>gc</emphasis>
1906 <emphasis remap='I'>line_width</emphasis>
1910 Specifies the line-width you want to set for the specified GC.
1916 <emphasis remap='I'>line_style</emphasis>
1920 Specifies the line-style you want to set for the specified GC.
1922 <symbol>LineSolid</symbol>,
1923 <symbol>LineOnOffDash</symbol>,
1925 <symbol>LineDoubleDash</symbol>.
1931 <emphasis remap='I'>cap_style</emphasis>
1935 Specifies the line-style and cap-style you want to set for the specified GC.
1937 <symbol>CapNotLast</symbol>,
1938 <symbol>CapButt</symbol>,
1939 <symbol>CapRound</symbol>,
1941 <symbol>CapProjecting</symbol>.
1947 <emphasis remap='I'>join_style</emphasis>
1951 Specifies the line join-style you want to set for the specified GC.
1953 <symbol>JoinMiter</symbol>,
1954 <symbol>JoinRound</symbol>,
1956 <symbol>JoinBevel</symbol>.
1964 <xref linkend='XSetLineAttributes' xrefstyle='select: title'/>
1966 <errorname>BadAlloc</errorname>,
1967 <errorname>BadGC</errorname>,
1969 <errorname>BadValue</errorname>
1975 To set the dash-offset and dash-list for dashed line styles of a given GC, use
1976 <xref linkend='XSetDashes' xrefstyle='select: title'/>.
1978 <indexterm significance="preferred"><primary>XSetDashes</primary></indexterm>
1980 <funcsynopsis id='XSetDashes'>
1982 <funcdef><function>XSetDashes</function></funcdef>
1983 <paramdef>Display<parameter> *display</parameter></paramdef>
1984 <paramdef>GC<parameter> gc</parameter></paramdef>
1985 <paramdef>int<parameter> dash_offset</parameter></paramdef>
1986 <paramdef>char<parameter> dash_list[]</parameter></paramdef>
1987 <paramdef>int<parameter> n</parameter></paramdef>
1994 <emphasis remap='I'>display</emphasis>
1998 Specifies the connection to the X server.
2004 <emphasis remap='I'>gc</emphasis>
2014 <emphasis remap='I'>dash_offset</emphasis>
2018 Specifies the phase of the pattern for the dashed line-style you want to set
2019 for the specified GC.
2025 <emphasis remap='I'>dash_list</emphasis>
2029 Specifies the dash-list for the dashed line-style
2030 you want to set for the specified GC.
2036 <emphasis remap='I'>n</emphasis>
2040 Specifies the number of elements in dash_list.
2049 <xref linkend='XSetDashes' xrefstyle='select: title'/>
2050 function sets the dash-offset and dash-list attributes for dashed line styles
2051 in the specified GC.
2052 There must be at least one element in the specified dash_list,
2054 <errorname>BadValue</errorname>
2056 The initial and alternating elements (second, fourth, and so on)
2057 of the dash_list are the even dashes, and
2058 the others are the odd dashes.
2059 Each element specifies a dash length in pixels.
2060 All of the elements must be nonzero,
2062 <errorname>BadValue</errorname>
2064 Specifying an odd-length list is equivalent to specifying the same list
2065 concatenated with itself to produce an even-length list.
2069 The dash-offset defines the phase of the pattern,
2070 specifying how many pixels into the dash-list the pattern
2071 should actually begin in any single graphics request.
2072 Dashing is continuous through path elements combined with a join-style
2073 but is reset to the dash-offset between each sequence of joined lines.
2077 The unit of measure for dashes is the same for the ordinary coordinate system.
2078 Ideally, a dash length is measured along the slope of the line, but implementations
2079 are only required to match this ideal for horizontal and vertical lines.
2080 Failing the ideal semantics, it is suggested that the length be measured along the
2081 major axis of the line.
2082 The major axis is defined as the x axis for lines drawn at an angle of between
2083 −45 and +45 degrees or between 135 and 225 degrees from the x axis.
2084 For all other lines, the major axis is the y axis.
2088 <xref linkend='XSetDashes' xrefstyle='select: title'/>
2090 <errorname>BadAlloc</errorname>,
2091 <errorname>BadGC</errorname>,
2093 <errorname>BadValue</errorname>
2097 <sect2 id='Setting_the_Fill_Style_and_Fill_Rule'>
2098 <title>Setting the Fill Style and Fill Rule</title>
2100 <!-- (SN Setting the Fill Style and Fill Rule -->
2104 To set the fill-style of a given GC, use
2105 <xref linkend='XSetFillStyle' xrefstyle='select: title'/>.
2107 <indexterm significance="preferred"><primary>XSetFillStyle</primary></indexterm>
2109 <funcsynopsis id='XSetFillStyle'>
2111 <funcdef><function>XSetFillStyle</function></funcdef>
2112 <paramdef>Display<parameter> *display</parameter></paramdef>
2113 <paramdef>GC<parameter> gc</parameter></paramdef>
2114 <paramdef>int<parameter> fill_style</parameter></paramdef>
2121 <emphasis remap='I'>display</emphasis>
2125 Specifies the connection to the X server.
2131 <emphasis remap='I'>gc</emphasis>
2141 <emphasis remap='I'>fill_style</emphasis>
2145 Specifies the fill-style you want to set for the specified GC.
2147 <symbol>FillSolid</symbol>,
2148 <symbol>FillTiled</symbol>,
2149 <symbol>FillStippled</symbol>,
2151 <symbol>FillOpaqueStippled</symbol>.
2159 <xref linkend='XSetFillStyle' xrefstyle='select: title'/>
2161 <errorname>BadAlloc</errorname>,
2162 <errorname>BadGC</errorname>,
2164 <errorname>BadValue</errorname>
2170 To set the fill-rule of a given GC, use
2171 <xref linkend='XSetFillRule' xrefstyle='select: title'/>.
2173 <indexterm significance="preferred"><primary>XSetFillRule</primary></indexterm>
2175 <funcsynopsis id='XSetFillRule'>
2177 <funcdef><function>XSetFillRule</function></funcdef>
2178 <paramdef>Display<parameter> *display</parameter></paramdef>
2179 <paramdef>GC<parameter> gc</parameter></paramdef>
2180 <paramdef>int<parameter> fill_rule</parameter></paramdef>
2187 <emphasis remap='I'>display</emphasis>
2191 Specifies the connection to the X server.
2197 <emphasis remap='I'>gc</emphasis>
2207 <emphasis remap='I'>fill_rule</emphasis>
2211 Specifies the fill-rule you want to set for the specified GC.
2213 <symbol>EvenOddRule</symbol>
2215 <symbol>WindingRule</symbol>.
2223 <xref linkend='XSetFillRule' xrefstyle='select: title'/>
2225 <errorname>BadAlloc</errorname>,
2226 <errorname>BadGC</errorname>,
2228 <errorname>BadValue</errorname>
2232 <sect2 id='Setting_the_Fill_Tile_and_Stipple'>
2233 <title>Setting the Fill Tile and Stipple</title>
2235 <!-- (SN Setting the Fill Tile and Stipple -->
2239 Some displays have hardware support for tiling or
2240 stippling with patterns of specific sizes.
2241 Tiling and stippling operations that restrict themselves to those specific
2242 sizes run much faster than such operations with arbitrary size patterns.
2243 Xlib provides functions that you can use to determine the best size,
2244 tile, or stipple for the display
2245 as well as to set the tile or stipple shape and the tile or stipple origin.
2250 To obtain the best size of a tile, stipple, or cursor, use
2251 <xref linkend='XQueryBestSize' xrefstyle='select: title'/>.
2253 <indexterm significance="preferred"><primary>XQueryBestSize</primary></indexterm>
2255 <funcsynopsis id='XQueryBestSize'>
2257 <funcdef>Status <function>XQueryBestSize</function></funcdef>
2258 <paramdef>Display<parameter> *display</parameter></paramdef>
2259 <paramdef>int<parameter> class</parameter></paramdef>
2260 <paramdef>Drawable<parameter> which_screen</parameter></paramdef>
2261 <paramdef>unsignedintwidth,<parameter> height</parameter></paramdef>
2262 <paramdef>unsignedint*width_return,<parameter> *height_return</parameter></paramdef>
2269 <emphasis remap='I'>display</emphasis>
2273 Specifies the connection to the X server.
2279 <emphasis remap='I'>class</emphasis>
2283 Specifies the class that you are interested in.
2285 <symbol>TileShape</symbol>,
2286 <symbol>CursorShape</symbol>,
2288 <symbol>StippleShape</symbol>.
2294 <emphasis remap='I'>which_screen</emphasis>
2298 Specifies any drawable on the screen.
2304 <emphasis remap='I'>width</emphasis>
2315 <emphasis remap='I'>height</emphasis>
2319 Specify the width and height.
2325 <emphasis remap='I'>width_return</emphasis>
2336 <emphasis remap='I'>height_return</emphasis>
2340 Return the width and height of the object best supported
2341 by the display hardware.
2350 <xref linkend='XQueryBestSize' xrefstyle='select: title'/>
2351 function returns the best or closest size to the specified size.
2353 <symbol>CursorShape</symbol>,
2354 this is the largest size that can be fully displayed on the screen specified by
2357 <symbol>TileShape</symbol>,
2358 this is the size that can be tiled fastest.
2360 <symbol>StippleShape</symbol>,
2361 this is the size that can be stippled fastest.
2363 <symbol>CursorShape</symbol>,
2364 the drawable indicates the desired screen.
2366 <symbol>TileShape</symbol>
2368 <symbol>StippleShape</symbol>,
2369 the drawable indicates the screen and possibly the window class and depth.
2371 <symbol>InputOnly</symbol>
2372 window cannot be used as the drawable for
2373 <symbol>TileShape</symbol>
2375 <symbol>StippleShape</symbol>,
2377 <errorname>BadMatch</errorname>
2382 <xref linkend='XQueryBestSize' xrefstyle='select: title'/>
2384 <errorname>BadDrawable</errorname>,
2385 <errorname>BadMatch</errorname>,
2387 <errorname>BadValue</errorname>
2393 To obtain the best fill tile shape, use
2394 <xref linkend='XQueryBestTile' xrefstyle='select: title'/>.
2396 <indexterm significance="preferred"><primary>XQueryBestTile</primary></indexterm>
2398 <funcsynopsis id='XQueryBestTile'>
2400 <funcdef>Status <function>XQueryBestTile</function></funcdef>
2401 <paramdef>Display<parameter> *display</parameter></paramdef>
2402 <paramdef>Drawable<parameter> which_screen</parameter></paramdef>
2403 <paramdef>unsignedintwidth,<parameter> height</parameter></paramdef>
2404 <paramdef>unsignedint*width_return,<parameter> *height_return</parameter></paramdef>
2411 <emphasis remap='I'>display</emphasis>
2415 Specifies the connection to the X server.
2421 <emphasis remap='I'>which_screen</emphasis>
2425 Specifies any drawable on the screen.
2431 <emphasis remap='I'>width</emphasis>
2442 <emphasis remap='I'>height</emphasis>
2446 Specify the width and height.
2452 <emphasis remap='I'>width_return</emphasis>
2463 <emphasis remap='I'>height_return</emphasis>
2467 Return the width and height of the object best supported
2468 by the display hardware.
2477 <xref linkend='XQueryBestTile' xrefstyle='select: title'/>
2478 function returns the best or closest size, that is, the size that can be
2479 tiled fastest on the screen specified by which_screen.
2480 The drawable indicates the screen and possibly the window class and depth.
2482 <symbol>InputOnly</symbol>
2483 window is used as the drawable, a
2484 <errorname>BadMatch</errorname>
2489 <xref linkend='XQueryBestTile' xrefstyle='select: title'/>
2491 <errorname>BadDrawable</errorname>
2493 <errorname>BadMatch</errorname>
2499 To obtain the best stipple shape, use
2500 <xref linkend='XQueryBestStipple' xrefstyle='select: title'/>.
2502 <indexterm significance="preferred"><primary>XQueryBestStipple</primary></indexterm>
2504 <funcsynopsis id='XQueryBestStipple'>
2506 <funcdef>Status <function>XQueryBestStipple</function></funcdef>
2507 <paramdef>Display<parameter> *display</parameter></paramdef>
2508 <paramdef>Drawable<parameter> which_screen</parameter></paramdef>
2509 <paramdef>unsignedintwidth,<parameter> height</parameter></paramdef>
2510 <paramdef>unsignedint*width_return,<parameter> *height_return</parameter></paramdef>
2517 <emphasis remap='I'>display</emphasis>
2521 Specifies the connection to the X server.
2527 <emphasis remap='I'>which_screen</emphasis>
2531 Specifies any drawable on the screen.
2537 <emphasis remap='I'>width</emphasis>
2548 <emphasis remap='I'>height</emphasis>
2552 Specify the width and height.
2558 <emphasis remap='I'>width_return</emphasis>
2569 <emphasis remap='I'>height_return</emphasis>
2573 Return the width and height of the object best supported
2574 by the display hardware.
2583 <xref linkend='XQueryBestStipple' xrefstyle='select: title'/>
2584 function returns the best or closest size, that is, the size that can be
2585 stippled fastest on the screen specified by which_screen.
2586 The drawable indicates the screen and possibly the window class and depth.
2588 <symbol>InputOnly</symbol>
2589 window is used as the drawable, a
2590 <errorname>BadMatch</errorname>
2595 <xref linkend='XQueryBestStipple' xrefstyle='select: title'/>
2597 <errorname>BadDrawable</errorname>
2599 <errorname>BadMatch</errorname>
2605 To set the fill tile of a given GC, use
2606 <xref linkend='XSetTile' xrefstyle='select: title'/>.
2608 <indexterm significance="preferred"><primary>XSetTile</primary></indexterm>
2610 <funcsynopsis id='XSetTile'>
2612 <funcdef><function>XSetTile</function></funcdef>
2613 <paramdef>Display<parameter> *display</parameter></paramdef>
2614 <paramdef>GC<parameter> gc</parameter></paramdef>
2615 <paramdef>Pixmap<parameter> tile</parameter></paramdef>
2622 <emphasis remap='I'>display</emphasis>
2626 Specifies the connection to the X server.
2632 <emphasis remap='I'>gc</emphasis>
2642 <emphasis remap='I'>tile</emphasis>
2646 Specifies the fill tile you want to set for the specified GC.
2654 The tile and GC must have the same depth,
2656 <errorname>BadMatch</errorname>
2661 <xref linkend='XSetTile' xrefstyle='select: title'/>
2663 <errorname>BadAlloc</errorname>,
2664 <errorname>BadGC</errorname>,
2665 <errorname>BadMatch</errorname>,
2667 <errorname>BadPixmap</errorname>
2673 To set the stipple of a given GC, use
2674 <xref linkend='XSetStipple' xrefstyle='select: title'/>.
2676 <indexterm significance="preferred"><primary>XSetStipple</primary></indexterm>
2678 <funcsynopsis id='XSetStipple'>
2680 <funcdef><function>XSetStipple</function></funcdef>
2681 <paramdef>Display<parameter> *display</parameter></paramdef>
2682 <paramdef>GC<parameter> gc</parameter></paramdef>
2683 <paramdef>Pixmap<parameter> stipple</parameter></paramdef>
2690 <emphasis remap='I'>display</emphasis>
2694 Specifies the connection to the X server.
2700 <emphasis remap='I'>gc</emphasis>
2710 <emphasis remap='I'>stipple</emphasis>
2714 Specifies the stipple you want to set for the specified GC.
2722 The stipple must have a depth of one,
2724 <errorname>BadMatch</errorname>
2729 <xref linkend='XSetStipple' xrefstyle='select: title'/>
2731 <errorname>BadAlloc</errorname>,
2732 <errorname>BadGC</errorname>,
2733 <errorname>BadMatch</errorname>,
2735 <errorname>BadPixmap</errorname>
2741 To set the tile or stipple origin of a given GC, use
2742 <xref linkend='XSetTSOrigin' xrefstyle='select: title'/>.
2744 <indexterm significance="preferred"><primary>XSetTSOrigin</primary></indexterm>
2746 <funcsynopsis id='XSetTSOrigin'>
2748 <funcdef><function>XSetTSOrigin</function></funcdef>
2749 <paramdef>Display<parameter> *display</parameter></paramdef>
2750 <paramdef>GC<parameter> gc</parameter></paramdef>
2751 <paramdef>intts_x_origin,<parameter> ts_y_origin</parameter></paramdef>
2758 <emphasis remap='I'>display</emphasis>
2762 Specifies the connection to the X server.
2768 <emphasis remap='I'>gc</emphasis>
2778 <emphasis remap='I'>ts_x_origin</emphasis>
2789 <emphasis remap='I'>ts_y_origin</emphasis>
2793 Specify the x and y coordinates of the tile and stipple origin.
2801 When graphics requests call for tiling or stippling,
2802 the parent's origin will be interpreted relative to whatever destination
2803 drawable is specified in the graphics request.
2807 <xref linkend='XSetTSOrigin' xrefstyle='select: title'/>
2809 <errorname>BadAlloc</errorname>
2811 <errorname>BadGC</errorname>
2815 <sect2 id='Setting_the_Current_Font'>
2816 <title>Setting the Current Font</title>
2818 <!-- (SN Setting the Current Font -->
2822 To set the current font of a given GC, use
2823 <xref linkend='XSetFont' xrefstyle='select: title'/>.
2825 <indexterm significance="preferred"><primary>XSetFont</primary></indexterm>
2827 <funcsynopsis id='XSetFont'>
2829 <funcdef><function>XSetFont</function></funcdef>
2830 <paramdef>Display<parameter> *display</parameter></paramdef>
2831 <paramdef>GC<parameter> gc</parameter></paramdef>
2832 <paramdef>Font<parameter> font</parameter></paramdef>
2839 <emphasis remap='I'>display</emphasis>
2843 Specifies the connection to the X server.
2849 <emphasis remap='I'>gc</emphasis>
2859 <emphasis remap='I'>font</emphasis>
2871 <xref linkend='XSetFont' xrefstyle='select: title'/>
2873 <errorname>BadAlloc</errorname>,
2874 <errorname>BadFont</errorname>,
2876 <errorname>BadGC</errorname>
2880 <sect2 id="Setting_the_Clip_Region">
2881 <title>Setting the Clip Region</title>
2883 <!-- (SN Setting the Clip Region -->
2887 Xlib provides functions that you can use to set the clip-origin
2888 and the clip-mask or set the clip-mask to a list of rectangles.
2893 To set the clip-origin of a given GC, use
2894 <xref linkend='XSetClipOrigin' xrefstyle='select: title'/>.
2896 <indexterm significance="preferred"><primary>XSetClipOrigin</primary></indexterm>
2898 <funcsynopsis id='XSetClipOrigin'>
2900 <funcdef><function>XSetClipOrigin</function></funcdef>
2901 <paramdef>Display<parameter> *display</parameter></paramdef>
2902 <paramdef>GC<parameter> gc</parameter></paramdef>
2903 <paramdef>intclip_x_origin,<parameter> clip_y_origin</parameter></paramdef>
2910 <emphasis remap='I'>display</emphasis>
2914 Specifies the connection to the X server.
2920 <emphasis remap='I'>gc</emphasis>
2930 <emphasis remap='I'>clip_x_origin</emphasis>
2941 <emphasis remap='I'>clip_y_origin</emphasis>
2945 Specify the x and y coordinates of the clip-mask origin.
2953 The clip-mask origin is interpreted relative to the origin of whatever
2954 destination drawable is specified in the graphics request.
2958 <xref linkend='XSetClipOrigin' xrefstyle='select: title'/>
2960 <errorname>BadAlloc</errorname>
2962 <errorname>BadGC</errorname>
2968 To set the clip-mask of a given GC to the specified pixmap, use
2969 <xref linkend='XSetClipMask' xrefstyle='select: title'/>.
2971 <indexterm significance="preferred"><primary>XSetClipMask</primary></indexterm>
2973 <funcsynopsis id='XSetClipMask'>
2975 <funcdef><function>XSetClipMask</function></funcdef>
2976 <paramdef>Display<parameter> *display</parameter></paramdef>
2977 <paramdef>GC<parameter> gc</parameter></paramdef>
2978 <paramdef>Pixmap<parameter> pixmap</parameter></paramdef>
2985 <emphasis remap='I'>display</emphasis>
2989 Specifies the connection to the X server.
2995 <emphasis remap='I'>gc</emphasis>
3005 <emphasis remap='I'>pixmap</emphasis>
3009 Specifies the pixmap or
3010 <symbol>None</symbol>.
3018 If the clip-mask is set to
3019 <symbol>None</symbol>,
3020 the pixels are always drawn (regardless of the clip-origin).
3024 <xref linkend='XSetClipMask' xrefstyle='select: title'/>
3026 <errorname>BadAlloc</errorname>,
3027 <errorname>BadGC</errorname>,
3028 <errorname>BadMatch</errorname>,
3030 <errorname>BadPixmap</errorname>
3036 To set the clip-mask of a given GC to the specified list of rectangles, use
3037 <xref linkend='XSetClipRectangles' xrefstyle='select: title'/>.
3039 <indexterm significance="preferred"><primary>XSetClipRectangles</primary></indexterm>
3041 <funcsynopsis id='XSetClipRectangles'>
3043 <funcdef><function>XSetClipRectangles</function></funcdef>
3044 <paramdef>Display<parameter> *display</parameter></paramdef>
3045 <paramdef>GC<parameter> gc</parameter></paramdef>
3046 <paramdef>intclip_x_origin,<parameter> clip_y_origin</parameter></paramdef>
3047 <paramdef>XRectangle<parameter> rectangles[]</parameter></paramdef>
3048 <paramdef>int<parameter> n</parameter></paramdef>
3049 <paramdef>int<parameter> ordering</parameter></paramdef>
3056 <emphasis remap='I'>display</emphasis>
3060 Specifies the connection to the X server.
3066 <emphasis remap='I'>gc</emphasis>
3076 <emphasis remap='I'>clip_x_origin</emphasis>
3087 <emphasis remap='I'>clip_y_origin</emphasis>
3091 Specify the x and y coordinates of the clip-mask origin.
3097 <emphasis remap='I'>rectangles</emphasis>
3101 Specifies an array of rectangles that define the clip-mask.
3107 <emphasis remap='I'>n</emphasis>
3111 Specifies the number of rectangles.
3117 <emphasis remap='I'>ordering</emphasis>
3121 Specifies the ordering relations on the rectangles.
3123 <symbol>Unsorted</symbol>,
3124 <symbol>YSorted</symbol>,
3125 <symbol>YXSorted</symbol>,
3127 <symbol>YXBanded</symbol>.
3136 <xref linkend='XSetClipRectangles' xrefstyle='select: title'/>
3137 function changes the clip-mask in the specified GC
3138 to the specified list of rectangles and sets the clip origin.
3139 The output is clipped to remain contained within the
3141 The clip-origin is interpreted relative to the origin of
3142 whatever destination drawable is specified in a graphics request.
3143 The rectangle coordinates are interpreted relative to the clip-origin.
3144 The rectangles should be nonintersecting, or the graphics results will be
3146 Note that the list of rectangles can be empty,
3147 which effectively disables output.
3148 This is the opposite of passing
3149 <symbol>None</symbol>
3151 <xref linkend='XCreateGC' xrefstyle='select: title'/>,
3152 <xref linkend='XChangeGC' xrefstyle='select: title'/>,
3154 <xref linkend='XSetClipMask' xrefstyle='select: title'/>.
3158 If known by the client, ordering relations on the rectangles can be
3159 specified with the ordering argument.
3160 This may provide faster operation
3162 If an incorrect ordering is specified, the X server may generate a
3163 <errorname>BadMatch</errorname>
3164 error, but it is not required to do so.
3165 If no error is generated, the graphics
3166 results are undefined.
3167 <symbol>Unsorted</symbol>
3168 means the rectangles are in arbitrary order.
3169 <symbol>YSorted</symbol>
3170 means that the rectangles are nondecreasing in their Y origin.
3171 <symbol>YXSorted</symbol>
3172 additionally constrains
3173 <symbol>YSorted</symbol>
3175 rectangles with an equal Y origin are nondecreasing in their X
3177 <symbol>YXBanded</symbol>
3178 additionally constrains
3179 <symbol>YXSorted</symbol>
3181 for every possible Y scanline, all rectangles that include that
3182 scanline have an identical Y origins and Y extents.
3186 <xref linkend='XSetClipRectangles' xrefstyle='select: title'/>
3188 <errorname>BadAlloc</errorname>,
3189 <errorname>BadGC</errorname>,
3190 <errorname>BadMatch</errorname>,
3192 <errorname>BadValue</errorname>
3197 Xlib provides a set of basic functions for performing
3199 For information about these functions,
3200 see <link linkend="Manipulating_Regions">section 16.5</link>.
3203 <sect2 id='Setting_the_Arc_Mode_Subwindow_Mode_and_Graphics_Exposure'>
3204 <title>Setting the Arc Mode, Subwindow Mode, and Graphics Exposure</title>
3206 <!-- (SN Setting the Arc Mode, Subwindow Mode, and Graphics Exposure -->
3210 To set the arc mode of a given GC, use
3211 <xref linkend='XSetArcMode' xrefstyle='select: title'/>.
3213 <indexterm significance="preferred"><primary>XSetArcMode</primary></indexterm>
3215 <funcsynopsis id='XSetArcMode'>
3217 <funcdef><function>XSetArcMode</function></funcdef>
3218 <paramdef>Display<parameter> *display</parameter></paramdef>
3219 <paramdef>GC<parameter> gc</parameter></paramdef>
3220 <paramdef>int<parameter> arc_mode</parameter></paramdef>
3227 <emphasis remap='I'>display</emphasis>
3231 Specifies the connection to the X server.
3237 <emphasis remap='I'>gc</emphasis>
3247 <emphasis remap='I'>arc_mode</emphasis>
3251 Specifies the arc mode.
3253 <symbol>ArcChord</symbol>
3255 <symbol>ArcPieSlice</symbol>.
3263 <xref linkend='XSetArcMode' xrefstyle='select: title'/>
3265 <errorname>BadAlloc</errorname>,
3266 <errorname>BadGC</errorname>,
3268 <errorname>BadValue</errorname>
3274 To set the subwindow mode of a given GC, use
3275 <xref linkend='XSetSubwindowMode' xrefstyle='select: title'/>.
3277 <indexterm significance="preferred"><primary>XSetSubwindowMode</primary></indexterm>
3279 <funcsynopsis id='XSetSubwindowMode'>
3281 <funcdef><function>XSetSubwindowMode</function></funcdef>
3282 <paramdef>Display<parameter> *display</parameter></paramdef>
3283 <paramdef>GC<parameter> gc</parameter></paramdef>
3284 <paramdef>int<parameter> subwindow_mode</parameter></paramdef>
3291 <emphasis remap='I'>display</emphasis>
3295 Specifies the connection to the X server.
3301 <emphasis remap='I'>gc</emphasis>
3311 <emphasis remap='I'>subwindow_mode</emphasis>
3315 Specifies the subwindow mode.
3317 <symbol>ClipByChildren</symbol>
3319 <symbol>IncludeInferiors</symbol>.
3327 <xref linkend='XSetSubwindowMode' xrefstyle='select: title'/>
3329 <errorname>BadAlloc</errorname>,
3330 <errorname>BadGC</errorname>,
3332 <errorname>BadValue</errorname>
3338 To set the graphics-exposures flag of a given GC, use
3339 <xref linkend='XSetGraphicsExposures' xrefstyle='select: title'/>.
3341 <indexterm significance="preferred"><primary>XSetGraphicsExposures</primary></indexterm>
3343 <funcsynopsis id='XSetGraphicsExposures'>
3345 <funcdef><function>XSetGraphicsExposures</function></funcdef>
3346 <paramdef>Display<parameter> *display</parameter></paramdef>
3347 <paramdef>GC<parameter> gc</parameter></paramdef>
3348 <paramdef>Bool<parameter> graphics_exposures</parameter></paramdef>
3355 <emphasis remap='I'>display</emphasis>
3359 Specifies the connection to the X server.
3365 <emphasis remap='I'>gc</emphasis>
3375 <emphasis remap='I'>graphics_exposures</emphasis>
3379 Specifies a Boolean value that indicates whether you want
3380 <symbol>GraphicsExpose</symbol>
3382 <symbol>NoExpose</symbol>
3383 events to be reported when calling
3384 <xref linkend='XCopyArea' xrefstyle='select: title'/>
3386 <xref linkend='XCopyPlane' xrefstyle='select: title'/>
3395 <xref linkend='XSetGraphicsExposures' xrefstyle='select: title'/>
3397 <errorname>BadAlloc</errorname>,
3398 <errorname>BadGC</errorname>,
3400 <errorname>BadValue</errorname>