[fpc-pascal] Fastest way of drawing 2D graphs
Hunter1972
Hunter1972 at mail.ru
Fri Sep 12 01:36:56 CEST 2014
Hello,
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:
...
type
TSingleArray = array of single;
TIntArray = array of integer;
TIntArrayArray = array of TIntArray;
procedure TForm1.FormPaint(Sender: TObject);
var
cb, cb2, iShift: integer;
Times: TSingleArray;
FileDetections: TIntArrayArray;
begin
canvas.Pen.Color:=clBlue;
for cb := 0 to High(FileDetections) do
begin
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);
end;
end;
...
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.
Ravil
-------------- 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