| Simple Graph | Lab Report |
Purpose
Create a simple graph, y = a* | sin(b*x)|. Show the graph in a
single step, or show the graph as it is being drawn.
Materials and Equipment
Software Requirements
Windows 95
Delphi 3 (to recompile)
SimpleGraph.EXEHardware Requirements
VGA display
Procedure
Discussion
The DrawLineGraphs procedure draws lines on the
Image.Canvas, the Printer.Canvas or a Bitmap.Canvas. The DrawState parameter to
DrawLineGraphs is a bit of a kludge. When this parameter has the value ptShowGraph,
and the Dynamic checkbox is checked, the Image is updated every 20th plotted
point.
As a simple way to blank an image, the ButtonClearClick method assigns NIL
to Image.Picture.
Conclusions
This example showed how to create a simple graph "from
scratch" using 2D vectors and a TPantograph object.
In Delphi 3, and for more complicated examples, the new TChart component is
probably a better alternative for small datasets. For very large datasets, this approach
shown here might be attractive.
Keywords
TPantograph, Vector2D, MoveTo, LineTo, Repaint, PointAt, TextOut
Download
Delphi 3 Source and EXE (140 KB): SimpleGraph.ZIP
Updated
14 Sep 2004
since 1 Nov 1998