All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups
Drawing Primitives

Detailed Description

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:

Function 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.

See Also
GBitmap
Parameters
ctxThe graphics context providing the frame buffer
Returns
A pointer to the frame buffer. NULL if failed.
void graphics_draw_bitmap_in_rect ( GContext *  ctx,
const GBitmap bitmap,
GRect  rect 
)

Draws a bitmap into the graphics context, inside the specified rectangle.

Parameters
ctxThe destination graphics context in which to draw the bitmap
bitmapThe bitmap to draw
rectThe rectangle in which to draw the bitmap
Note
If the size of 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.
See Also
GBitmap
GContext
void graphics_draw_circle ( GContext *  ctx,
GPoint  p,
uint16_t  radius 
)

Draws the outline of a circle in the current stroke color.

Parameters
ctxThe destination graphics context in which to draw
pThe center point of the circle
radiusThe radius in pixels
void graphics_draw_line ( GContext *  ctx,
GPoint  p0,
GPoint  p1 
)

Draws a 1-pixel wide line in the current stroke color.

Parameters
ctxThe destination graphics context in which to draw
p0The starting point of the line
p1The ending point of the line
void graphics_draw_pixel ( GContext *  ctx,
GPoint  point 
)

Draws a pixel at given point in the current stroke color.

Parameters
ctxThe destination graphics context in which to draw
pointThe 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.

Parameters
ctxThe destination graphics context in which to draw
rectThe rectangle for which to draw the outline
void graphics_draw_round_rect ( GContext *  ctx,
GRect  rect,
uint16_t  radius 
)

Draws the outline of a rounded rectangle in the current stroke color.

Parameters
ctxThe destination graphics context in which to draw
rectThe rectangle defining the dimensions of the rounded rectangle to draw
radiusThe corner radius in pixels
void graphics_fill_circle ( GContext *  ctx,
GPoint  p,
uint16_t  radius 
)

Fills a circle in the current fill color.

Parameters
ctxThe destination graphics context in which to draw
pThe center point of the circle
radiusThe 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.

Parameters
ctxThe destination graphics context in which to draw
rectThe rectangle to fill
corner_radiusThe rounding radius of the corners in pixels (maximum is 8 pixels)
corner_maskBitmask of the corners that need to be rounded.
See Also
GCornerMask
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.

Parameters
ctxThe graphics context providing the frame buffer
Returns
True if the frame buffer has been captured
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.

Parameters
ctxThe graphics context providing the frame buffer
bufferThe pointer to frame buffer
Returns
True if the frame buffer was released successfully

Enumeration Type Documentation

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)

Enumerator
GCornerNone 

No corners.

GCornerTopLeft 

Top-Left corner.

GCornerTopRight 

Top-Right corner.

GCornerBottomLeft 

Bottom-Left corner.

GCornerBottomRight 

Bottom-Right corner.

GCornersAll 

All corners.

GCornersTop 

Top corners.

GCornersBottom 

Bottom corners.

GCornersLeft 

Left corners.

GCornersRight 

Right corners.