Introduction
Often on the forum there are questions about drawing this or that figure on the canvas, and also ask to give a list of all drawing functions, as they themselves do not understand anything in these Arc's, Chord's and other complex and incomprehensible figures. Therefore, I decided and write this article, which will be useful both for beginners, and perhaps act as a brief guide for the knowledgeable.
This article in no way replaces the relevant literature. No, this is just a small guide that contains only practical information and the bare minimum of theory. All of the above, you can learn in one form or another from any other source, perhaps in a more understandable and "professional" form. And I decided to write everything down purely in a simple and understandable language, because I can't do it any other way, so please don't blame me for possible semantic errors.
And now a couple of words about the structure of this material:
This article consists of 3 parts: The first part is a little guide for
Table of Contents:
1. First steps
1.1 Drawing lines
1.2 How to draw a square using the LineTo method
2. Drawing simple shapes
2.1 Rectangle
2.2 Ellipse
3. Changing the appearance of shapes
3.1 Pen property
3.2 Brush property
4. Filling areas
4.1 Filling areas
4.2. Complex filling (Using the FloodFill method)
5. Text output
5.1 Text appearance
6. Image output
6.1 A brief introduction
6.2 Outputting images to the form canvas using the Draw() method
6.3 Transparency of the output images
6.4 Using the StretchDraw() method
6.5 Copying sections of the canvas
7. Conclusion
1.1. Drawing lines
1 void __fastcall TForm1::Button1Click(TObject *Sender)
2 {
3 Form1->Canvas->LineTo(250,250); //Draw the first line
4 Form1->Canvas->LineTo(500,100); //Now draw another line
5 }
6 //---------------------------------------------------------------------------

But the current pen position can also be changed manually, without drawing any extra lines. To do this, use the MoveTo (x, y) method, where x is the new horizontal pen position and y is the new vertical pen position.
1
2
3
4
5
6
1 void __fastcall TForm1::Button1Click(TObject *Sender)
2 {
3 Form1->Canvas->MoveTo(100,25); //Move the pen to the point (100,25)
4 Form1->Canvas->LineTo(500,100); //Draw a line to the point (500,100)
5 }
6 //---------------------------------------------------------------------------

Often on the forum there are questions about drawing this or that figure on the canvas, and also ask to give a list of all drawing functions, as they themselves do not understand anything in these Arc's, Chord's and other complex and incomprehensible figures. Therefore, I decided and write this article, which will be useful both for beginners, and perhaps act as a brief guide for the knowledgeable.
This article in no way replaces the relevant literature. No, this is just a small guide that contains only practical information and the bare minimum of theory. All of the above, you can learn in one form or another from any other source, perhaps in a more understandable and "professional" form. And I decided to write everything down purely in a simple and understandable language, because I can't do it any other way, so please don't blame me for possible semantic errors.
And now a couple of words about the structure of this material:
This article consists of 3 parts: The first part is a little guide for
Table of Contents:
1. First steps
1.1 Drawing lines
1.2 How to draw a square using the LineTo method
2. Drawing simple shapes
2.1 Rectangle
2.2 Ellipse
3. Changing the appearance of shapes
3.1 Pen property
3.2 Brush property
4. Filling areas
4.1 Filling areas
4.2. Complex filling (Using the FloodFill method)
5. Text output
5.1 Text appearance
6. Image output
6.1 A brief introduction
6.2 Outputting images to the form canvas using the Draw() method
6.3 Transparency of the output images
6.4 Using the StretchDraw() method
6.5 Copying sections of the canvas
7. Conclusion
1.1. Drawing lines
1 void __fastcall TForm1::Button1Click(TObject *Sender)
2 {
3 Form1->Canvas->LineTo(250,250); //Draw the first line
4 Form1->Canvas->LineTo(500,100); //Now draw another line
5 }
6 //---------------------------------------------------------------------------

But the current pen position can also be changed manually, without drawing any extra lines. To do this, use the MoveTo (x, y) method, where x is the new horizontal pen position and y is the new vertical pen position.
1
2
3
4
5
6
1 void __fastcall TForm1::Button1Click(TObject *Sender)
2 {
3 Form1->Canvas->MoveTo(100,25); //Move the pen to the point (100,25)
4 Form1->Canvas->LineTo(500,100); //Draw a line to the point (500,100)
5 }
6 //---------------------------------------------------------------------------
