Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
40
Task/Fractal-tree/FreeBASIC/fractal-tree.basic
Normal file
40
Task/Fractal-tree/FreeBASIC/fractal-tree.basic
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
' version 17-03-2017
|
||||
' compile with: fbc -s gui
|
||||
|
||||
Const As Double deg2rad = Atn(1) / 45
|
||||
Dim Shared As Double scale = 0.76
|
||||
Dim Shared As Double spread = 25 * deg2rad ' convert degree's to rad's
|
||||
|
||||
Sub branch(x1 As ULong, y1 As ULong, size As ULong, angle As Double, depth As ULong)
|
||||
|
||||
Dim As ULong x2, y2
|
||||
|
||||
x2 = x1 + size * Cos(angle)
|
||||
y2 = y1 + size * Sin(angle)
|
||||
|
||||
Line (x1,y1) - (x2,y2), 2 ' palette color green
|
||||
If depth > 0 Then
|
||||
branch(x2, y2, size * scale, angle - spread, depth -1)
|
||||
branch(x2, y2, size * scale, angle + spread, depth -1)
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
' ------=< MAIN >=-----
|
||||
|
||||
Dim As Double angle = -90 * deg2rad ' make sure that the tree grows up
|
||||
Dim As ULong SizeX = 800
|
||||
Dim As ULong SizeY = SizeX * 3 \ 4
|
||||
Dim As Double size = SizeY \ 4
|
||||
Dim As ULong depth = 11
|
||||
|
||||
ScreenRes SizeX, SizeY, 8
|
||||
WindowTitle ("Fractal Tree")
|
||||
|
||||
branch(SizeX\2, SizeY, size, angle, depth)
|
||||
|
||||
' empty keyboard buffer
|
||||
While InKey <> "" : Wend
|
||||
windowtitle ("Fractal Tree, hit any key to end program")
|
||||
Sleep
|
||||
End
|
||||
Loading…
Add table
Add a link
Reference in a new issue