How do I compete the transformation matrix needed to transform a rectangle into a trapezium?

前端 未结 4 1913
青春惊慌失措
青春惊慌失措 2020-12-19 18:38

I\'m playing around with css transforms and the equivalent filters in IE, and want to simulate perspective by transforming a 2d rectangle into a trapezium.

Specifica

4条回答
  •  臣服心动
    2020-12-19 18:46

    There are 2 answers for it in:

    how to skew image like this

    One for the stripe-based transformation which should be good enough for the original question (transform rectangle to a trapezoid):

    https://stackoverflow.com/a/10427836/6336464

    The other is a bit more complicated but allows custom pixel-based transformation based on a 4x2 matrix (transform rectangle to a convex quadrilateral where each corner of the quadrilateral can be custom-defined):

    https://stackoverflow.com/a/37236664/6336464

提交回复
热议问题