[cairo] Drawing points?
Ian Britten
britten at caris.com
Fri Jun 19 11:24:14 PDT 2009
Carl Worth wrote:
>> Is there a recommended way of drawing points with Cairo?
> If that idiom seems odd, here's another:
>
> cairo_move_to (cr, x, y);
> cairo_line_to (cr, x, y);
> /* repeat for each point */
>
> cairo_stroke (cr);
That's what we ended up trying ...
> Within the implementation (and test suite) we call these "degenerate"
> paths and we explicitly support drawing round caps for such degenerate
> paths. So this should work perfectly for the case of
> CAIRO_LINE_CAP_ROUND and you'll get the diameter controlled by
> cairo_set_line_width just like you want.
Yep, we found that to be the case. :)
> However, I believe that we have specified that degenerate paths do not
> draw anything in the case of CAIRO_LINE_CAP_SQUARE. The problem their is
> that there's ambiguity as to what direction the square caps should be
> drawn in. (Contrast this with the case of stroking a dashed line with
> square caps and a dash pattern with a zero-length "on" section. In that
> case, we do have direction information and we do draw the caps.)
Yep, we had also run into this, and I was just getting ready to ask
about the apparent bug/inconsistency.
Do you think the possible ambiguity justifies not drawing anything
at all (which seems to be the current behaviour), as opposed to
drawing something (At some documented orientation)?
> It might be desirable to draw axis-aligned squares in the case of
> stroking degenerate paths with square caps, and one could argue that
> this is what cairo should do. But so far we've opted not to do that.
>
> I'd definitely be open for more opinions on this. It's good for us to
> strengthen our rationale for various decisions. And obviously we need to
> document some of these idioms more completely.
I'd vote for that. I suspect an axis-aligned box would be a
sane/traditional default (dating back to earlier graphics systems),
and would be what I would have assumed Cairo would do.
Otherwise, I guess I'm left to calculate+position+draw an appropriate
square myself, eh?
Many thanks for the explanation (And for any enhancements! ;) )
Ian
More information about the cairo
mailing list