Liberty BASIC Community Forum
« superformula »

Welcome Guest. Please Login or Register.
Jul 25th, 2017, 11:42am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: superformula  (Read 129 times)
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 894
xx superformula
« Thread started on: Apr 16th, 2017, 05:27am »

whit thanks to johan gielis
who invented this formula

you have to contact him for use in comercial code
hy has the patend for this

Code:
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , pi
winx = WindowWidth
winy = WindowHeight
pi = atn( 1 ) * 4
nomainwin
open "superformule" for graphics as #m
  #m "trapclose [quit]"
  #m "size 5"
  call superformule 5 , 2 , 7 , 7 , 1 , 1
wait
[quit]
  close #m
end
sub superformule m , n1 , n2 , n3 , a , b
  for u = 0 to 2 * pi step pi / 100
    raux = abs( 1 / a ) _
    * abs( cos( m * u / 4 ) ) ^ n2 _
    + abs( sin( m * u / 4 ) ) ^ n3
    r = abs( raux ) ^ ( -1 / n1 )
    x = r * sin( u ) * winx / 8
    y = r * cos( u ) * winy / 8
    #m "goto " ; winx / 2 + x ; " " ; winy / 2 - y
    #m "down"
    #m "set " ; winx / 2 + x ; " " ; winy / 2 - y
    #m "up"
  next u
end sub
 

please report beatiful combinations of arguments
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 894
xx Re: superformula
« Reply #1 on: Apr 16th, 2017, 06:06am »

version 2.0
Code:
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , pi
winx = WindowWidth
winy = WindowHeight
pi = atn( 1 ) * 4
nomainwin
open "superformule" for graphics as #m
  #m "trapclose [quit]"
  #m "fill black"
  #m "size 5"
    call superformule winx/2,winy/2,winx/8 _
    , 5 , 2 , 7 , 7 , 1 , 3
wait
[quit]
  close #m
end
sub superformule x,y,d, m , n1 , n2 , n3 , a , b
  for u = 0 to 2 * pi step pi / 360
    raux = abs( 1 / a ) _
    * abs( cos( m * u / 4 ) ) ^ n2 _
    + abs( sin( m * u / 4 ) ) ^ n3
    r = abs( raux ) ^ ( -1 / n1 )
    xx = r * sin( u ) * d
    yy = r * cos( u ) * d
    call lino x,y , x+xx , y+yy
  next u
end sub
function rgb$( r , g , b )
  r = int( r ) and 255
  g = int( g ) and 255
  b = int( b ) and 255
  rgb$ = str$( r ) ; " " ; g ; " " ; b
end function
function rainbow$( radians )
  r = sin( radians ) * 127 + 128
  g = sin( radians - 2 / 3 * pi ) * 127 + 128
  b = sin( radians + 2 / 3 * pi ) * 127 + 128
  rainbow$ = rgb$( r , g , b )
end function
sub lino x1,y1 , x2,y2
  af = sqr( ( x1-x2 ) ^ 2 + ( y1-y2 ) ^ 2 )
  dx = ( x2 - x1 ) / af
  dy = ( y2 - y1 ) / af
  for i = 0 to af
    #m "goto " ; x1+dx*i ; " " ; y1+dy*i
    #m "color " ; rainbow$( i * pi * 2 / af )
    #m "down"
    #m "set " ; x1+dx*i ; " " ; y1+dy*i
    #m "up"
  next i
end sub
 
User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls