RetroBASIC

Basicprogramming(.org) => Code and examples => Topic started by: B+ on January 04, 2017, 11:01:29 PM

Title: Vargraph.bas
Post by: B+ on January 04, 2017, 11:01:29 PM
Code: [Select]
'Vargraf.bas for SmallBASIC v12.8 [B+=MGA] 2017-01-04
' from Vargraf.yab, in Galileo's Collection
' Author: Antonio Navarro Andreu, 2009
' Adaptacion del programa 'Variaciones graficas' del n� 3 de la revista ZX
' docu Programa original escrito en Sinclair BASIC para ZX Spectrum.

' 2017-01-04 completely overhauled removing line numbers and read / data for q
' adding two outer loops and coloring, random selections for infinite variety
' dPlaces function created for display of decimal numbers

const s=(min(xmax, ymax))\2 - 25  'to fit in middle of screen
color 15, 0 'for prints
while 1  'new outer loop picks two random numbers
  r1 = rnd*100 + 1 : r2 = rnd*100 + 1
  for q = 20 to 150 step .1 
    ' added this loop, orig q read from 10 data points 20 to 83
    ' and showed 10 screens and was done!
    cls
    f=0 : counter = 0
    ? "r1 = ";dPlaces(r1,1);"  r2 = ";dPlaces(r2,1);"    q = ";dPlaces(q,1)
    for n=0 to 2*pi+.01 step 2*pi/q
      counter +=1 'added for coloring
      x=(sin(r1*n))*s+xmax/2 'orig  60 let x=(sin(29*n)+1)*60+68
      y=(cos(r2*n))*s+ymax/2 'orig  70 let y=(cos(11*n)+1)*60+28
      if f=1 then line a, b, x, y, (counter\16) mod 6 + 9
      f=1 : a=x :  b=y
    next
    delay 70
  next
wend

func dPlaces(number, places)
  local ns, dot
  ns = str(number) : dot = instr(ns, ".")
  if dot then
    dPlaces = mid(ns, 1, dot) + mid(ns, dot+1, places)
  else
    dPlaces = ns
  end if
end

out of chaos the occasional flash of beauty... (this was cherry picked!)
Title: Re: Vargraph.bas
Post by: Galileo on January 05, 2017, 07:18:31 PM
Fantastic job!