📄 treeanimate.pas
字号:
end;
function TTransparencyAnimation.GetValue: Integer;
begin
result:=Node.Transparency;
end;
procedure TTransparencyAnimation.Preview;
begin
inherited;
Node.Transparent:=False;
Node.Color:=clYellow;
FStartValue:=0;
FEndValue:=100;
end;
{ TSizeAnimation }
procedure TSizeAnimation.SetValue(AValue: Integer);
begin
Case FDirection of
mdHorizontal : Node.Width:=AValue;
mdVertical : Node.Height:=AValue;
end;
end;
function TSizeAnimation.GetValue: Integer;
begin
if FDirection=mdHorizontal then result:=Node.Width
else result:=Node.Height;
end;
{ TBoolAnimation }
procedure TBooleanAnimation.NewNode;
begin
if Assigned(IAnimate) and (not (csLoading in IAnimate.ComponentState)) then
FNewValue:=not Value;
end;
procedure TBooleanAnimation.NextFrame;
begin
Value:=NewValue;
inherited;
end;
procedure TBooleanAnimation.EndAnimation;
begin
if not (csDestroying in ComponentState) then
Value:=OldValue;
inherited;
end;
procedure TBooleanAnimation.StoreValue;
begin
inherited;
OldValue:=Value;
end;
{ TVisibleAnimation }
function TVisibleAnimation.GetValue: Boolean;
begin
result:=Node.Visible;
end;
procedure TVisibleAnimation.SetValue(AValue: Boolean);
begin
Node.Visible:=AValue;
end;
procedure TVisibleAnimation.Stop;
begin
Value:=OldValue;
inherited;
end;
{ TColorAnimation }
constructor TColorAnimation.Create(AOwner: TComponent);
begin
inherited;
FStartColor:=clNone;
FEndColor:=clNone;
end;
procedure TColorAnimation.EndAnimation;
begin
if not (csDestroying in ComponentState) then
Value:=OldColor;
inherited;
end;
procedure TColorAnimation.NewNode;
begin
if Assigned(IAnimate) and (not (csLoading in IAnimate.ComponentState)) then
if Assigned(Node) then
begin
if FStartColor=clNone then FStartColor:=Value;
if FEndColor=clNone then FEndColor:=Value;
end;
end;
procedure TColorAnimation.NextFrame;
var tmp0 : TRGBTriple;
tmp1 : TRGBTriple;
tmp : TColor;
tmpFactor : Double;
begin
tmp0:=RGBValue(StartColor);
tmp1:=RGBValue(EndColor);
tmpFactor:=(ICurrentFrame-StartFrame)/Duration;
tmp0.rgbtRed:=tmp0.rgbtRed+Round(tmpFactor*(tmp1.rgbtRed-tmp0.rgbtRed));
tmp0.rgbtGreen:=tmp0.rgbtGreen+Round(tmpFactor*(tmp1.rgbtGreen-tmp0.rgbtGreen));
tmp0.rgbtBlue:=tmp0.rgbtBlue+Round(tmpFactor*(tmp1.rgbtBlue-tmp0.rgbtBlue));
tmp:=RGB(tmp0.rgbtRed,tmp0.rgbtGreen,tmp0.rgbtBlue);
Value:=tmp;
if EndColor>=StartColor then
begin
if tmp>=FEndColor then Stop;
end
else
if tmp<=FEndColor then Stop;
inherited;
end;
procedure TColorAnimation.Play;
begin
if IPlaying=asStopped then Value:=FStartColor;
inherited;
end;
procedure TColorAnimation.StoreValue;
begin
inherited;
OldColor:=Value;
end;
{ TNodeColorAnimation }
function TNodeColorAnimation.GetColor: TColor;
begin
if Assigned(Node) then
Case FColor of
ncColor : result:=Node.Color;
ncBorder : result:=Node.Border.Color;
ncFont : result:=Node.Font.Color;
ncGradientStart : result:=Node.Gradient.StartColor;
ncGradientEnd : result:=Node.Gradient.EndColor;
else
{ncGradientMiddle :} result:=Node.Gradient.MidColor;
end
else result:=clWhite;
end;
procedure TNodeColorAnimation.Preview;
begin
inherited;
Node.Transparent:=False;
FStartColor:=Node.Color;
FEndColor:=clRed;
end;
procedure TNodeColorAnimation.SetColor(AColor: TColor);
begin
Case FColor of
ncColor : Node.Color:=AColor;
ncBorder : Node.Border.Color:=AColor;
ncFont : Node.Font.Color:=AColor;
ncGradientStart : Node.Gradient.StartColor:=AColor;
ncGradientEnd : Node.Gradient.EndColor:=AColor;
ncGradientMiddle : Node.Gradient.MidColor:=AColor;
end;
end;
{ TTreeColorAnimation }
function TTreeColorAnimation.GetColor: TColor;
begin
Case FColor of
tcColor : result:=IAnimate.Tree.Color;
tcGrid : result:=IAnimate.Tree.Grid.Color;
tcGradientStart : result:=IAnimate.Tree.Gradient.StartColor;
tcGradientEnd : result:=IAnimate.Tree.Gradient.EndColor;
else
{tcGradientMiddle :} result:=IAnimate.Tree.Gradient.MidColor;
end;
end;
function TTreeColorAnimation.IsEnabled: Boolean;
begin
result:=FEnabled;
end;
procedure TTreeColorAnimation.Preview;
begin
inherited;
FStartColor:=IAnimate.Tree.Color;
FEndColor:=clWhite;
end;
procedure TTreeColorAnimation.SetColor(AColor: TColor);
begin
Case FColor of
tcColor : IAnimate.Tree.Color:=AColor;
tcGrid : IAnimate.Tree.Grid.Color:=AColor;
tcGradientStart : IAnimate.Tree.Gradient.StartColor:=AColor;
tcGradientEnd : IAnimate.Tree.Gradient.EndColor:=AColor;
tcGradientMiddle : IAnimate.Tree.Gradient.MidColor:=AColor;
end;
end;
{ TAddTextAnimation }
procedure TAddTextAnimation.EndAnimation;
begin
Node.SimpleText:=OldText;
inherited;
end;
procedure TAddTextAnimation.NextFrame;
var tmp0 : Integer;
tmp1 : Integer;
begin
tmp1:=Length(OldText);
tmp0:=Round((ICurrentFrame-StartFrame)*tmp1/Duration);
Node.SimpleText:=Copy(OldText,1,tmp0);
if Node.SimpleText=OldText then Stop;
inherited;
end;
procedure TAddTextAnimation.Play;
begin
if IPlaying=asStopped then Node.SimpleText:='';
inherited;
end;
procedure TAddTextAnimation.Preview;
begin
inherited;
Node.Text.HorizAlign:=htaLeft;
end;
procedure TAddTextAnimation.StoreValue;
begin
inherited;
OldText:=Node.SimpleText;
Node.SimpleText:='';
end;
{ TMoveTextAnimation }
procedure TMoveTextAnimation.EndAnimation;
begin
Node.Text.HorizOffset:=OldOffset;
inherited;
end;
procedure TMoveTextAnimation.NextFrame;
var tmp0 : Integer;
begin
tmp0:=Round((ICurrentFrame-StartFrame)*(2*Node.Width)/Duration);
Node.Text.HorizOffset:=Node.Width-tmp0;
if tmp0>100 then Stop;
inherited;
end;
procedure TMoveTextAnimation.Play;
begin
if IPlaying=asStopped then Node.Text.HorizOffset:=Node.Width;
inherited;
end;
procedure TMoveTextAnimation.StoreValue;
begin
OldOffset:=Node.Text.HorizOffset;
Node.Text.ClipText:=True;
inherited;
end;
{ TTextAngleAnimation }
function TTextAngleAnimation.GetValue: Integer;
begin
result:=Node.Text.Angle;
end;
procedure TTextAngleAnimation.Preview;
begin
inherited;
FStartValue:=0;
FEndValue:=360;
end;
procedure TTextAngleAnimation.SetValue(AValue: Integer);
begin
Node.Text.Angle:=AValue;
end;
{ TTextTranspAnimation }
function TTextTranspAnimation.GetValue: Integer;
begin
result:=Node.Text.Transparency;
end;
procedure TTextTranspAnimation.Preview;
begin
inherited;
FStartValue:=0;
FEndValue:=100;
end;
procedure TTextTranspAnimation.SetValue(AValue: Integer);
begin
Node.Text.Transparency:=AValue;
end;
{ TTextFlashAnimation }
constructor TTextFlashAnimation.Create(AOwner: TComponent);
begin
inherited;
FSizePercent:=100;
end;
procedure TTextFlashAnimation.EndAnimation;
begin
Node.Font.Size:=OldSize;
inherited;
end;
procedure TTextFlashAnimation.NextFrame;
var tmp : Integer;
MaxSize : Integer;
begin
MaxSize:=StartSize+Round(StartSize*SizePercent/50.0);
if (ICurrentFrame-StartFrame)>Duration div 2 then
tmp:=MaxSize-Round((ICurrentFrame-StartFrame)*(MaxSize-StartSize)/Duration)
else
tmp:=StartSize+Round((ICurrentFrame-StartFrame)*(MaxSize-StartSize)/Duration);
Node.Font.Size:=tmp;
if ICurrentFrame>=EndFrame then Stop;
inherited;
end;
procedure TTextFlashAnimation.Play;
begin
if IPlaying=asStopped then StartSize:=Node.Font.Size;
inherited;
end;
procedure TTextFlashAnimation.StoreValue;
begin
OldSize:=Node.Font.Size;
inherited;
end;
{ TTextColorAnimation }
function TTextColorAnimation.GetColor: TColor;
begin
result:=Node.Font.Color;
end;
procedure TTextColorAnimation.Preview;
begin
inherited;
Node.Font.Size:=18;
Node.Font.Style:=[fsBold];
FStartColor:=Node.Font.Color;
FEndColor:=clRed;
end;
procedure TTextColorAnimation.SetColor(AColor: TColor);
begin
Node.Font.Color:=AColor;
end;
{ TNodeZoomAnimation }
constructor TNodeZoomAnimation.Create(AOwner: TComponent);
begin
inherited;
FZoomPercent:=100;
end;
procedure TNodeZoomAnimation.EndAnimation;
begin
if not (csDestroying in ComponentState) then
SetNodeBounds(OldBounds);
inherited;
end;
procedure TNodeZoomAnimation.NextFrame;
var tmpZoom : Double;
tmpW : Double;
tmpH : Double;
begin
tmpZoom:=(ICurrentFrame-StartFrame)*ZoomPercent/Duration;
tmpW:=OldBounds.Right-OldBounds.Left;
tmpW:=tmpW+(tmpW*tmpZoom*0.01);
tmpH:=OldBounds.Bottom-OldBounds.Top;
tmpH:=tmpH+(tmpH*tmpZoom*0.01);
with Node do
begin
Left:=Round((OldBounds.Right+OldBounds.Left-tmpW)*0.5);
Width:=Round(tmpW);
Top:=Round((OldBounds.Bottom+OldBounds.Top-tmpH)*0.5);
Height:=Round(tmpH);
end;
if tmpZoom>=ZoomPercent then Stop;
inherited;
end;
procedure TNodeZoomAnimation.Preview;
begin
inherited;
Node.Transparent:=False;
Node.Border.Visible:=True;
end;
Procedure TNodeZoomAnimation.SetNodeBounds(Const R:TRect);
begin
Node.Left:=R.Left;
Node.Top:=R.Top;
Node.Width:=R.Right-R.Left;
Node.Height:=R.Bottom-R.Top;
end;
procedure TNodeZoomAnimation.StoreValue;
begin
inherited;
with OldBounds do
begin
Left:=Node.Left;
Top:=Node.Top;
Right:=Left+Node.Width;
Bottom:=Top+Node.Height;
end;
end;
initialization
AnimationClasses:=TList.Create;
RegisterAnimation(TFontSizeAnimation);
RegisterAnimation(TMovementAnimation);
RegisterAnimation(TTransparencyAnimation);
RegisterAnimation(TTextTranspAnimation);
RegisterAnimation(TVisibleAnimation);
RegisterAnimation(TNodeColorAnimation);
RegisterAnimation(TTreeColorAnimation);
RegisterAnimation(TCustomAnimation);
RegisterAnimation(TAddTextAnimation);
RegisterAnimation(TMoveTextAnimation);
RegisterAnimation(TTextAngleAnimation);
RegisterAnimation(TTextFlashAnimation);
RegisterAnimation(TTextColorAnimation);
RegisterAnimation(TNodeZoomAnimation);
finalization
AnimationClasses.Free;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -