g. Restore Defaults

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 09 - Setting Graphics Context >

g. Restore Defaults

This section shows how to restore Backgroundcolor, BackgroundGradient, AngleType and DefaultContext to its default values using the SetDefaultContext() command.

 

 

Command Prototype

 

uint16_t SetDefaultContext()

 

 

Code

 

 

void setup()

{

   int centerX = 800/2;

 

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

   CleO.begin();

 

  /* Start building a screen frame */

   CleO.Start();

 

  /* Select angle unit */

   CleO.SetAngleType(FURMANS);

 

   CleO.LineAngle(45);

   CleO.LineXY(400, 100, 60);

 

 /* Restore default context */

   CleO.SetDefaultContext();

 

   CleO.StringExt(FONT_MEDIUM, centerX, 300, WHITE, MM, 0, 0, "Default Context");

 

  /* 45 will be treated as degree instead of FURMANS */

   CleO.LineAngle(45);

   CleO.LineXY(400, 350, 60);

 

  /* Display completed screen frame */

   CleO.Show();

}

 

void loop() { }

 

 

Description

 

The above code snippet draws a line with FURMANS angle at (400,100) then default context is restored using the SetDefaultContext()command. Later a line is drawn with the same value of 45 but this time, since the context is restored, it will be treated in degree.

 

 

Output

 

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

 

Tutorials09-RestoreDefaults.50