4
votes

I need to visualize a playing field for a robot game. Unfortunately, the game uses a right handed coordinate system, with the y axis pointing up.

Is there a way to adjust the cairo context of a drawing area so that it matches this coordinate system?

I can scale, translate and rotate, but I cant find a way of switching the y axis orientation, which would be more convenient compared to converting all coordinates individually.

Thank you for any input!

1

1 Answers

4
votes

You are allowed to define every field in a cairo_matrix_t:

cairo_matrix_t flip_y;
cairo_matrix_init(&flip_y, 1, 0, 0, -1, 0, 0);
cairo_set_matrix(cr, &flip_y);

Just remember how the trasformation is applied:

x_new = xx * x + xy * y + x0;
y_new = yx * x + yy * y + y0;