![]() |
TX Library Help – Version: 00173a, Revision: 174
|
00001 //{=========================================================================== 00011 // $Copyright: (C) Ded (Ilya Dedinsky, http://txlib.ru) <mail@txlib.ru> $ 00012 //}=========================================================================== 00013 00014 #include "TXLib.h" 00015 00016 //---------------------------------------------------------------------------- 00017 00018 void DrawMan (int x, int y, int sizeX, int sizeY, COLORREF color, 00019 double hand = 0, double legs = 0, double head = 0, double twist = 0); 00020 void DrawEarth (int x, int y, int sizeX, int sizeY, COLORREF color); 00021 void DrawFlag (int x, int y, int sizeX, int sizeY, COLORREF color, COLORREF bkColor); 00022 void DrawHello (int x, int y, const char* text, int size, COLORREF color); 00023 void DrawFrame (int sizeX, int sizeY, int size, COLORREF color); 00024 00025 //---------------------------------------------------------------------------- 00026 00027 int main() 00028 { 00029 txCreateWindow (800, 600); 00030 00031 DrawFrame (800, 600, 10, TX_WHITE); 00032 DrawHello (400, 480, "Hello, world!", 60, TX_LIGHTGREEN); 00033 00034 DrawEarth (400, 300, 400, 300, TX_LIGHTCYAN); 00035 00036 DrawFlag (400, 150, 50, 75, TX_YELLOW, TX_TRANSPARENT); 00037 DrawMan (385, 150, 20, 40, TX_YELLOW, 0, 0, 0); 00038 00039 txTextCursor (false); 00040 return 0; 00041 } 00042 00043 //---------------------------------------------------------------------------- 00044 00045 void DrawMan (int x, int y, int sizeX, int sizeY, COLORREF color, 00046 double hand, double legs, double head, double twist) 00047 { 00048 txSetColor (color); 00049 txSetFillColor (color); 00050 00051 txLine (x, y - (0.35 + twist) * sizeY, x, y - 0.7*sizeY); 00052 00053 txLine (x, y - (0.35 + twist) * sizeY, x - (0.5 + legs) * sizeX, y); 00054 txLine (x, y - (0.35 + twist) * sizeY, x + (0.5 + legs) * sizeX, y); 00055 00056 txLine (x, y - 0.65*sizeY, x - sizeX/2, y - 0.4*sizeY); 00057 txLine (x, y - 0.65*sizeY, x + sizeX/1.2, y - (0.7 + hand) * sizeY); 00058 00059 txCircle (x, y - sizeY + (0.3 + head) * sizeX, 0.3*sizeX); 00060 } 00061 00062 //---------------------------------------------------------------------------- 00063 00064 void DrawEarth (int x, int y, int sizeX, int sizeY, COLORREF color) 00065 { 00066 txSetColor (color); 00067 00068 int r = sizeX/2; 00069 while (r >= 0) 00070 { 00071 txEllipse (x-r, y-sizeY/2, x+r, y+sizeY/2); 00072 r -= sizeX/9; 00073 } 00074 00075 r = sizeY/2; 00076 while (r >= 0) 00077 { 00078 txEllipse (x-sizeX/2, y-r, x+sizeX/2, y+r); 00079 r -= sizeY/6; 00080 } 00081 00082 txLine (x - sizeX/2, y, x + sizeX/2, y); 00083 } 00084 00085 //---------------------------------------------------------------------------- 00086 00087 void DrawFlag (int x, int y, int sizeX, int sizeY, COLORREF color, COLORREF bkColor) 00088 { 00089 txSetColor (color); 00090 txSetFillColor (bkColor); 00091 00092 txLine (x, y, x, y - sizeY); 00093 txRectangle (x, y - sizeY/2, x + sizeX, y - sizeY); 00094 00095 txSelectFont ("Times New Roman", 20); 00096 txTextOut (x + sizeX/2, y - sizeY*7/8, "C++"); 00097 } 00098 00099 //---------------------------------------------------------------------------- 00100 00101 void DrawHello (int x, int y, const char* text, int size, COLORREF color) 00102 { 00103 txSetColor (color); 00104 00105 txSelectFont ("Times New Roman", size); 00106 txSetTextAlign (TA_CENTER); 00107 00108 txTextOut (x, y, text); 00109 } 00110 00111 //---------------------------------------------------------------------------- 00112 00113 void DrawFrame (int sizeX, int sizeY, int size, COLORREF color) 00114 { 00115 txSetColor (color); 00116 txSetFillColor (TX_TRANSPARENT); 00117 00118 txRectangle (size, size, sizeX-size, sizeY-size); 00119 } 00120 00121 00122 00123 00124