d. Drawing Line Segments at Angles

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 04 - Drawing Lines >

d. Drawing Line Segments at Angles

This section shows how to draw line segments at different angles using the LineR1R2() command.

 

 

Command Prototype

 

uint16_t LineR1R2(int X, int Y, int Radius1, int Radius2, int16_t Angle);

 

Parameters

Description

X, Y

(x,y) coordinate of the line

Radius1

Inner radius

Radius2

Outer radius

Angle

Angle

 

 

Code

 

 

void setup()

{

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

 CleO.begin();

 

 /* Start building a screen frame */

 CleO.Start();

 

/* Inner radius */

 int radius1 = 143;

 

/* Outer radius */

 int radius2 = 155;

 

 for (int deg = 0; deg < 360; deg += 6)

 {

   if (deg == 0 || deg == 90 || deg == 180 || deg == 270)

     radius1 = 135;

   else

     radius1 = 143;

 

  /* Draw a line with center (400, 240) at deg angle */

   CleO.LineR1R2(400, 240, radius1, radius2, deg);

 }

 

/* Display completed screen frame */

 CleO.Show();

}

 

void loop() { }

 

 

Description

 

The above code snippet draws a line with a center(400,240). In each iteration, the for loop changes the degree of angle by 6 degrees.

 

 

Output

 

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

 

Tutorials04-DrawingLineSegmentsAtAngles.50