/******************************************************************* * * _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(); }
/******************************************************************* * * _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); } }