ErosOlmi
27-09-2019, 21:14
An example using FreeBasic inside thinBasic.
Just open script in thinAir and execute. thinBasic will do the rest.
Very fast execution :)
thinBasic 1.11.1.x minimum version required
#MinVersion 1.11.1
#compiled "===Mandelbrot Example==="
'----------------------------------------------------------------------------
function Mandelbrot_Screen Cdecl (byval XMax as long, byval YMax as long, ByVal depth As Long) As long Export
'----------------------------------------------------------------------------
ScreenRes XMax, YMax, depth
end function
'----------------------------------------------------------------------------
function Mandelbrot_Show Cdecl (byval XMax as long, byval YMax as long, byval lLimit as long) As long Export
'----------------------------------------------------------------------------
dim lx as double
dim ly as DOUBLE
dim x as long
dim y as long
dim a as DOUBLE
dim b as DOUBLE
dim c as DOUBLE
dim x2 as DOUBLE
dim y2 as DOUBLE
dim a2 as DOUBLE
dim b2 as DOUBLE
dim z as double
lx = 3 / XMax
ly = 2 / YMax
For x = 1 To XMax
For y = 1 To YMax
a = 0
b = 0
c = 0
x2 = lx * x - 2
y2 = ly * y - 1
While c < 50
a2 = a * a - b * b
b2 = 2 * a * b
a = a2 + x2
b = b2 + y2
z = a * a + b * b
If z >= 4 Then Exit While
c = C + 1
Wend
Select Case c
Case 50
PSet (x, y), Rgb(0, 0, 0)
Case is < lLimit
PSet (x, y), Rgb(245-((17 - c) * 3), 0, 0)
Case is < 33
PSet (x, y), Rgb(245, ((c - 16) * 16) - 16, 0)
Case Else
PSet (x, y), Rgb(641-(c * 12), 245, ((c - 32) * 15))
End Select
Next
Next
return 0
end Function
'----------------------------------------------------------------------------
function Mandelbrot_Sleep Cdecl () As long Export
'----------------------------------------------------------------------------
sleep
end function
#endcompiled
long lWidth = 1024
long lHeight = 768
long lDepth = 32
long l
'---Call FreeBasic functions
Mandelbrot_Screen(lWidth, lHeight, lDepth)
for l = 2 to 21
Mandelbrot_Show(lWidth, lHeight, l)
next
Mandelbrot_Sleep
10059
Just open script in thinAir and execute. thinBasic will do the rest.
Very fast execution :)
thinBasic 1.11.1.x minimum version required
#MinVersion 1.11.1
#compiled "===Mandelbrot Example==="
'----------------------------------------------------------------------------
function Mandelbrot_Screen Cdecl (byval XMax as long, byval YMax as long, ByVal depth As Long) As long Export
'----------------------------------------------------------------------------
ScreenRes XMax, YMax, depth
end function
'----------------------------------------------------------------------------
function Mandelbrot_Show Cdecl (byval XMax as long, byval YMax as long, byval lLimit as long) As long Export
'----------------------------------------------------------------------------
dim lx as double
dim ly as DOUBLE
dim x as long
dim y as long
dim a as DOUBLE
dim b as DOUBLE
dim c as DOUBLE
dim x2 as DOUBLE
dim y2 as DOUBLE
dim a2 as DOUBLE
dim b2 as DOUBLE
dim z as double
lx = 3 / XMax
ly = 2 / YMax
For x = 1 To XMax
For y = 1 To YMax
a = 0
b = 0
c = 0
x2 = lx * x - 2
y2 = ly * y - 1
While c < 50
a2 = a * a - b * b
b2 = 2 * a * b
a = a2 + x2
b = b2 + y2
z = a * a + b * b
If z >= 4 Then Exit While
c = C + 1
Wend
Select Case c
Case 50
PSet (x, y), Rgb(0, 0, 0)
Case is < lLimit
PSet (x, y), Rgb(245-((17 - c) * 3), 0, 0)
Case is < 33
PSet (x, y), Rgb(245, ((c - 16) * 16) - 16, 0)
Case Else
PSet (x, y), Rgb(641-(c * 12), 245, ((c - 32) * 15))
End Select
Next
Next
return 0
end Function
'----------------------------------------------------------------------------
function Mandelbrot_Sleep Cdecl () As long Export
'----------------------------------------------------------------------------
sleep
end function
#endcompiled
long lWidth = 1024
long lHeight = 768
long lDepth = 32
long l
'---Call FreeBasic functions
Mandelbrot_Screen(lWidth, lHeight, lDepth)
for l = 2 to 21
Mandelbrot_Show(lWidth, lHeight, l)
next
Mandelbrot_Sleep
10059