|
||
A graphics context includes the following settings:
This is used to determine the logical operation used to put pen or brush colour onto the graphics device. The usual modes are: no effect; write colour; and exclusive or. Other possible logical combinations are supported.
The pen is used for free line and shape outline drawing and also for text. The line styles include solid and various dot and dash combinations. Lines may be drawn in various sizes.
The brush is used for filling areas drawn with the shape primitives, and also for text background fills. You can specify a colour, pattern and style. The brush also has an origin point for the pattern. The way the brush fills depends on the drawing mode. A bitmap pattern may be used and then discarded.
Font specification allows for a variety of typefaces and styles for sizes (bold, underline, italic, etc.). Text colour (foreground) depends on the pen colour and drawing mode. Text background fill depends on the brush settings. Text justification may be set for word justification, or full WYSIWYG with character justification. A font may be used and then discarded.
All GDI operations take place within a co-ordinate system. By default the pixel in the top left corner of the screen is the origin, and has co-ordinates (0,0). The co-ordinates of the pixel in the bottom right of the screen depend on the dimensions of the display in use.
There is a function to set the position of the origin of a graphics context: CGraphicsContext::SetOrigin()
. All subsequent drawing operations are then done relative to this new origin.
A graphics context maintains an internal drawing position relative to its origin. This can be set, without drawing, by using:
CGraphicsContext::MoveTo()
CGraphicsContext::MoveBy()
The internal drawing position is also changed to the last point of the line(s) drawn by the operations:
CGraphicsContext::DrawLine()
CGraphicsContext::DrawLineTo()
CGraphicsContext::DrawLineBy()
CGraphicsContext::DrawPolyline()
The internal drawing position is used as the start point of the line drawn by:
CGraphicsContext::DrawLineTo()
CGraphicsContext::DrawLineBy()