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. SpringMVC框架03——数据绑定

    1.绑定基本数据类型 在Controller类中添加业务方法: /** * 绑定基本数据类型 */ @RequestMapping("/baseType") @ResponseBo ...

  2. 基于jquery的垂直滚动触发器,多参数可设置。

    最近闲来无事,多封装些功能性组件.后期会有更多放出来,大家可以多关注一下. 先上参数: type:"show",           默认为“show”,“show”意为当能够在可 ...

  3. InnoDB的锁机制浅析(All in One)

    目录 InnoDB的锁机制浅析 1. 前言 2. 锁基本概念 2.1 共享锁和排它锁 2.2 意向锁-Intention Locks 2.3 锁的兼容性 3. InnoDB中的锁 3.1 准备工作 3 ...

  4. android弹出对话框

    我们在平时做开发的时候,免不了会用到各种各样的对话框,相信有过其他平台开发经验的朋友都会知道,大部分的平台都只提供了几个最简单的实现,如果我们想实现自己特定需求的对话框,大家可能首先会想到,通过继承等 ...

  5. poj 1797 最短路变形dijkstra

    题意:题目大意:有n个城市,m条道路,在每条道路上有一个承载量,现在要求从1到n城市最大承载量,而最大承载量就是从城市1到城市n所有通路上的最大承载量 链接:点我 解题思路:其实这个求最大边可以近似于 ...

  6. (转载)Python 的 JPype 模块调用 Jar 包

    Python 的 JPype 模块调用 Jar 包 背景与需求 最近学习并安装使用了HttpRunner框架去尝试做接口测试,并有后续在公司推广的打算. HttpRunner由Python开发,调用接 ...

  7. sublime text2 用ctags插件实现方法定位(转)

    我们用sublime几乎都会首先安装这个插件,这个插件是管理插件的功能,先安装它,再安装其他插件就方便了. 点击sublime的菜单栏 view->show console :现在打开了控制台, ...

  8. LPC43xx SGPIO Slice 示意图

    SGPIO inverted clock qualifier Hi, With bits 6:5 of SGPIO_MUX_CFG the QUALIFIER_MODE is selected (0x ...

  9. SIMATIC PID温度控制

    SIMATIC PID温度控制 // VAR_INPUT ------------------------------------------------------------------- #if ...

  10. cmsis dap interface firmware

    cmsis dap interface firmware The source code of the mbed HDK (tools + libraries) is available in thi ...