unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls,
BGRAVirtualScreen, BGRABitmap, BGRABitmapTypes;
type
{ TForm1 }
TForm1 = class(TForm)
BGRAVirtualScreen1: TBGRAVirtualScreen;
Timer1: TTimer;
procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure DotPlot();
private
public
end;
var
Form1: TForm1;
message_bitmap,message_bitmap1,bm : TBGRABitmap;
message : Array[0..19] Of String =('2222222222222222222222222222222222222222222222222222222222222222',
'2222222222222222222222222222222222222222222222222222222222222222',
'2200000000000000000000000000000000000000000000000000000000000022',
'2200001111111111111100011111111111111000111111111111100000000022',
'2200001000000000000000000000001000000000100000000000100000000022',
'2200001000000000000000000000001000000000100000000000100000000022',
'2200001000000000000000000000001000000000100000000000100000000022',
'2200001000000000000000000000001000000000100000000000100000000022',
'2200001000000000000000000000001000000000100000000000100000000022',
'2200001000000000000000000000001000000000111111111111000000000022',
'2200001000011111111100000000001000000000100110000000000000000022',
'2200001000000000000100000000001000000000100001100000000000000022',
'2200001000000000000100000000001000000000100000010000000000000022',
'2200001000000000000100000000001000000000100000001100000000000022',
'2200001000000000000100000000001000000000100000000010000000000022',
'2200001000000000000100000000001000000000100000000001000000000022',
'2200001111111111111100000000001000000000100000000000100000000022',
'2200000000000000000000000000000000000000000000000000000000000022',
'2222222222222222222222222222222222222222222222222222222222222222',
'2222222222222222222222222222222222222222222222222222222222222222');
pos_x,pos_y,x,y : integer;
ta,xapp,yapp : single;
// dot plot
s,a,ag : single;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Timer1Timer(Sender: TObject);
begin
BGRAVirtualScreen1.RedrawBitmap;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
pos_x := 0;
pos_y := 0;
ta :=0;
xapp :=0;
yapp :=0;
message_bitmap := TBGRABitmap.Create(ClientWidth,ClientHeight,BGRABlack);
message_bitmap1 := TBGRABitmap.Create(ClientWidth,ClientHeight,BGRABlack); // buffer
// plot fx
s := 255/sqrt(3)*2/30;
a := 0.0;
// angle
ag := 0.0;
end;
procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
begin
DotPlot();
Bitmap.PutImage(0,0,message_bitmap,dmDrawWithTransparency);
end;
procedure TForm1.DotPlot;
var
ii,jj : integer;
r,z,x1,x2,y1,y2 : single;
begin
message_Bitmap1.FillRect(0,0,ClientWidth,ClientHeight,BGRA(10,10,10)); // clear screen
for ii:=1 to 64 do
begin
for jj:=0 to High(message) do
begin
ta := ta + 0.00004;
xapp := x + 32 * sin(ta-jj*0.2);
yApp := y + 4 * sin(tA-jj*0.1+ii/2) ;
r := (sqrt(ii*ii+jj*jj))+2;
z := 10*sin(r+a*0.6)/r*0.8;
x2 := -jj*cos(a*PI/180)-jj*sin(ag*PI/180);
y2 := ii*sin(a*PI/180)-jj*cos(ag*PI/180);
x1 := round(60+(y2-x2)*s*sqrt(3)/2);
y1 := round(120+z-(y2+x2)*s/2);
pos_x := round(x1+xApp)+ii*12;
pos_y := round(y1+yApp)+jj*12;
if(message[jj][ii]='1') then message_Bitmap1.FillRect(pos_x, pos_y,pos_x+3,pos_y+3,BGRA(255,0,0,255),dmSet)
else if
(message[jj][ii]='2') then message_Bitmap1.FillRect(pos_x, pos_y,pos_x+3,pos_y+3,BGRA(0,125,255,255),dmSet)
else
message_Bitmap1.FillRect(pos_x,pos_y,pos_x+3,pos_y+3,BGRA(255,255,255,255),dmSet);
end;
end;
ag := ag + 0.4;
message_bitmap.PutImage(0,0,message_bitmap1,dmSet);
end;
end.