GDI Topics: Lines |
|
Introduction |
A line is a junction of two points. This means that a line has a beginning and an end: The beginning and the end are two distinct points. In real life, before drawing, you should define where you would start. To help with this, the TCanvas class provides the MoveTo() method. Its syntax is: |
void __fastcall MoveTo(int X, int Y);
The X argument represents the horizontal distance of the line beginning from the (0, 0) origin. void __fastcall LineTo(int X, int Y);
The X argument represents the horizontal end of the line from the (0, 0) origin.
We have mentioned that the TCanvas::MoveTo() method is used to set the starting position of a line. When using LineTo(), the line would start from the MoveTo() point to the LineTo() end. As long as you do not call MoveTo(), any subsequent call to LineTo() would draw a line from the previous LineTo() to the new LineTo() point. You can use this property of the LineTo() method to draw various lines. Here is an example:
|
//--------------------------------------------------------------------------- void __fastcall TForm1::FormPaint(TObject *Sender) { Canvas->MoveTo(60, 20); Canvas->LineTo(60, 122); Canvas->LineTo(264, 122); Canvas->LineTo(60, 20); } //--------------------------------------------------------------------------- |
Home | Copyright © 2004-2016, FunctionX, Inc. | |