kota kota wroteok here is an example,
(look the red letters)
OK, I see what you mean... I improved the performance very slightly by reducing the two for loops to a single one. I also updated the uses clause to the latest revision of fpGUI Toolkit. I also removed all the unnecessary .BeginDraw and .EndDraw calls. The whole HandlePaint method that you override is alread wrapped in a begindraw..enddraw call for double buffering support.
Unfortunately I am not sure how to show the image while it is being generated. How is this done in Delphi VCL or Lazarus LCL?
Also, fpGUI Toolkit doesn't support painting to a Image via Canvas calls. This is planned for later this year, when I implement support for the Free Pascal fpimage and fpcanvas units (part of Free Pascal's FCL packages).
PS:
I highly recommend you rather use the Source Code directly from the git repository, and not the last released version. The v0.6 is rather old. See the following url for more details:
http://opensoft.homeip.net/fpgui/index.html#Sourcecode
======================================
program drawtest;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes,
fpg_main,
fpg_base,
fpg_form,
Math,
crt,
fpg_imgfmt_bmp;
type
TMainForm = class(TfpgForm)
private
R: real;
n: integer;
procedure PreCalculations;
procedure GenerateImage;
protected
procedure HandlePaint; override;
public
constructor Create(AOwner: TComponent); override;
end;
const
m = 10000;
l1 = 1;
l2 = 2;
var
results: array [1..m] of integer;
intS: array[1..m, 1..2] of integer;
i: longint;
x2, y2: integer;
function logos(c, b: integer): integer;
begin
Result := (1 * c + 1 * b) div 2;
end;
{ TMainForm }
constructor TMainForm.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
WindowTitle := 'Ελληνικά γράμματα ';
SetPosition(10, 10, 1024, 768);
Sizeable := False;
PreCalculations;
end;
procedure MainProc;
var
frm: TMainForm;
begin
fpgApplication.Initialize;
frm := TMainForm.Create(nil);
try
frm.Show;
fpgApplication.Run;
finally
frm.Free;
end;
end;
procedure TMainForm.PreCalculations;
begin
n := 3;
R := intpower(380, n);
end;
procedure TMainForm.GenerateImage;
begin
end;
procedure TMainForm.HandlePaint;
var
x, y, u: real;
k: integer;
begin
// inherited HandlePaint;
{ We are doing all the painting, so no need to call inherited }
Canvas.Clear(clWhite);
k := 0;
u := pi / 2;
for i := 1 to n do
begin
x := power(R, (1 / n)) * cos(((2 * k * pi + u) / n)) + 512;
y := power(R, (1 / n)) * sin(((2 * k * pi + u) / n)) + 384;
ints[i, 1] := trunc(x);
ints[i, 2] := trunc(y);
k := k + 1;
end;{For-loop}
Canvas.SetColor(clBlack);
Canvas.DrawLine(intS[1, 1], intS[1, 2], intS[n, 1], intS[n, 2]);
for i := 2 to n do
Canvas.DrawLine(intS[i - 1, 1], intS[i - 1, 2], ints[i, 1],
intS[i, 2]);
{ if m is very big (e.g 1000000) the user gets a black screen until
all the points are drawn }
X2 := 500;
y2 := 500;
for i := 1 to m do
begin
results[i] := random(n) + 1;
x2 := logos(x2, intS[results[i], 1]);
y2 := logos(y2, intS[results[i], 2]);
Canvas.Pixels[x2, y2] := clBlack;
end;{For-loop}
end;
begin
Randomize;
MainProc;
end.
======================================
Regards,
- Graeme -
_______________________________________________________ fpGUI - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/