﻿ Tutorials > Tutorial 03 - Displaying Bitmaps & Icons > f. Bitmaps at Angles

# f. Bitmaps at Angles

Navigation:  Tutorials > Tutorial 03 - Displaying Bitmaps & Icons >

# f. Bitmaps at Angles

This section shows how to draw bitmap images at various angles using the CleO commands. To draw a bitmap at an angle, you are required to have an angle and a radius set for the bitmap. The angle and radius can be adjusted using the BitmapRadius() and BitmapAngle() commands. Upon setting these values, a bitmap can be drawn using the Bitmap() command.

Command Prototype:

uint16_t Bitmap(int16_t Handle, int X, int Y)

Parameters

Description

Handle

X

x coordinate value

Y

y coordinate value

Parameters

Description

Distance from center at which bitmap will be drawn

uint16_t BitmapAngle(int16_t Angle);

Parameters

Description

Angle

Angle at which bitmap will be drawn

Code

The following code snippet illustrates how to draw multiple bitmaps files at various angles:

void setup()

{

int16_t digit[10];

int centerX = 800 / 2, centerY = 480 / 2;

/* Initialize CleO - needs to be done only once */

CleO.begin();

/* Get handles for all bitmap files */

/* Start building a screen frame */

CleO.Start();

/* Set the radius and justification for the bitmap files */

CleO.BitmapJustification(MM);

int angle = 0;

for (int i = 0; i <10; ++i)

{

CleO.BitmapAngle(angle);

/* Draw bitmap at updated angle */

CleO.Bitmap(digit[i], centerX, centerY);

angle = (angle + 36) % 360;

CleO.Free(digit[i]);

}

/* Display completed screen frame */

CleO.Show();

}

void loop() { }

Description

In the above code snippet, the Setup() routine loads the set of png bitmap files by getting the bitmap handle.

Upon setting these shared values for bitmap drawing, all the bitmaps are drawn inside a for loop by changing the angle of each bitmap.

The Bitmap() command takes the bitmap handle and draws it with centerX and centerY as a center coordinate.

Use the @ symbol only when performing the file operation from the eFlash and not from the SD Card.

Output

Here is the output displayed upon executing the above code snippet -