Symbian3/SDK/Source/GUID-D38C47AD-ED05-5693-A734-498788B9B85B.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Wed, 31 Mar 2010 11:11:55 +0100
changeset 7 51a74ef9ed63
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 12 contribution of API Specs and fix SDK submission

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-D38C47AD-ED05-5693-A734-498788B9B85B"><title>Using Relative and Sequential Drawing</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>This topic provides examples that demonstrate how to draw a triangle first using relative drawing with a thin solid line, then using relative drawing and a wide line (illustrating curved corners) and finally using sequential drawing between points, with a dot dash line, illustrating line pattern continuation. </p> <p>Note that there is a third way to draw a triangle, using <codeph>DrawPolygon()</codeph>. This must be to used to draw a filled triangle. </p> <section><title>Drawing a triangle using relative drawing (thin lines)</title> <p>You can draw a triangle of thin lines, using relative drawing, <codeph>MoveTo()</codeph> and <codeph>DrawLineBy()</codeph>. </p> <codeblock id="GUID-45B63152-282C-5E8C-8539-0350CC25649A" xml:space="preserve">...
// 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)
...</codeblock> <p> <b>Note</b>: The sum of the three <codeph>TPoint</codeph> vectors used by the <codeph>DrawLineBy()</codeph> calls comes to <codeph>(0,0)</codeph>, thus creating a closed shape. </p> </section> <section><title>Drawing a triangle using relative drawing (thick lines)</title> <p>You can draw a triangle of thick lines, using relative drawing, <codeph>MoveTo()</codeph> and <codeph>DrawLineBy()</codeph>. </p> <codeblock id="GUID-9AF54D2D-16E8-5C2E-9022-A692D37FF4EA" xml:space="preserve">...
// 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)
...</codeblock> </section> <section><title>Drawing a triangle using sequential drawing between points</title> <p>This topic provides an example that demonstrates how to draw a triangle of dot dash lines, using sequential drawing between points, <codeph>DrawLineTo()</codeph>. </p> <codeblock id="GUID-C7DDA7DC-1B49-5AD0-99A9-45807AF76C40" xml:space="preserve">...
// 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)
...</codeblock> <p> <b>Note</b>: The final point drawn to is the same as the point originally moved to, thus creating a closed shape. </p> </section> </conbody><related-links><link href="GUID-55C8C429-1BEC-5A58-94EC-DA1E51F62867.dita"><linktext>Drawing
                to a Graphics Context Tutorials</linktext> </link> <link href="GUID-E3AC8F3E-9D5C-5E7D-9760-023B77C7C8A8.dita"><linktext>Drawing and Graphics Contexts</linktext> </link> </related-links></concept>