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< ...
随机推荐
- IntellijIDEA快速入门(Windows版)
跟随公司变更技术堆栈的步伐,开始学习相应工具IntelliJ的使用,之前一个大神同时也提到,最近该IDE的市场份额已然超越了免费的Eclipse,因此该工具已经到了必须会的程度了. 新年快乐,鸡年大吉 ...
- jqplot导入包小结
对于jqplot画图的导入包,总结起来就是两种,一种是每个jsp文件都是导入一样的js或css包!这些包可以另新建一个文件存放,有如下这些包! <link rel="styleshee ...
- Android-LayoutAnimation
Android-LayoutAnimation 学习自 <Android开发艺术探索> LayoutAnimation漫谈 LayoutAnimation 也是View动画的一种,作用是为 ...
- BZOJ.4695.最假女选手(线段树 Segment tree Beats!)
题目链接 区间取\(\max,\ \min\)并维护区间和是普通线段树无法处理的. 对于操作二,维护区间最小值\(mn\).最小值个数\(t\).严格次小值\(se\). 当\(mn\geq x\)时 ...
- BZOJ.2134.[国家集训队]单选错位(概率 递推)
题目链接 如题目中的公式,我们只要把做对每个题的概率加起来就可以了(乘个1就是期望). 做对第i道题的概率 \[P_i=\frac{1}{max(a_{i-1},a_i)}\] 原式是 \(P_i=\ ...
- 【转】Asp.net实现URL重写
[概述] URL重写就是首先获得一个进入的URL请求然后把它重新写成网站可以处理的另一个URL的过程.重写URL是非常有用的一个功能,因为它可以让你提高搜索引擎阅读和索引你的网站的能力:而且在你改变了 ...
- HDU5320 : Fan Li
考虑枚举左端点i,则随着右端点的右移,一共只有$O(\log n)$种不同的gcd取值.所以首先通过ST表+二分查找预处理出$O(n\log n)$个四元组(x,i,l,r),表示左端点为i,右端点取 ...
- 【BZOJ】3751: [NOIP2014]解方程【秦九韶公式】【大整数取模技巧】
3751: [NOIP2014]解方程 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 4856 Solved: 983[Submit][Status ...
- 完全卸载oracle11g步骤(转)
转自:http://blog.csdn.net/machinecat0898/article/details/7792471 完全卸载oracle11g步骤:1. 开始->设置->控制面板 ...
- nuxus 3在Maven项目的配置和POM文件的配置
在nuxus 3中的Maven默认会创建三个仓库,这三个仓库的关系如下: public是release和snapshot的全集,release默认为关闭状态,所以在配置nexus 3时需要将其开启. ...