[cairo] Cairo lines disappear in a certain scale range

robert9reen at yahoo.com robert9reen at yahoo.com
Wed Apr 1 05:50:39 PDT 2009


Hi everyone,

I'm testing Cairo under Win32 so I wrote a small Windows program (in C) that draws lines on a child window. So far, I have implemented panning and zooming successfully. I use cairo_win32_surface_create() to create the surface. User space origin is translated to the center of my display window with the Y axis going up (like in a CAD program). I have a dozen of random lines whose endpoints coord. range approx. between -32000.0 and +32000.0 
When my program starts with a cairo_scale(cr, 0.125, -0.125), I can't see all the lines (I'm zoomed in and can only see parts of a few lines) so I zoom out (gradually by dividing the scale factor -- initially 0.125 -- by 2.0) until I reach cairo_scale(cr, 0.0078125, -0.0078125) in order to have all my lines shown inside the display window.
 Fine.

Then I decided to
 add a taller line (-1000000000.0, -1000000000.0, 1000000000.0, 1000000000.0) [that's one billion, ok?] which should obviously pass through the orgin (0,0).. but when I start the program with my initial scale factor 0.125, the tall line is not displayed; Logically, I should be able to see it crossing my window! Now here's the wierd part: if I zoom out from 0.125 to 0.000061035156 (dividing scale factor by 2.0 each time), nothing special happens except that my bunch of initial lines become a tiny spot at the middle of my display window.. logical.. now if I zoom out just one more time -- so I move from cairo_scale(cr, 0.000061035156 to cairo_scale(cr, 0.000030517578) -- the tall line appears! It crosses the display window's central point (0,0) as expected.. in order to see the tall lines endpoints (-/+ 1 billion) on my screen, I have to zoom out to 0.000000238419.

Note: In order to keep line width 1 single pixel regardless of transformation, I'm
 using:

double w1, w2;
 w1 = w2 = 1.0;
 cairo_device_to_user_distance (cr, &w1, &w2);
 cairo_set_line_width (cr, w1 > w2 ? w1 : w2); 

Could someone please explain to me what's going on? According to my past programming experience with other libraries, such behavior may be related to a variable range overflow during user-space to device-space conversion operations. Do you have a fix for that? If not, what are the minimum/maximum limits for shape coordinates and scale factors to avoid such problems?

Thank you very much!

PS. If I can provide further information to clear out this issue, please let me know.

Robert




      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20090401/e685dec3/attachment-0001.html 


More information about the cairo mailing list