FMX.Controls单元 中图形矩阵变换
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单元 中图形矩阵变换的更多相关文章
- 二维图形的矩阵变换(二)——WPF中的矩阵变换基础
原文:二维图形的矩阵变换(二)--WPF中的矩阵变换基础 在前文二维图形的矩阵变换(一)——基本概念中已经介绍过二维图像矩阵变换的一些基础知识,本文中主要介绍一下如何在WPF中进行矩阵变换. Matr ...
- EHlib在数据单元中显示字段值为图形。
-[定制网格数据单元] 在数据单元中显示字段值为图形. TDBGridEh allows to show bitmaps from TImageList component depending o ...
- 当前线程不在单线程单元中,因此无法实例化 ActiveX 控件
“/”应用程序中的服务器错误. 当前线程不在单线程单元中,因此无法实例化 ActiveX 控件“c552ea94-6fbb-11d5-a9c1-00104bb6fc1c”. 说明: 执行当前 Web ...
- tableau中图形分析相关设置
1.柱形堆叠图单元格顶部显示总计值(可通过参考线实现) 2.调节图形单元格的宽窄度 (ctrl + 右键/左键) 3.折线图预测区间 趋势区间线 分析中预测并不是针对所有的日期格式均其作用,比如日期格 ...
- openstack-kilo--issue(九) heat stacks topology中图形无法正常显示
======声明======= 欢迎转载:转载请注明出处 http://www.cnblogs.com/horizonli/p/6186581.html ==========环境=========== ...
- C语言 将整数写入内存指定的连续字节单元中
将整数数组写入0x40003000开始的连续10个字节内存单元中,注意unsigned char *指向一个字节,而int *指向1个字(4个字),但是可以把字中存储的整数放入字节单元中,只要不超过表 ...
- iOS开发-在表单元中添加子视图
#import <UIKit/UIKit.h> @interface NameAndColorCellTableViewCell : UITableViewCell @property(c ...
- SQLite 对中文路径的支持(用到了StringToWideChar和Utf8Encode在D7的System单元中自带)
最近用SQLITE作为数据库,发现,如果直接传递带中文路径或文件名的数据库,会导致无法打开数据库的情况.看了一下SQLITE的源码,才发现,原来SQLITE中是用UTF8编码进行文件打开操作的. 所以 ...
- WPF/Silverlight中图形的平移,缩放,旋转,倾斜变换演示
原文:WPF/Silverlight中图形的平移,缩放,旋转,倾斜变换演示 为方便描述, 这里仅以正方形来做演示, 其他图形从略. 运行时效果图:XAML代码:// Transform.XAML< ...
随机推荐
- [代码审计]covercms 后台getshell
0x00 环境介绍 CMS名称: covercms 运行环境: php 5.6.27-nts + apache + mysql 系统版本: 1.16 漏洞等级:高危 漏洞简介: 后台awnotas.i ...
- leetcode 二叉搜索树中第K小的元素 python
二叉搜索树中第K小的元素 给定一个二叉搜索树,编写一个函数 kthSmallest 来查找其中第 k 个最小的元素. 说明:你可以假设 k 总是有效的,1 ≤ k ≤ 二叉搜索树元 ...
- Linux系统的组成
<linux系统7大子系统> a:SCI(system call interface) ————用户程序通过软件中断后,调用系统内核提供的功能,这个在用户空间和内核提供的服务之间的接口称为 ...
- NOIP练习赛题目6
长途旅行 难度级别:A: 运行时间限制:3000ms: 运行空间限制:262144KB: 代码长度限制:2000000B 试题描述 JY 是一个爱旅游的探险家,也是一名强迫症患者.现在JY 想要在C ...
- BZOJ2888 : 资源运输
显然资源集合处就是树的重心,这题需要动态维护树的重心. 每个连通块以重心为根,用link-cut tree维护每个点的子树大小以及子树内所有点到它的距离和. 合并两个连通块时,考虑启发式合并,暴力往大 ...
- Centos部署使用Jexus承载asp.net core2 web应用
一,首先安装本地开发项目用的的 core对应版本运行时: https://www.microsoft.com/net/download/linux-package-manager/centos/run ...
- Codeforces Round #396 (Div. 2) D. Mahmoud and a Dictionary 并查集
D. Mahmoud and a Dictionary 题目连接: http://codeforces.com/contest/766/problem/D Description Mahmoud wa ...
- BZOJ 3339: Rmq Problem 莫队算法
3339: Rmq Problem 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=3339 Description n个数,m次询问l,r ...
- rabbitmq的发布确认和事务 - 2207872494的个人空间
rabbitmq的发布确认和事务 - 2207872494的个人空间 https://my.oschina.net/lzhaoqiang/blog/670749
- AxonFramework
AxonFramework