Functions to draw into a graphics context.
Use these drawing functions inside a Layer's .update_proc
drawing callback. A GContext
is passed into this callback as an argument. This GContext
can then be used with all of the drawing functions which are documented below. See Graphics Context for more information about the graphics context.
Refer toBuilding User Interfaces chapter in Pebble Developer Guide (chapter "Layers" and "Graphics") for a conceptual overview of the drawing system, Layers and relevant code examples.
Other drawing functions and related documentation:
GBitmap* graphics_capture_frame_buffer | ( | GContext * | ctx) |
Captures the frame buffer for direct access. Graphics functions will not affect the frame buffer while it is captured. The frame buffer is released when graphics_release_frame_buffer is called. The frame buffer must be released before the end of a layer's .update_proc
for the layer to be drawn properly.
While the frame buffer is captured calling graphics_capture_frame_buffer will fail and return NULL
.
ctx | The graphics context providing the frame buffer |
NULL
if failed. Draws a bitmap into the graphics context, inside the specified rectangle.
ctx | The destination graphics context in which to draw the bitmap |
bitmap | The bitmap to draw |
rect | The rectangle in which to draw the bitmap |
rect
is smaller than the size of the bitmap, the bitmap will be clipped on right and bottom edges. If the size of rect
is larger than the size of the bitmap, the bitmap will be tiled automatically in both horizontal and vertical directions, effectively drawing a repeating pattern. Draws the outline of a circle in the current stroke color.
ctx | The destination graphics context in which to draw |
p | The center point of the circle |
radius | The radius in pixels |
Draws a 1-pixel wide line in the current stroke color.
ctx | The destination graphics context in which to draw |
p0 | The starting point of the line |
p1 | The ending point of the line |
void graphics_draw_pixel | ( | GContext * | ctx, |
GPoint | point | ||
) |
Draws a pixel at given point in the current stroke color.
ctx | The destination graphics context in which to draw |
point | The point at which to draw the pixel |
void graphics_draw_rect | ( | GContext * | ctx, |
GRect | rect | ||
) |
Draws a 1-pixel wide rectangle outline in the current stroke color.
ctx | The destination graphics context in which to draw |
rect | The rectangle for which to draw the outline |
Draws the outline of a rounded rectangle in the current stroke color.
ctx | The destination graphics context in which to draw |
rect | The rectangle defining the dimensions of the rounded rectangle to draw |
radius | The corner radius in pixels |
Fills a circle in the current fill color.
ctx | The destination graphics context in which to draw |
p | The center point of the circle |
radius | The radius in pixels |
void graphics_fill_rect | ( | GContext * | ctx, |
GRect | rect, | ||
uint16_t | corner_radius, | ||
GCornerMask | corner_mask | ||
) |
Fills a retangle with the current fill color, optionally rounding all or a selection of its corners.
ctx | The destination graphics context in which to draw |
rect | The rectangle to fill |
corner_radius | The rounding radius of the corners in pixels (maximum is 8 pixels) |
corner_mask | Bitmask of the corners that need to be rounded. |
bool graphics_frame_buffer_is_captured | ( | GContext * | ctx) |
Whether or not the frame buffer has been captured by graphics_capture_frame_buffer. Graphics functions will not affect the frame buffer until it has been released by graphics_release_frame_buffer.
ctx | The graphics context providing the frame buffer |
bool graphics_release_frame_buffer | ( | GContext * | ctx, |
GBitmap * | buffer | ||
) |
Releases the frame buffer. Must be called before the end of a layer's .update_proc
for the layer to be drawn properly.
If buffer
does not point to the address previously returned by graphics_capture_frame_buffer the frame buffer will not be released.
ctx | The graphics context providing the frame buffer |
buffer | The pointer to frame buffer |
enum GCornerMask |
Bit mask values to specify the corners of a rectangle. The values can be combines using binary OR (|
), For example: the mask to indicate top left and bottom right corners can: be created as follows: (GCornerTopLeft | GCornerBottomRight)