Reputation: 7390
I am trying to understand the cairo_scale()
function. There is a documentation but I still don't get it.
Consider the following code
cairo_scale(cr,1./WIDTH,1./HEIGHT);
cairo_move_to(cr,0,0);
cairo_line_to(cr,1,1);
cairo_stroke(cr); //draw a line across the image
and (the working version) without scale
cairo_move_to(cr,0,0);
cairo_line_to(cr,WIDTH,HEIGHT);
cairo_stroke(cr);
As far as I understand cairo_scale(1/width,1/height)
should scale all following verbs, so the x and y ranges are from 0 to 1 (instead of 0 to WIDTH and 0 to HEIGHT).
Unfortunately it does not work and I cannot see anything. What is my mistake?
Upvotes: 1
Views: 3632
Reputation: 9877
You can think of cairo_scale()
as multiplying all the following coordinates with its argument.
In your case this means you are drawing a line from (0, 0)
to (1/width, 1/height)
which is less than a pixel.
You want to call cairo_scale(cr, WIDTH, HEIGHT)
instead.
Upvotes: 3