slackey@bbn.com (Stan Lackey) (10/19/88)
OK, Atari fans! Here it is! New, improved Mandelbrot! No need to stand! I think it's right.. just be on the lookout for typos. Anyway, it has two new features, zooming and better accuracy. When it is done drawing a screen, you will see a blinking spot in the upper left corner. You are looking at four corners of the select rectangle. Pressing the button and moving the stick causes the rectangle to change in size. Moving the stick alone will cause the rectangle to move without changing size. When you have the area you'd like to zoom in on in the rectangle, press any of the option, start, or select buttons and it will redraw the whole screen, scaling the selected region up to the full screen size. In playing with this, I found that the approximation (quitting after 15 iterations) is too inaccurate when getting into serious zooming. So, I recoded it to go through the 15 [non-black] colors twice before giving up and drawing the pixel black. This will eventually fizzle out too, but hey give me a break. The only disadvantage of this is that in the full screen version, black takes twice as long to draw. I have a version that lets you select which algorithm to use by pressing a different button, but didn't feel like typing the whole thing in. Oh - pressing the joystick button during the calculation causes it to immediately stop and let you zoom, before a full screen is done. Impress your friends. -Stan 100 GRAPHICS 11 110 SS=0:SE=79:TS=0:TE=191 120 RS=1/20 130 ORGR=2.2:ORGI=1.2 140 GOTO 400:REM Do the first screen 150 REM Do the joystick stuff 160 X=0:Y=0:XD=1:YD=1 170 OLDX=X:OLDY=Y:OLDXD=X+XD:OLDYD=Y=YD 180 GOSUB 630:REM Show cursors 190 ST=STICK(0) 200 IF STRIG(0)=0 THEN 260:REM If button is down, change rectangle size 205 REM Button is up: move rectangle 210 IF (ST=10 OR ST=14 OR ST=6) AND Y>0 THEN Y=Y-1 220 IF (ST=9 OR ST=13 OR ST=5) AND Y+YD<191 THEN Y=Y+1 230 IF (ST=10 OR ST=11 OR ST=9) AND X>0 THEN X=X-1 240 IF (ST=6 OR ST=7 OR ST=5) AND X+XD<78 THEN X=X+1 250 GOTO 290 260 IF (ST=11 OR ST=10 OR ST=14) AND YD>0 THEN YD=YD-1 270 XD=YD*80/192 280 IF (ST=7 OR ST=5 OR ST=13) AND Y+YD<191 AND X+XD<78 THEN YD=YD+1 290 XD=YD*80/192 300 ST=PEEK(53279):REM Read buttons 310 GOSUB 630:REM Remove old cursors 320 IF ST=7 THEN 170:REM No keys pushed 330 REM 340 REM Calculate a new screen 350 REM 360 ORGR=ORGR-X*RS 370 ORGI=ORGI-Y*IS 380 RS=RS*XD/80 390 SS=0:SE=79:TS=0:TE=191 400 IS=RS/4 410 FOR S=SS TO SE 420 R=S*RS-ORGR 430 FOR T=TS TO TE 440 I=T*IS-ORGI 450 C=1 460 COLOR 1:PLOT S,T:REM Show point being calc'ed 470 R1=R:I1=I 480 IF ABS(R1)<1.0E-49 THEN R1=0 490 IF ABS(I1)<1.0E-49 THEN I1=0 500 R12=R1*R1:I12=I1*I1 510 IF R12+I12>4 THEN 570 520 R2=R12-I12+R:I2=2*R1*I1+I 530 C=C+1:IF C>31 THEN C=0:GOTO 570 540 IF C=16 THEN C=17:REM Skip black if in the middle 550 R1=R2:I1=I2 560 GOTO 480 570 COLOR C 580 PLOT S,T 590 IF STRIG(0)=0 THEN 170:REM Quit if button is pushed 600 NEXT T 610 NEXT S 620 GOTO 170 630 REM 640 REM Subr "exors"-in the cursors 650 REM 660 XX=OLDX:YY=OLDY:GOSUB 710 670 YY=OLDYD:GOSUB 710 680 XX=OLDXD:GOSUB 710 690 YY=OLDY:GOSUB 710 700 RETURN 710 LOCATE XX,YY,C 720 COLOR C+8:PLOT XX,YY 730 RETURN