Functions to draw polygons into a graphics context.
Code example:
static GPath *s_my_path_ptr = NULL;
static const GPathInfo BOLT_PATH_INFO = {
.num_points = 6,
.points = (GPoint []) {{21, 0}, {14, 26}, {28, 26}, {7, 60}, {14, 34}, {0, 34}}
};
// .update_proc of my_layer:
void my_layer_update_proc(Layer *my_layer, GContext* ctx) {
// Fill the path:
graphics_context_set_fill_color(ctx, GColorWhite);
gpath_draw_filled(ctx, s_my_path_ptr);
// Stroke the path:
graphics_context_set_stroke_color(ctx, GColorBlack);
gpath_draw_outline(ctx, s_my_path_ptr);
}
void setup_my_path(void) {
s_my_path_ptr = gpath_create(&BOLT_PATH_INFO);
// Rotate 15 degrees:
gpath_rotate_to(s_my_path_ptr, TRIG_MAX_ANGLE / 360 * 15);
// Translate by (5, 5):
gpath_move_to(s_my_path_ptr, GPoint(5, 5));
}
// For brevity, the setup of my_layer is not written out...
Free a dynamically allocated gpath created with gpath_create()
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.
The graphics context to draw into
The path to fill
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.
The graphics context to draw into
The path to draw
Sets the absolute rotation of the path. The current rotation will be replaced by the specified angle.
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().
The path onto which to set the rotation
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.
Sets the absolute offset of the path. The current translation will be replaced by the specified offset.
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().
The path onto which to set the translation
The point which is used as the vector for the translation.
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.
The graphics context to draw into
The path to draw
Data structure describing a path, plus its rotation and translation.
See the remark with GPathInfo
The number of points in the points
array.
Pointer to an array of points.
The rotation that will be used when drawing the path with gpath_draw_filled() or gpath_draw_outline()
The translation that will to be used when drawing the path with gpath_draw_filled() or gpath_draw_outline()
Data structure describing a naked path.
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.
Do you have questions about the Pebble SDK?
Do you need some help understanding something on this page?
You can either take advantage of our awesome developer community and check out the SDK Help forums, or you can send us a message through the website!