REM *** MAD TEDDY'S M-SET ZOOM PROGRAM - SPLIT-SCREEN VERSION *** REM Zooming in on the "Love Canal", starting from the entire M-set REM left picture shows zoom; right picture shows location re. the M-set SCREEN 12: REM graphics, 640x480 aspectratio = 4 / 3: REM ratio of horizontal (x) pixels to vertical (y) pixels ypixels = 216 ypixelsminusone = ypixels - 1 xpixels = ypixels * aspectratio xpixelsminusone = xpixels - 1 numberofframes = 100 numberofzoomstoshow = 20 xoffset = xpixels + 8: REM horizontal offset of right-hand graphic from left of screen REM coordinates for first frame ylowinitial = -1.25 yhighinitial = 1.25 xlowinitial = -2.15 xhighinitial = xlowinitial + (yhighinitial - ylowinitial) * aspectratio REM coordinates for final frame ylowfinal = .8271696 yhighfinal = .8272704 xlowfinal = -.2351922 xhighfinal = xlowfinal + (yhighfinal - ylowfinal) * aspectratio REM dimensions of first frame xlowdelta = xlowfinal - xlowinitial ylowdelta = ylowfinal - ylowinitial REM dimensions of final frame xhighdelta = xhighfinal - xhighinitial yhighdelta = yhighfinal - yhighinitial REM locate vanishing point a = ylowdelta B = -xlowdelta c = yhighdelta d = -xhighdelta m = ylowdelta * xlowinitial - xlowdelta * ylowinitial n = yhighdelta * xhighinitial - xhighdelta * yhighinitial determinant = a * d - B * c xvanish = (m * d - B * n) / determinant yvanish = (a * n - m * c) / determinant xvanishpixel = INT(xpixelsminusone * (xvanish - xlowinitial) / (xhighinitial - xlowinitial) + .5) yvanishpixel = INT(ypixelsminusone - ypixelsminusone * (yvanish - ylowinitial) / (yhighinitial - ylowinitial) + .5) shrinkratio = (yhighfinal - ylowfinal) / (yhighinitial - ylowinitial) REM number of iterations before it is decided that a point is in the M-set iterationlimit = 250 FOR frame = 0 TO numberofframes STEP numberofframes / numberofzoomstoshow REM print frame number at bottom of left-hand graphic - three digits LOCATE 15, 14: PRINT "Frame "; IF frame < 100 THEN PRINT "0"; IF frame < 10 THEN PRINT "0"; PRINT RIGHT$(STR$(frame), LEN(STR$(frame)) - 1) REM print commentary under right-hand box LOCATE 15, 41: PRINT "white box shows frame location" REM locate coordinates of this frame lambda = frame / numberofframes z = 1 - shrinkratio ^ lambda ylow = ylowinitial + z * ylowdelta yhigh = yhighinitial + z * yhighdelta xlow = xlowinitial + z * xlowdelta xhigh = xhighinitial + z * xhighdelta REM do the Mandelbrot plot FOR i = 0 TO ypixelsminusone FOR j = 0 TO xpixelsminusone x = xlow + j * (xhigh - xlow) / xpixelsminusone y = yhigh - i * (yhigh - ylow) / ypixelsminusone xc = x: yc = y iterations = 0 rsquared = 0 DO UNTIL rsquared >= 4 OR iterations > iterationlimit u = x * x - y * y + xc v = 2 * x * y + yc rsquared = u * u + v * v x = u: y = v iterations = iterations + 1 LOOP IF rsquared >= 4 THEN PSET (j, i), 2: REM plots a green dot IF frame = 0 THEN PSET (j + xoffset, i), 2 REM don't bother plotting a black dot if point is in M-set REM - just leave it as it is, black, and save a bit of time END IF NEXT j NEXT i REM join vanishing point to frame corners (left-hand graphic) REM LINE (0, 0)-(xvanishpixel, yvanishpixel), 10 REM LINE (xpixelsminusone, 0)-(xvanishpixel, yvanishpixel), 10 REM LINE (0, ypixelsminusone)-(xvanishpixel, yvanishpixel), 10 REM LINE (xpixelsminusone, ypixelsminusone)-(xvanishpixel, yvanishpixel), 10 IF frame = 0 THEN REM join vanishing point to frame corners (right-hand graphic) LINE (0 + xoffset, 0)-(xvanishpixel + xoffset, yvanishpixel), 10 LINE (xpixelsminusone + xoffset, 0)-(xvanishpixel + xoffset, yvanishpixel), 10 LINE (0 + xoffset, ypixelsminusone)-(xvanishpixel + xoffset, yvanishpixel), 10 LINE (xpixelsminusone + xoffset, ypixelsminusone)-(xvanishpixel + xoffset, yvanishpixel), 10 END IF FOR i = numberofframes TO 0 STEP -numberofframes / numberofzoomstoshow boxcolour = 14 IF i = frame THEN boxcolour = 15 xboxleft = xvanish - (xvanish - xlowinitial) * shrinkratio ^ (i / numberofframes) xboxright = xvanish - (xvanish - xhighinitial) * shrinkratio ^ (i / numberofframes) yboxtop = yvanish - (yvanish - ylowinitial) * shrinkratio ^ (i / numberofframes) yboxbottom = yvanish - (yvanish - yhighinitial) * shrinkratio ^ (i / numberofframes) xboxleftpixel = INT(xoffset + xpixelsminusone * (xboxleft - xlowinitial) / (xhighinitial - xlowinitial) + .5) yboxtoppixel = INT(ypixelsminusone - ypixelsminusone * (yboxtop - ylowinitial) / (yhighinitial - ylowinitial) + .5) xboxrightpixel = INT(xoffset + xpixelsminusone * (xboxright - xlowinitial) / (xhighinitial - xlowinitial) + .5) yboxbottompixel = INT(ypixelsminusone - ypixelsminusone * (yboxbottom - ylowinitial) / (yhighinitial - ylowinitial) + .5) LINE (xboxleftpixel, yboxtoppixel)-(xboxrightpixel, yboxbottompixel), boxcolour, B NEXT i BEEP a$ = "" DO: a$ = INKEY$: LOOP UNTIL a$ = " " LINE (0, 0)-(xpixelsminusone, ypixelsminusone), 0, BF NEXT frame