unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
Buttons, BGRAVirtualScreen, basslight, basscode, BGRABitmap, BGRABitmapTypes;
type
{ TForm1 }
TForm1 = class(TForm)
BGRAVirtualScreen1: TBGRAVirtualScreen;
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
Panel1: TPanel;
Timer1: TTimer;
procedure BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
public
end;
var
Form1: TForm1;
// dots related
off,addq : single;
// text
pos_y : integer;
s_sin : single;
stopped : boolean;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
LoadBASS;
StartBASS;
addq :=0.0;
pos_y :=600;
stopped := true;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
PlayFreeBASS;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
dec(pos_y);
if(pos_y<-40) then pos_y :=600;
s_sin := s_sin +0.02;
BGRAVirtualScreen1.RedrawBitmap;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if stopped then
begin
if OpenDialog1.Execute then
begin
PlayFreeBASS;
PlayBASS(PChar(OpenDialog1.FileName),false,0,30);
stopped :=false;
addq :=0.01;
end
else ShowMessage('Can''t play the file');
end;
end;
procedure TForm1.BGRAVirtualScreen1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
var
i,maxdot : integer;
angle, posx, posy,pos2: single;
begin
/// dot
maxdot := 79 ;
for i:=0 to maxdot do
begin
angle := 2* Pi / maxdot * i+off*1.4;
posx := 400 + 180 * Cos(angle + off)+sin(off)*30;
pos2 := 400 + 180 * -Cos(angle + off)+sin(off)*30;
posy := 230 + 220 * Sin(angle);
bitmap.FillRect(round(pos2),round(posy),round(pos2+4),round(posy+4),BGRA(0,195,255),dmSet);
bitmap.FillRect(round(posx),round(posy),round(posx+4),round(posy+4),BGRA(0,195,255),dmSet);
end;
off := off + addq ;
bitmap.TextOut(50+80*sin(s_sin*4.0),pos_y,'BASS DLL EXAMPLE ',BGRA(1-pos_y div 5,255,255));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
PlayFreeBASS;
stopped := true;
addq := 0.00 ;
end;
end.