Pebble Draw Commands are a way to encode arbitrary path draw and fill calls in binary format, so that vector-like graphics can be represented on the watch.
More...
|
void | gdraw_command_draw (GContext *ctx, GDrawCommand *command) |
|
GDrawCommandType | gdraw_command_get_type (GDrawCommand *command) |
|
void | gdraw_command_set_fill_color (GDrawCommand *command, GColor fill_color) |
|
GColor | gdraw_command_get_fill_color (GDrawCommand *command) |
|
void | gdraw_command_set_stroke_color (GDrawCommand *command, GColor stroke_color) |
|
GColor | gdraw_command_get_stroke_color (GDrawCommand *command) |
|
void | gdraw_command_set_stroke_width (GDrawCommand *command, uint8_t stroke_width) |
|
uint8_t | gdraw_command_get_stroke_width (GDrawCommand *command) |
|
uint16_t | gdraw_command_get_num_points (GDrawCommand *command) |
| Get the number of points in a command.
|
|
void | gdraw_command_set_point (GDrawCommand *command, uint16_t point_idx, GPoint point) |
|
GPoint | gdraw_command_get_point (GDrawCommand *command, uint16_t point_idx) |
|
void | gdraw_command_set_radius (GDrawCommand *command, uint16_t radius) |
|
uint16_t | gdraw_command_get_radius (GDrawCommand *command) |
|
void | gdraw_command_set_path_open (GDrawCommand *command, bool path_open) |
|
bool | gdraw_command_get_path_open (GDrawCommand *command) |
|
void | gdraw_command_set_hidden (GDrawCommand *command, bool hidden) |
|
bool | gdraw_command_get_hidden (GDrawCommand *command) |
|
void | gdraw_command_frame_draw (GContext *ctx, GDrawCommandSequence *sequence, GDrawCommandFrame *frame, GPoint offset) |
|
void | gdraw_command_frame_set_duration (GDrawCommandFrame *frame, uint32_t duration) |
|
uint32_t | gdraw_command_frame_get_duration (GDrawCommandFrame *frame) |
|
GDrawCommandImage * | gdraw_command_image_create_with_resource (uint32_t resource_id) |
|
GDrawCommandImage * | gdraw_command_image_clone (GDrawCommandImage *image) |
|
void | gdraw_command_image_destroy (GDrawCommandImage *image) |
|
void | gdraw_command_image_draw (GContext *ctx, GDrawCommandImage *image, GPoint offset) |
|
GSize | gdraw_command_image_get_bounds_size (GDrawCommandImage *image) |
|
void | gdraw_command_image_set_bounds_size (GDrawCommandImage *image, GSize size) |
|
GDrawCommandList * | gdraw_command_image_get_command_list (GDrawCommandImage *image) |
|
void | gdraw_command_list_iterate (GDrawCommandList *command_list, GDrawCommandListIteratorCb handle_command, void *callback_context) |
|
void | gdraw_command_list_draw (GContext *ctx, GDrawCommandList *command_list) |
|
GDrawCommand * | gdraw_command_list_get_command (GDrawCommandList *command_list, uint16_t command_idx) |
|
uint32_t | gdraw_command_list_get_num_commands (GDrawCommandList *command_list) |
|
GDrawCommandSequence * | gdraw_command_sequence_create_with_resource (uint32_t resource_id) |
|
GDrawCommandSequence * | gdraw_command_sequence_clone (GDrawCommandSequence *sequence) |
|
void | gdraw_command_sequence_destroy (GDrawCommandSequence *sequence) |
|
GDrawCommandFrame * | gdraw_command_sequence_get_frame_by_elapsed (GDrawCommandSequence *sequence, uint32_t elapsed_ms) |
|
GDrawCommandFrame * | gdraw_command_sequence_get_frame_by_index (GDrawCommandSequence *sequence, uint32_t index) |
|
GSize | gdraw_command_sequence_get_bounds_size (GDrawCommandSequence *sequence) |
|
void | gdraw_command_sequence_set_bounds_size (GDrawCommandSequence *sequence, GSize size) |
|
uint32_t | gdraw_command_sequence_get_play_count (GDrawCommandSequence *sequence) |
|
void | gdraw_command_sequence_set_play_count (GDrawCommandSequence *sequence, uint32_t play_count) |
|
uint32_t | gdraw_command_sequence_get_total_duration (GDrawCommandSequence *sequence) |
|
uint32_t | gdraw_command_sequence_get_num_frames (GDrawCommandSequence *sequence) |
|
GDrawCommandList * | gdraw_command_frame_get_command_list (GDrawCommandFrame *frame) |
|
Pebble Draw Commands are a way to encode arbitrary path draw and fill calls in binary format, so that vector-like graphics can be represented on the watch.
These draw commands can be loaded from resources, manipulated in place and drawn to the current graphics context. Each GDrawCommand can be an arbitrary path or a circle with optional fill or stroke. The stroke width and color of the stroke and fill are also encoded within the GDrawCommand. Paths can can be drawn open or closed.
All aspects of a draw command can be modified, except for the number of points in a path (a circle only has one point, the center).
Draw commands are grouped into a GDrawCommandList, which can be drawn all at once. Each individual GDrawCommand can be accessed from a GDrawCommandList for modification.
A GDrawCommandList forms the basis for GDrawCommandImage and GDrawCommandFrame objects. A GDrawCommandImage represents a static image and can be represented by the PDC file format and can be loaded as a resource.
Once you have a GDrawCommandImage loaded in memory you can draw it on the screen in a LayerUpdateProc with the gdraw_command_image_draw().
A GDrawCommandFrame represents a single frame of an animated sequence, with multiple frames making up a single GDrawCommandSequence, which can also be stored as a PDC and loaded as a resource.
To draw a GDrawCommandSequence, use the gdraw_command_sequence_get_frame_by_elapsed() to obtain the current GDrawCommandFrame and gdraw_command_frame_draw() to draw it.
Draw commands also allow access to drawing with sub-pixel precision. The points are treated as Fixed point types in the format 13.3, so that 1/8th of a pixel precision is possible. Only the points in draw commands of the type GDrawCommandTypePrecisePath will be treated as higher precision.
◆ GDrawCommand
Draw commands are the basic building block of the draw command system, encoding the type of command to draw, the stroke width and color, fill color, and points that define the path (or center of a circle
◆ GDrawCommandFrame
Draw command frames contain a list of commands to draw for that frame and a duration, indicating the length of time for which the frame should be drawn in an animation sequence. Frames form the building blocks of a GDrawCommandSequence, which consists of multiple frames.
◆ GDrawCommandImage
Draw command images contain a list of commands that can be drawn. An image can be loaded from PDC file data.
◆ GDrawCommandListIteratorCb
typedef bool(* GDrawCommandListIteratorCb) (GDrawCommand *command, uint32_t index, void *context) |
Callback for iterating over draw command list
- Parameters
-
command | current GDrawCommand in iteration |
index | index of the current command in the list |
context | context pointer for the iteration operation |
- Returns
- true if the iteration should continue after this command is processed
◆ GDrawCommandSequence
Draw command sequences allow the animation of frames over time. Each sequence has a list of frames that can be accessed by the elapsed duration of the animation (not maintained internally) or by index. Sequences can be loaded from PDC file data.
◆ GDrawCommandType
Enumerator |
---|
GDrawCommandTypeInvalid | Invalid draw command type.
|
GDrawCommandTypePath | Arbitrary path draw command type.
|
GDrawCommandTypeCircle | Circle draw command type.
|
GDrawCommandTypePrecisePath | Arbitrary path drawn with sub-pixel precision (1/8th precision)
|
◆ gdraw_command_draw()
void gdraw_command_draw |
( |
GContext * |
ctx, |
|
|
GDrawCommand * |
command |
|
) |
| |
Draw a command
- Parameters
-
ctx | The destination graphics context in which to draw |
command | GDrawCommand to draw |
◆ gdraw_command_frame_draw()
Draw a frame
- Parameters
-
ctx | The destination graphics context in which to draw |
sequence | The sequence from which the frame comes from (this is required) |
frame | Frame to draw |
offset | Offset from draw context origin to draw the frame |
◆ gdraw_command_frame_get_command_list()
Get the command list of the frame
- Parameters
-
- Returns
- command list
◆ gdraw_command_frame_get_duration()
Get the duration of the frame
- Parameters
-
- Returns
- duration of the frame in milliseconds
◆ gdraw_command_frame_set_duration()
void gdraw_command_frame_set_duration |
( |
GDrawCommandFrame * |
frame, |
|
|
uint32_t |
duration |
|
) |
| |
Set the duration of the frame
- Parameters
-
frame | GDrawCommandFrame for which to set the duration |
duration | duration of the frame in milliseconds |
◆ gdraw_command_get_fill_color()
Get the fill color of a command
- Parameters
-
- Returns
- fill color of the given GDrawCommand
◆ gdraw_command_get_hidden()
Return whether a command is hidden
- Parameters
-
- Returns
- true if command is hidden
◆ gdraw_command_get_path_open()
Return whether a stroke command path is open
- Note
- This only works for commands of type GDrawCommandPath and GDrawCommandPrecisePath
- Parameters
-
- Returns
- true if the path is open
◆ gdraw_command_get_point()
Get the value of a point in a command from the specified index
- Parameters
-
command | GDrawCommand from which to get a point |
point_idx | The index to get the point for |
- Returns
- The point in the GDrawCommand specified by point_idx
- Note
- The index must be less than the number of points
◆ gdraw_command_get_radius()
Get the radius of a circle command.
- Note
- this only works for commands of typeGDrawCommandCircle.
- Parameters
-
- Returns
- The radius in pixels if command is of type GDrawCommandCircle
◆ gdraw_command_get_stroke_color()
Get the stroke color of a command
- Parameters
-
- Returns
- The stroke color of the given GDrawCommand
◆ gdraw_command_get_stroke_width()
uint8_t gdraw_command_get_stroke_width |
( |
GDrawCommand * |
command | ) |
|
Get the stroke width of a command
- Parameters
-
- Returns
- The stroke width of the given GDrawCommand
◆ gdraw_command_get_type()
Get the command type
- Parameters
-
- Returns
- The type of the given GDrawCommand
◆ gdraw_command_image_clone()
Creates a GDrawCommandImage as a copy from a given image
- Parameters
-
- Returns
- cloned image or NULL if the operation failed
◆ gdraw_command_image_create_with_resource()
Creates a GDrawCommandImage from the specified resource (PDC file)
- Parameters
-
resource_id | Resource containing data to load and create GDrawCommandImage from. |
- Returns
- GDrawCommandImage pointer if the resource was loaded, NULL otherwise
◆ gdraw_command_image_destroy()
Deletes the GDrawCommandImage structure and frees associated data
- Parameters
-
image | Pointer to the image to free (delete) |
◆ gdraw_command_image_draw()
Draw an image
- Parameters
-
ctx | The destination graphics context in which to draw |
image | Image to draw |
offset | Offset from draw context origin to draw the image |
◆ gdraw_command_image_get_bounds_size()
Get size of the bounding box surrounding all draw commands in the image. This bounding box can be used to set the graphics context or layer bounds when drawing the image.
- Parameters
-
- Returns
- bounding box size
◆ gdraw_command_image_get_command_list()
Get the command list of the image
- Parameters
-
- Returns
- command list
◆ gdraw_command_image_set_bounds_size()
Set size of the bounding box surrounding all draw commands in the image. This bounding box can be used to set the graphics context or layer bounds when drawing the image.
- Parameters
-
◆ gdraw_command_list_draw()
void gdraw_command_list_draw |
( |
GContext * |
ctx, |
|
|
GDrawCommandList * |
command_list |
|
) |
| |
Draw all commands in a command list
- Parameters
-
ctx | The destination graphics context in which to draw |
command_list | list of commands to draw |
◆ gdraw_command_list_get_command()
Get the command at the specified index
- Note
- the specified index must be less than the number of commands in the list
- Parameters
-
command_list | GDrawCommandList from which to get a command |
command_idx | index of the command to get |
- Returns
- pointer to GDrawCommand at the specified index
◆ gdraw_command_list_get_num_commands()
Get the number of commands in the list
- Parameters
-
- Returns
- number of commands in command list
◆ gdraw_command_list_iterate()
Iterate over all commands in a command list
- Parameters
-
command_list | GDrawCommandList over which to iterate |
handle_command | iterator callback |
callback_context | context pointer to be passed into the iterator callback |
◆ gdraw_command_sequence_clone()
Creates a GDrawCommandSequence as a copy from a given sequence
- Parameters
-
- Returns
- cloned sequence or NULL if the operation failed
◆ gdraw_command_sequence_create_with_resource()
Creates a GDrawCommandSequence from the specified resource (PDC file)
- Parameters
-
resource_id | Resource containing data to load and create GDrawCommandSequence from. |
- Returns
- GDrawCommandSequence pointer if the resource was loaded, NULL otherwise
◆ gdraw_command_sequence_destroy()
Deletes the GDrawCommandSequence structure and frees associated data
- Parameters
-
image | Pointer to the sequence to destroy |
◆ gdraw_command_sequence_get_bounds_size()
Get the size of the bounding box surrounding all draw commands in the sequence. This bounding box can be used to set the graphics context or layer bounds when drawing the frames in the sequence.
- Parameters
-
- Returns
- bounding box size
◆ gdraw_command_sequence_get_frame_by_elapsed()
Get the frame that should be shown after the specified amount of elapsed time The last frame will be returned if the elapsed time exceeds the total time
- Parameters
-
- Returns
- pointer to GDrawCommandFrame that should be displayed at the elapsed time
◆ gdraw_command_sequence_get_frame_by_index()
Get the frame at the specified index
- Parameters
-
- Returns
- pointer to GDrawCommandFrame at the specified index
◆ gdraw_command_sequence_get_num_frames()
Get the number of frames in the sequence
- Parameters
-
- Returns
- number of frames in the sequence
◆ gdraw_command_sequence_get_play_count()
Get the play count of the sequence
- Parameters
-
- Returns
- play count of sequence
◆ gdraw_command_sequence_get_total_duration()
Get the total duration of the sequence.
- Parameters
-
- Returns
- total duration of the sequence in milliseconds
◆ gdraw_command_sequence_set_bounds_size()
Set size of the bounding box surrounding all draw commands in the sequence. This bounding box can be used to set the graphics context or layer bounds when drawing the frames in the sequence.
- Parameters
-
◆ gdraw_command_sequence_set_play_count()
Set the play count of the sequence
- Parameters
-
◆ gdraw_command_set_fill_color()
Set the fill color of a command
- Parameters
-
command | ref DrawCommand for which to set the fill color |
fill_color | GColor to set for the fill |
◆ gdraw_command_set_hidden()
void gdraw_command_set_hidden |
( |
GDrawCommand * |
command, |
|
|
bool |
hidden |
|
) |
| |
Set a command as hidden. This command will not be drawn when gdraw_command_draw is called with this command
- Parameters
-
command | GDrawCommand for which to set the hidden status |
hidden | true if command should be hidden |
◆ gdraw_command_set_path_open()
void gdraw_command_set_path_open |
( |
GDrawCommand * |
command, |
|
|
bool |
path_open |
|
) |
| |
Set the path of a stroke command to be open
- Note
- This only works for commands of type GDrawCommandPath and GDrawCommandPrecisePath
- Parameters
-
command | GDrawCommand for which to set the path open status |
path_open | true if path should be hidden |
◆ gdraw_command_set_point()
Set the value of the point in a command at the specified index
- Parameters
-
command | GDrawCommand for which to set the value of a point |
point_idx | Index of the point to set the value for |
point | new point value to set |
◆ gdraw_command_set_radius()
void gdraw_command_set_radius |
( |
GDrawCommand * |
command, |
|
|
uint16_t |
radius |
|
) |
| |
Set the radius of a circle command
- Note
- This only works for commands of type GDrawCommandCircle
- Parameters
-
command | GDrawCommand from which to set the circle radius |
radius | The radius to set for the circle. |
◆ gdraw_command_set_stroke_color()
Set the stroke color of a command
- Parameters
-
command | GDrawCommand for which to set the stroke color |
stroke_color | GColor to set for the stroke |
◆ gdraw_command_set_stroke_width()
void gdraw_command_set_stroke_width |
( |
GDrawCommand * |
command, |
|
|
uint8_t |
stroke_width |
|
) |
| |
Set the stroke width of a command
- Parameters
-
command | GDrawCommand for which to set the stroke width |
stroke_width | stroke width to set for the command |