Re: is skew supposed to move/shift top/left x?
Lawrence D'Oliveiro <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Organization | Geek Central |
| Message-ID | <[email protected]> |
On Wed, 10 Feb 2016 21:38:30 -0700, Mark Olesen wrote: > When skewing in the x direction, top x seems to move to the right a > bit. > /* > http://cairographics.org/cookbook/matrix_transform/http://cairographics.org/cookbook/matrix_transform/ > Lets take that C = math.cos(A), S = math.sin(A), T = math.tan(A) > X-skew by A -- mtrx = cairo.Matrix(1,0,T,1,0,0) > Y-skew by A -- mtrx = cairo.Matrix(1,T,0,1,0,0) > */ These skew formulas apply about the origin. Therefore for skew along X, only points on the line through Y = 0 remain unaffected, while for skew along Y, only the line through X = 0 remains unaffected. > cairo_matrix_init( > &matrix, > 1.0, 0.0, > skewx, 1.0, > 0.0, 0.0); > cairo_transform(cr, &matrix); > cairo_rectangle(cr, 10., 10., 50., 50.); Your rectangle is offset from Y = 0, which is why the whole thing gets skewed. If you want a more general skew formula with a stationary line somewhere other than at the origin, you can compose it out of the basic skew formula combined with additional translations as described here <http://cairographics.org/cookbook/transform_about_point/>. -- cairo mailing list [email protected] https://lists.cairographics.org/mailman/listinfo/cairo