反映沿x和y轴的对象 [英] Reflect a object along x and y axis

查看:182
本文介绍了反映沿x和y轴的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要反映一组包含的物体如上图。

我有什么,我在我的最新进展做了样本图像。

目标:物体的反射应沿X轴和Y轴按照下面的图片来完成

解决方案

简单的code是这样的:

  copiedDisplayObject.scaleY = -1;
copiedDisplayObject.alpha = 0.4;
 

这是真的反射通过线,其中所述线恰好是x轴的一个具体例子。 (即Y = 0X + 0)如果你想反映过来另一条线,你可以用一个矩阵。下面的显示对象上preserves previous变换的code,并反映过来一条通过原点。

  VAR M:数= 0.25; //例如坡 - 来自行:表达式y = mx + 0
VAR tmpMatrix = copiedDisplayObject.transform.matrix;
VAR relectMatrix:矩阵=新的Matrix(1-m * m的,2 * M,2 * M,M * M-1);
tmpMatrix.concat(relectMatrix);
copiedDisplayObject.transform.matrix = tmpMatrix;
 

我发现了矩阵式浏览: math.stackexchange问​​题

Need to reflect a group containing objects as shown in picture.

I have a sample image for what i have done in my current progress.

Objective: Reflection of objects should be done along x and y axis as per the below image

解决方案

The simple code looks like this:

copiedDisplayObject.scaleY = -1;
copiedDisplayObject.alpha = 0.4;

That is really a specific example of reflection over a line, where the line happens to be the x axis. (ie y = 0x + 0) If you want to reflect over another line, you can use a matrix. The code below preserves previous transformations on the display object, and reflects it over a line passing through the origin.

var m:Number = 0.25; //example slope -- from line: y = mx + 0
var tmpMatrix = copiedDisplayObject.transform.matrix;
var relectMatrix:Matrix = new Matrix(1-m*m, 2*m, 2*m, m*m -1);
tmpMatrix.concat(relectMatrix);
copiedDisplayObject.transform.matrix = tmpMatrix;

I found the matrix formula here: math.stackexchange question.

这篇关于反映沿x和y轴的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆