![]() |
![]() |
![]() |
GooCanvas Reference Manual | ![]() |
---|---|---|---|---|
#include <goocanvas.h> enum GooCanvasPathCommandType; union GooCanvasPathCommand; GooCanvasPath; GooCanvasItem* goo_canvas_path_new (GooCanvasItem *parent, gchar *path_data, ...);
GooCanvasPath represents a path item, which is a series of one or more lines, bezier curves, or elliptical arcs.
It is a subclass of GooCanvasItemSimple and so inherits all of the style properties such as "stroke-color", "fill-color" and "line-width".
It also implements the GooCanvasItem interface, so you can use the
GooCanvasItem functions such as goo_canvas_item_raise()
and
goo_canvas_item_rotate()
.
GooCanvasPath uses the same path specification strings as the Scalable Vector Graphics (SVG) path element. For details see the SVG specification.
To create a GooCanvasPath use goo_canvas_path_new()
.
To get or set the properties of an existing GooCanvasPath, use
g_object_get()
and g_object_set()
.
To respond to events such as mouse clicks on the path you must connect
to the signal handlers of the corresponding GooCanvasPathView objects.
(See goo_canvas_view_get_item_view()
and GooCanvasView::item-view-created.)
typedef enum { /* Simple commands like moveto and lineto: MmZzLlHhVv. */ GOO_CANVAS_PATH_MOVE_TO, GOO_CANVAS_PATH_CLOSE_PATH, GOO_CANVAS_PATH_LINE_TO, GOO_CANVAS_PATH_HORIZONTAL_LINE_TO, GOO_CANVAS_PATH_VERTICAL_LINE_TO, /* Bezier curve commands: CcSsQqTt. */ GOO_CANVAS_PATH_CURVE_TO, GOO_CANVAS_PATH_SMOOTH_CURVE_TO, GOO_CANVAS_PATH_QUADRATIC_CURVE_TO, GOO_CANVAS_PATH_SMOOTH_QUADRATIC_CURVE_TO, /* The elliptical arc commands: Aa. */ GOO_CANVAS_PATH_ELLIPTICAL_ARC } GooCanvasPathCommandType;
GooCanvasPathCommandType specifies the type of each command in the path. See the path element in the Scalable Vector Graphics (SVG) specification for more details.
union GooCanvasPathCommand { /* Simple commands like moveto and lineto: MmZzLlHhVv. */ struct { guint type : 5; /* GooCanvasPathCommandType */ guint relative : 1; gdouble x, y; } simple; /* Bezier curve commands: CcSsQqTt. */ struct { guint type : 5; /* GooCanvasPathCommandType */ guint relative : 1; gdouble x, y, x1, y1, x2, y2; } curve; /* The elliptical arc commands: Aa. */ struct { guint type : 5; /* GooCanvasPathCommandType */ guint relative : 1; guint large_arc_flag : 1; guint sweep_flag : 1; gdouble rx, ry, x_axis_rotation, x, y; } arc; };
GooCanvasPathCommand holds the data for each command in the path.
The relative
flag specifies that the coordinates for the command are
relative to the current point. Otherwise they are assumed to be absolute
coordinates.
typedef struct { GArray *commands; } GooCanvasPath;
The GooCanvasPath contains the list of commands specifying the path.
GArray *commands ; |
an array of GooCanvasPathCommand holding the specification of
the path. Applications can modify this directly, but must call
goo_canvas_item_simple_emit_changed() afterwards to notify the
views that the GooCanvasPath has changed.
|
GooCanvasItem* goo_canvas_path_new (GooCanvasItem *parent, gchar *path_data, ...);
Creates a new path item.
parent : |
the parent item, or NULL . If a parent is specified, it will assume
ownership of the item, and the item will automatically be freed when it is
removed from the parent. Otherwise call g_object_unref() to free it.
|
path_data : |
the sequence of path commands, specified as a string using the same syntax as in the Scalable Vector Graphics (SVG) path element. |
... : |
optional pairs of property names and values, and a terminating NULL .
|
Returns : | a new path item. |
Here's an example showing how to create a red line from (20,20) to (40,40):
GooCanvasItem *path = goo_canvas_path_new (mygroup, "M 20 20 L 40 40", "stroke-color", "red", NULL);
This example creates a cubic bezier curve from (20,100) to (100,100) with the control points at (20,50) and (100,50):
GooCanvasItem *path = goo_canvas_path_new (mygroup, "M20,100 C20,50 100,50 100,100", "stroke-color", "blue", NULL);
This example uses an elliptical arc to create a filled circle with one quarter missing:
GooCanvasItem *path = goo_canvas_path_new (mygroup, "M200,500 h-150 a150,150 0 1,0 150,-150 z", "fill-color", "red", "stroke-color", "blue", "line-width", 5.0, NULL);
data
" property"data" gchararray : Write
The sequence of path commands, specified as a string using the same syntax as in the Scalable Vector Graphics (SVG) path element.
Default value: NULL