[fpc-pascal] Fastest way of drawing 2D graphs

Hunter1972 Hunter1972 at mail.ru
Fri Sep 12 01:36:56 CEST 2014

I am new in FPC and want to understand the correct(fastest) methods when drawing 2D graphics.
The task is simple but extensive: to draw about 200 polylines with 50000-200000 points in each.
I have made a test code in OnPaint event:

  TSingleArray = array of single;
  TIntArray = array of integer;
  TIntArrayArray = array of TIntArray;

procedure TForm1.FormPaint(Sender: TObject);
  cb, cb2, iShift: integer;
  Times: TSingleArray;
  FileDetections: TIntArrayArray;
  for cb := 0 to High(FileDetections) do
    iShift := round(Self.Height - cb * Self.Height / High(FileDetections));
    canvas.MoveTo(0, iShift);
    for cb2 := 0 to High(FileDetections[cb]) do
      canvas.LineTo(round(Times[cb2] * Width/15), round(FileDetections[cb, cb2]/20) + iShift);

It works fine (png is attached).

Then I'd like to add some actions to the graphics:
1)Scaling around some point (by mouse wheel), actually magnifying
2)Moving this scaled point quickly to another part of graphics( using scroll bars?)

The main question is:
1)How to correctly organize this drawing that it'll take a lot of time only once before the first display?
Later actions (scaling and moving) should be as fast as possible provided that points array (Times and FileDetections)
are not changed.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: seismic.png
Type: image/png
Size: 84037 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140912/cefc3dbe/attachment.png>

More information about the fpc-pascal mailing list