Functions to draw polygons into a graphics context.
More...
Functions to draw polygons into a graphics context.
Code example:
static GPath *s_my_path_ptr = NULL;
.points = (
GPoint []) {{21, 0}, {14, 26}, {28, 26}, {7, 60}, {14, 34}, {0, 34}}
};
void my_layer_update_proc(Layer *my_layer, GContext* ctx) {
}
void setup_my_path(void) {
}
◆ GPath
Data structure describing a path, plus its rotation and translation.
- Note
- See the remark with GPathInfo
◆ GPathInfo
Data structure describing a naked path
- Note
- Note that this data structure only refers to an array of points; the points are not stored inside this data structure itself. In most cases, one cannot use a stack-allocated array of GPoints. Instead one often needs to provide longer-lived (static or "global") storage for the points.
◆ gpath_create()
Creates a new GPath on the heap based on a series of points described by a GPathInfo.
Values after initialization:
num_points
and points
pointer: copied from the GPathInfo.
rotation
: 0
offset
: (0, 0) - Returns
- A pointer to the GPath.
NULL
if the GPath could not be created
◆ gpath_draw_filled()
void gpath_draw_filled |
( |
GContext * |
ctx, |
|
|
GPath * |
path |
|
) |
| |
Draws the fill of a path into a graphics context, using the current fill color, relative to the drawing area as set up by the layering system.
- Parameters
-
ctx | The graphics context to draw into |
path | The path to fill |
- See also
- graphics_context_set_fill_color()
◆ gpath_draw_outline()
void gpath_draw_outline |
( |
GContext * |
ctx, |
|
|
GPath * |
path |
|
) |
| |
Draws the outline of a path into a graphics context, using the current stroke color and width, relative to the drawing area as set up by the layering system. The first and last points in the path do have a line between them.
- Parameters
-
ctx | The graphics context to draw into |
path | The path to draw |
- See also
- graphics_context_set_stroke_color()
-
gpath_draw_outline_open()
◆ gpath_draw_outline_open()
void gpath_draw_outline_open |
( |
GContext * |
ctx, |
|
|
GPath * |
path |
|
) |
| |
Draws an open outline of a path into a graphics context, using the current stroke color and width, relative to the drawing area as set up by the layering system. The first and last points in the path do not have a line between them.
- Parameters
-
ctx | The graphics context to draw into |
path | The path to draw |
- See also
- graphics_context_set_stroke_color()
-
gpath_draw_outline()
◆ gpath_move_to()
Sets the absolute offset of the path. The current translation will be replaced by the specified offset.
- Parameters
-
path | The path onto which to set the translation |
point | The point which is used as the vector for the translation. |
- Note
- Setting a translation does not affect the points in the path directly. The translation is applied on-the-fly during drawing, either using gpath_draw_filled() or gpath_draw_outline().
◆ gpath_rotate_to()
void gpath_rotate_to |
( |
GPath * |
path, |
|
|
int32_t |
angle |
|
) |
| |
Sets the absolute rotation of the path. The current rotation will be replaced by the specified angle.
- Parameters
-
path | The path onto which to set the rotation |
angle | The absolute angle of the rotation. The angle is represented in the same way that is used with sin_lookup(). See TRIG_MAX_ANGLE for more information. |
- Note
- Setting a rotation does not affect the points in the path directly. The rotation is applied on-the-fly during drawing, either using gpath_draw_filled() or gpath_draw_outline().