initial check in.

This commit is contained in:
Kelvin Sherlock 2021-12-18 17:15:15 -05:00
commit bdc7588060
3 changed files with 83 additions and 0 deletions

7
Makefile Normal file
View File

@ -0,0 +1,7 @@
tree.basic : tree.mdbasic
mdbasic++ -o tree.basic tree.mdbasic
tree.applesoft : tree.mdbasic
mdbasic++ -S tree.mdbasic | tr -d ' ' > tree.applesoft

3
tree.applesoft Normal file
View File

@ -0,0 +1,3 @@
1A=2:B=-3:C=3.14159:D=1/(2*C):E=D/3:HOME:HGR2:F=0:HCOLOR=1:FORG=0TO14STEP.1:GOSUB2:NEXT:F=C:HCOLOR=5:FORG=0TO14STEP.1:GOSUB2:NEXT:END
2H=G+F:I=G*E:J=I*COS(H):K=-I*SIN(H):L=D*G:K=K-B:IFK<2.9THENRETURN
3J=INT(140+180*(J/K)):L=INT(160+230*((L-A)/K)):HPLOTJ,L:RETURN

73
tree.mdbasic Normal file
View File

@ -0,0 +1,73 @@
'
' Christmas tree.
' See https://github.com/anvaka/atree for explanation.
'
#define yScreenOffset 160
#define xScreenOffset 140
#define yScreenScale 230 ' 192
#define xScreenScale 180
yCamera = 2
zCamera = -3
pi = 3.14159
'pi4 = pi/4
rate = 1 / (2 * pi)
factor = rate/3
'minx=100
'max=0
'miny=100
'maxy=0
home
hgr2
'theta = 0
angleOffset = 0
hcolor 1 ' green
for theta=0 to 14 step .1
gosub update
next
'theta = 0
angleOffset = pi
hcolor 5 ' orange
for theta=0 to 14 step .1
gosub update
next
'print "x=";minx;"..";maxx
'print "y=";miny;"..";maxy
end
update:
ta = theta + angleOffset
tf = theta * factor
x = tf * cos(ta) 'theta + angleOffset
z = - tf * sin(ta) 'theta + angleOffset
y = rate * theta
'if x>maxx then maxx=x
'if y>maxy then maxy=y
'if x<minx then minx=x
'if y<miny then miny=y
z = z - zCamera
if z<2.9 then return
x = int(xScreenOffset + xScreenScale * (x / z))
y = int(yScreenOffset + yScreenScale * ((y - yCamera) / z))
hplot x,y
'print "x=";x;" y=";y;" z=";z
return