Pebble Foundation Classes  0.2.0
C++ for Pebble
RotBitmapLayer

Layer that displays a rotated bitmap image. More...

Collaboration diagram for RotBitmapLayer:

Typedefs

typedef struct RotBitmapLayer RotBitmapLayer
 

Functions

RotBitmapLayer * rot_bitmap_layer_create (GBitmap *bitmap)
 
void rot_bitmap_layer_destroy (RotBitmapLayer *bitmap)
 
void rot_bitmap_layer_set_corner_clip_color (RotBitmapLayer *bitmap, GColor color)
 
void rot_bitmap_layer_set_angle (RotBitmapLayer *bitmap, int32_t angle)
 
void rot_bitmap_layer_increment_angle (RotBitmapLayer *bitmap, int32_t angle_change)
 
void rot_bitmap_set_src_ic (RotBitmapLayer *bitmap, GPoint ic)
 
void rot_bitmap_set_compositing_mode (RotBitmapLayer *bitmap, GCompOp mode)
 

Detailed Description

Layer that displays a rotated bitmap image.

A RotBitmapLayer is like a BitmapLayer but has the ability to be rotated (by default, around its center). The amount of rotation is specified using rot_bitmap_layer_set_angle() or rot_bitmap_layer_increment_angle(). The rotation argument to those functions is specified as an amount of clockwise rotation, where the value 0x10000 represents a full 360 degree rotation and 0 represent no rotation, and it scales linearly between those values, just like sin_lookup.

The center of rotation in the source bitmap is always placed at the center of the RotBitmapLayer and the size of the RotBitmapLayer is automatically calculated so that the entire Bitmap can fit in at all rotation angles.

For example, if the image is 10px wide and high, the RotBitmapLayer will be 14px wide ( sqrt(10^2+10^2) ).

By default, the center of rotation in the source bitmap is the center of the bitmap but you can call rot_bitmap_set_src_ic() to change the center of rotation.

Note
RotBitmapLayer has performance limitations that can degrade user experience (see graphics_draw_rotated_bitmap). Use sparingly.

Function Documentation

◆ rot_bitmap_layer_create()

RotBitmapLayer* rot_bitmap_layer_create ( GBitmap *  bitmap)

Creates a new RotBitmapLayer on the heap and initializes it with the default values:

  • Angle: 0
  • Compositing mode: GCompOpAssign
  • Corner clip color: GColorClear
Parameters
bitmapThe bitmap to display in this RotBitmapLayer
Returns
A pointer to the RotBitmapLayer. NULL if the RotBitmapLayer could not be created

◆ rot_bitmap_layer_destroy()

void rot_bitmap_layer_destroy ( RotBitmapLayer *  bitmap)

Destroys a RotBitmapLayer and frees all associated memory.

Note
It is the developer responsibility to free the GBitmap.
Parameters
bitmapThe RotBitmapLayer to destroy.

◆ rot_bitmap_layer_increment_angle()

void rot_bitmap_layer_increment_angle ( RotBitmapLayer *  bitmap,
int32_t  angle_change 
)

Change the rotation angle of this RotBitmapLayer

Parameters
bitmapThe RotBitmapLayer on which to change the rotation
angle_changeThe rotation angle change

◆ rot_bitmap_layer_set_angle()

void rot_bitmap_layer_set_angle ( RotBitmapLayer *  bitmap,
int32_t  angle 
)

Sets the rotation angle of this RotBitmapLayer

Parameters
bitmapThe RotBitmapLayer on which to change the rotation
angleRotation is an integer between 0 (no rotation) and 0x10000 (360 degree rotation).
See also
sin_lookup()

◆ rot_bitmap_layer_set_corner_clip_color()

void rot_bitmap_layer_set_corner_clip_color ( RotBitmapLayer *  bitmap,
GColor  color 
)

Defines what color to use in areas that are not covered by the source bitmap. By default this is GColorClear.

Parameters
bitmapThe RotBitmapLayer on which to change the corner clip color
colorThe corner clip color

◆ rot_bitmap_set_compositing_mode()

void rot_bitmap_set_compositing_mode ( RotBitmapLayer *  bitmap,
GCompOp  mode 
)

Sets the compositing mode of how the bitmap image is composited onto what has been drawn beneath the RotBitmapLayer. By default this is GCompOpAssign. The RotBitmapLayer is automatically marked dirty after this operation.

Parameters
bitmapThe RotBitmapLayer on which to change the rotation
modeThe compositing mode to set
See also
GCompOp for visual examples of the different compositing modes.

◆ rot_bitmap_set_src_ic()

void rot_bitmap_set_src_ic ( RotBitmapLayer *  bitmap,
GPoint  ic 
)

Defines the only point that will not be affected by the rotation in the source bitmap.

For example, if you pass GPoint(0, 0), the image will rotate around the top-left corner.

This point is always projected at the center of the RotBitmapLayer. Calling this function automatically adjusts the width and height of the RotBitmapLayer so that the entire bitmap can fit inside the layer at all rotation angles.

Parameters
bitmapThe RotBitmapLayer on which to change the rotation
icThe only point in the original image that will not be affected by the rotation.