d. Setting Gradient Backgrounds

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 09 - Setting Graphics Context >

d. Setting Gradient Backgrounds

This section shows how to set a gradient screen background using the SetBackgroundGradient() command.



Command Prototype


uint16_t SetBackgroundGradient(int X1,int Y1,int X2,int Y2,uint32_t rgb1,uint32_t rgb2)




X1 Y1

Start point coordinate

X2 Y2

End point coordinate

rgb1 rgb2

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






void setup()


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



/* Set background gradient */

 CleO.SetBackgroundGradient(0, 0, 320, 480, DARK_BLUE, DARK_GREEN);


 /* Start building a screen frame */



/* Draw string */

 CleO.StringExt(FONT_MEDIUM, 160, 240, WHITE, MM, 0, 0, "Hello world");


/* Display completed screen frame */




void loop() {}





The above code snippet uses the SetBackgroundGradient() command to set the gradient background.

The left, top, right and bottom coordinates are required to define the region and the two colors to create the desired gradient effect.





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