Xref: utzoo alt.fractals:1027 alt.sources:3461 Path: utzoo!utgpu!cs.utexas.edu!uunet!sco!staceyc From: staceyc@sco.COM (Stacey Campbell) Newsgroups: alt.fractals,alt.sources Subject: Re: Looking for source code for producing fractal images Message-ID: <10727@scolex.sco.COM> Date: 11 Mar 91 21:09:33 GMT References: <9103080303.AA15566@cat3.cs.wisc.edu> Sender: news@sco.COM Followup-To: alt.fractals Organization: The Santa Cruz Operation, Inc. Lines: 128 In article <9103080303.AA15566@cat3.cs.wisc.edu> cheukki@GARFIELD.CS.WISC.EDU writes: >Hello guys, I'm looking for either C or Pascal source code for producing >fractal images. If you have one or you know where can I get it,please >tell me. Thank you. Try not to gag, but here is my color curses version of the Mandelbrot Set. If you don't have color it's still fairly easy to get working. Resolution is _great_(*)! I've written a slightly better optimized X/Motif version, that includes rubberbanding code for magnification, that's under 400 lines and is reasonably understandable if anyone is interested. Stacey. * - on a terminal with 1000 lines and columns at a distance of 10 yards! #!/bin/sh # This is a shell archive (produced by shar 3.49) # To extract the files from this archive, save it to a file, remove # everything above the "!/bin/sh" line above, and type "sh file_name". # # existing files will NOT be overwritten unless -c is specified # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 106 -rw-rw-r-- Makefile # 1054 -rw-rw-r-- code.c # # ============= Makefile ============== if test -f 'Makefile' -a X"$1" != X"-c"; then echo 'x - skipping Makefile (File already exists)' else echo 'x - extracting Makefile (Text)' sed 's/^X//' << 'SHAR_EOF' > 'Makefile' && LIBS= -lcurses OBJS= code.o CFLAGS= -O CC= cc X mandel: $(OBJS) X $(CC) $(CFLAGS) $(OBJS) $(LIBS) -o mandel SHAR_EOF chmod 0664 Makefile || echo 'restore of Makefile failed' Wc_c="`wc -c < 'Makefile'`" test 106 -eq "$Wc_c" || echo 'Makefile: original size 106, current size' "$Wc_c" fi # ============= code.c ============== if test -f 'code.c' -a X"$1" != X"-c"; then echo 'x - skipping code.c (File already exists)' else echo 'x - extracting code.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'code.c' && #include X static void Plot(); X int main() X { X int a, b, K, k, M, n_p, n_q, i; X double p_min, p_max, q_min, q_max, delta_p, delta_q, p, q, x, y; X double x_2, y_2, r, new_x; X X initscr(); X start_color(); X for (i = 1; i <= COLOR_WHITE; ++i) X init_pair(i, i, COLOR_BLACK); X a = COLS; X b = LINES; X p_min = -2.25; X p_max = 0.75; X q_min = -1.5; X q_max = 1.5; X K = 'z' - 'a'; X M = 100; X delta_p = (p_max - p_min) / (a - 1); X delta_q = (q_max - q_min) / (b - 1); X for (n_p = 0; n_p < a; ++n_p) X for (n_q = 0; n_q < b; ++n_q) X { X p = p_min + n_p * delta_p; X q = q_min + n_q * delta_q; X k = 0; X x = 0; X y = 0; X do X { X x_2 = x * x; X y_2 = y * y; X new_x = x_2 - y_2 + p; X y = 2 * x * y + q; X x = new_x; X ++k; X r = x_2 + y_2; X } while (r <= M && k != K); X Plot(n_q, n_p, k != K ? k : 0); X } X endwin(); X return 0; } X static void Plot(y, x, color) X int y, x, color; X { X if (color != 0) X mvwaddch(stdscr, y, x, 'a' + color | COLOR_PAIR((color % 7) + X 1) | A_STANDOUT); X wmove(stdscr, y, x); X wrefresh(stdscr); } SHAR_EOF chmod 0664 code.c || echo 'restore of code.c failed' Wc_c="`wc -c < 'code.c'`" test 1054 -eq "$Wc_c" || echo 'code.c: original size 1054, current size' "$Wc_c" fi exit 0 -- Stacey Campbell Internet: staceyc@sco.com UUCP: {uunet,ucscc,att,sq,altos,lotus,sun,microsoft}!sco!staceyc