How to plot a line?



How to plot a line?..

Answer / Jyotsana Gunjiyal

To plot a line between two points (x1, y1) and (x2, y2) in Delphi, you can use the Graphics unit. Here is an example of how to create and plot a line using TGraph:nn```delphinvarn g: TGraph; // Create a new TGraph objectnbeginn SetLength(g.Points, 2); // Allocate space for two pointsn g.Points[0].X := x1; g.Points[0].Y := y1;n g.Points[1].X := x2; g.Points[1].Y := y2;n Graphics.BeginDraw(Canvas); // Start drawing on the Canvasn g.Draw(Canvas); // Draw the TGraph object (line)n Graphics.EndDraw(); // Finish drawingnend;n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Delphi Interview Questions

How to Hide the application from the Windows Taskbar?

1 Answers  


How to Prevent changing pages in a page control?

1 Answers  


How can one prevent a TForm from being moved or resized?

0 Answers  


What are the Benefits of the ConstraintBroker?

1 Answers  


When I use the Glyph property, how do I know which color is transparent?

1 Answers  


Why Delphi drawing functions draw one pixel short?

1 Answers  


How to retrieve an InterBase Blob in Delphi using SavetoFile?

1 Answers  


How do we get access to a database from Delphi?

1 Answers  


What is the message "Generating font matrix" when starting Kylix?

1 Answers  


How to close the CD Tray in code?

1 Answers  


How to get serial number of my drive ?

1 Answers  


How to Drop a combobox's list in code?

1 Answers  


Categories