e. Drawing Strings at Angles

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 02 - Drawing Strings >

e. Drawing Strings at Angles

This section shows how to draw a string at various angles using the CleO commands. To draw an angled string, an angle and a radius set for the string is required. Upon setting these values, a string can be drawn using the StringExt() command.

 

 

Command Prototype

 

uint16_t StringExt(int16_t Handle, int X, int Y,  uint32_t Color,  just_t Justification,  int16_t Angle, int Radius, const char* String)

 

Parameters

Description

Handle

Font Size

X

x-coordinate for string

Y

y-coordinate for string

Color

String color

Justification

Justification values (i.e MM,TL,BL, etc.)

Angle

Angle at which string will be drawn

Radius

Distance from center at which string will be drawn

String

String text

 

 

Code

 

The following code snippet illustrates how to draw Strings at various angles:

 

char message[] = "HELLOWORLD!!";

char currentStr[2] = { '\0', '\0' };

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

 

void setup()

{

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

   CleO.begin();

 

   /* Start building a screen frame */

   CleO.Start();

 

   int angle = 0;

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

  {

       currentStr[0] = message[i];

 

   /* Draw text at various angles */

       CleO.StringExt(FONT_HUGE, centerX, centerY, LIGHT_GREEN, MM, angle, 240 - 40, currentStr);

       angle = (angle + 30) % 360;

 }

 

  /* Display completed screen frame */

   CleO.Show();

}

 

 

Description

 

In the above code snippet, the code selects each character of the message in turn and draws it at an angle which is getting incremented by 30 degrees in each iteration.

 

 

Output

 

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

 

Tutorials02-StringAtAngles.50