Стартовый пул
This commit is contained in:
147
bgracontrols/test/test_extra/effect_fading/fading.lpi
Normal file
147
bgracontrols/test/test_extra/effect_fading/fading.lpi
Normal file
@@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="fading"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="2">
|
||||
<Item1 Name="Debug" Default="True"/>
|
||||
<Item2 Name="Release">
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="fading"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
<Optimizations>
|
||||
<OptimizationLevel Value="3"/>
|
||||
</Optimizations>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<GenerateDebugInfo Value="False"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<MsgFileName Value=""/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</Item2>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="bgracontrols"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="fading.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="fading"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="fading"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<IncludeAssertionCode Value="True"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<CodeGeneration>
|
||||
<Checks>
|
||||
<IOChecks Value="True"/>
|
||||
<RangeChecks Value="True"/>
|
||||
<OverflowChecks Value="True"/>
|
||||
<StackChecks Value="True"/>
|
||||
</Checks>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf2Set"/>
|
||||
<UseHeaptrc Value="True"/>
|
||||
<UseExternalDbgSyms Value="True"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<MsgFileName Value=""/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
21
bgracontrols/test/test_extra/effect_fading/fading.lpr
Normal file
21
bgracontrols/test/test_extra/effect_fading/fading.lpr
Normal file
@@ -0,0 +1,21 @@
|
||||
program fading;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, Unit1
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
104
bgracontrols/test/test_extra/effect_fading/unit1.lfm
Normal file
104
bgracontrols/test/test_extra/effect_fading/unit1.lfm
Normal file
@@ -0,0 +1,104 @@
|
||||
object Form1: TForm1
|
||||
Left = 353
|
||||
Height = 240
|
||||
Top = 169
|
||||
Width = 501
|
||||
Caption = 'Fading'
|
||||
ClientHeight = 240
|
||||
ClientWidth = 501
|
||||
OnCloseQuery = FormCloseQuery
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
LCLVersion = '1.1'
|
||||
object bgImage: TBGRAGraphicControl
|
||||
Left = 15
|
||||
Height = 108
|
||||
Top = 16
|
||||
Width = 185
|
||||
OnRedraw = bgImageRedraw
|
||||
Color = clWhite
|
||||
ColorOpacity = 128
|
||||
Alignment = taCenter
|
||||
Caption = 'bgImage'
|
||||
end
|
||||
object cbFadingMode: TComboBox
|
||||
Left = 208
|
||||
Height = 23
|
||||
Top = 16
|
||||
Width = 180
|
||||
ItemHeight = 15
|
||||
OnChange = cbFadingModeChange
|
||||
Style = csDropDownList
|
||||
TabOrder = 0
|
||||
end
|
||||
object seFadingStep: TSpinEdit
|
||||
Left = 208
|
||||
Height = 23
|
||||
Top = 45
|
||||
Width = 114
|
||||
MaxValue = 255
|
||||
MinValue = 1
|
||||
OnChange = seFadingStepChange
|
||||
TabOrder = 1
|
||||
Value = 5
|
||||
end
|
||||
object seTimerInterval: TSpinEdit
|
||||
Left = 208
|
||||
Height = 23
|
||||
Top = 73
|
||||
Width = 114
|
||||
MaxValue = 1000
|
||||
MinValue = 1
|
||||
OnChange = seTimerIntervalChange
|
||||
TabOrder = 2
|
||||
Value = 16
|
||||
end
|
||||
object Label1: TLabel
|
||||
Left = 336
|
||||
Height = 15
|
||||
Top = 49
|
||||
Width = 62
|
||||
Caption = 'Fading Step'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 336
|
||||
Height = 15
|
||||
Top = 77
|
||||
Width = 73
|
||||
Caption = 'Timer Interval'
|
||||
ParentColor = False
|
||||
end
|
||||
object Label3: TLabel
|
||||
Left = 15
|
||||
Height = 15
|
||||
Top = 144
|
||||
Width = 31
|
||||
Caption = 'Alpha'
|
||||
ParentColor = False
|
||||
end
|
||||
object seDuration: TSpinEdit
|
||||
Left = 208
|
||||
Height = 23
|
||||
Top = 101
|
||||
Width = 114
|
||||
Increment = 100
|
||||
MaxValue = 10000
|
||||
OnChange = seDurationChange
|
||||
TabOrder = 3
|
||||
end
|
||||
object Label4: TLabel
|
||||
Left = 336
|
||||
Height = 15
|
||||
Top = 105
|
||||
Width = 73
|
||||
Caption = 'Duration (ms)'
|
||||
ParentColor = False
|
||||
end
|
||||
object Timer1: TTimer
|
||||
Interval = 33
|
||||
OnTimer = Timer1Timer
|
||||
left = 16
|
||||
top = 16
|
||||
end
|
||||
end
|
149
bgracontrols/test/test_extra/effect_fading/unit1.pas
Normal file
149
bgracontrols/test/test_extra/effect_fading/unit1.pas
Normal file
@@ -0,0 +1,149 @@
|
||||
unit Unit1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
||||
StdCtrls, BGRAGraphicControl, BGRABitmap, BGRABitmapTypes, BCFilters, Spin, BCEffect;
|
||||
|
||||
type
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
bgImage: TBGRAGraphicControl;
|
||||
cbFadingMode: TComboBox;
|
||||
Label1: TLabel;
|
||||
Label2: TLabel;
|
||||
Label3: TLabel;
|
||||
Label4: TLabel;
|
||||
seFadingStep: TSpinEdit;
|
||||
seTimerInterval: TSpinEdit;
|
||||
seDuration: TSpinEdit;
|
||||
Timer1: TTimer;
|
||||
procedure bgImageRedraw(Sender: TObject; Bitmap: TBGRABitmap);
|
||||
procedure cbFadingModeChange(Sender: TObject);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure seDurationChange(Sender: TObject);
|
||||
procedure seFadingStepChange(Sender: TObject);
|
||||
procedure seTimerIntervalChange(Sender: TObject);
|
||||
procedure Timer1Timer(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
Fade: TFading;
|
||||
{$ifdef Windows}
|
||||
FadeForm: TFading;
|
||||
{$endif}
|
||||
Image: TBGRABitmap;
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.bgImageRedraw(Sender: TObject; Bitmap: TBGRABitmap);
|
||||
begin
|
||||
// set black background
|
||||
Bitmap.Fill(BGRABlack);
|
||||
// draw image with fading alpha
|
||||
Bitmap.BlendImageOver(0, 0, Image, boLinearBlend, Fade.Alpha);
|
||||
end;
|
||||
|
||||
procedure TForm1.cbFadingModeChange(Sender: TObject);
|
||||
begin
|
||||
// set fading mode
|
||||
Fade.Mode := StrToTFadingMode(cbFadingMode.Caption);
|
||||
// reset
|
||||
Fade.Reset;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
begin
|
||||
{$ifdef Windows}
|
||||
if (FadeForm.Alpha > 0) then
|
||||
begin
|
||||
FadeForm.Mode := fmFadeOut;
|
||||
CanClose := False;
|
||||
end
|
||||
else
|
||||
CanClose := True;
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
// add items to combo box
|
||||
FadingModeStrList(cbFadingMode.Items);
|
||||
// load step from spin edit
|
||||
Fade.Step := seFadingStep.Value;
|
||||
// load interval from spin edit
|
||||
Timer1.Interval := seTimerInterval.Value;
|
||||
|
||||
// create test image
|
||||
Image := TBGRABitmap.Create(bgImage.Width, bgImage.Height);
|
||||
NoiseBWA(Image);
|
||||
|
||||
// fade form Windows
|
||||
{$ifdef Windows}
|
||||
Self.DoubleBuffered := True;
|
||||
Self.AlphaBlend := True;
|
||||
Self.AlphaBlendValue := 0;
|
||||
FadeForm.Mode := fmFadeIn;
|
||||
FadeForm.Duration := 300;
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure TForm1.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
// free test image
|
||||
Image.Free;
|
||||
end;
|
||||
|
||||
procedure TForm1.seDurationChange(Sender: TObject);
|
||||
begin
|
||||
Fade.Duration := seDuration.Value;
|
||||
end;
|
||||
|
||||
procedure TForm1.seFadingStepChange(Sender: TObject);
|
||||
begin
|
||||
// set fading step
|
||||
Fade.Step := seFadingStep.Value;
|
||||
end;
|
||||
|
||||
procedure TForm1.seTimerIntervalChange(Sender: TObject);
|
||||
begin
|
||||
// change timer interval
|
||||
Timer1.Interval := seTimerInterval.Value;
|
||||
end;
|
||||
|
||||
procedure TForm1.Timer1Timer(Sender: TObject);
|
||||
begin
|
||||
Timer1.Enabled:= false; //avoid freezing application
|
||||
|
||||
{ calculate fading // display alpha }
|
||||
Label3.Caption := concat('FadingAlpha: ', IntToStr(Fade.Execute));
|
||||
|
||||
// update bitmap
|
||||
bgImage.RedrawBitmap;
|
||||
|
||||
{$ifdef Windows}
|
||||
if FadeForm.Mode <> fmSuspended then
|
||||
Self.AlphaBlendValue := FadeForm.Execute;
|
||||
|
||||
if (FadeForm.Mode = fmSuspended) and (FadeForm.Alpha = 0) then
|
||||
Close;
|
||||
{$endif}
|
||||
Timer1.Enabled:= true;
|
||||
end;
|
||||
|
||||
end.
|
Reference in New Issue
Block a user