Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 柔性矩阵将图像旋转n度_Apache Flex_Actionscript 3_Matrix_Rotation - Fatal编程技术网

Apache flex 柔性矩阵将图像旋转n度

Apache flex 柔性矩阵将图像旋转n度,apache-flex,actionscript-3,matrix,rotation,Apache Flex,Actionscript 3,Matrix,Rotation,如何使用矩阵将图像顺时针旋转180度 我可以使用下面的代码将图像旋转90度,但它是增量的 var matrix:Matrix = new Matrix(); matrix.rotate(Math.PI/2); matrix.tx = imgControl.content.height; var bitmapData:BitmapData = new BitmapData(imgControl.content.height, imgControl.content.width); bitmapD

如何使用矩阵将图像顺时针旋转180度

我可以使用下面的代码将图像旋转90度,但它是增量的

var matrix:Matrix = new Matrix();

matrix.rotate(Math.PI/2);
matrix.tx = imgControl.content.height;

var bitmapData:BitmapData = new BitmapData(imgControl.content.height, imgControl.content.width);
bitmapData.draw(imgControl.content, matrix);
imgControl.source = new Bitmap( bitmapData);
每次运行代码时,图像都会旋转+90度

我想要的不是每次增加90,而是明确地说旋转180,旋转90等等

我不熟悉这个矩阵,但我想它可以进行真正的位图数据操作,而不仅仅是旋转图像组件框(如果我错了就逮捕我)

如果是这样,我想每次执行“旋转”命令时都必须重置图像

我错过什么了吗

提前感谢您的建议和提示


Ran

矩阵不进行真正的位图数据操作

正是
bitmap.draw
调用将imgcontrol.content的旋转图像绘制到位图中,然后代码用旋转图像覆盖imgcontrol.content

因此,由于您的代码当前处于静止状态,是的,您必须在每次旋转之前从头刷新图像,或者必须跟踪变量中的旋转,并计算需要旋转多少次才能达到所需的旋转

如果您需要在一个步骤中进行多个90度旋转,请更换

matrix.rotate(Math.PI/2);


像真正的神谕一样说话。我认为这是一个.matrix.rotate(Math.PI/2*2);使图像消失哦,对!这就是
matrix.tx
行的作用。旋转围绕图像的一个角旋转(可能是左下角?);因此,您将图像从框/矩形中“向外”旋转,因此您必须将图像转换(平移/推)回框中。你可以用.tx表示x方向,我猜.ty表示y方向。拿一张纸自己画出来,用代码做实验,看看你要翻译的方向和翻译量。
matrix.rotate(Math.PI/2 * howmanytimesyouwanttorotateby90degrees);