mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-05 03:18:30 +02:00
TAChart: Minor refactoring of "bgra" demo
git-svn-id: trunk@40082 -
This commit is contained in:
parent
0b5f32e4bd
commit
9e61f1b1e4
@ -172,17 +172,10 @@ object Form1: TForm1
|
|||||||
OnClick = btnStartStopClick
|
OnClick = btnStartStopClick
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
end
|
end
|
||||||
object lblSkipped: TLabel
|
|
||||||
Left = 9
|
|
||||||
Height = 1
|
|
||||||
Top = 340
|
|
||||||
Width = 1
|
|
||||||
ParentColor = False
|
|
||||||
end
|
|
||||||
object Image1: TImage
|
object Image1: TImage
|
||||||
Left = 9
|
Left = 10
|
||||||
Height = 148
|
Height = 148
|
||||||
Top = 176
|
Top = 146
|
||||||
Width = 61
|
Width = 61
|
||||||
Picture.Data = {
|
Picture.Data = {
|
||||||
1754506F727461626C654E6574776F726B477261706869636D0C000089504E47
|
1754506F727461626C654E6574776F726B477261706869636D0C000089504E47
|
||||||
|
@ -26,7 +26,6 @@ type
|
|||||||
chSliceScaling: TChart;
|
chSliceScaling: TChart;
|
||||||
chSliceScalingBarSeries1: TBarSeries;
|
chSliceScalingBarSeries1: TBarSeries;
|
||||||
Image1: TImage;
|
Image1: TImage;
|
||||||
lblSkipped: TLabel;
|
|
||||||
ListChartSource1: TListChartSource;
|
ListChartSource1: TListChartSource;
|
||||||
PageControl1: TPageControl;
|
PageControl1: TPageControl;
|
||||||
PaintBox1: TPaintBox;
|
PaintBox1: TPaintBox;
|
||||||
@ -50,12 +49,10 @@ type
|
|||||||
procedure rgMethodClick(Sender: TObject);
|
procedure rgMethodClick(Sender: TObject);
|
||||||
private
|
private
|
||||||
FAnimatedSource: TCustomAnimatedChartSource;
|
FAnimatedSource: TCustomAnimatedChartSource;
|
||||||
|
FSliceScaling: TBGRASliceScaling;
|
||||||
procedure OnGetItem(
|
procedure OnGetItem(
|
||||||
ASource: TCustomAnimatedChartSource;
|
ASource: TCustomAnimatedChartSource;
|
||||||
AIndex: Integer; var AItem: TChartDataItem);
|
AIndex: Integer; var AItem: TChartDataItem);
|
||||||
procedure OnStop(ASource: TCustomAnimatedChartSource);
|
|
||||||
public
|
|
||||||
sliceScaling: TBGRASliceScaling;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -105,11 +102,14 @@ var
|
|||||||
temp: TBGRABitmap;
|
temp: TBGRABitmap;
|
||||||
sz: TPoint;
|
sz: TPoint;
|
||||||
begin
|
begin
|
||||||
|
Unused(ASender);
|
||||||
|
Unused(APointIndex, AStackIndex);
|
||||||
|
ADoDefaultDrawing := false;
|
||||||
sz := ARect.BottomRight - ARect.TopLeft;
|
sz := ARect.BottomRight - ARect.TopLeft;
|
||||||
temp := TBGRABitmap.Create(
|
temp := TBGRABitmap.Create(
|
||||||
sliceScaling.BitmapWidth, Round(sliceScaling.BitmapWidth * sz.Y / sz.X));
|
FSliceScaling.BitmapWidth, Round(FSliceScaling.BitmapWidth * sz.Y / sz.X));
|
||||||
try
|
try
|
||||||
sliceScaling.Draw(temp, 0, 0, temp.Width, temp.Height);
|
FSliceScaling.Draw(temp, 0, 0, temp.Width, temp.Height);
|
||||||
temp.Draw(ACanvas, ARect);
|
temp.Draw(ACanvas, ARect);
|
||||||
finally
|
finally
|
||||||
temp.Free;
|
temp.Free;
|
||||||
@ -123,16 +123,15 @@ begin
|
|||||||
FAnimatedSource.AnimationInterval := 30;
|
FAnimatedSource.AnimationInterval := 30;
|
||||||
FAnimatedSource.AnimationTime := 1000;
|
FAnimatedSource.AnimationTime := 1000;
|
||||||
FAnimatedSource.OnGetItem := @OnGetItem;
|
FAnimatedSource.OnGetItem := @OnGetItem;
|
||||||
FAnimatedSource.OnStop := @OnStop;
|
|
||||||
chSliceScalingBarSeries1.Source := FAnimatedSource;
|
chSliceScalingBarSeries1.Source := FAnimatedSource;
|
||||||
|
|
||||||
sliceScaling := TBGRASliceScaling.Create(Image1.Picture.Bitmap, 70, 0, 35, 0);
|
FSliceScaling := TBGRASliceScaling.Create(Image1.Picture.Bitmap, 70, 0, 35, 0);
|
||||||
sliceScaling.AutodetectRepeat;
|
FSliceScaling.AutodetectRepeat;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.FormDestroy(Sender: TObject);
|
procedure TForm1.FormDestroy(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
sliceScaling.Free;
|
FSliceScaling.Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.PaintBox1Paint(Sender: TObject);
|
procedure TForm1.PaintBox1Paint(Sender: TObject);
|
||||||
@ -175,11 +174,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.OnStop(ASource: TCustomAnimatedChartSource);
|
|
||||||
begin
|
|
||||||
lblSkipped.Caption := Format('Skipped frames: %d', [ASource.SkippedFramesCount]);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TForm1.rgMethodClick(Sender: TObject);
|
procedure TForm1.rgMethodClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
FAnimatedSource.Start;
|
FAnimatedSource.Start;
|
||||||
|
Loading…
Reference in New Issue
Block a user