Spline (Sample)

From SEGGER Wiki
Jump to: navigation, search
GUI_SPLINE.c
GUI SPLINE.png
File(s) required
  • GUI_SPLINE.c
Runs in simulation Yes
Runs on target Yes
Download GUI_SPLINE.c

This sample demonstrates how spline curves can be drawn with emWin.

Code

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

** emWin V6.10 - 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_SPLINE.c
Purpose     : Sample that demonstrates how splines can be drawn with
              emWin.
Requirements: WindowManager - ( )
              MemoryDevices - ( )
              AntiAliasing  - (x)
              VNC-Server    - ( )
              PNG-Library   - ( )
              TrueTypeFonts - ( )
---------------------------END-OF-HEADER------------------------------
*/

#include "DIALOG.h"
#include <stdio.h>

/*********************************************************************
*
*       Defines
*
**********************************************************************
*/

/*********************************************************************
*
*       Static data
*
**********************************************************************
*/
/*********************************************************************
*
*       _axValues
*/
static const int _axValues[] = {
  0, 10, 30, 50, 80, 95, 110, 130, 160, 180, 200, 230
};

/*********************************************************************
*
*       _ayValues
*/
static const int _ayValues[] = {
  50, -20, -30, 20, 40, -10, 25, 75, 90, 110, -10, 30
};

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

/*********************************************************************
*
*       Public code
*
**********************************************************************
*/
/*********************************************************************
*
*       MainTask
*/
void MainTask(void) {
  GUI_HMEM hSpline;
  int      xSize;
  char     acBuffer[32];
  
  //
  // Init emWin.
  //
  GUI_Init();
  //
  // Create spline handle.
  // The arrays holding the x and y values are passed.
  //
  hSpline = GUI_SPLINE_Create(_axValues, _ayValues, GUI_COUNTOF(_axValues));
  //
  // Draw anti-aliased spline.
  //
  GUI_SetColor(GUI_BLUE);
  GUI_SPLINE_DrawAA(hSpline, 10, 100, 3);
  //
  // Get information about spline.
  //
  xSize = GUI_SPLINE_GetXSize(hSpline);
  GUI_SetColor(GUI_WHITE);
  sprintf(acBuffer, "X-size of SPLINE: %d", xSize);
  GUI_DispStringAt(acBuffer, 10, 10);
  //
  // Delete the spline handle.
  //
  GUI_SPLINE_Delete(hSpline);
  
  while (1) {
    GUI_Delay(100);
  }
}

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