Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


Shape operations

A graphics context provides line and shape drawing graphics operations for points, lines, and fillable shapes.

[Top]


Lines 

There are three line primitives — straight line, polyline and arc. These are drawn with the pen, with all its current settings. Straight lines can be drawn between two given points, to a single given point from the current internal drawing position, or by moving the internal drawing position by a given vector. They are constructed with the help of a linear DDA.

[Top]


Fillable shapes 

There are five shape drawing primitives —pie slice, ellipse, rectangle, rounded rectangle, and polygon. All may be drawn with or without an outline.

Outlines are drawn with the pen, and thus subject to pen colour, pen size and pen style settings. The effective outline colour depends on the drawing mode. If the pen size has been set to greater than or equal to half the size of the shape, then the shape will be filled with solid pen colour. The pen style should be set to null if no outline is required.

Shapes are filled using the brush, and thus subject to the brush style (colour, hash or pattern) and brush pattern origin. The effective fill colour depends on the drawing mode. The brush style should be set to null if no fill is required.

[Top]


Pen size

Note that when the pen is a single pixel wide:

If the pen size is greater than one pixel, a straight line is drawn as a rectangular shaped region of pixels, with rounded ends that extend beyond the start and end points. See CGraphicsContext::SetPenSize() for details.

[Top]


Rectangles

All the fillable shape drawing primitives, (except DrawPolygon()), either use a rectangle directly or to define the position of an ellipse that is used in the construction of the shape. This rectangle is passed as an argument of type TRect.

Care is needed when specifying rectangles. The TRect class is defined to include the pixel at its top left corner, but to exclude the pixel at its bottom right corner. Thus, a rectangle specified as:

TRect(TPoint(100,50),TPoint(300,150))

includes the point (100,50) but not the point (300,150). No pixels will be written to column 300, nor to row 150, on the display. The rectangle drawn on the screen will be 300–100=200 pixels wide, and 150–50=100 pixels high.

[Top]


Ellipses

Ellipses whose axes are aligned with the x and y axes of the co-ordinate system, are supported; other ellipses are not. Ellipses are defined with reference to their bounding rectangle. The comments above on the behaviour of TRect also need to be observed when drawing ellipses. Arcs, pie slices and the corners of rounded rectangles are all defined as sections of an ellipse.

[Top]


See also

The linear DDA.