-
[RESOLVED] negative x / y areas with copypixels
Hi,
this is quite tricky to explain, so apologies if it's a bit confusing...
I have a movieclip which contains graphics within negative x and y areas. I'm trying to duplicate some of the graphics within this negative space using copyPixels. I've tried all variety of negative values in my code but all negative areas remain uncopied within the duplicated bitmap.
Can anyone advise please? Is it even possible? Thank you. Jon ...
PHP Code:
var bitmapData1:BitmapData = new BitmapData(700, 600, false, 0xCC0000);// width height
var bitmapData2 :BitmapData = new BitmapData(350, 600, false, 0xCCCC00);// width height
function enterFrameFunc(e:Event) {
bitmapData1.draw(allIntro);
var rect1:Rectangle = new Rectangle(350, -100, 350, 600);
bitmapData2.copyPixels(bitmapData1, rect1, new Point(0,100));
}
allIntro.addEventListener(Event.ENTER_FRAME,enterFrameFunc);
var bm2:Bitmap=new Bitmap(bitmapData2);
this.addChild(bm2);
-
I think the problem is not the copypixels, but the original draw. You might have to offset the draw with a matrix argument so that the entirety of allIntro will be at positive coordinates.
-
Thanks for taking time to reply 5TonsOfFlax,
do you mean something like:
PHP Code:
bitmapData1.draw(allIntro, null, null, null, new Rectangle(350, -100, 350, 600));
?
because that didn't work either. If you mean something else, could you please elaborate?
Many thanks
-
That would be the clipRect, which I have never satisfactorily gotten to do anything useful.
The second parameter to draw is a Matrix which can define a rotation, translation, scale or skew to transform the source by. You need a translation.
Code:
var transMat:Matrix = new Matrix();
transMat.translate(100, 0); //move right by 100. Might be backwards.
bitmapData1.draw(allIntro, transMat);
Another alternative would be to place allIntro into a container sprite such that allIntro is entirely in positive coordinates of the container, then draw the container instead of allIntro.
-
Nice one!
The matrix / translate solution works a treat
Thanks very much.
Last edited by jon ps; 04-25-2008 at 11:08 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|