Rubber Banding Example
Go Up to Overview of Graphics Programming
This example describes the details of implementing the "rubber banding" effect in an graphics application that tracks mouse movements as the user draws a graphic at run time. The example code is from a sample located in the
C:\Users\Public\Documents\Embarcadero\Studio\22.0\Samples\Object Pascal\VCL\Graphex directory (click Start | Programs | Embarcadero RAD Studio Alexandria | Samples and navigate to
\Object Pascal\VCL\Graphex directory). The application draws lines and shapes on a window's canvas in response to clicks and drags: pressing a mouse button starts drawing, and releasing the button ends the drawing.
To start with, the example code shows how to draw on the surface of the main form. Later examples demonstrate drawing on a bitmap.
The following topics describe the example:
- Responding to the Mouse
- Adding a Field to a Form Object to Track Mouse Actions
- Refining Line Drawing