我们有一个正方形的电影剪辑,上面有一些平淡的电影剪辑。考虑一个斜角的斜角。我想用电影剪辑的bimap数据进行以下转换:位于上面的三角形然后对角线保持不变,下三角形应该用上三角形的尺寸反射代替。
是否有一种简单的方法来做到这一点?
发布于 2011-04-20 13:56:43
确切地说,方法是拍摄电影的快照,然后镜像,再拍另一张快照,并将这两个快照组合在一起。请注意,您将获得的内容将是“静态的”,因此这样您就不能复制电影的动画部分。
//store the movie's graphical content in a bitmapdata
var bmd:BitmapData = new BitmapData(movie.width, movie.height);
bmd.draw(movie);
//then create a temporary movie in which you will do the mirroring
var temp:MovieClip = new MovieClip();
temp.addChild(new Bitmap(bmd));
//create the diagonal mask
var _mask:MovieClip = new MovieClip();
with(_mask.graphics) beginFill(0xff0000), lineTo(movie.width, 0), lineTo(movie.width, movie.height), lineTo(0, 0), endFill();
temp.addChild(_mask);
temp.mask = _mask;
//this is the mirroring part
temp.scaleX = temp.scaleY = -1;
addChild(temp);
//then create another bitmapdata for storing the so called "upper-triangle"
//important, that this bitmapdata should be transparent, "true" sets this
var bmd1:BitmapData = new BitmapData(temp.width, temp.height, true, 0x00);
//then do another mirroring transformation
var matrix:Matrix = new Matrix(-1, 0, 0, -1);
matrix.tx = temp.width;
matrix.ty = temp.height;
//draw the visual content on the bitmapdata
bmd1.draw(temp, matrix);
//and finally, on the original bitmapdata, draw the mirrored part
bmd.draw(bmd1);
//and add it to the top layer of the original movie, or whatever you want to do with it
movie.addChild(new Bitmap(bmd));发布于 2011-04-20 13:40:39
我能想到的最简单的方法是旋转电影45,把上面的矩形反画成下矩形,然后将位图旋转回45。您可以使用矩阵( BitmapData.draw方法中的第二个参数)来绘制旋转的矩阵,而不是实际地旋转任何东西。
https://stackoverflow.com/questions/5729589
复制相似问题