#include “GUI.H”
static const GUI_POINT aPoints[] =
{
{-50,0},{-10,10},{0,50},{10,10},{50,0},{10,-10},{0,-50},{-10,-10}
};
#define SIZE_OF_ARRAY (Array)(sizeof(Array)/sizeof(Array[0]))
typedef struct
{
int XPos_Poly, YPos_Poly; int XPos_Text, YPos_Text; GUI_POINT aPointsDest[8];
} tDrawItContext;
/***************************************************************************
* 绘图函数 *
***************************************************************************/
static void DrawIt(void * pData)
{
tDrawItContext * pDrawItContext = (tDrawItContext *)pData;
GUI_Clear();
GUI_SetFont(&GUI_Font8x8);
第11页 µC/GUI中文手册
第10章 存储设备
GUI_SetTextMode(GUI_TM_TRANS);
/* 绘背景 */
GUI_SetColor(GUI_GREEN);
GUI_FillRect ( pDrawItContext->XPos_Text,
pDrawItContext->YPos_Text - 25,
pDrawItContext->XPos_Text + 100,
pDrawItContext->YPos_Text - 5);
/* 绘多边形 * /
GUI_SetColor(GUI_BLUE);
GUI_FillPolygon (pDrawItContext->aPointsDest,
SIZE_OF_ARRAY(aPoints),
160, 120);
/* 绘前景 * /
GUI_SetColor(GUI_RED);
GUI_FillRect( 220 - pDrawItContext->XPos_Text,
pDrawItContext->YPos_Text + 5,
220 - pDrawItContext->XPos_Text + 100,
pDrawItContext -> YPos_Text + 25);
}
/***************************************************************************
* 展示分片存储设备 *
***************************************************************************/
#define USE_BANDING_MEMDEV (1)
/* 如设为 0,则定义不使用分片存储设备进行绘图 */
void DemoBandingMemdev(void)
{
int i;
int XSize = LCD_GET_XSIZE();
int YSize = LCD_GET_YSIZE();
tDrawItContext DrawItContext;
GUI_SetFont(&GUI_Font8x9);
GUI_SetColor(GUI_WHITE);
GUI_DispStringHCenterAt ( “Banding memory device\nwithout flickering”,
XSize/40)
DrawItContext.XPos_Poly = Xsize/2;
DrawItContext.YPos_Poly = Ysize/2;
第12页 µC/GUI中文手册
第10章 存储设备
DrawItContext.YPos_Text = Ysize/2-4;
for(i = 0; i < (XSize - 100); i++)
float angle = i * 3.1415926 / 60;
DrawItContext.XPos_Text = i;
/* 旋转多边形 * /
GUI_RotatePolygon ( DrawItContext.aPointsDest,
aPoints,
SIZE_OF_ARRAY(aPoints),
angle);
#if USE_BANDING_MEMDEV
{
GUI_RECT Rect = { 0, 70, 320, 170} ;
/* 使用分片存储设备进行绘图 */
GUI_MEMDEV_Draw(&Rect, &DrawIt, &DrawItContext, 0, 0);
}
#else
/* 不使用存储设备的简单绘图 */
DrawIt((void *)&DrawItContext);
#endif
#ifdef WIN32
GUI_Delay(20); /* 只有在仿真时才使用一段短延时 */
#endif
}
/***************************************************************************
* 主函数 *
***************************************************************************/
void main (void)
{
GUI_Init () ;
while(1)
{
DemoBandingMemdev();
}
}
SIZE_OF_ARRAY(aPoints)这一句有错误,怎么改呀?
这是UCGUI手册上的例子。
请高手指教,谢谢!
|