views:

56

answers:

3

In Photoshop there is a tool that allows the selection to be "Distorted". This allows easy shadow creation among other things. How could this sort of distortion be applied for a polygon (a bunch of points)?

Thanks

+1  A: 

This all links into matrices unless I'm mistaken - you'll want to look it up on the net, I'll not be onto it for a couple of weeks but thought I might as well give you a pointer.

46Bit
[Perspective](http://en.wikipedia.org/wiki/Transformation_matrix) or [Projective Transform](http://www.leptonica.com/affine.html) is more complex than most [affine transform](http://en.wikipedia.org/wiki/Affine_transformation) distortions and shadows often involve blur.
drawnonward
+2  A: 

If your aim is to accomplish something like this (black original, red after distortion) alt text

then you can:

  • fix a base for applying distortion (generally normal to the direction in which you want to distort, for example - here the direction of distortion is towards the right and the base is the bottom edge of the rectangle)
  • displace each point on the figure by a distance proportional to its distance from the base, for example - point A (assuming it to be at 70% height) would be displaced by a distance of 0.7 * (displacement of top left corner point)

Using such a sequence of such distortion cycles, you can get the transformation that you want.

Lazer
+1  A: 

This particular distortion (pictured) is called the "shear" effect and is just a matter of applying an horizontal offset to each scanline of the polygon.

Many graphic effects can be done with simple primitives like this (there is even a shear rotation).

Have a look at "Graphic GEMS" with Google.

Loric