[cairo] Default line width == 2.0?

Øyvind Kolås islewind at gmail.com
Mon Sep 20 23:16:56 PDT 2004


On Mon, 20 Sep 2004 22:32:32 +0100, Calum Robinson <calumr at mac.com> wrote:
> I have started a CoreGraphics (Mac OS X native drawing API) backend for
> Cairo, and so far I have had reasonable success, except for drawing
> lines.
> 
> The sample app I am using has only 2 Cairo drawing calls in it (taken
> from the snippets page):
> 
> cairo_move_to (cr, 0.5, 0.1);
> cairo_line_to (cr, 0.9, 0.9);
> 
> When my CoreGraphics port draws this, is works, only the line is twice
> as thick as the screen. At a glance, this appears to be because
> CAIRO_GSTATE_LINE_WIDTH_DEFAULT is 2.0, but I get the impression that
> lines aren't set up to be twice as think as the default canvas size.
> What am I missing?

Are you doing the same initialization that cairo_snippets is doing?

    int width = canvas_width_in_pixels;
    int height = canvas_width_in_pixels;
    #define LINE_WIDTH 0.04

    cairo_save (cr);
      cairo_scale (cr, width/1.0, height/1.0);
      cairo_rectangle (cr, 0,0, 1.0, 1.0);
      cairo_set_rgb_color (cr, 1,1,1);
      cairo_fill (cr);
      cairo_set_rgb_color (cr, 0.0, 0.0, 0.0);
      cairo_set_line_width (cr, LINE_WIDTH);

      snippet_do (cr, current_snippet);
    cairo_restore (cr);

is the actual surrounding cairo code for a snippet,
if you skip the cairo_set_line_width call, the default
line width of 2.0 (
http://cairographics.org/FAQ#Why_does_my_1_pixel_wide_horizon  )
will be scaled to be twice the canvas size.

/pippin



More information about the cairo mailing list