b. Drawing Rectangles with Parameters

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 07 - Drawing Rectangles >

b. Drawing Rectangles with Parameters

This section shows how to draw rectangles with parameters like color and justification using the RectangleColor() and RectangleJustification() commands.

 

 

Command Prototype

 

uint16_t RectangleJustification(just_t Justification)

uint16_t RectangleColor(uint32_t argb)

 

Parameters

Description

Justification

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

argb

Color values (for example - red, yellow, green etc.)

 

 

Code

 

 

void setup()

{

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

 CleO.begin();

 

 /* Start building a screen frame */

 CleO.Start();

 CleO.RectangleJustification(MM);

 

/* Draw a rectangle at (160, 240) point with 200 width, 400 height */

 CleO.RectangleXY(160, 240, 200, 400);

 CleO.RectangleColor(LIGHT_GREEN);

 

/* Draw a rectangle at (160, 240) point with 100 width, 200 height */

 CleO.RectangleXY(160, 240, 100, 200);

 

/* Display completed screen frame */

 CleO.Show();

}

 

void loop()

{

}

 

 

Description

 

The above code snippet draws a white color rectangle at (160,240) with MM justification.

The height and width are set to 200 and 400 respectively.

This is overlaid with a light green color rectangle at (160, 240) with MM justification.

The height and width are set to 100 and 200 respectively.

 

 

Output

 

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

 

RectangleParametersXYWidthHeight