|
GEOS SDK TechDocs|
|
6 Graphics State |
6.2 Working with GStates
Sometimes it's convenient to think of the GState as being analogous to the Properties boxes in GeoDraw. The GState keeps track of how the program wants to draw lines, text, and filled areas, just as the Line Properties, Text Properties, and Area Properties boxes keep track of how the GeoDraw user wants to draw these objects.
While handy, this analogy doesn't do the GState justice. The GState keeps track of many things:
-
Mix Mode
The graphics system allows for different mix modes (sometimes known as copy modes). These drawing modes permit the geode to draw in such ways that it erases instead of drawing, draws using the inverse of whatever it's drawing on, or uses various other modes.
-
Current Position (also known as Pen Position)
The graphics system keeps track of the position of the last thing drawn. If your geode wants to draw something else at this location, there are drawing commands that will draw at the current position.
-
Area Attributes
The GState contains information that the graphics system will use when filling areas. This information includes the color and fill pattern to use.
-
Line attributes
The graphics system uses information stored in the Graphics State to keep track of what color and pattern to use when drawing lines. The GState also keeps track of whether lines should be drawn as dotted, and if so what sort of dot-dash pattern to use. The GState contains the line width. It also contains line join information, which controls how lines will be drawn when they meet at an angle, as at the vertices of a polygon.
-
Text Attributes
The Graphics State contains the ID of the current font, the font size, and the text style. It also contains a color and pattern to use, information about the font, and some esoteric text-drawing options.
-
Coordinate Space Transformations
The GState keeps track of the current coordinate space transformation. If there is an associated window, the window's transformation matrix is maintained separately with the window's information.
-
Associated Window
The GState knows the handle of the window associated with the GState. This is the window that will determine where drawings appear and how they are clipped.
-
Associated GString
If the application is building a GString, the GState is aware of it. The GState contains a reference to the GString. When the graphics system turns graphics commands into GString elements, these elements will be appended to the referenced GString.
-
Associated Path
If the application is building a path, the GState contains a pointer to the path along which new path elements are passed, similar to the way GString elements are passed. The GState also keeps track of whether the current path is to be combined with another path or should be used "as is."
-
Clipping Information
The GState keeps track of clipping information in addition to that maintained by the window.
The function of many of these parts may be fairly intuitive to someone used to working with graphics programs. Some of the others may require additional explanation, especially when it comes to how to work with them.
|
GEOS SDK TechDocs|
|
6 Graphics State |
6.2 Working with GStates