'=========================================================================== ' Subject: 3D GRAPHS Date: 09-18-96 (18:27) ' Author: Nathan Wittich Code: QB, QBasic, PDS ' Origin: wittich@cdsnet.net Packet: GRAPHICS.ABC '=========================================================================== ' 3dgraph ' a cool screensaver by Nathan Wittich ' wittich@cdsnet.net in subject put in "Nathan:" someone else is in ' an email based newsgroup that I share internet access with. ' ' This program draws new 3d graphs on the screen. Each one is different ' in colors, sizes, smoothness, and how high the bumps are. My goal ' when I made it was to make each one as different as I can, not just ' different graphs that look alike ' ' here's how it makes the graph: ' A dimmensioned variable (u) has all the grids ' Into each place, it puts a random number. ' it averages each grid's height with the heights of surrounding ones. ' It does that lots of times. ' Then it draws the graph ' ' Although random #'s make each different, changing the source code will ' be even better. ' ' How come in basic I can make a cooler screensaver than Microsuck? ' RANDOMIZE TIMER DEFINT A-Z DIM u(75, 60) SCREEN 12 DO c1 = RND * 8 c2 = RND * 8 c3 = RND * 8 'PRINT "palette" FOR a = 1 TO 14 'PALETTE a, a * 4 NEXT a 'PRINT "setting up" l1 = RND * 500 l2 = l1 + RND * 500 FOR a = 1 TO 64 FOR b = 1 TO 48 u(a, b) = (u(a, b) * .9) + RND * l1 - RND * l1 IF RND < .01 THEN u(a, b) = l2 * RND NEXT b NEXT a 'FOR a = 55 TO 64 'FOR b = 5 TO 43 'u(a, b) = (u(a - 1, b) - 10) 'NEXT b 'NEXT a FOR i = 1 TO 4 + RND * 2 LOCATE 3, 1 'PRINT "smoothening "; INT((i / 7) * 100); "%" FOR a = 2 TO 64 'smoothen it FOR b = 2 TO 48 u(a, b) = (u(a + 1, b) + u(a - 1, b) + u(a, b - 1) + u(a, b + 1) + u(a, b + 2) + u(a + 2, b)) / 6 NEXT b NEXT a NEXT i 'FOR i = 1 TO 2 'FOR a = -480 + RND + RND + RND TO 640 STEP 2 + RND * 3 'LINE (640 - a, 0)-(640 - a - 480, 480), 0 'LINE (a, 0)-(a + 480, 480), 0 'NEXT a 'NEXT CLS 'd = 1 n = RND * 10 + RND * 10 FOR a = 60 TO 2 STEP -1 FOR b = 2 TO 45 IF ABS(a - b) < 35 AND (a + b) > 15 AND a > 5 AND b > 5 THEN 'SWAP d, e 'LINE (a * n + u(a, b), b * n - u(a, b))-(a * n + u(a - 1, b + 1) - n, n + b * n - u(a - 1, b + 1)),RND * 16, BF LINE (a * n + u(a, b), b * n - u(a, b))-(a * n + u(a + 1, b + 1) + n, n + b * n - u(a + 1, b + 1)),c1 'LINE (a * n + u(a, b), b * n - u(a, b + 1) + n)-(a * n + n + u(a + 1, b), b * n - u(a + 1, b)), c1 LINE (a * n + u(a, b), b * n - u(a, b))-(a * n + u(a + 1, b) + n, b * n - u(a + 1, b)), c2 LINE (a * n + u(a, b), b * n - u(a, b))-(a * n + u(a, b + 1), b * n + n - u(a, b + 1)), c3 END IF NEXT b SWAP d, e NEXT a 'a$ = INPUT$(1) LOOP WHILE INKEY$ = ""