procedure TControl.DoMatrixChanged(Sender: TObject);
var
TranslateMatrix, ScaleMatrix, RotMatrix: TMatrix;
M1, M2: TMatrix;
begin
if (not FInPaintTo) and not IsUpdating then
Repaint;
if SameValue(FScale.X, 1.0, TEpsilon.Scale) and SameValue(FScale.Y, 1.0, TEpsilon.Scale) and SameValue(FRotationAngle, 0.0, TEpsilon.Scale) then
begin
if (FParentControl <> nil) and not FParentControl.FSimpleTransform then
FSimpleTransform := False
else
FSimpleTransform := True;
end
else
FSimpleTransform := False;

if not FSimpleTransform then
begin
if not SameValue(FRotationAngle, 0.0, TEpsilon.Scale) then
begin
// scale
ScaleMatrix := TMatrix.Identity;
ScaleMatrix.m11 := FScale.X;
ScaleMatrix.m22 := FScale.Y;
FLocalMatrix := ScaleMatrix;
// rotation
if FRotationAngle <> 0 then
begin
M1 := TMatrix.Identity;
M1.m31 := -FRotationCenter.X * FSize.Width * FScale.X;
M1.m32 := -FRotationCenter.Y * FSize.Height * FScale.Y;
M2 := TMatrix.Identity;
M2.m31 := FRotationCenter.X * FSize.Width * FScale.X;
M2.m32 := FRotationCenter.Y * FSize.Height * FScale.Y;
RotMatrix := M1 * (TMatrix.CreateRotation(DegToRad(FRotationAngle)) * M2);
FLocalMatrix := FLocalMatrix * RotMatrix;
end;
// translate
TranslateMatrix := TMatrix.Identity;
TranslateMatrix.m31 := FPosition.X;
TranslateMatrix.m32 := FPosition.Y;
FLocalMatrix := FLocalMatrix * TranslateMatrix;
end
else
begin
FLocalMatrix := TMatrix.Identity;
FLocalMatrix.m31 := FPosition.X;
FLocalMatrix.m32 := FPosition.Y;
FLocalMatrix.m11 := FScale.X;
FLocalMatrix.m22 := FScale.Y;
end;
end
else
begin
FLocalMatrix := TMatrix.Identity;
FLocalMatrix.m31 := FPosition.X;
FLocalMatrix.m32 := FPosition.Y;
end;

RecalcAbsolute;
RecalcUpdateRect;
if HasDisablePaintEffect then
UpdateEffects;
if Visible and (ParentContent <> nil) then
ParentContent.Changed;
if not FAnchorMove then
begin
UpdateExplicitBounds;
UpdateAnchorRules(True);
end;
if (not FInPaintTo) and not IsUpdating then
Repaint;
end;

procedure TControl.DoMatrixChanged(Sender: TObject);
var
TranslateMatrix, ScaleMatrix, RotMatrix: TMatrix;
M1, M2: TMatrix;
begin
if (not FInPaintTo) and not IsUpdating then
Repaint;
if SameValue(FScale.X, 1.0, TEpsilon.Scale) and SameValue(FScale.Y, 1.0, TEpsilon.Scale) and SameValue(FRotationAngle, 0.0, TEpsilon.Scale) then
begin
if (FParentControl <> nil) and not FParentControl.FSimpleTransform then
FSimpleTransform := False
else
FSimpleTransform := True;
end
else
FSimpleTransform := False;

if not FSimpleTransform then
begin
if not SameValue(FRotationAngle, 0.0, TEpsilon.Scale) then
begin
// scale
ScaleMatrix := TMatrix.Identity;
ScaleMatrix.m11 := FScale.X;
ScaleMatrix.m22 := FScale.Y;
FLocalMatrix := ScaleMatrix;
// rotation
if FRotationAngle <> 0 then
begin
M1 := TMatrix.Identity;
M1.m31 := -FRotationCenter.X * FSize.Width * FScale.X;
M1.m32 := -FRotationCenter.Y * FSize.Height * FScale.Y;
M2 := TMatrix.Identity;
M2.m31 := FRotationCenter.X * FSize.Width * FScale.X;
M2.m32 := FRotationCenter.Y * FSize.Height * FScale.Y;
RotMatrix := M1 * (TMatrix.CreateRotation(DegToRad(FRotationAngle)) * M2);
FLocalMatrix := FLocalMatrix * RotMatrix;
end;
// translate
TranslateMatrix := TMatrix.Identity;
TranslateMatrix.m31 := FPosition.X;
TranslateMatrix.m32 := FPosition.Y;
FLocalMatrix := FLocalMatrix * TranslateMatrix;
end
else
begin
FLocalMatrix := TMatrix.Identity;
FLocalMatrix.m31 := FPosition.X;
FLocalMatrix.m32 := FPosition.Y;
FLocalMatrix.m11 := FScale.X;
FLocalMatrix.m22 := FScale.Y;
end;
end
else
begin
FLocalMatrix := TMatrix.Identity;
FLocalMatrix.m31 := FPosition.X;
FLocalMatrix.m32 := FPosition.Y;
end;

RecalcAbsolute;
RecalcUpdateRect;
if HasDisablePaintEffect then
UpdateEffects;
if Visible and (ParentContent <> nil) then
ParentContent.Changed;
if not FAnchorMove then
begin
UpdateExplicitBounds;
UpdateAnchorRules(True);
end;
if (not FInPaintTo) and not IsUpdating then
Repaint;
end;

FMX.Controls单元 中图形矩阵变换的更多相关文章

  1. 二维图形的矩阵变换(二)——WPF中的矩阵变换基础

    原文:二维图形的矩阵变换(二)--WPF中的矩阵变换基础 在前文二维图形的矩阵变换(一)——基本概念中已经介绍过二维图像矩阵变换的一些基础知识,本文中主要介绍一下如何在WPF中进行矩阵变换. Matr ...

  2. EHlib在数据单元中显示字段值为图形。

    -[定制网格数据单元]  在数据单元中显示字段值为图形.  TDBGridEh allows to show bitmaps from TImageList component depending o ...

  3. 当前线程不在单线程单元中,因此无法实例化 ActiveX 控件

    “/”应用程序中的服务器错误. 当前线程不在单线程单元中,因此无法实例化 ActiveX 控件“c552ea94-6fbb-11d5-a9c1-00104bb6fc1c”. 说明: 执行当前 Web ...

  4. tableau中图形分析相关设置

    1.柱形堆叠图单元格顶部显示总计值(可通过参考线实现) 2.调节图形单元格的宽窄度 (ctrl + 右键/左键) 3.折线图预测区间 趋势区间线 分析中预测并不是针对所有的日期格式均其作用,比如日期格 ...

  5. openstack-kilo--issue(九) heat stacks topology中图形无法正常显示

    ======声明======= 欢迎转载:转载请注明出处 http://www.cnblogs.com/horizonli/p/6186581.html ==========环境=========== ...

  6. C语言 将整数写入内存指定的连续字节单元中

    将整数数组写入0x40003000开始的连续10个字节内存单元中,注意unsigned char *指向一个字节,而int *指向1个字(4个字),但是可以把字中存储的整数放入字节单元中,只要不超过表 ...

  7. iOS开发-在表单元中添加子视图

    #import <UIKit/UIKit.h> @interface NameAndColorCellTableViewCell : UITableViewCell @property(c ...

  8. SQLite 对中文路径的支持(用到了StringToWideChar和Utf8Encode在D7的System单元中自带)

    最近用SQLITE作为数据库,发现,如果直接传递带中文路径或文件名的数据库,会导致无法打开数据库的情况.看了一下SQLITE的源码,才发现,原来SQLITE中是用UTF8编码进行文件打开操作的. 所以 ...

  9. WPF/Silverlight中图形的平移,缩放,旋转,倾斜变换演示

    原文:WPF/Silverlight中图形的平移,缩放,旋转,倾斜变换演示 为方便描述, 这里仅以正方形来做演示, 其他图形从略. 运行时效果图:XAML代码:// Transform.XAML< ...

随机推荐

  1. Eclipse中从svn中检出maven项目

    相信很多初学者都遇到过Eclipse中从SVN检出Maven项目之后看到的目录结构并不是Maven目录结构:或者只能先用SVN将Maven项目签入到本地,然后再用Eclipse导入Maven项目,但是 ...

  2. [mysql] update……from……

    今天插入一条数据就像这样 limit ), , )) 然后报错: You can't specify target table 'categorys' for update in FROM claus ...

  3. Linux块设备驱动详解

    <机械硬盘> a:磁盘结构 -----传统的机械硬盘一般为3.5英寸硬盘,并由多个圆形蝶片组成,每个蝶片拥有独立的机械臂和磁头,每个堞片的圆形平面被划分了不同的同心圆,每一个同心圆称为一个 ...

  4. INSTALL_FAILED_CONFLICTING_PROVIDER

    主要是由于调试的环境中已有一个同名的Provider存在. 解决方法是修改AndroidManifest.xml中的 <provider android:name=".apps.App ...

  5. Codeforces.1040E.Network Safety(思路 并查集)

    题目链接 \(Description\) 有一张\(n\)个点\(m\)条边的无向图,每个点有点权.图是安全的当且仅当所有边的两个端点权值不同.保证初始时图是安全的. 现在有权值为\(x\)的病毒,若 ...

  6. hdu 4445 37届金华赛区 D题

    题意:给一个坦克的高度,求炮弹能打中最多的数量 枚举角度,作为一名学霸虽然很快推出了公式,但是却没有考虑到,角度可以朝下的情况 #include<cstdio> #include<i ...

  7. Linux/CentOS设置全局代理(http)

    说明:为什么说是http代理,其实这个还不能说是全称走代理,罪名写的区别就是ICMP协议这个设置就无效,只能说是90%的应用都可以使用这个设置来实现代理访问,只有个别不行,比如一些软件根本不走http ...

  8. github入门教程:第一步

    [git教程] 以前在网上找过一些,见 http://www.wojilu.com/Forum1/Topic/702  我自己会一边学,一边写教程,过程中有不明白的,会跟大家请教交流.   ----- ...

  9. MySQL客户端输出窗口显示中文乱码问题解决办法

    最近发现,在MySQL的dos客户端输出窗口中查询表中的数据时,表中的中文数据都显示成乱码,如下图所示:

  10. 执行nova-manage db sync时出错,提示’Specified key was too long; max key length is 1000 bytes’

    执行nova-manage db sync时出错: 2012-03-24 14:07:01 CRITICAL nova [-] (OperationalError) (1071, ‘Specified ...