Graphics with Math

5 REM Spiral
10 open#0,0,"200"
20 close#1:open#1,11,"150"
30 plot range (640,480)
40 plot pla (0,0),mve(0,479)
50 for n=1 to 50000
60 s = log(rnd)
70 t= 300 * rnd
80 u = 60 * s * sin(t)
90 v = 50 * s * cos(t)
100 p = 3 * s
110 c = cos(p)
120 s2 = sin(p)
130 x = u * c + v * s2
140 y = -u * s2 + v * c
150 r = x * x + y * y
160 z = 80 * exp(-r/10)
170 z = z * (rnd - 0.5)
180 y = y + z + int(rnd *40) + 1
190 x = x +(-z * 0.3 * int(rnd * 20 + 1))
200 xx = 2 * int(160 + x * 0.7 + y * 0.3)
210 yy = 2 * int(160 + x * 0.1 + y * 0.4)
220 if xx >= 0 and xx < 640 and yy >= 0 and yy < 480 then plot pla(xx,yy), mve(xx + 1,yy + 1)
250 next n
300 end
10 rem FIELD LINES
15 open#0,0,"200":close#1:open#1,11,"150":plot range(1280,960)
20 rem pi = 3.1415926 no need newbrain knows pi
30 RANDOMIZE
40 np = 800: n = 180: m = 30: k = .02
50 FOR i = 0 TO n
60 x = RND: y = RND
70 FOR j = 0 TO m
80 xp = INT(np * x): yp = INT(np * y)
90 sX = xp + (1280 - np) / 2
100 sY = yp
110 IF j > 0 THEN plot pla(pX, pY),mve(sX, sY)
120 pX = sX: py=sY
130 xx = 2 * x - 1: yy = 2 * y - 1
135 an = pi / 2 * SGN(yy)
140 IF xx <> 0 THEN an = ATN(yy / xx) 
150 IF xx < 0 THEN an = an+ pi * sgn(yy)
160 an = an+4* pi / 3+ SIN(6 * pi * SQR(xx * xx + yy * yy)) / 4
170 x = x + k * COS(an): y + k * SIN(an)
180 IF x <= 0 OR x >= 1 OR y <= 0 OR y >= 1 THEN 200
190 NEXT j
200 NEXT i
400 END

Leave a Reply