[Cairo] New functions to get/set current path (in Cairo 0.1.4)

Carl Worth cworth at east.isi.edu
Thu Sep 25 08:16:15 PDT 2003


By request, I've added to Cairo the ability to get/set the current
path. The necessary new functions are:

	cairo_path_t *
	cairo_current_path (cairo_t *cr);

	void
	cairo_set_path (cairo_t *cr, cairo_path_t *path);

	void
	cairo_path_destroy (cairo_path_t *path);
	
A path returned by cairo_current_path will have coordinates in the
current user space and cairo_set_path will transform from user to
device space. This means that the path will be affected by changes to
the transformation matrix that occur between cairo_current_path and
cairo_set_path. I think this is the expected and desired behavior.

As always, any feedback is quite welcome.

-Carl

PS. The new cairo_path_t is another opaque object. Since I had to add
that, I also exposed functions for creating paths "off-line", (without
reference to any cairo_t state object):

	cairo_path_t *
	cairo_path_create (void);

	cairo_status_t
	cairo_path_move_to (cairo_path_t *path, double x, double y);

	cairo_status_t
	cairo_path_line_to (cairo_path_t *path, double x, double y);

	cairo_status_t
	cairo_path_curve_to (cairo_path_t *path,
        	             double x1, double y1,
		             double x2, double y2,
		             double x3, double y3);

	cairo_status_t
	cairo_path_rel_move_to (cairo_path_t *path,
		                double dx, double dy);

	cairo_status_t
	cairo_path_rel_line_to (cairo_path_t *path,
		                double dx, double dy);

	cairo_status_t
	cairo_path_rel_curve_to (cairo_path_t *path,
		                 double dx1, double dy1,
		                 double dx2, double dy2,
		                 double dx3, double dy3);

	cairo_status_t
	cairo_path_close_path (cairo_path_t *path);

Currently, cairo_path_t is primarily a "write-only" object. The only
query function available is to get the current point:

	cairo_status_t
	cairo_path_current_point (cairo_path_t *path,
		                  double *x_ret,
		                  double *y_ret);

If someone needs a real mechanism to query the actual path
coordinates, I would be glad to look at a proposed API, (or better, an
implementation).




More information about the cairo mailing list