•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Legacy and Other Languages section within the Software Development category of DaniWeb, a massive community of 375,276 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,129 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Legacy and Other Languages advertiser:
A simple experiment with the ever so popular Mandelbrot fractal graphics, call it mathematical art, nice to look at. This set of experiments loops through a number of colors to make the whole thing more exciting.
' experiments with Mandelbrot sets (math induced graphics) ' needs BCX basic, download free package from: ' http://www.rjpcomputing.com/programming/bcx/devsuite.html ' tested with BCX basic and Pelles C vegaseat 01aug2005 ' generates WinMain() and sets the Classname GUI "mandelbrot2" CONST Yellow = RGB(255,255,0) CONST SeaGreen = RGB(60,179,113) CONST Aqua = RGB(0,255,255) CONST Blue = RGB(0,0,255) CONST Orange = RGB(255,165,0) CONST Red = RGB(255,0,0) CONST Green = RGB(0,255,0) GLOBAL Form1 AS CONTROL GLOBAL Farbe AS INTEGER Farbe = Yellow ' start with this color ' create the form, center it, show it SUB FORMLOAD Form1 = BCX_FORM("Mandelbrot Sets") BCX_SET_FORM_COLOR(Form1, 0) CENTER(Form1) SHOW(Form1) END SUB ' code between BEGIN EVENTS/END EVENTS takes care of the event messages BEGIN EVENTS SELECT CASE CBMSG CASE WM_CREATE ' 3500 miliseconds for each color IF NOT SetTimer(hWnd, 1, 3500, 0) THEN MessageBox (hWnd, "timer error", "error", MB_OK) PostQuitMessage (0) END IF CASE WM_PAINT DIM RAW ps AS PAINTSTRUCT DIM RAW hdc AS HDC hdc = BeginPaint (hWnd, &ps) DrawMandelbrot(hdc) DeleteDC (hdc) EndPaint (hWnd, &ps) CASE WM_TIMER SELECT CASE Farbe CASE Yellow Farbe = SeaGreen ' go from yellow to seagreen CASE SeaGreen Farbe = Aqua ' from seagreen to aqua CASE Aqua Farbe = Orange ' etc CASE Orange Farbe = Green ' etc CASE Green Farbe = Blue CASE Blue Farbe = Red CASE Red Farbe = Yellow ' back to yellow again CASE ELSE Farbe = Yellow ' default Farbe END SELECT InvalidateRect(Form1,0,1) END SELECT END EVENTS SUB DrawMandelbrot (hdc AS HDC) DIM RAW Count AS INTEGER DIM RAW A AS SINGLE, B AS SINGLE, C AS SINGLE DIM RAW I AS SINGLE, R AS SINGLE FOR I = -1.3 TO 1.3 STEP .01 DOEVENTS ' process external events FOR R = -2.0 TO 1 STEP .01 A = B = C = Count = 0 WHILE ABS(A) <= 2 AND ABS(B) <= 2 AND Count < 128 C = A*A - B*B + R B = 2*A*B + I A = C INCR Count WEND SetPixel (hdc, 280 + R*100, 140 + I*100, Count*Farbe) NEXT NEXT UpdateWindow(Form1) END SUB
Comments (Newest First)
bumsfeld | Posting Shark | Aug 1st, 2005
•
•
•
•
I do not know anything of BCX, but you make it read interesting.
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)