Javascript first steps

Two things occupying me at the moment. I’m mucking around with javascript and web development. I’m also digging through an archive of old BBC Micro software, including a ton of magazine cover disk images from back when that was a thing.

There’s heaps of stuff that make little or no sense without the accompanying magazine. Control programs for hardware projects, or code fragments that are part of a larger tutorial or series. That kind of thing. The bits I enjoy are the tiny BASIC programs that render something cool. Take this one, for example:

   10REM > <BasicSave$dir>.KAM_ATRACT
   20PRINT"Strange Attractors 1"
   30PRINT"The KAM attractor"
   40PRINT"By Mike Cook"
   50PRINT"A defines the Angle of the orbit in radians"
   60REPEAT
   70INPUT"Enter a value for A about (1.1 to 1.7) ",A
   80MODE0
   90PRINT TAB(0,0);"The KAM attractor By Mike Cook"
  100sinA=SIN(A)
  110cosA=COS(A)
  120C%=0
  130FOR orbit= 0.1 TO 2.5 STEP 0.05
  140C%=C%+1
  150REMGCOL 0,C%
  160U=orbit/3
  170V=orbit/3
  180FOR B%= 1 TO 300
  190IF ABS(U)>1E6 OR ABS(V)>1E6 THEN GOTO 240
  200PLOT 69,(U*640)+640,(V*512)+512
  210X=U*cosA-(V-U*U)*sinA
  220Y=U*sinA+(V-U*U)*cosA
  230U=X:V=Y
  240NEXT
  250NEXT
  260PRINT TAB(0,0)"This is A = ";A;SPC(18)
  270PRINT TAB(0,31);
  280UNTIL FALSE

I found this one on the April 1991 copy of Micro User. Simple looking thing, but then it goes and does this:

Although it does take a few minutes to get there. I googled KAM attractor and ended up with a bunch of scary looking math papers, and a wikipedia entry. I’ve read the wikipedia entry a couple of times, but I must need another cup of tea because while most of the words appear to be in English, I’m none the wiser at the end of it than I was at the start.

So I’ve got this cool little BASIC program, and I’m trying to figure out javascript, so the consequences were pretty much inevitable.

Leave a Reply

Your email address will not be published.