Line Drawing with a Delphi Canvas
This project shows how the canvas class can be used in Delphi to draw straight lines onto the screen. These lines are drawn via a drag and draw method, clicking on the canvas starts drawing the line, and releasing the button finishes drawing the line - the draw lines button must be clicked before any lines can be drawn.
Whilst drawing lines is the main feature this program is demonstrating, I have also made some other additions:
A snap to grid button allows horizontal and vertical lines to be drawn with ease, drawing on the canvas the nearest 10 pixel to the mouse position.
It is also possible so signify individual rooms by selecting the draw room button, and adding a rectangle to the screen. Clicking on this rectangle selects the room in question.
Finally, it is possible to undo the last 10 drawings made to the canvas object using the undo button.
View and download the code at...
Continue reading →