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.
Draw a command.
The destination graphics context in which to draw
GDrawCommand to draw
Get the command type.
GDrawCommand from which to get the type
The type of the given GDrawCommand
Set the fill color of a command.
ref DrawCommand for which to set the fill color
GColor to set for the fill
Get the fill color of a command.
GDrawCommand from which to get the fill color
fill color of the given GDrawCommand
Set the stroke color of a command.
GDrawCommand for which to set the stroke color
GColor to set for the stroke
Get the stroke color of a command.
GDrawCommand from which to get the stroke color
The stroke color of the given GDrawCommand
Set the stroke width of a command.
GDrawCommand for which to set the stroke width
stroke width to set for the command
Get the stroke width of a command.
GDrawCommand from which to get the stroke width
The stroke width of the given GDrawCommand
Get the number of points in a command.
Set the value of the point in a command at the specified index.
GDrawCommand for which to set the value of a point
Index of the point to set the value for
new point value to set
Get the value of a point in a command from the specified index.
The index must be less than the number of points
GDrawCommand from which to get a point
The index to get the point for
The point in the GDrawCommand specified by point_idx
Set the radius of a circle command.
This only works for commands of type GDrawCommandCircle
GDrawCommand from which to set the circle radius
The radius to set for the circle.
Get the radius of a circle command.
this only works for commands of typeGDrawCommandCircle.
GDrawCommand from which to get the circle radius
The radius in pixels if command is of type GDrawCommandCircle
Set the path of a stroke command to be open.
This only works for commands of type GDrawCommandPath and GDrawCommandPrecisePath
GDrawCommand for which to set the path open status
true if path should be hidden
Return whether a stroke command path is open.
This only works for commands of type GDrawCommandPath and GDrawCommandPrecisePath
GDrawCommand from which to get the path open status
true if the path is open
Set a command as hidden. This command will not be drawn when gdraw_command_draw is called with this command.
GDrawCommand for which to set the hidden status
true if command should be hidden
Return whether a command is hidden.
GDrawCommand from which to get the hidden status
true if command is hidden
Draw a frame.
The destination graphics context in which to draw
The sequence from which the frame comes from (this is required)
Frame to draw
Offset from draw context origin to draw the frame
Set the duration of the frame.
GDrawCommandFrame for which to set the duration
duration of the frame in milliseconds
Get the duration of the frame.
GDrawCommandFrame from which to get the duration
duration of the frame in milliseconds
Creates a GDrawCommandImage from the specified resource (PDC file)
Resource containing data to load and create GDrawCommandImage from.
GDrawCommandImage pointer if the resource was loaded, NULL otherwise
Creates a GDrawCommandImage as a copy from a given image.
Image to copy.
cloned image or NULL if the operation failed
Deletes the GDrawCommandImage structure and frees associated data.
Pointer to the image to free (delete)
Draw an image.
The destination graphics context in which to draw
Image to draw
Offset from draw context origin to draw the image
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.
GDrawCommandImage from which to get the bounding box size
bounding box 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.
GDrawCommandImage for which to set the bounding box size
bounding box size
Get the command list of the image.
GDrawCommandImage from which to get the command list
command list
Iterate over all commands in a command list.
GDrawCommandList over which to iterate
iterator callback
context pointer to be passed into the iterator callback
Draw all commands in a command list.
The destination graphics context in which to draw
list of commands to draw
Get the command at the specified index.
the specified index must be less than the number of commands in the list
GDrawCommandList from which to get a command
index of the command to get
pointer to GDrawCommand at the specified index
Get the number of commands in the list.
GDrawCommandList from which to get the number of commands
number of commands in command list
Creates a GDrawCommandSequence from the specified resource (PDC file)
Resource containing data to load and create GDrawCommandSequence from.
GDrawCommandSequence pointer if the resource was loaded, NULL otherwise
Creates a GDrawCommandSequence as a copy from a given sequence.
Sequence to copy
cloned sequence or NULL if the operation failed
Deletes the GDrawCommandSequence structure and frees associated data.
Pointer to the sequence to destroy
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.
GDrawCommandSequence from which to get the frame
elapsed time in milliseconds
pointer to GDrawCommandFrame that should be displayed at the elapsed time
Get the frame at the specified index.
GDrawCommandSequence from which to get the frame
Index of frame to get
pointer to GDrawCommandFrame at the specified index
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.
GDrawCommandSequence from which to get the bounds
bounding box 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.
GDrawCommandSequence for which to set the bounds
bounding box size
Get the play count of the sequence.
GDrawCommandSequence from which to get the play count
play count of sequence
Set the play count of the sequence.
GDrawCommandSequence for which to set the play count
play count
Get the total duration of the sequence.
GDrawCommandSequence from which to get the total duration
total duration of the sequence in milliseconds
Get the number of frames in the sequence.
GDrawCommandSequence from which to get the number of frames
number of frames in the sequence
Get the command list of the frame.
GDrawCommandFrame from which to get the command list
command list
Invalid draw command type.
Arbitrary path draw command type.
Circle draw command type.
Arbitrary path drawn with sub-pixel precision (1/8th precision)
Draw command images contain a list of commands that can be drawn. An image can be loaded from PDC file data.
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.
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.
Draw command lists contain a list of commands that can be iterated over and drawn all at once.
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.
Callback for iterating over draw command list.
current GDrawCommand in iteration
index of the current command in the list
context pointer for the iteration operation
true if the iteration should continue after this command is processed
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!