开发者

Distorting a polygon (Like Photoshop's distort) (Perspective Transformation)

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 disto开发者_运维问答rtion be applied for a polygon (a bunch of points)?

Thanks


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

Distorting a polygon (Like Photoshop's distort) (Perspective Transformation)

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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜