//---------------------WINDOWS-FORMULIERUNGEN------------------------ #include #include #define febr 800 // 796 FENSTERBREITE #define feho 600 // 576 FENSTERHOEHE //---------------------VARIABLEN------------------------------------- int i, c, d, e, f, xx, yy, ax, ay, ii, j, jj, an, en, ir, xt[30000], yt[30000]; double x[38], y[38], p[38], r[38], a[38], b[38], s[38], pi, xa, xf, ya, yf, w, v, rr, ss, ff; char tx[ 20 ]; //---------------------WINDOWS-FORMULIERUNGEN------------------------ static int cxClient, cyClient ; HDC hdc ; LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) { static TCHAR szAppName[] = TEXT ("DASSISSESS") ; HWND hwnd ; MSG msg ; WNDCLASS wndclass ; wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hInstance = hInstance ; wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ; wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ; wndclass.lpszMenuName = NULL ; wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass)) { MessageBox (NULL, TEXT ("Program requires Windows NT!"), szAppName, MB_ICONERROR) ; return 0 ; } hwnd = CreateWindow (szAppName, TEXT ("DASSISSESS"), WS_OVERLAPPEDWINDOW, 0, 0, febr, feho, NULL, NULL, hInstance, NULL) ; ShowWindow (hwnd, SW_SHOWMAXIMIZED) ; UpdateWindow (hwnd) ; while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } return msg.wParam ; } //------------------------------------UNTERPROGRAMME----------------- void muli(void) { for( i=1; i<38; i++ ) { // 37 Linien for( w=a[i]; w<=b[i]; w=w+( 57/(p[i]+r[i]) ) ) { // Winkel-Schritte v = w * pi; // Grad zu rad umrechnen xx=int(floor(0.5+xa-xf*(x[i]+p[i]*sin(v)))); // Muffel X u. Y yy=int(floor(0.5+ya-yf*(y[i]+r[i]*cos(v))-s[i]*yf*p[i]*sin(v))); SetPixel( hdc, xx , yy , RGB( 0, 0, 0 ) ); } /* for ( w ) */ } /* for ( i ) */ } // void muli( void mufa(void) { // Farben einfuellen if( jj < 6 ) { // nur wenn nicht zu klein SelectObject( hdc, CreateSolidBrush( RGB( 255, 0, 255 ) ) ); FloodFill( hdc, int(xa-xf* 90), int(ya-yf* 0), RGB(0,0,0) ); //01 FloodFill( hdc, int(xa-xf* 10), int(ya-yf* 80), RGB(0,0,0) ); FloodFill( hdc, int(xa-xf* -90), int(ya-yf* -60), RGB(0,0,0) ); SelectObject( hdc, CreateSolidBrush( RGB( 0, 255, 0 ) ) ); FloodFill( hdc, int(xa-xf* -10), int(ya-yf* -20), RGB(0,0,0) ); //02 SelectObject( hdc, CreateSolidBrush( RGB( 0, 255, 0 ) ) ); FloodFill( hdc, int(xa-xf* -70), int(ya-yf* 30), RGB(0,0,0) ); //03 SelectObject( hdc, CreateSolidBrush( RGB( 255, 0, 0 ) ) ); FloodFill( hdc, int(xa-xf*-167), int(ya-yf*-119), RGB(0,0,0) ); //04 SelectObject( hdc, CreateSolidBrush( RGB( 0, 255, 0 ) ) ); FloodFill( hdc, int(xa-xf* 90), int(ya-yf* 170), RGB(0,0,0) ); //05 SelectObject( hdc, CreateSolidBrush( RGB( 0, 255, 0 ) ) ); FloodFill( hdc, int(xa-xf* 20), int(ya-yf* 210), RGB(0,0,0) ); //06 SelectObject( hdc, CreateSolidBrush( RGB( 0, 255, 0 ) ) ); FloodFill( hdc, int(xa-xf* 20), int(ya-yf*-165), RGB(0,0,0) ); //07 SelectObject( hdc, CreateSolidBrush( RGB( 0, 255, 0 ) ) ); FloodFill( hdc, int(xa-xf* 140), int(ya-yf*-125), RGB(0,0,0) ); //08 SelectObject( hdc, CreateSolidBrush( RGB( 0, 255, 0 ) ) ); FloodFill( hdc, int(xa-xf* -50), int(ya-yf*-125), RGB(0,0,0) ); //09 SelectObject( hdc, CreateSolidBrush( RGB( 0, 0, 255 ) ) ); FloodFill( hdc, int(xa-xf* -40), int(ya-yf* -55), RGB(0,0,0) ); //10 SelectObject( hdc, CreateSolidBrush( RGB( 0, 0, 255 ) ) ); FloodFill( hdc, int(xa-xf* -94), int(ya-yf* 2), RGB(0,0,0) ); //11 SelectObject( hdc, CreateSolidBrush( RGB( 255, 255, 0 ) ) ); FloodFill( hdc, int(xa-xf* -40), int(ya-yf* -80), RGB(0,0,0) ); //12 SelectObject( hdc, CreateSolidBrush( RGB( 255, 255, 0 ) ) ); FloodFill( hdc, int(xa-xf* -90), int(ya-yf* -15), RGB(0,0,0) ); //13 } /* if( jj */ } // void mufa( void muff(void) { ax = (int)floor( 0.5 + xa ); ay = (int)floor( 0.5 + ya ); ir = (int)floor( 0.5 + rr ); // nur wenn dieser Platz frei ist if( GetPixel( hdc, ax, ay ) == RGB( 255, 255, 255 ) ) { // Platz sichtbar belegen // SelectObject( hdc, CreatePen( PS_SOLID, 1, RGB( 255, 0, 0 ) ) ); // SelectObject( hdc, CreateSolidBrush( RGB( 255, 255, 0 ) ) ); // Platz unsichtbar belegen SelectObject( hdc, CreatePen( PS_SOLID, 1, RGB( 255, 255, 254 ) ) ); SelectObject( hdc, CreateSolidBrush( RGB( 255, 255, 254 ) ) ); ii = ii + 1; xt[ii] = ax; yt[ii] = ay; // Platz merken itoa( jj, tx, 10 ); TextOut( hdc, 10, 10, tx, strlen( tx ) ); // Fraktal-Ebene itoa( ii, tx, 10 ); TextOut( hdc, 10, 30, tx, strlen( tx ) ); // Muffel-Nummer Ellipse( hdc, ax - ir, ay - ir, ax + ir + 1, ay + ir + 1 ); // Platz belegen muli(); mufa(); // Muffel zeichnen } /* if( GetPixel */ } // void muff( //---------------------WINDOWS-FORMULIERUNGEN------------------------ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps ; switch (message) { case WM_SIZE: cxClient = LOWORD (lParam) ; cyClient = HIWORD (lParam) ; return 0 ; case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; //----------------------------------------HAUPTPROGRAMM-------------- /* 37 mal 7 Schief-Ellipsen-Fragment-Daten X-Position; Y-Position; X-Radius ; Y-Radius : Anf-Winkel; End-Winkel; Steigung;*/ x[ 1]= 50; y[ 1]= 0; p[ 1]= 150; r[ 1]= 130; a[ 1]= 265; b[ 1]= 360; s[ 1]= 0.1; x[ 2]= 50; y[ 2]= 0; p[ 2]= 150; r[ 2]= 130; a[ 2]= 29; b[ 2]= 140; s[ 2]= 0.1; x[ 3]= 50; y[ 3]= 0; p[ 3]= 150; r[ 3]= 130; a[ 3]= 146; b[ 3]= 189; s[ 3]= 0.1; x[ 4]= 50; y[ 4]= 0; p[ 4]= 150; r[ 4]= 130; a[ 4]= 194; b[ 4]= 230; s[ 4]= 0.1; x[ 5]=-167; y[ 5]=-119; p[ 5]= 20; r[ 5]= 25; a[ 5]= 0; b[ 5]= 370; s[ 5]=-1.2; x[ 6]=-149; y[ 6]= -40; p[ 6]= 50; r[ 6]= 50; a[ 6]= 80; b[ 6]= 210; s[ 6]= 0.2; x[ 7]= -98; y[ 7]=-140; p[ 7]= 50; r[ 7]= 50; a[ 7]= 272; b[ 7]= 410; s[ 7]= 0.2; x[ 8]= -10; y[ 8]= -20; p[ 8]= 60; r[ 8]= 60; a[ 8]= 0; b[ 8]= 365; s[ 8]= 0.6; x[ 9]= -95; y[ 9]= 30; p[ 9]= 60; r[ 9]= 60; a[ 9]= 57; b[ 9]= 185; s[ 9]= 0.6; x[10]= -25; y[10]= -35; p[10]= 30; r[10]= 30; a[10]= 162; b[10]= 308; s[10]= 0.6; x[11]=-100; y[11]= 15; p[11]= 30; r[11]= 25; a[11]= 148; b[11]= 182; s[11]= 0.6; x[12]= 30; y[12]= 30; p[12]= 100; r[12]= 100; a[12]= 193; b[12]= 243; s[12]= 0; x[13]= -35; y[13]= 90; p[13]= 100; r[13]= 100; a[13]= 198; b[13]= 219; s[13]= 0; x[14]= 90; y[14]= 170; p[14]= 50; r[14]= 70; a[14]= 205; b[14]= 515; s[14]= 0; x[15]= 45; y[15]= 85; p[15]= 30; r[15]= 33; a[15]= 35; b[15]= 165; s[15]= 0; x[16]= 135; y[16]= 85; p[16]= 30; r[16]= 33; a[16]= 195; b[16]= 325; s[16]= 0; x[17]= 90; y[17]= -30; p[17]= 90; r[17]= 90; a[17]= 335; b[17]= 385; s[17]= 0; x[18]= 20; y[18]= 210; p[18]= 50; r[18]= 70; a[18]= 205; b[18]= 435; s[18]= 0; x[19]= -25; y[19]= 125; p[19]= 30; r[19]= 33; a[19]= 35; b[19]= 105; s[19]= 0; x[20]= 65; y[20]= 125; p[20]= 30; r[20]= 33; a[20]= 270; b[20]= 315; s[20]= 0; x[21]= -27; y[21]=-135; p[21]= 40; r[21]= 40; a[21]= 35; b[21]= 145; s[21]= 0; x[22]= 67; y[22]=-135; p[22]= 40; r[22]= 40; a[22]= 215; b[22]= 325; s[22]= 0; x[23]= 20; y[23]=-180; p[23]= 10; r[23]= 10; a[23]= 70; b[23]= 290; s[23]= 0; x[24]= 3; y[24]=-174; p[24]= 10; r[24]= 10; a[24]= 100; b[24]= 320; s[24]= 0; x[25]= 37; y[25]=-174; p[25]= 10; r[25]= 10; a[25]= 40; b[25]= 260; s[25]= 0; x[26]= 20; y[26]= -76; p[26]= 35; r[26]= 35; a[26]= 140; b[26]= 220; s[26]= 0; x[27]= 93; y[27]= -95; p[27]= 40; r[27]= 40; a[27]= 35; b[27]= 145; s[27]= 0; x[28]= 187; y[28]= -95; p[28]= 40; r[28]= 40; a[28]= 215; b[28]= 325; s[28]= 0; x[29]= 140; y[29]=-140; p[29]= 10; r[29]= 10; a[29]= 70; b[29]= 290; s[29]= 0; x[30]= 123; y[30]=-134; p[30]= 10; r[30]= 10; a[30]= 100; b[30]= 320; s[30]= 0; x[31]= 157; y[31]=-134; p[31]= 10; r[31]= 10; a[31]= 40; b[31]= 260; s[31]= 0; x[32]= 140; y[32]= -36; p[32]= 35; r[32]= 35; a[32]= 140; b[32]= 220; s[32]= 0; x[33]= -97; y[33]= -95; p[33]= 40; r[33]= 40; a[33]= 95; b[33]= 145; s[33]= 0; x[34]= -3; y[34]= -95; p[34]= 40; r[34]= 40; a[34]= 215; b[34]= 240; s[34]= 0; x[35]= -50; y[35]=-140; p[35]= 10; r[35]= 10; a[35]= 70; b[35]= 290; s[35]= 0; x[36]= -67; y[36]=-134; p[36]= 10; r[36]= 10; a[36]= 100; b[36]= 320; s[36]= 0; x[37]= -33; y[37]=-134; p[37]= 10; r[37]= 10; a[37]= 40; b[37]= 260; s[37]= 0; SelectObject( hdc, GetStockObject( OEM_FIXED_FONT ) ); SetTextColor( hdc, RGB( 0, 0, 0 ) ); SetBkColor( hdc, RGB( 255, 255, 255 ) ); pi = atan( 1 ) / 45 ; // Grad zu rad Umrechnungsfaktor ii = 0; an = 1; en = 1; // ZAEHLER FUER LISTE ANFANG UND ENDE ff = 0.42; // FAKTOR rr = 128; // RADIUS xa = 140 * 3 - 120 + 100 ; // X-Abstand ya = 114 * 2.8 + 20 - 15 - 30 ; // Y-Abstand xf = 0.6 * 3 * 0.8 * ff * rr / 128; // X-Faktor yf = 0.4 * 2.8 * 1.05 * ff * rr / 128; // Y-Faktor muff(); // MUFFEL for(jj = 1; jj < 5 ; jj =jj + 1 ) { // FRAKTAL-EBENEN MUSS NICHT 5 SEIN rr = rr / 2; // RADIUS HALBIEREN ss = rr * 3 * sin( atan( 1 ) ); // DIAGONALE xf = 0.6 * 3 * 0.8 * ff * rr / 128; // X-Faktor yf = 0.4 * 2.8 * 1.05 * ff * rr / 128; // Y-Faktor for( j= an; j< ( en + 1 ); j = j + 1 ) { // STARTPLAETZE-LISTE // VIER FOLGE-PLAETZE PRUEFEN OB SIE FREI SIND xa = (double)xt[ j ] - ss; // X-Abstand ya = (double)yt[ j ] - ss; muff(); // Y-Abstand LINKS OBEN xa = (double)xt[ j ] + ss; // X-Abstand ya = (double)yt[ j ] - ss; muff(); // Y-Abstand RECHTS OBEN xa = (double)xt[ j ] - ss; // X-Abstand ya = (double)yt[ j ] + ss; muff(); // Y-Abstand LINKS UNTEN xa = (double)xt[ j ] + ss; // X-Abstand ya = (double)yt[ j ] + ss; muff(); // Y-Abstand RECHTS UNTEN } /* for( j */ an = en + 1; en = ii; // LISTE ANFANG UND ENDE } // for( jj ENDE UND AUS // DAS FOLGENDE WIRD NICHT BENOETIGT // SelectObject( hdc, CreateSolidBrush( RGB( 255, 0, 255 ) ) ); // FloodFill( hdc, 0, 0, RGB( 255, 255, 254 ) ); // SelectObject( hdc, CreatePen( PS_SOLID, 1, RGB( 0, 0, 0 ) ) ); // SelectObject( hdc, GetStockObject( NULL_BRUSH ) ); // Ellipse( hdc, 400 - 128, 300 - 128, 400 + 129, 300 + 129 ); // Ellipse( hdc, 400 - 5, 300 - 5, 400 + 6, 300 + 6 ); // Ellipse( hdc, ax - 5, ay - 5, ax + 6, ay + 6 ); //---------------------WINDOWS-FORMULIERUNGEN------------------------ EndPaint (hwnd, &ps) ; return 0 ; case WM_DESTROY: PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam) ; }