Most attributes of graphics operations are stored in GCs. These include line width, line style, plane mask, foreground, background, tile, stipple, clipping region, end style, join style, and so on. Graphics operations (for example, drawing lines) use these values to determine the actual drawing operation.
x:create-gc. The order in which components are verified and
altered is server dependent. If an error occurs, a subset of the
components may have been altered.
Both x:create-gc and x:change-gc take one argument
followed by pairs of arguments, where the first is one of the
property-name symbols (or its top-level value) listed below; and the
second is the value to associate with that property.
x:G-Xclear 0 x:G-Xand (AND src dst) x:G-Xand-Reverse (AND src (NOT dst)) x:G-Xcopy src x:G-Xand-Inverted (AND (NOT src) dst) x:G-Xnoop dst x:G-Xxor (XOR src dst) x:G-Xor (OR src dst) x:G-Xnor (AND (NOT src) (NOT dst)) x:G-Xequiv (XOR (NOT src) dst) x:G-Xinvert (NOT dst) x:G-Xor-Reverse (OR src (NOT dst)) x:G-Xcopy-Inverted (NOT src) x:G-Xor-Inverted (OR (NOT src) dst) x:G-Xnand (OR (NOT src) (NOT dst)) x:G-Xset 1
Many graphics operations depend on either pixel values or planes in a GC. The planes attribute is an integer which specifies which planes of the destination are to be modified, one bit per plane. A monochrome display has only one plane and will be the least significant bit of the integer. As planes are added to the display hardware, they will occupy more significant bits in the plane mask.
In graphics operations, given a source and destination pixel, the result
is computed bitwise on corresponding bits of the pixels. That is, a
Boolean operation is performed in each bit plane. The plane-mask
restricts the operation to a subset of planes. x:All-Planes can be
used to refer to all planes of the screen simultaneously. The result is
computed by the following:
(OR (AND (FUNC src dst) plane-mask) (AND dst (NOT plane-mask)))
Range checking is not performed on a plane-mask value. It is simply truncated to the appropriate number of bits.
Note that foreground and background are not initialized to any values likely to be useful in a window.
Thin lines (zero line-width) are one-pixel-wide lines drawn using an unspecified, device-dependent algorithm. There are only two constraints on this algorithm.
A wide line drawn from [x1,y1] to [x2,y2] always draws the same pixels as a wide line drawn from [x2,y2] to [x1,y1], not counting cap-style and join-style. It is recommended that this property be true for thin lines, but this is not required. A line-width of zero may differ from a line-width of one in which pixels are drawn. This permits the use of many manufacturers' line drawing hardware, which may run many times faster than the more precisely specified wide lines.
In general, drawing a thin line will be faster than drawing a wide line of width one. However, because of their different drawing algorithms, thin lines may not mix well aesthetically with wide lines. If it is desirable to obtain precise and uniform results across all displays, a client should always use a line-width of one rather than a linewidth of zero.
The cap-style defines how the endpoints of a path are drawn:
The join-style defines how corners are drawn for wide lines:
The fill-style defines the contents of the source for line, text, and fill requests. For all text and fill requests (for example, X:Draw-Text, X:Fill-Rectangle, X:Fill-Polygon, and X:Fill-Arc); for line requests with linestyle x:Line-Solid (for example, X:Draw-Line, X:Draw-Segments, X:Draw-Rectangle, X:Draw-Arc); and for the even dashes for line requests with line-style x:Line-On-Off-Dash or x:Line-Double-Dash, the following apply:
When drawing lines with line-style x:Line-Double-Dash, the odd dashes are controlled by the fill-style in the following manner:
A clockwise directed path segment is one that crosses the ray from left to right as observed from the point. A counterclockwise segment is one that crosses the ray from right to left as observed from the point. The case where a directed line segment is coincident with the ray is uninteresting because you can simply choose a different ray that is not coincident with a segment.
For both x:Even-Odd-Rule and x:Winding-Rule, a point is infinitely small, and the path is an infinitely thin line. A pixel is inside if the center point of the pixel is inside and the center point is not on the boundary. If the center point is on the boundary, the pixel is inside if and only if the polygon interior is immediately to its right (x increasing direction). Pixels with centers on a horizontal edge are a special case and are inside if and only if the polygon interior is immediately below (y increasing direction).
The tile pixmap must have the same root and depth as the GC, or an error results. The stipple pixmap must have depth one and must have the same root as the GC, or an error results. For stipple operations where the fill-style is x:Fill-Stippled but not x:Fill-Opaque-Stippled, the stipple pattern is tiled in a single plane and acts as an additional clip mask to be ANDed with the clip-mask. Although some sizes may be faster to use than others, any size pixmap can be used for tiling or stippling.
x:Include-Inferiors on a window of one depth with mapped
inferiors of differing depth is not illegal, but the semantics are
undefined by the core protocol.
X:Set-Region. Only
pixels where the clip-mask has a bit set to 1 are drawn. Pixels are not
drawn outside the area covered by the clip-mask or where the clip-mask
has a bit set to 0. The clip-mask affects all graphics requests. The
clip-mask does not clip sources. The clip-mask origin is interpreted
relative to the origin of whatever destination drawable is specified in
a graphics request.
The unit of measure for dashes is the same for the ordinary coordinate system. Ideally, a dash length is measured along the slope of the line, but implementations are only required to match this ideal for horizontal and vertical lines. Failing the ideal semantics, it is suggested that the length be measured along the major axis of the line. The major axis is defined as the x axis for lines drawn at an angle of between -45 and +45 degrees or between 135 and 225 degrees from the x axis. For all other lines, the major axis is the y axis.