TBitmap 主要成员:
--------------------------------------------------------------------------------
{ 方法 }
SetSize(); //设置大小
Clear(); //取消, 就是用指定颜色覆盖
ClearRect(); //覆盖指定矩形范围, 默认覆盖为透明色
BitmapChanged(); //刷新改变
IsEmpty(); //是否为空
UpdateHandles(); //将 Handles 数组中的对象标记为需要更新
AddFreeNotify(); //将指定对象添加到可以释放的列表; 这一般是针对添加到 Handles 中的对象
RemoveFreeNotify(); //释放指定对象; 这一般是针对添加到 Handles 中的对象
Rotate(); //旋转角度
FlipHorizontal(); //水平翻转
FlipVertical(); //垂直翻转
InvertAlpha(); //翻转透明度, 只适于透明图片
FillColor(); //填充遮罩色, 用于透明图片
CreateMask(); //建立蒙版; 是从 TBitmap 中把各像素的透明度提取为一个数组, 返回数组指针
ApplyMask(); //添加蒙版, 其参数应该是有 CreateMask() 建立的
CreateThumbnail(); //建立略缩图
LoadFromFile(); //从文件载入
LoadFromStream(); //从流中载入
LoadThumbnailFromFile(); //从文件载入为略缩图
SaveToFile(); //保存到文件
SaveToStream(); //保存到流
HandleRemove(); //从 Handles 数组移除对象, 并没有释放
HandleAdd(); //添加对象到 Handles 数组
HandleExists(); //判断指定对象是否已添加到 Handles 数组
{ 属性 }
Width : Integer; //宽
Height : Integer; //高
Handles[AItem: Pointer] : Pointer; //访问 Handles 中的对象, 索引是指针; 写入前需要先 HandleAdd();
HandlesNeedUpdate[AItem: Pointer] : Boolean; //判断 Handles 中的指定对象是否需要更新
Canvas : TCanvas; //获取绘图表面
Pixels[X, Y: Integer] : TAlphaColor; //获取或设置指定位置的颜色值
ScanLine[Y: Integer] : PAlphaColorArray; //获取一条横线上的像素数组的指针
StartLine : PAlphaColorArray; //获取像素数组的指针
ResourceBitmap : TBitmap; //该属性应该是内部使用的
StyleLookup : string; //这应该是和控件的造型相关的, 暂不知 TBitmap 要它干嘛
//特效
就从 Tool Palette 窗口的 Effects 组中发现洋洋洒洒的六十多个特效...
每个特效分别对应一个类, 分别来自 FMX.Effects 和 FMX.Filter.Effects 单元. FMX.Effects 中的特效属于附加特效,
FMX.Filter.Effects 中的特效只是某种滤镜效果; 它们都是滤镜的一种快捷应用.
每个特效有不同的参数; 因都是直接或间接地继承与 FMX.Types 中的 TEffect,
也都拥有 Trigger、Enabled、GetDisablePaint 等功能.
//动画
在 HD 窗体上添加一个 TAniIndicator, 修改其 Enabled 属性为 True, 动画完成了. 这是最简单的动画相关的控件了, 只有两个值得注意的属性:
--------------------------------------------------------------------------------
Enabled: Boolean; //
Style: TAniIndicatorStyle; //TAniIndicatorStyle = (aiLinear, aiCircular);
{例}
AniIndicator1.Style := TAniIndicatorStyle.aiCircular;
--------------------------------------------------------------------------------
它是怎么动起来的? 追源码, 发现它有一个 FAni: TFloatAnimation; 内部变量. 再就追出 TFloatAnimation 的父类 TAnimation; TAnimation 在 FMX.Types 单元, 看来是核心成员了. TAnimation 的子类们都在 FMX.Ani 单元:
--------------------------------------------------------------------------------
TFloatAnimation //
TFloatKeyAnimation //
TColorAnimation //
TColorKeyAnimation //
TGradientAnimation //
TPathAnimation //
TRectAnimation //
TBitmapAnimation //
TBitmapListAnimation //
TFloatKeyAnimation //
TColorKeyAnimation //
--------------------------------------------------------------------------------
早在 TFmxObject(FMX 们的祖先)就有了一些动画相关的方法:
--------------------------------------------------------------------------------
StartAnimation(); //
StopAnimation(); //
StartTriggerAnimation(); //
StartTriggerAnimationWait(); //
StopTriggerAnimation(); //
AnimateFloat(); //
AnimateColor(); //
AnimateFloatDelay(); //
AnimateFloatWait(); //
StopPropertyAnimation(); //
--------------------------------------------------------------------------------
另在 FMX.Types 单元还有一些动画插入算法的一些公用函数(应该主要是内部使用):
--------------------------------------------------------------------------------
InterpolateSingle(); //
InterpolateRotation(); //
InterpolateColor(); //
InterpolateLinear(); //
InterpolateSine(); //
InterpolateQuint(); //
InterpolateQuart(); //
InterpolateQuad(); //
InterpolateExpo(); //
InterpolateElastic(); //
InterpolateCubic(); //
InterpolateCirc(); //
InterpolateBounce(); //
InterpolateBack(); //
--------------------------------------------------------------------------------
很多动画应该在设计时就可以方便完成, 在选择某些属性值时可直接添加动画, 如:
--------------------------------------------------------------------------------
//Bitmap 属性:
Create New TBitmapAnimation
Create New TBitmapListAnimation
//Color 属性:
Create New TColorAnimation
Create New TColorKeyAnimation
//Gradient 属性:
Create New TGradientAnimation
//Width、Height、X、Y、StrokeThickness、XRadius、YRadius、Opacity、RotationAngle 等属性:
Create New TFloatAnimation
Create New TFloatKeyAnimation
--------------------------------------------------------------------------------
先尝试一个让控件转起来的动画吧: 添加一个 TRectangle, 从其 RotationAngle 属性 Create New TFloatAnimation (需要删除时, 选定后按 Delete), 然后调整自动建立的 FloatAnimation1 的属性值:
--------------------------------------------------------------------------------
//一般在设计时取值即可, 下面是运行时的代码:
procedure TForm1.FormCreate(Sender: TObject);
begin
FloatAnimation1.Enabled := True;
FloatAnimation1.Loop := True;
FloatAnimation1.Duration := 2.5; //一个动画周期的长度(秒)
FloatAnimation1.StartValue := 0; //起点角度
FloatAnimation1.StopValue := 360; //终点角度
end;
--------------------------------------------------------------------------------
procedure TForm5.Button1Click(Sender: TObject);
begin
//rect := TRectangle.Create(Self);
//rect.Parent := Self;
//rect.Align := TAlignLayout.alCenter;
with TFloatAnimation.Create(Self) do
begin
Parent := image1; //旋转对象
PropertyName := 'RotationAngle';
Enabled := True;
Loop := True;
Duration := 2.5; //旋转速度
StartValue := 0;
StopValue := 360;
end;
end;
procedure TForm5.Button2Click(Sender: TObject);
begin
with Image1.BitmapMargins do
begin
Left := Left + 10;
end;
image1.Repaint;
// Image1.Bitmap.; //刷新
end;
procedure TForm5.Button3Click(Sender: TObject);
begin
image1.Bitmap.FlipHorizontal; //水平翻转
end;
动画下:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
TAnimation 类的主要成员:
--------------------------------------------------------------------------------
protected
function NormalizedTime: Single; //
procedure ProcessAnimation; virtual; //其子类们主要通过覆盖此方法来实现不同的动画
procedure Loaded; override; //
public
procedure Start; virtual; //播放
procedure Stop; virtual; //停止
procedure StopAtCurrent; virtual; //停止在当前帧; 和 Pause 属性不同的是它会触动 OnFinish 事件
procedure StartTrigger(...); virtual; //如果不是覆盖, 一般应使用 Trigger、TriggerInverse 属性而不是该方法
procedure ProcessTick(...); //内部使用的动画执行方法, 主要由它来调用 ProcessAnimation 过程.
property Running: Boolean ...; //是否运行中; 只读
property Pause: Boolean ...; //暂停
published
prop