Post by bereb on May 16, 2011 9:52:14 GMT 1
Hello, I've discovered GFA-Basic 32 since one month and I'm trying to adapt some scripts from other languages (Basics, Logo, etc.) to GFA or to create my own little programs.
Programing with GFA seems really easy to me and the results are very amazing, as regards speed in particular. Moreover I'm a Logo fan too, so I appreciate the GFA Draw command, which allows me to transcribe my Logo scripts easlily and quickly and run them with increased performance, of course.
Here is a script adapted from Just/Liberty Basic ...
Programing with GFA seems really easy to me and the results are very amazing, as regards speed in particular. Moreover I'm a Logo fan too, so I appreciate the GFA Draw command, which allows me to transcribe my Logo scripts easlily and quickly and run them with increased performance, of course.
Here is a script adapted from Just/Liberty Basic ...
'==========================================================
'FIREWORKS de "coolFractal.bas"
'un script JustBasic réalisé par Rod (www.justbasic.com)
'--- adapté pour GFA-Basic 32 v2.3 (1169)
'par Bereb Carac - mai 2011 --------------------------
'==========================================================
'-- Constants (constantes)
Const WindowWidth = 1024, WindowHeight = 740 'taille fenêtre
Const CenterX = WindowWidth / 2, CenterY = WindowHeight / 2 'centre fenêtre
'-- Building the GUI (création de l 'interface graphique)
Form Center Fixed fen = " Cool Fractals with GFA-BASIC ", 0, 0, WindowWidth, WindowHeight
.BackColor = 0 ' black background (fond noir)
'-- Control button (définition du bouton de contrôle)
Ocx Command btn = "CLEAR", WindowWidth - 75, WindowHeight - 65, 50, 25
'-- Temporizing (temporisation) : here you can change the timing
Ocx Timer temp
.Interval = 1
.Enabled = True
'-- Events loop (attente évènements)
Do
Sleep
Until Me Is Nothing
'-- Events subs (routines gérant les évènements)
Sub temp_Timer
DrawPoints
EndSub
Sub btn_Click
Cls
EndSub
Sub fen_Destroy
temp.Enabled = False
Me.Close
End ' of program
EndSub
'-- Main Procedure (procédure principale)
Proc DrawPoints
Local Integer col, dots, i
Local Single a, b, c, x, y, j, z, xp, yp
' set up some random colors (couleurs aléatoires)
col = RGB(Rnd() * 256, Rnd() * 256, Rnd() * 256)
' set up some random starting positions (positions aléatoires)
a = Rnd()
b = 0.9998
c = 2 - 2 * a
dots = 12000
x = j = 0
y = Rnd() * 12 + 0.1
' calculate and draw the points (calcul et affichage des points)
For i = 0 To dots
z = x
x = b * y + j
j = a * x + c * (x ^ 2) / (1 + x ^ 2)
y = j - z
xp = x * 20 + CenterX
yp = y * 20 + CenterY
Pset xp, yp, col
Next
EndProc