<div dir="ltr">When skewing in the x direction, top x seems to move to the right a bit.I have attached a png. The red rectangle is not skewed, while the black is skewed at 45. The skewed (black) rectangle looks shifted to the right a few pixels. That is the top is not aligned. I would think there should be a diagonal line cutting through the top left hitting the bottom right corner. From my past history, I am probably doing something wrong. Thanks in advance.<br><br>#include <cairo.h><br>#include <math.h><br>#include <string.h><br>#include <stdlib.h><br><br>/*<br><a href="http://cairographics.org/cookbook/matrix_transform/http://cairographics.org/cookbook/matrix_transform/">http://cairographics.org/cookbook/matrix_transform/http://cairographics.org/cookbook/matrix_transform/</a><br>Lets take that C = math.cos(A), S = math.sin(A), T = math.tan(A)<br>X-skew by A    --    mtrx = cairo.Matrix(1,0,T,1,0,0)<br>Y-skew by A    --    mtrx = cairo.Matrix(1,T,0,1,0,0)<br>*/<br><br>int<br>main (int argc, char *argv[])<br>{<br>  cairo_surface_t* cs;<br>  cairo_t *cr;<br>  double angle;<br>  double skewx;<br>  cairo_matrix_t matrix;<br><br>  cs= cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 130.,100.);<br>  cr= cairo_create(cs);<br><br>  cairo_set_source_rgb(cr, 1., 0., 0.);<br>  cairo_rectangle(cr, 10., 10., 50., 50.);<br>  cairo_stroke(cr);<br><br>  angle= 45.;<br>  skewx= tan(angle * M_PI / 180.);<br>  cairo_matrix_init(<br>      &matrix,<br>      1.0, 0.0,<br>      skewx, 1.0,<br>      0.0, 0.0);<br>  cairo_transform(cr, &matrix);<br>  cairo_rectangle(cr, 10., 10., 50., 50.);<br>  cairo_set_source_rgb(cr, 0., 0., 0.);<br>  cairo_stroke(cr);<br><br>  cairo_surface_write_to_png(cs, "skew.png");<br><br>  cairo_destroy(cr);<br>  cairo_surface_destroy(cs);<br><br>  return 0;<br>}<br><br><br></div>