[cairo] is skew supposed to move/shift top/left x?

Mark Olesen markjolesen at gmail.com
Thu Feb 11 07:12:10 UTC 2016


your correct, translating fixes it. Thanks.

...
cairo_matrix_init(
   &matrix,
   1.0, 0.0,
   skewx, 1.0,
   10.0, 10.0);
cairo_transform(cr, &matrix);
cairo_rectangle(cr, 0., 0., 50., 50.);
cairo_translate(cr, -10., -10.);
...


On Wed, Feb 10, 2016 at 10:45 PM, Lawrence D'Oliveiro <
ldo at geek-central.gen.nz> wrote:

> 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
> cairo at cairographics.org
> https://lists.cairographics.org/mailman/listinfo/cairo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20160211/b7f5d641/attachment.html>


More information about the cairo mailing list