[fpc-pascal] gtk+ linux-windows

kota kota youkol123 at gmail.com
Wed Jun 24 11:57:30 CEST 2009


ok here is an example,
(look the red letters)


///////////////////////////////////////////////////////////////////////////////////////
program drawtest;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes,
  fpgfx,
  gfxbase,
  gui_form,
  math,crt,
  gfx_imgfmt_bmp;

type

  TMainForm = class(TfpgForm)
   public
  img: TfpgImage;
     constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;
     procedure   HandlePaint; override;
      end;

Const

m=1000;

Var
 results : array [1..m] of integer;
   intS : array[1..m,1..2] of integer;


    i     :longint;
    x2,y2,l1,l2 :integer;
frm: TMainForm;

{ TMainForm }
FUNCTION logos(c,b :integer): integer;
BEGIN
  logos:= (l1*c+(l2-l1)*b) div (l2)
 END;

constructor TMainForm.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  WindowTitle := 'Ελληνικά γράμματα ';
  SetPosition(1000, 1000, 1024, 768);
   Sizeable := False;

end;

destructor TMainForm.Destroy;
begin
  img.Free;
  inherited Destroy;
end;
procedure MainProc;

begin
  fpgApplication.Initialize;
  frm := TMainForm.Create(nil);
  frm.Show;
  fpgApplication.Run;
  frm.Free;
end;
procedure TMainForm.HandlePaint;


var
x,R,y,u:real;
n,k:integer;
Begin

  Canvas.BeginDraw;
  inherited HandlePaint;
  Canvas.Clear(clWhite);
  Canvas.DrawImage(1024, 768, img);
l1:=1;
l2:=2;
    n:=3;
    R:=intpower(380,n);

    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]);

    Canvas.EndDraw;
    Randomize;

    For i:=1 to m do
    begin
        results[i]:=random(n)+1;
    end;{For-loop}
X2:= 500;
y2:=500;

For i:=1 to m do  *// if m is very big (e.g 1000000) the user gets a black
screen until all the points are drawn *
    Begin
        x2:=logos(x2,intS[results[i],1]);
        y2:=logos(y2,intS[results[i],2]);
    Canvas.BeginDraw;
         Canvas.Pixels[x2, y2] := clblack;
    Canvas.EndDraw;
    end;{For-loop}

end;

begin
  MainProc;
end.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

So  is there any way to show to the user the points *the moment* they are
drawn ? In other words i want to make a window which draws and shows points
real-time.

Is these explanation good enough ? If it isn't, i can make a more simple
example.




2009/6/24 Graeme Geldenhuys <graemeg at opensoft.homeip.net>

> kota kota wrote:
>
>>
>> Now i need some more specific information: Is there any way to show the
>> drawing's steps(created on a Canvas) before the final image is ready?
>>
>
> Sorry, I do not understand? What drawings?
>
>
>
> Regards,
> - Graeme -
>
> ________________________________________________
> fpGUI - a cross-platform Free Pascal GUI toolkit
>
> http://opensoft.homeip.net/fpgui/
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20090624/d0cc57a0/attachment.html>


More information about the fpc-pascal mailing list