/******************************************************************* * * _DrawEye */ static void _DrawEye(int xPos0, int yPos0, int xPos1, int yPos1, int rx, int ry) { int Hyp; int dx; int dy; int x; int y; GUI_SetColor(GUI_WHITE); GUI_FillEllipse(xPos0, yPos0, rx, ry); GUI_SetColor(GUI_BLACK); GUI_DrawEllipse(xPos0, yPos0, rx, ry); // // Calculate the coordinates // dx = xPos1 - xPos0 + 1; dy = yPos1 - yPos0 + 1; Hyp = GUI__sqrt32(dx * dx + dy * dy); x = (dx * _Min(rx - 5, abs(dx)) * FACTOR / Hyp) + xPos0 * FACTOR; y = (dy * _Min(ry - 5, abs(dy)) * FACTOR / Hyp) + yPos0 * FACTOR; // // Draw the pupil // GUI_AA_SetFactor(FACTOR); GUI_AA_EnableHiRes(); GUI_SetColor(0xD00000); GUI_AA_FillCircle(x, y, (int)(5.75 * FACTOR)); GUI_SetColor(GUI_BLACK); GUI_AA_FillCircle(x, y, (int)(3.75 * FACTOR)); GUI_SetColor(GUI_GRAY); GUI_AA_FillCircle(x - (int)(1.25 * FACTOR), y - (int)(1.25 * FACTOR), (int)(1.25 * FACTOR)); GUI_AA_DisableHiRes(); }
/******************************************************************* * * MainTask * ******************************************************************** */ void MainTask_AppClock(void) { WM_HWIN hWinClock; GUI_AUTODEV AutoDev; PARAM Param; int hour = 0; time_t oldtimestamp = 0; time_t curtimestamp = 0; struct tm *currUtime; //Init time curtimestamp = time(0); oldtimestamp = curtimestamp; currUtime=localtime(&curtimestamp); hWinClock = WM_CreateWindowAsChild(0, 0, 320, 240, WM_HBKWIN, WM_CF_SHOW, _cbClock, 0); WM_SelectWindow(hWinClock); WM_SetCreateFlags(WM_CF_MEMDEV); WM_SetFocus(hWinClock); _MoveShiftWindow(&hWinClock, MEMDEV_ANIMATION_LEFT, WM_Shift_ToLCD, 0); /*hWinClock = WM_CreateWindow(0, 0, 320, 240, WM_CF_SHOW, _cbClock, 0); WM_SetFocus(hWinClock); //_MoveShiftWindow(&hWinCalendar, MEMDEV_ANIMATION_LEFT, WM_Shift_ToLCD, 0); WM_EnableMemdev(hWinClock);*/ /* GUI_SetBkColor(GUI_WHITE); GUI_Clear(); GUI_SetColor(GUI_BLACK);*/ GUI_AA_EnableHiRes(); GUI_AA_SetFactor(MAG); GUI_MEMDEV_CreateAuto(&AutoDev); while (!GUI_CheckCancel(APP_Clock)) { GUI_Delay(10); curtimestamp = time(0); currUtime = localtime(&curtimestamp); if (1 == curtimestamp - oldtimestamp) { Param.Angle1 = (59 - currUtime->tm_sec) * 6 * (3.1415926f / 180); Param.Angle2 = (3599 - ((currUtime->tm_min * 60) + (currUtime->tm_sec)))*0.1*(3.1415926f / 180); hour = (currUtime->tm_hour>12) ? (currUtime->tm_hour - 12) : (currUtime->tm_hour); Param.Angle3 = (43199 - ((hour * 3600) + (currUtime->tm_min * 60) + (currUtime->tm_sec)))*0.0083333*(3.1415926f / 180); GUI_RotatePolygon(Param.aPoint1, _aNeedle[0], GUI_COUNTOF(_aNeedle[0]), Param.Angle1); GUI_RotatePolygon(Param.aPoint2, _aNeedle[1], GUI_COUNTOF(_aNeedle[1]), Param.Angle2); GUI_RotatePolygon(Param.aPoint3, _aNeedle[2], GUI_COUNTOF(_aNeedle[2]), Param.Angle3); GUI_MEMDEV_DrawAuto(&AutoDev, &Param.AutoDevInfo, &Draw, &Param); } oldtimestamp = curtimestamp; } WM_DeleteWindow(hWinClock); hWinClock = 0; }
/******************************************************************* * * _ShowHiresAntialiasing * * Function description * This function creates the memory auto devices and handle the * rotation of the pointers */ static void _ShowHiresAntialiasing(void) { GUI_AUTODEV aAuto[2]; PARAM Param; unsigned i; Param.Factor = 3; GUI_SetBkColor(GUI_BLACK); GUI_Clear(); GUI_SetColor(GUI_WHITE); GUI_SetTextAlign(GUI_TA_HCENTER); GUI_SetFont(&GUI_Font24_ASCII); GUI_DispStringAt("AA_HiResAntialiasing - Sample", 160, 5); GUI_SetFont(&GUI_Font6x8); GUI_DispStringHCenterAt("Using\nhigh\nresolution\nmode", 110, 180); GUI_DispStringHCenterAt("Not using\nhigh\nresolution\nmode", 210, 180); // // Create GUI_AUTODEV objects // for (i = 0; i < countof(aAuto); i++) { GUI_MEMDEV_CreateAuto(&aAuto[i]); } // // Calculate pointer for high resolution // for (i = 0; i < countof(_aPointer); i++) { _aPointerHiRes[i].x = _aPointer[i].x * Param.Factor; _aPointerHiRes[i].y = _aPointer[i].y * Param.Factor; } GUI_AA_SetFactor(Param.Factor); /* Set antialiasing factor */ while (1) { for (i = 0; i < 1800; i++) { float Angle = (i >= 900) ? 1800 - i : i; Angle *= 3.1415926f / 1800; // // Draw pointer with high resolution // GUI_AA_EnableHiRes(); GUI_RotatePolygon(Param.aPoints, _aPointerHiRes, countof(_aPointer), Angle); GUI_MEMDEV_DrawAuto(&aAuto[0], &Param.AutoInfo, _DrawHiRes, &Param); // // Draw pointer without high resolution // GUI_AA_DisableHiRes(); GUI_RotatePolygon(Param.aPoints, _aPointer, countof(_aPointer), Angle); GUI_MEMDEV_DrawAuto(&aAuto[1], &Param.AutoInfo, _Draw, &Param); GUI_Delay(2); } } }
/********************************************************************* * * _DrawAlphaCircles */ static void _DrawAlphaCircles(int mx, int my, int r, int a, int FactorAA) { int Index; int x; int y; I32 SinHQ; I32 CosHQ; U32 a1000; U32 i; const GUI_COLOR aColor[] = { 0xC00FFF38, 0xC000FF8E, 0xC000FCEA, 0xC000B4FF, 0xC0004EFF, 0xC01304FF, 0xC06E00FF, 0xC0D200FF, 0xC0FF00D2, 0xC0FF006E, 0xC0FF0413, 0xC0FF4E00, 0xC0FFB400, 0xC0EAFC00, 0xC08EFF00, 0xC038FF0F }; mx *= FactorAA; my *= FactorAA; r *= FactorAA; a1000 = a * -1000; GUI_AA_EnableHiRes(); GUI_AA_SetFactor(FactorAA); for (i = 0, Index = 0; i < 360000; i += 22500, Index++) { SinHQ = GUI__SinHQ(i + a1000); CosHQ = GUI__CosHQ(i + a1000); x = SHIFT_RIGHT_16(r * CosHQ); y = SHIFT_RIGHT_16(r * SinHQ); GUI_SetColor(aColor[Index % (int)GUI_COUNTOF(aColor)]); GUI_AA_FillCircle(mx + x, my + y, r); } GUI_AA_DisableHiRes(); }
/******************************************************************* * * _cbWindow This is the callback for the window. A callback was used for memory devices. */ static void _cbWindow(WM_MESSAGE* pMsg) { switch (pMsg->MsgId) { case WM_PAINT: GUI_SetBkColor(_color_a); GUI_ClearRect( 0, 0, 250, 14); GUI_SetBkColor(_color_b); GUI_ClearRect( 0, 15, 250, 29); GUI_SetBkColor(GUI_BLACK); GUI_ClearRect( 0, 30, 250, 60); GUI_SetColor(_color_c); GUI_FillPolygon(_aPolygon, POLY_POINTS, _pos_x1, _pos_y1); GUI_AA_FillPolygon(_aPolygon, POLY_POINTS, _pos_x2, _pos_y2); GUI_AA_EnableHiRes(); GUI_AA_FillPolygon(_aPolygonHiRes, POLY_POINTS, _pos_x3, _pos_y3); GUI_AA_DisableHiRes(); break; default: WM_DefaultProc(pMsg); } }
void GUIDEMO_DemoPolygon(void) { int XMid = LCD_GetXSize() / 2; int YMid = LCD_GetYSize() / 2; GUIDEMO_ShowIntro("Arbitrary Polygons", "\nStandard and antialiased"); GUI_SetColor(GUI_WHITE); GUI_SetFont(&GUI_FontComic18B_ASCII); #if GUIDEMO_LARGE GUI_DispStringAt("Arbitrary\nPolygons", 0, 0); #endif GUI_FillPolygon(&_aArrow[0], 7, XMid - 50, YMid + 40); GUI_FillPolygon(&_aArrow[0], 7, XMid + 50, YMid + 40); GUI_SetColor(GUI_GREEN); GUI_FillPolygon(&_aTriangle[0], 3, XMid, YMid + 60); GUI_SetColor(GUI_WHITE); #if GUI_SUPPORT_AA GUI_AA_EnableHiRes(); GUI_AA_FillPolygon(&_aiCursor[0], 4, XMid * 3, (YMid - 40) * 3); #endif GUIDEMO_Wait(); }