Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



How to use relative and sequential drawing

In the following example code a triangle is drawn:

Note that there is a third way to draw a triangle, using DrawPolygon(). This must be to used to draw a filled triangle.


Drawing a triangle using relative drawing (thin lines)

You can draw a triangle of thin lines, using relative drawing, MoveTo() and DrawLineBy().

...
// draw a triangle by relative drawing
gc.MoveTo(TPoint(300,50)); // drawing position (300,50)
gc.DrawLineBy(TPoint(205,100)); // drawing position (505,150)
gc.DrawLineBy(TPoint(-410,0)); // drawing position (95,150)
gc.DrawLineBy(TPoint(205,-100)); // drawing position (300,50)
...


Note

[Top]


Drawing a triangle using relative drawing (thick lines)

You can draw a triangle of thick lines, using relative drawing, MoveTo() and DrawLineBy().

...
// draw a triangle, by relative drawing
// illustrating rounded ends at corners when using very wide lines
gc.SetPenWidth(penSizeFat);
gc.MoveTo(TPoint(300,50)); // drawing position (300,50)
gc.DrawLineBy(TPoint(205,100)); // drawing position (505,150)
gc.DrawLineBy(TPoint(-410,0)); // drawing position (95,150)
gc.DrawLineBy(TPoint(205,-100)); // drawing position (300,50)
...

[Top]


Drawing a triangle using sequential drawing between points

You can draw a triangle of dot dash lines, using sequential drawing between points, DrawLineTo().

...
// draw a triangle by sequential drawing between specified points,
// using dot-dash line style, illustrating line pattern continuation
gc.SetPenStyle(CGraphicsContext::EDotDashPen);
gc.MoveTo(TPoint(300,50)); // drawing position (300,50)
gc.DrawLineTo(TPoint(505,150)); // drawing position (505,150)
gc.DrawLineTo(TPoint(95,150)); // drawing position (95,150)
gc.DrawLineTo(TPoint(300,50)); // drawing position (300,50)
...


Note