You are viewing the archives of the original Pixelfumes blog. This blog is no longer maintained. All of the content available on this site is available on the new Pixelfumes blog in addition to all of our new posts! Visit: http://blog.pixelfumes.com.

« Home | Flash 8 Matrix Effect Source Available for Downloa... » | Blogger Web Comments for Firefox from Google » | Adobe Apollo - Flash and Acrobat (Web Should Dodge... » | IKEA Website - Here's Who Did It and How » | Flash 8 SWFs still open in the Flash 7 Standalone ... » | Flash 8 Get Pixel and Some Snow... » | New IKEA Site - Wow » | Matrix Effects » | Red Eye Removal With Flash 8 - Upload Your Picture... » | Need to Find an XBOX 360 Where You Live? Google M... » 

Friday, January 06, 2006 

Flash Why Do You Mock Me? (Bitmap Transform/Matrix/Skew Problems)

Today I wanted to try a new effect and thought it would be a good time to get my hands dirty with the Matrix Transformations in Flash 8. It was fairly easy to get a transformation on my BitmapData object and get some skewing going on. That was until I wanted to get a "keystone" effect. I have seen this done using the Drawing API back in the day and figured it would be easy enough to do the same now that Flash 8 was here. I researched a bunch on blogs and hit my Flash buddies up for ideas and as of right now we are stumped. I may be missing something or maybe don't know about a new method or class. It does not seem possible to get the effect I am looking for, at least not by the way of any example code I have seen. That's why I figured I'd post my cry for help here.

In the image below you can see in the left column what I want to achieve and in the right column what I have been able to achieve. Any insight, leads, code, etc would be greatly appreciated. Thanks!


I spent about 6 hours on it a couple of months ago, couldn't get it to work either!! Obviously it would be do-able on a pixel-by-pixel basis, but I doubt that would be fast enough for video keystoning - Jay

http://teknision.blogspot.com/2005/09/give-us-distortion-in-flash-player-9.html

Yeah, you can't achieve perspective distortion with skewing (though a number of people have come up with workarounds to fake it). For example, you can get close with the DisplacementMapFilter, but it's a pain in the arse. You can also use multiple skewed clips to do it, but it's even messier.

I thought Id go on about what you can and cant do but Grant Skinner nailed it down pretty well. At the bottom of

http://www.senocular.com/flash/tutorials/transformmatrix/

theres a little swf showing you what exactly you can do using the transformation matrix (and if you read the whole thing you could get a better idea too).

This post by Thomas Pfeiffer might do the trick for now.

Andy Hall managed to pull off perspective transforms pretty convincingly using the DisplacementMapFilter applying it to video and bitmaps. There is a demo online at: http://www.scionf8.com

André Michelle has a Flash 7 based perspective image mapping demo in his lab, too: http://lab.andre-michelle.com/ (look down on the left under F7:3D)

Director offers a non parallelogram distortion wih tht Quad property, accessible programatically, but not by edit interface.

Here's a Goo demo with 4 quads intersecting at the mouse loc.

http://www.geocities.com/mambolingo/shocksamples/goo_demo_extended.htm

do what you wnat

http://lesitekilestbien.free.fr/distordImage/meshtextured.swf

:)

g_w_master@yahoo.com

I did some image skewing in flash 5 back in 2000 (here - its a little ugly, but it works).

The principle I used was to create a whole lot of copies of a movie clip, and show a thin slice of each one at a different scale and position. The maths was a bit tricky and I had to code in some things for it to run on slow machines (it ran jerky instead..).

The example on http://lab.andre-michelle.com/ looks a whole lot better. It'd be interesting to find out how that was done! If you want to see my code, there's a link on my site.

Ian,

I have been trying to draw perspective views of an image by slicing the image into smaller pieces and manipulating them. I think it's very similar to what you have done and curious to see the source code but couldn't find the source code. How can I look at the source code?

T

I have done some searching as well, will report back when I see it pulled off.

Until then, a clever solve is to use a combination a api-drawn mask to exagerate the keystone, and an xscale crunch. Don't like it, but gets me closer.

Cheers and goodluck!
a

Sarge, wondering if you found a 'easy-ish' solution to this? Found a similar thread;

http://teknision.blogspot.com/2005/09/give-us-distortion-in-flash-player-9.html

but does not seem to provide a clear method - unless i missed something?

Kind regards,
Andy

Hey guys, this is Ant from Onyro.com,

has anybody managed to get perspective in a movieclip, not a image bitmap..?

thanks

http://pixelfumes.blogspot.com/2006/01/perspective-distort-example.html should help - no?

look this www.absolut.com; the same effect

or this: somaap.com

this is how to do it easily by cutting your image into two triangles:

you have 4 destination points:
p0,p1,p2,p3 with x and y coordinates and disposed so:
p0-p3
| |
p1-p2

w and h are width and height of the source (the bitmap)

bmp is a the bitmap as BitmapData object


var mat:Matrix = new Matrix();
mat.a = (p3.x-p0.x)/w;
mat.b = (p3.y-p0.y)/w;
mat.c = (p1.x-p0.x)/h;
mat.d = (p1.y-p0.y)/h;

mat.translate(p0.x,p0.y);

var mat1:Matrix = new Matrix();
mat1.a = (p1.x-p2.x)/-w;
mat1.b = (p1.y-p2.y)/-w;
mat1.c = (p3.x-p2.x)/-h;
mat1.d = (p3.y-p2.y)/-h;

mat1.translate(p2.x,p2.y);

//then you fill the bitmap with repetition into the triangles

clip.beginBitmapFill(bmp,mat,true,false);
clip.moveTo(p0.x,p0.y);
clip.lineTo(p1.x,p1.y);
clip.lineTo(p3.x,p3.y);
clip.lineTo(p0.y,p0.y);
clip.endFill();


clip.beginBitmapFill(bmp,mat1,true,false);
clip.moveTo(p2.x,p2.y);
clip.lineTo(p1.x,1p.y);
clip.lineTo(p3.x,p3.y);
clip.lineTo(p2.x,p2.y);
clip.endFill();


this should do the trick and is fast. I use it to draw textures on cube faces.

you can contact me if you need more information: justin dot espinosa at freesurf dot ch

Post a Comment