Author Topic: Gem 7 in fig translated to SB  (Read 1139 times)

B+

  • Guest
Gem 7 in fig translated to SB
« on: April 14, 2017, 04:48:22 PM »
figosdev was at SmallBASIC forum also,
http://smallbasic.sourceforge.net/?q=node/1684

Here is sample, we worked on a translation of his Gem 7
Code: [Select]
'gem seven.bas for SmallBASIC 0.12.8 [B+=MGA] and whoever else wants to help, 2017-03-27 started
' orig by mn, 2017 found here
'http://thejoyfulprogrammer.com/qb64/forum/showthread.php?tid=607&pid=1802&rndtime=14903133282021184396#pid1802

'#### license: creative commons cc0 1.0 (public domain)
'#### http://creativecommons.org/publicdomain/zero/1.0/
'proginf = "gem seven 2017 mn"
'function rgbcolour r g b c
'python
'    figcgapal[c] = (r, g, b)
'    fig
'    fig
'

'v 1
v = 1

'c 400
c = 400

'w 3.14159 divby 2
w = pi/2

'xb (in SB xb is already 0)
'yb (in SB yb is already 0)

'for r 490 300 -.25
for r = 490 to 300 step -.25
 
  ' oh yeah # is comment in fig !!!!!!!!!!!!!!!!!!!!!!!!!!!!
  '    e w minus 0.00413367105263 swap e w # 3.14159 / 4 / (490 - 300)
  e = w - pi/4/(490 - 300) : swap e, w
  '                                        V
  '    for p 0 3.14159 0.44879857142857144 # 3.14159 / 7
  for p = 0 to pi step pi / 7
   
    'e w cos times 380 divby 2 int
    e = int((cos(w) * 380)/2)
   
    'rc r divby 3 plus 40  int
    rc = int((r/3) + 40)
   
    ' rd 256 minus rc rgbcolour rd rc 0 11
    rd = rgb(256 - rc, rc, 0) 
   
    'x p times 2 cos times e plus c int
    x = int(cos(p * 2) * e + c)
   
    'y p times 2 sin times e plus r minus 50  int
    y = int(sin(p * 2) * e + r - 50)
   
    'm 6.28 plus 1.57 divby 108.503 divby 2
    m = (((2 * pi) + pi/2)/108.503)/2
   
    'now v plus m swap now v
    now = v + m : swap now, v
   
    'rc r divby 4 int mod 2
    rc = int(r/4) mod 2
   
    'iftrue rc
    if rc then
     
      'iftrue xb
      if xb then
       
        'now v int mod 2 times 11 line xb yb x y now
        now = (int(v) mod 2) * 11 : line xb, yb, x, y, now
     
      'else   
      else
       
        'now v int mod 2 times 11 pset x y now
        now = (int(v) mod 2) * 11 : pset x, y, now
       
      end if
      'fig

      'xb x
      xb = x
     
      'yb y
      yb = y
    end if
    'fig

    'next
  next
 
  'now display
  showpage

'next
next

'now display lineinput
pause
« Last Edit: April 14, 2017, 04:54:30 PM by B+ »