Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
2DGL_DrawPolygon.c
00001 /********************************************************************* 00002 * SEGGER Microcontroller GmbH * 00003 * Solutions for real time microcontroller applications * 00004 ********************************************************************** 00005 * * 00006 * (c) 1996 - 2018 SEGGER Microcontroller GmbH * 00007 * * 00008 * Internet: www.segger.com Support: support@segger.com * 00009 * * 00010 ********************************************************************** 00011 00012 ** emWin V5.48 - Graphical user interface for embedded applications ** 00013 All Intellectual Property rights in the Software belongs to SEGGER. 00014 emWin is protected by international copyright laws. Knowledge of the 00015 source code may not be used to write a similar product. This file may 00016 only be used in accordance with the following terms: 00017 00018 The software has been licensed to Cypress Semiconductor Corporation, 00019 whose registered office is situated at 198 Champion Ct. San Jose, CA 00020 95134 USA solely for the purposes of creating libraries for Cypress 00021 PSoC3 and PSoC5 processor-based devices, sublicensed and distributed 00022 under the terms and conditions of the Cypress End User License 00023 Agreement. 00024 Full source code is available at: www.segger.com 00025 00026 We appreciate your understanding and fairness. 00027 ---------------------------------------------------------------------- 00028 Licensing information 00029 Licensor: SEGGER Microcontroller Systems LLC 00030 Licensed to: Cypress Semiconductor Corp, 198 Champion Ct., San Jose, CA 95134, USA 00031 Licensed SEGGER software: emWin 00032 License number: GUI-00319 00033 License model: Services and License Agreement, signed June 10th, 2009 00034 Licensed platform: Any Cypress platform (Initial targets are: PSoC3, PSoC5) 00035 ---------------------------------------------------------------------- 00036 Support and Update Agreement (SUA) 00037 SUA period: 2009-06-12 - 2022-07-27 00038 Contact to extend SUA: sales@segger.com 00039 ---------------------------------------------------------------------- 00040 File : 2DGL_DrawPolygon.c 00041 Purpose : Example for drawing polygons 00042 Requirements: WindowManager - ( ) 00043 MemoryDevices - ( ) 00044 AntiAliasing - ( ) 00045 VNC-Server - ( ) 00046 PNG-Library - ( ) 00047 TrueTypeFonts - ( ) 00048 ---------------------------------------------------------------------- 00049 */ 00050 00051 #include "GUI.h" 00052 00053 /********************************************************************* 00054 * 00055 * Defines 00056 * 00057 ********************************************************************** 00058 */ 00059 // 00060 // Recommended memory to run the sample with adequate performance 00061 // 00062 #define RECOMMENDED_MEMORY (1024L * 5) 00063 00064 /******************************************************************* 00065 * 00066 * Static variables 00067 * 00068 ******************************************************************** 00069 */ 00070 static const GUI_POINT _aPointArrow[] = { 00071 { 0, 0 }, 00072 {-40, -30 }, 00073 {-10, -20 }, 00074 {-10, -70 }, 00075 { 10, -70 }, 00076 { 10, -20 }, 00077 { 40, -30 }, 00078 }; 00079 00080 static const GUI_POINT _aPointStar[] = { 00081 { 0, -36 }, 00082 { 8, -8 }, 00083 { 36, 0 }, 00084 { 8, 8 }, 00085 { 0, 36 }, 00086 { -8, 8 }, 00087 {-36, 0 }, 00088 { -8, -8 } 00089 }; 00090 00091 static const GUI_POINT _aPointHexagon[] = { 00092 { 0, -30 }, 00093 { 26, -15 }, 00094 { 26, 15 }, 00095 { 0, 30 }, 00096 {-26, 15 }, 00097 {-26, -15 }, 00098 }; 00099 00100 /******************************************************************* 00101 * 00102 * Static code 00103 * 00104 ******************************************************************** 00105 */ 00106 /******************************************************************* 00107 * 00108 * _DrawPolygons 00109 * 00110 * Function description 00111 * Draws polygons of different shapes and colors 00112 */ 00113 static void _DrawPolygons(void) { 00114 int y; 00115 00116 y = 90; 00117 // 00118 // clear display 00119 // 00120 GUI_SetBkColor(GUI_BLACK); 00121 GUI_Clear(); 00122 // 00123 // display text 00124 // 00125 GUI_SetColor(GUI_WHITE); 00126 GUI_SetFont(&GUI_Font24_ASCII); 00127 GUI_SetTextAlign(GUI_TA_HCENTER); 00128 GUI_DispStringAt("DrawPolygon - Sample", 160, 5); 00129 GUI_SetFont(&GUI_Font8x16); 00130 GUI_DispStringAt("using", 5, 40); 00131 GUI_DispStringAt("GUI_FillPolygon", 5, 55); 00132 GUI_SetTextAlign(GUI_TA_HCENTER); 00133 GUI_DispStringAt("Polygons of arbitrary shape\nin any color", 160, y + 90); 00134 GUI_Delay(500); 00135 // 00136 // draw filled polygons 00137 // 00138 while (1) { 00139 GUI_ClearRect(100, y, 220, y + 85); 00140 GUI_SetColor(GUI_BLUE); 00141 GUI_FillPolygon (&_aPointArrow[0], 7, 160, y + 80); 00142 GUI_Delay(1000); 00143 GUI_ClearRect(100, y, 220, y + 85); 00144 GUI_SetColor(GUI_RED); 00145 GUI_FillPolygon (&_aPointStar[0], 8, 160, y + 45); 00146 GUI_Delay(1000); 00147 GUI_ClearRect(100, y, 220, y + 85); 00148 GUI_SetColor(GUI_GREEN); 00149 GUI_FillPolygon(&_aPointHexagon[0], 6, 160, y + 45); 00150 GUI_Delay(1000); 00151 } 00152 } 00153 00154 /********************************************************************* 00155 * 00156 * Public code 00157 * 00158 ********************************************************************** 00159 */ 00160 /********************************************************************* 00161 * 00162 * MainTask 00163 */ 00164 void MainTask(void) { 00165 GUI_Init(); 00166 // 00167 // Check if recommended memory for the sample is available 00168 // 00169 if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) { 00170 GUI_ErrorOut("Not enough memory available."); 00171 return; 00172 } 00173 _DrawPolygons(); 00174 while (1); 00175 } 00176 00177 /*************************** End of file ****************************/ 00178
Generated on Thu Jul 14 2022 12:58:38 by
