HiRes AA (Sample)

From SEGGER Wiki
Jump to: navigation, search
GUI_HiResAA.c
Anti-aliased rectangle drawn with high-resolution coordinates.
File(s) required
  • GUI_HiResAA.c
Runs in simulation Yes
Runs on target Yes
Download GUI_HiResAA.c

This sample demonstrates how anti-aliased shapes can be drawn with sub-pixel coordinates.

Code

/*********************************************************************
*                    SEGGER Microcontroller GmbH                     *
*        Solutions for real time microcontroller applications        *
**********************************************************************
*                                                                    *
*        (c) 1996 - 2022  SEGGER Microcontroller GmbH                *
*                                                                    *
*        Internet: www.segger.com    Support:  support@segger.com    *
*                                                                    *
**********************************************************************

** emWin V6.24 - Graphical user interface for embedded applications **
emWin is protected by international copyright laws.   Knowledge of the
source code may not be used to write a similar product.  This file may
only  be used  in accordance  with  a license  and should  not be  re-
distributed in any way. We appreciate your understanding and fairness.
----------------------------------------------------------------------
File        : GUI_HiResAA.c
Purpose     : Sample that demonstrates how to draw sub-pixelwise with
              high-resolution anti-aliasing.
Requirements: WindowManager - ( )
              MemoryDevices - ( )
              AntiAliasing  - (x)
              VNC-Server    - ( )
              PNG-Library   - ( )
              TrueTypeFonts - ( )
Wiki link   : https://wiki.segger.com/HiRes_AA_(Sample)
---------------------------END-OF-HEADER------------------------------
*/

#include "DIALOG.h"


/*********************************************************************
*
*       Defines
*
**********************************************************************
*/
#define AA_FACTOR    4

/*********************************************************************
*
*       Static data
*
**********************************************************************
*/

/*********************************************************************
*
*       Static code
*
**********************************************************************
*/


/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  GUI_RECT Rect;
  int      OldFactor;
  int      Radius;

  GUI_Init();
  GUI_SetBkColor(GUI_WHITE);
  GUI_Clear();
  GUI_SetColor(GUI_GRAY_C0);
  //
  // Enable high-resolution anti-aliasing
  //
  OldFactor = GUI_AA_GetFactor();
  GUI_AA_SetFactor(AA_FACTOR);
  GUI_AA_EnableHiRes();
  //
  // Set up rectangle with high-resolution coordinates.
  //
  Rect.x0 = (10  * AA_FACTOR);
  Rect.y0 = (10  * AA_FACTOR);
  Rect.x1 = (30  * AA_FACTOR);
  Rect.y1 = (100 * AA_FACTOR);
  Radius  = (3   * AA_FACTOR);
  GUI_AA_FillRoundedRectEx(&Rect, Radius);
  //
  // Disable HiRes anti-aliasing and restore factor
  //
  GUI_AA_SetFactor(OldFactor);
  GUI_AA_DisableHiRes();

  while (1) {
    GUI_Delay(100);
  }
}

/*************************** End of file ****************************/