June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
45
Task/Fractal-tree/BASIC/fractal-tree-1.basic
Normal file
45
Task/Fractal-tree/BASIC/fractal-tree-1.basic
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
graphsize 300,300
|
||||
|
||||
level = 12 : len =63 # initial values
|
||||
x = 230: y = 285
|
||||
rotation = pi/2
|
||||
|
||||
A1 = pi/27 : A2 = pi/8 # constants which determine shape
|
||||
C1 = 0.7 : C2 = 0.85
|
||||
|
||||
dim xs(level+1) : dim ys(level+1) # stacks
|
||||
|
||||
fastgraphics
|
||||
color black
|
||||
rect 0,0,graphwidth,graphheight
|
||||
refresh
|
||||
color green
|
||||
gosub tree
|
||||
refresh
|
||||
imgsave "Fractal_tree_BASIC-256.png", "PNG"
|
||||
end
|
||||
|
||||
tree:
|
||||
xs[level] = x : ys[level] = y
|
||||
gosub putline
|
||||
if level>0 then
|
||||
level = level - 1
|
||||
len = len*C1
|
||||
rotation = rotation - A1
|
||||
gosub tree
|
||||
len = len/C1*C2
|
||||
rotation = rotation + A1 + A2
|
||||
gosub tree
|
||||
rotation = rotation - A2
|
||||
len = len/C2
|
||||
level = level + 1
|
||||
end if
|
||||
x = xs[level] : y = ys[level]
|
||||
return
|
||||
|
||||
putline:
|
||||
yn = -sin(rotation)*len + y
|
||||
xn = cos(rotation)*len + x
|
||||
line x,y,xn,yn
|
||||
x = xn : y = yn
|
||||
return
|
||||
Loading…
Add table
Add a link
Reference in a new issue