[cairo] Problems with cairo_get_line_width and "new" semantics

Behdad Esfahbod behdad at cs.toronto.edu
Tue May 16 14:24:11 PDT 2006


On Tue, 16 May 2006, Bill Spitzak wrote:

> Carl Worth wrote:
>
> > Perhaps what we should do is to add two new functions for working with
> > the pen directly as the ellipse it is?
> >
> > 	cairo_public void
> > 	cairo_set_pen (cairo_t			*cr,
> > 		       double			 line_width,
> > 		       const cairo_matrix_t	*matrix);
> >
> > 	cairo_public void
> > 	cairo_get_pen (cairo_t			*cr,
> > 		       double			*line_width,
> > 		       cairo_matrix_t		*matrix);
> >
> > Then it's simple enough to specify cairo_set_line_width as being
> > equivalent to calling cairo_set_pen with the matrix argument equal to
> > the current CTM.
> >
> > Then I suppose cairo_get_line_width could be specified as being
> > equivalent to cairo_get_pen and simply ignoring the matrix
> > returned. That is, this would return a line width in the _original_
> > user space and not in the current user space.
> >
> > Thoughts?
>
> I think the "all api is in user CTM" idea would also apply here. So I
> would propose:
>
> set_pen(size, matrix) would multiply the matrix by the CTM and store
> that as the penCTM. It would also store the size.
>
> get_pen() would divide the penCTM by the CTM and return that, and return
> the size unchanged.
>
> set_pen_width(size) would be the same as set_pen(size, identity).
>
> get_pen_width() would return the size multiplied by the square root of
> the determinant of the penCTM divided by the CTM.

I'll rather go like your font suggestion:

set_pen_matrix(m) multiples m by CTM and sets as penCTM.
get_pen_matrix() divides penCTM by CTM and returns.
set_pen_width(s) does set_pen_matrix([s, 0, 0, s]).
get_pen_width() returns square root of the determinant of the
penCTM divided by the CTM.

This makes the pen_width handling exactly like the font_size is.


--behdad
http://behdad.org/

"Commandment Three says Do Not Kill, Amendment Two says Blood Will Spill"
	-- Dan Bern, "New American Language"


More information about the cairo mailing list