Upload
buinhan
View
224
Download
0
Embed Size (px)
Citation preview
Tiny Basic for Windows
tbasic.org *1
[2014 11]
Tiny Basic for Windows
1 tbasic 21.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2 tbasic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 tbasic 82.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3 153.1 Cls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.2 PSet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.3 Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.4 Circle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.5 Paint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.6 GLocate GPrint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4 234.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
*1 http://www.tbasic.org
1
2
tbasictbasic tbasic
1 tbasictbasic N88-BASICQuick BASIC Windows Visual Basic Quick BASIC tbasic
1.1
(pixel) tbasic
800 600 800 600 Windows 800 6001024 7681152 8641280 960128010241600 1200Windows
3
1.2 tbasic
Print tbasictbasic
tbasic
tbasic GScreenGScreen Graph Screen
GScreen()
1.1 (600 400).
GScreen(600,400)
600 400
600 400
4
1.3
600 400 600 400600 400=240000
600 400 ( )
600 400 400600
xy (x, y)
0
(0, 0) (599, 399)
OS
(x, y) (0, 0) (3, 0) (3, 0)y = f (x)*23 x 3 (x, f (x))
(100x + 300 100 f (x) + 200)
WindowWindow
*2 (3,2) (3, 2)
5
Window (x0,y0)-(x1,y1)
(x0,y0)(x1,y1) x0
6
CLS PSet Line Circle Paint GLocate GPrint
tbasic
1.5
CloseGScreen tbasic
CloseGScreen
CloseGScreenCloseGScreen
GScreen()
GScreen tbasic
GScreen
7
*4
tbasic
1.6
tbasic
(1) Alt+PrintScreen tbasicPC
*4 tbasic
8
(2) tbasictbasic SavePicture jpgpnggif bmp tbasic
BASIC sample enseki.tbt
Alt+PrintScreen SavePicture
BASIC
2 tbasic
2.1
Paint
9
Cls 2 Cls 2
GBackColorGForeColorGBorderColor
html
16 0 15
: : : : 0 : Black 1 : Navy 2 : Green 3 : Teal
4 : Maroon 5 : Purple 6 : Olive 7 : Silver
8 : Gray 9 : Blue 10 : Lime 11 : Cyan(Aqua)
12 : Red 13 : Fuchsia 14 : Yellow 15 : White
GBackColor=0
GBackColor="Black"
htmlhtml RGB 16FFCCAA GBackColor="#FFCCAA"
10
2.2
(1) (2) (3) (4)
html RGB
600 400 (3,2)(3, 2)
GBackColor="Navy"GForeColor="Cyan"GScreen(600,400)Window (-3,-2)-(3,2)MathGraph On
2.3
CLS PSet Line Circle Paint GLocate GPrint
PSetLine CircleRND*5 (0, 0) (1, 1)
*5 RND 0 RND < 1
11
GBackColor="Black"GForeColor="White"GScreen(300,300)Window (0,0)-(1,1)MathGraph On
1000 PSetPSet Point Set PSet (x,y) *6
PSet (Rnd,Rnd)
1000 For
2.1.
1000GBackColor="Black"GForeColor="White"GScreen(300,300)Window (0,0)-(1,1)MathGraph OnFor i=1 to 1000PSet (Rnd,Rnd)
Next iEnd
GForeColor
3
j=((i-1) mod 3)+1
i=1,2,3,4,5,6,...j=1,2,3,1,2,3,...
*6 PSet (x,y), c c
'1000_GBackColor="Black"GForeColor="White"GScreen(300,300)Window (0,0)-(1,1)MathGraph OnFor i=1 to 1000 PSet (Rnd,Rnd)Next iEnd
tbasic.org1000Points.txt12
GForeColor GForeColor Sleep
2.2. 1000Dim CLR$(3)CLR$(1)="Yellow"CLR$(2)="Red"CLR$(3)="Cyan"GBackColor="Black"GForeColor="White"GScreen(300,300)Window (0,0)-(1,1)MathGraph OnFor i=1 to 1000Sleep(10)C$ = CLR$(((i-1) mod 3)+1) :1,2,3GForeColor= C$PSet (Rnd,Rnd)
Next iEnd
C$ = CLR$(((i-1) mod 3)+1)
i = 1, 2, 3, . . .C$YellowRedCyan
Line Line
Line (x1,y1)-(x2,y2)
(x1,y1) (x2,y2) 1000 100 6
2.3. 100Dim CLR$(6)CLR$(1)="White" : CLR$(2)="Green": CLR$(3)="Blue"CLR$(4)="Yellow": CLR$(5)="Red" : CLR$(6)="Cyan"BackColor="Black"ForeColor="White"GScreen(300,300)Window (0,0)-(1,1)MathGraph OnFor i=1 to 100Sleep(10)C$ = CLR$(((i-1) mod 6)+1) :1,2,...,6GForeColor= C$Line (Rnd,Rnd)-(Rnd,Rnd)
Next iEnd
'1000Dim CLR$(3)CLR$(1)="Yellow"CLR$(2)="Red"CLR$(3)="Cyan"GBackColor="Black"GForeColor="White"GScreen(300,300)Window (0,0)-(1,1)MathGraph OnFor i=1 to 1000 Sleep(10) C$ = CLR$(((i-1) mod 3)+1) :'1,2,3 GForeColor= C$ PSet (Rnd,Rnd)Next iEnd
tbasic.org1000ColoredPoints.txt'100Dim CLR$(6) CLR$(1)="White" : CLR$(2)="Green": CLR$(3)="Blue" CLR$(4)="Yellow": CLR$(5)="Red" : CLR$(6)="Cyan"BackColor="Black"ForeColor="White"GScreen(300,300)Window (0,0)-(1,1)MathGraph OnFor i=1 to 100 Sleep(10) C$ = CLR$(((i-1) mod 6)+1) :'1,2,...,6 GForeColor= C$ Line (Rnd,Rnd)-(Rnd,Rnd)Next iEnd
tbasic.org100Lines.txt13
CLR$(1)="White" : CLR$(2)="Green": CLR$(3)="Blue"CLR$(4)="Yellow": CLR$(5)="Red" : CLR$(6)="Cyan"
:6
66
C$ = CLR$(((i-1) mod 6)+1)
6 C$
Line
Line (x1,y1)-(x2,y2),,B
(x1,y1) (x2,y2)*7
Line B
2.4. 100Dim CLR$(6)CLR$(1)="White" : CLR$(2)="Green": CLR$(3)="Blue"CLR$(4)="Yellow": CLR$(5)="Red" : CLR$(6)="Cyan"BackColor="Black"ForeColor="White"GScreen(300,300)Window (0,0)-(1,1)MathGraph OnFor i=1 to 100Sleep(10)C$ = CLR$(((i-1) mod 6)+1) :1,2,...,6GForeColor= C$Line (Rnd,Rnd)-(Rnd,Rnd),,B
Next iEnd
CircleCircle
Circle (x,y),r
(x,y) r
Circle (x,y),r,,,,,F
(x,y) r
*7 Line (x1,y1)-(x2,y2),,BF (x1,y1) (x2,y2)
14
html 20Randomize*8 2
2.5. 20Dim CLR$(2)GBackColor="Black": GForeColor="White"GScreen(300,300) : Window (0,0)-(1,1)MathGraph OnRandomizeFor i=1 to 20X=Rnd:Y=Rnd:R0=Rnd/80: CN=Int(Rnd * 3)For j=10 to 0 step -1CLR$(CN)="FF"CLR$((CN+1) mod 3)=Right$("0"+Hex$(j*17),2)CLR$((CN+2) mod 3)=CLR$((CN+1) mod 3)C$="#"+CLR$(0)+CLR$(1)+CLR$(2)R=R0*(j+1)GForeColor= C$Circle (x,y),R,,,,,F
Next jNext iEnd
CLR$(0)CLR$(1)CLR$(2)C$="#"+CLR$(0)+CLR$(1)+CLR$(2) html C$0,1,2 CN
#FFAAAA, #FF9999, . . . , #FF1111, #FF0000#AAFFAA, #99FF99, . . . , #11FF11, #00FF00#AAAAFF, #9999FF, . . . , #1111FF, #0000FF
C$GForeColorHex$(j*17) Hex$1617 = 16 + 1 = 11(16)
j=1,. . . ,9Hex$(j*17) 16jj
j=10AAj=00 0
Right$("0"+Hex$(j*17),2)
j=0,. . . ,1016 jj
html
*8 Randomize
'20~Dim CLR$(2)GBackColor="Black": GForeColor="White"GScreen(300,300) : Window (0,0)-(1,1)MathGraph OnRandomizeFor i=1 to 20 X=Rnd:Y=Rnd:R0=Rnd/80: CN=Int(Rnd * 3) For j=10 to 0 step -1 CLR$(CN)="FF" CLR$((CN+1) mod 3)=Right$("0"+Hex$(j*17),2) CLR$((CN+2) mod 3)=CLR$((CN+1) mod 3) C$="#"+CLR$(0)+CLR$(1)+CLR$(2) R=R0*(j+1) GForeColor= C$ Circle (x,y),R,,,,,F Next jNext iEnd
tbasic.org20Circles.txt15
2.4
CloseGScreen
3
(1) Cls
(2) PSet
(3) Line
(4) Circle
(5) Paint
(6) GLocate GPrint
16
3.1 Cls
Cls Clear Screen Cls 2 *9
Cls 2
Cls 2 GScreenGScreen GBackColorCls 2Cls 2 GBackColor
Cls 2
Dim CLR$(2)GScreen(300,300)For i=1 to 10CN=Int(Rnd * 3)For j=15 to 0 step -1Sleep(100)CLR$(CN)="FF"CLR$((CN+1) mod 3)=Right$("0"+Hex$(j*17),2)CLR$((CN+2) mod 3)=CLR$((CN+1) mod 3)C$="#"+CLR$(0)+CLR$(1)+CLR$(2)GBackColor= C$Cls 2
Next jNext iEnd
CLR$(0)CLR$(1)CLR$(2)
CN=Int(Rnd * 3)
0,1,2
CLR$(CN)="FF"
CLR$(CN) 2 CLR$((CN+1) mod 3) CLR$((CN+2) mod 3)
#FFFFFF, #FFEEEE, . . . , #FF1111, #FF0000#FFFFFF, #EEFFEE, . . . , #11FF11, #00FF00#FFFFFF, #EEEEFF, . . . , #1111FF, #0000FF
C$="#"+CLR$(0)+CLR$(1)+CLR$(2) html C$
*9 ClsCls 1 Cls 2 Cls 3
Dim CLR$(2)GScreen(300,300)For i=1 to 10 CN=Int(Rnd * 3) For j=15 to 0 step -1 Sleep(100) CLR$(CN)="FF" CLR$((CN+1) mod 3)=Right$("0"+Hex$(j*17),2) CLR$((CN+2) mod 3)=CLR$((CN+1) mod 3) C$="#"+CLR$(0)+CLR$(1)+CLR$(2) GBackColor= C$ Cls 2 Next jNext iEnd
takeuchiCls2.txt17
3.2 PSet
PSet Point Set ()
PSet (x,y)
*10
(0,0) (1,1)
01 GBackColor = "Black"02 GForeColor = "White"03 GScreen(300,300)04 Window(0,0)-(1,1)05 MathGraph On06 For i=1 to 1000007 x = RND08 y = RND09 If (x2+y2
18
C$="#"+Hex$(16*RND)+Hex$(16*RND)+Hex$(16*RND)+Hex$(16*RND)+Hex$(16*RND)+Hex$(16*RND)
C$ html
GBackColor="Black"GScreen(300,300)Window(0,0)-(1,1)MathGraph OnFor i=1 to 10000x = RNDy = RNDIf (x2+y2
19
Line
3.1 ().
GBackColor="Black"GScreen(300,300)Window (-2,-2)-(2,2)MathGraph OnGForeColor = "Cyan"Line (-2,0)-(2,0) :xLine (0,-2)-(0,2) :yGForeColor = "White"End
xy
n
3.2 (). nn=5GBackColor="Black"GScreen(300,300)Window (-2,-2)-(2,2)MathGraph OnGForeColor = "Cyan"Line (-2,0)-(2,0) :xLine (0,-2)-(0,2) :yGForeColor = "#555555"Circle(0,0),1ForeColor = "White"For i=0 to n-1x0=Cos(2*Pi*i/n)y0=Sin(2*Pi*i/n)x1=Cos(2*Pi*(i+1)/n)y1=Sin(2*Pi*(i+1)/n)Line (x0,y0)-(x1,y1)
Next iEnd
n GForeColor = "#555555" 2*Pi n (x,y) Cos(2*Pi*i/n),Sin(2*Pi*i/n) Line
'np`n=5GBackColor="Black"GScreen(300,300)Window (-2,-2)-(2,2)MathGraph OnGForeColor = "Cyan"Line (-2,0)-(2,0) :'xLine (0,-2)-(0,2) :'yGForeColor = "#555555"Circle(0,0),1ForeColor = "White"For i=0 to n-1 x0=Cos(2*Pi*i/n) y0=Sin(2*Pi*i/n) x1=Cos(2*Pi*(i+1)/n) y1=Sin(2*Pi*(i+1)/n) Line (x0,y0)-(x1,y1)Next iEnd
tbasic.orgPolygon.txt20
3.4 Circle
Circle
Circle (x,y),r
(x,y) r 16 GForeColor GForeColor
3.3 ().
GBackColor="Black"GScreen(300,300)Window (-2,-2)-(2,2)MathGraph OnGForeColor = "White"For i=0 to 2x=Cos(2*Pi*i/3+Pi/2)*0.6y=Sin(2*Pi*i/3+Pi/2)*0.6Circle(x,y),1
Next iEnd
Window (-2,-2)-(2,2) (0, 0) 4 1 (0, 0) 0.6 2 32 3 2 i/3 i = 0 xy /2
x=Cos(2*Pi*i/3+Pi/2)*0.6
y=Sin(2*Pi*i/3+Pi/2)*0.6
(x, y)
21
3.5 Paint
Paint
Paint (x,y)
(x,y) GBorderColor GForeColor*13
3.4 (). GBackColor="Black"GScreen(300,300)Window (-2,-2)-(2,2)MathGraph OnGForeColor = "White"For i=1 to 3x=Cos(2*Pi*i/3+Pi/2)*0.6y=Sin(2*Pi*i/3+Pi/2)*0.6Circle(x,y),1
Next iGBorderColor = "White"
GForeColor ="#FF0000":Paint (Cos(Pi/2)*0.8,Sin(Pi/2)*0.8)GForeColor ="#00FF00":Paint (Cos(2*Pi/3+Pi/2)*0.8,Sin(2*Pi/3+Pi/2)*0.8)GForeColor ="#0000FF":Paint (Cos(2*Pi*2/3+Pi/2)*0.8,Sin(2*Pi*2/3+Pi/2)*0.8)
GForeColor ="#FF00FF":Paint (Cos(Pi/3)*0.6,Sin(Pi/3)*0.6)GForeColor ="#FFFF00":Paint (Cos(2*Pi/3+Pi/3)*0.6,Sin(2*Pi/3+Pi/3)*0.6)GForeColor ="#00FFFF":Paint (Cos(2*Pi*2/3+Pi/3)*0.6,Sin(2*Pi*2/3+Pi/3)*0.6)
GForeColor ="#FFFFFF":Paint (0,0)End
html "#FF0000" "#00FF00" "#0000FF" "#FF0000""#00FF00""#FFFF00""#FFFFFF" BorderColor
*13
'GBackColor="Black"GScreen(300,300)Window (-2,-2)-(2,2)MathGraph OnGForeColor = "White"For i=1 to 3 x=Cos(2*Pi*i/3+Pi/2)*0.6 y=Sin(2*Pi*i/3+Pi/2)*0.6 Circle(x,y),1Next iGBorderColor = "White"GForeColor ="#FF0000":'Paint (Cos(Pi/2)*0.8,Sin(Pi/2)*0.8)GForeColor ="#00FF00":'Paint (Cos(2*Pi/3+Pi/2)*0.8,Sin(2*Pi/3+Pi/2)*0.8)GForeColor ="#0000FF":'Paint (Cos(2*Pi*2/3+Pi/2)*0.8,Sin(2*Pi*2/3+Pi/2)*0.8)GForeColor ="#FF00FF":'Paint (Cos(Pi/3)*0.6,Sin(Pi/3)*0.6)GForeColor ="#FFFF00":'Paint (Cos(2*Pi/3+Pi/3)*0.6,Sin(2*Pi/3+Pi/3)*0.6)GForeColor ="#00FFFF":'Paint (Cos(2*Pi*2/3+Pi/3)*0.6,Sin(2*Pi*2/3+Pi/3)*0.6)GForeColor ="#FFFFFF":'Paint (0,0)GForeColor = "Cyan"GLocate (-1.5,-1.5)GPrint "()"End
tbasic.orgAdditivePrimaryColors.txt22
3.6 GLocate GPrint
GPrint Graph Print
GPrint
GLocate Graph Locate GLocate (x,y)GPrint End
GForeColor = "Cyan"GLocate (-1.5,-1.5)GPrint " ()"
"#FFFF00""#00FFFF""#00FF00"AND
3.5 ().
GBackColor="White"GScreen(300,300)Window (-2,-2)-(2,2)MathGraph OnGForeColor = "Black"For i=1 to 3x=Cos(2*Pi*i/3+Pi/2)*0.6y=Sin(2*Pi*i/3+Pi/2)*0.6Circle(x,y),1
Next iGBorderColor = "Black"GForeColor ="#FFFF00":Paint (Cos(Pi/2)*0.8,Sin(Pi/2)*0.8)GForeColor ="#00FFFF":Paint (Cos(2*Pi/3+Pi/2)*0.8,Sin(2*Pi/3+Pi/2)*0.8)GForeColor ="#FF00FF":Paint (Cos(2*Pi*2/3+Pi/2)*0.8,Sin(2*Pi*2/3+Pi/2)*0.8)
GForeColor ="#FF0000":Paint (Cos(Pi/3)*0.6,Sin(Pi/3)*0.6)GForeColor ="#00FF00":Paint (Cos(2*Pi/3+Pi/3)*0.6,Sin(2*Pi/3+Pi/3)*0.6)GForeColor ="#0000FF":Paint (Cos(2*Pi*2/3+Pi/3)*0.6,Sin(2*Pi*2/3+Pi/3)*0.6)GForeColor ="#000000":Paint (0,0)GForeColor = "Navy"GLocate (-1.5,-1.5)GPrint " ()"End
'GBackColor="White"GScreen(300,300)Window (-2,-2)-(2,2)MathGraph OnGForeColor = "Black"For i=1 to 3 x=Cos(2*Pi*i/3+Pi/2)*0.6 y=Sin(2*Pi*i/3+Pi/2)*0.6 Circle(x,y),1Next iGBorderColor = "Black"GForeColor ="#FFFF00":'Paint (Cos(Pi/2)*0.8,Sin(Pi/2)*0.8)GForeColor ="#00FFFF":'Paint (Cos(2*Pi/3+Pi/2)*0.8,Sin(2*Pi/3+Pi/2)*0.8)GForeColor ="#FF00FF":'Paint (Cos(2*Pi*2/3+Pi/2)*0.8,Sin(2*Pi*2/3+Pi/2)*0.8)GForeColor ="#FF0000":'Paint (Cos(Pi/3)*0.6,Sin(Pi/3)*0.6)GForeColor ="#00FF00":'Paint (Cos(2*Pi/3+Pi/3)*0.6,Sin(2*Pi/3+Pi/3)*0.6)GForeColor ="#0000FF":'Paint (Cos(2*Pi*2/3+Pi/3)*0.6,Sin(2*Pi*2/3+Pi/3)*0.6)GForeColor ="#000000":'Paint (0,0)GForeColor = "Navy"GLocate (-1.5,-1.5)GPrint "()"End
tbasic.orgSubtractivePrimaryColors.txt23
4 y = f (x)x = x(t)y = y(t)
4.1
GScreen 1 : 1 2 : 1
Window*14
x y
4.1 ().
GBackColor="Navy"GScreen(300,300)Window (-10,-10)-(10,10)MathGraph OnGForeColor = "Cyan"Line (-10,0)-(10,0) :xLine (0,-10)-(0,10) :yGForeColor = "White"End
*14
24
4.2
pixcelxy y = f (x)
x x(x, f (x))
y = sin(x) PSet
4.2 (sin(x)).
GBackColor = "Navy"GScreen(300,300)Window (-10,-10)-(10,10)MathGraph OnGForeColor = "Cyan"Line (-10,0)-(10,0)Line (0,-10)-(0,10)GForeColor = "White"For i=0 to 100x = -10 + 2*i/10y = Sin(x)PSet(x,y)
Next iEnd
101 x = 10 10 100 x x = 10 + 2 i/10 y = sin(x) (x, y)
*15
201301
201 301
*15
GBackColor = "Navy"GScreen(300,300)Window (-10,-10)-(10,10)MathGraph OnGForeColor = "Cyan"Line (-10,0)-(10,0)Line (0,-10)-(0,10)GForeColor = "White"For i=0 to 100 x = -10 + 2*i/10 y = Sin(x) PSet(x,y)Next iEnd
tbasic.orgPSetSin.txt25
201301 300*16
4.3
x1, x2 (x1, f (x1)) (x2, f (x2))
PSet Line
100
4.3 (sin(x)). GBackColor = "Navy"GScreen(300,300)Window (-10,-10)-(10,10)MathGraph OnGForeColor = "Cyan"Line (-10,0)-(10,0)Line (0,-10)-(0,10)GForeColor = "White"For i=0 to 100-1x1 = -10 + 2*i/10y1 = Sin(x1)x2 = -10 + 2*(i+1)/10y2 = Sin(x2)Line (x1,y1)-(x2,y2)
Next iEnd
x = 10 x = 10 20 100 20/100 = 2/10i = 0(x1, x2) = (10,10 + 2/10). . .
i = 100 1(x1, x2) = (10 + 2 99/10,10 + 2 100/10) = (10 2/10, 20) Line
100300
*16 /2 tan(x)
GBackColor = "Navy"GScreen(300,300)Window (-10,-10)-(10,10)MathGraph OnGForeColor = "Cyan"Line (-10,0)-(10,0)Line (0,-10)-(0,10)GForeColor = "White"For i=0 to 100-1 x1 = -10 + 2*i/10 y1 = Sin(x1) x2 = -10 + 2*(i+1)/10 y2 = Sin(x2) Line (x1,y1)-(x2,y2)Next iEnd
tbasic.orgLineSin.txt26
2050For
20 50For i=0 to 20-1 For i=0 to 50-1x1 = -10 + 2*i/2 x1 = -10 + 2*i/5y1 = Sin(x1) y1 = Sin(x1)x2 = -10 + 2*(i+1)/2 x2 = -10 + 2*(i+1)/5y2 = Sin(x2) y2 = Sin(x2)Line (x1,y1)-(x2,y2) Line (x1,y1)-(x2,y2)
Next i Next i
20 50
20 50 50300
27
tan(x) 100
4.4 (tan(x)). GBackColor = "Navy"GScreen(300,300)Window (-10,-10)-(10,10)MathGraph OnGForeColor = "Cyan"Line (-10,0)-(10,0)Line (0,-10)-(0,10)GForeColor = "White"For i=0 to 100-1x1 = -10 + 2*i/10y1 = Tan(x1)x2 = -10 + 2*(i+1)/10y2 = Tan(x2)Line (x1,y1)-(x2,y2)
Next iEnd
tan(x) . . . ,/2, /2, 3/2, . . . 100 200 40001 100 400*17
200 40001
*17 PC
GBackColor = "Navy"GScreen(300,300)Window (-10,-10)-(10,10)MathGraph OnGForeColor = "Cyan"Line (-10,0)-(10,0)Line (0,-10)-(0,10)GForeColor = "White"For i=0 to 100-1 x1 = -10 + 2*i/10 y1 = Tan(x1) x2 = -10 + 2*(i+1)/10 y2 = Tan(x2) Line (x1,y1)-(x2,y2)Next iEnd
tbasic.orgLineTan.txtGBackColor = "Navy"GScreen(300,300)Window (-10,-10)-(10,10)MathGraph OnGForeColor = "Cyan"Line (-10,0)-(10,0)Line (0,-10)-(0,10)GForeColor = "White"For i=0 to 200-1 x1 = -10 + 2*i/20 y1 = Tan(x1) x2 = -10 + 2*(i+1)/20 y2 = Tan(x2) Line (x1,y1)-(x2,y2)Next iEnd
tbasic.orgLineTan200.txtGBackColor = "Navy"GScreen(300,300)Window (-10,-10)-(10,10)MathGraph OnGForeColor = "Cyan"Line (-10,0)-(10,0)Line (0,-10)-(0,10)GForeColor = "White"For i=0 to 40000 x = -10 + 2*i/4000 y = Tan(x) PSet(x,y)Next iEnd
tbasic.orgPSetTan40001.txt28
4.4
*18 *19
*20
GWWGWH
XLEFT xXRIGHT xYBOTTOM yYTOP yFunction f(x)
NLINES
*18 *19 BASIC*20
29
4.5 ().
-----------------------GWW = 300GWH = 300XLEFT = -10XRIGHT = 10YBOTTOM = -10NLINES = 100
Function f(x)f = Sin(x)
End Function-----------------------GBackColor = "Navy"GScreen(GWW,GWH)YTOP = GWH*(XRIGHT-XLEFT)/GWW + YBOTTOMWindow (XLEFT,YBOTTOM)-(XRIGHT,YTOP)MathGraph OnGForeColor = "Cyan"Line (XRIGHT,0)-(XLEFT,0)Line (0,YBOTTOM)-(0,YTOP)GForeColor = "White"For i=0 to NLINES-1x1 = XLEFT + (XRIGHT-XLEFT)*i/NLINESy1 = f(x1)x2 = XLEFT + (XRIGHT-XLEFT)*(i+1)/NLINESy2 = f(x2)Line (x1,y1)-(x2,y2)
Next iEnd----------------------------------
[----][]Function f = *21
4.5
4.5.1 t f (x)x(t)y(t)
TSTATRTtTENDt
Function x(t)
Function y(t)
*21 f (x) = sin(x) f = sin(x)
''-----------------------GWW = 300GWH = 300XLEFT = -10XRIGHT = 10YBOTTOM = -10NLINES = 100Function f(x) f = Sin(x)End Function'-----------------------GBackColor = "Navy"GScreen(GWW,GWH)YTOP = GWH*(XRIGHT-XLEFT)/GWW + YBOTTOMWindow (XLEFT,YBOTTOM)-(XRIGHT,YTOP)MathGraph OnGForeColor = "Cyan"Line (XRIGHT,0)-(XLEFT,0)Line (0,YBOTTOM)-(0,YTOP)GForeColor = "White"For i=0 to NLINES-1 x1 = XLEFT + (XRIGHT-XLEFT)*i/NLINES y1 = f(x1) x2 = XLEFT + (XRIGHT-XLEFT)*(i+1)/NLINES y2 = f(x2) Line (x1,y1)-(x2,y2)Next iEnd'----------------------------------
tbasic.orgExplicit.txt30
4.6 ().
-----------------------GWW = 300GWH = 300XLEFT = -10XRIGHT = 10YBOTTOM = -10TSTART = 0TEND = 2*PiNLINES = 200
Function x(t)x = 8*Sin(4*t)
End FunctionFunction y(t)y = 5*Sin(5*t)
End Function-----------------------BackColor = "Navy"GScreen(GWW,GWH)YTOP = GWH*(XRIGHT-XLEFT)/GWW + YBOTTOMWindow (XLEFT,YBOTTOM)-(XRIGHT,YTOP)MathGraph OnForeColor = "Cyan"Line (XRIGHT,0)-(XLEFT,0)Line (0,YBOTTOM)-(0,YTOP)ForeColor = "White"For i=0 to NLINES-1t1 = TSTART + (TEND-TSTART)*i/NLINESx1 = x(t1)y1 = y(t1)t2 = TSTART + (TEND-TSTART)*(i+1)/NLINESx2 = x(t2)y2 = y(t2)Line (x1,y1)-(x2,y2)
Next iEnd----------------------------------
Function x(t)Function y(t)
x = 8 sin(4t)
y = 5 sin(5t)
x = 4 (1 + cos(t)) cos(2t)y = 4 (1 + cos(t)) sin(2t)
''-----------------------GWW = 300GWH = 300XLEFT = -10XRIGHT = 10YBOTTOM = -10TSTART = 0TEND = 2*PiNLINES = 200Function x(t) x = 8*Sin(4*t)End FunctionFunction y(t) y = 5*Sin(5*t)End Function'-----------------------BackColor = "Navy"GScreen(GWW,GWH)YTOP = GWH*(XRIGHT-XLEFT)/GWW + YBOTTOMWindow (XLEFT,YBOTTOM)-(XRIGHT,YTOP)MathGraph OnForeColor = "Cyan"Line (XRIGHT,0)-(XLEFT,0)Line (0,YBOTTOM)-(0,YTOP)ForeColor = "White"For i=0 to NLINES-1 t1 = TSTART + (TEND-TSTART)*i/NLINES x1 = x(t1) y1 = y(t1) t2 = TSTART + (TEND-TSTART)*(i+1)/NLINES x2 = x(t2) y2 = y(t2) Line (x1,y1)-(x2,y2)Next iEnd'----------------------------------
tbasic.orgParameter.txt31
4.5.2 r = f ()r =
x2 + y2 t = x = f (t) cos(t)y = f (t) sin(t)
Function r(s)r=5*(1+Cos(s))
End Function
Function x(t)x=r(t)*Cos(t)
End Function
Function y(t)y=r(t)*Sin(t)
End Function
Function r(s)t
r = s r = cos(2s)
xy
4.6
PC tbasic
''-----------------------GWW = 300GWH = 300XLEFT = -10XRIGHT = 10YBOTTOM = -10TSTART = 0TEND = 2*PiNLINES = 200Function r(s) r=5*(1+Cos(s))End FunctionFunction x(t) x=r(t)*Cos(t)End FunctionFunction y(t) y=r(t)*Sin(t)End Function'-----------------------BackColor = "Navy"GScreen(GWW,GWH)YTOP = GWH*(XRIGHT-XLEFT)/GWW + YBOTTOMWindow (XLEFT,YBOTTOM)-(XRIGHT,YTOP)MathGraph OnForeColor = "Cyan"Line (XRIGHT,0)-(XLEFT,0)Line (0,YBOTTOM)-(0,YTOP)ForeColor = "White"For i=0 to NLINES-1 t1 = TSTART + (TEND-TSTART)*i/NLINES x1 = x(t1) y1 = y(t1) t2 = TSTART + (TEND-TSTART)*(i+1)/NLINES x2 = x(t2) y2 = y(t2) Line (x1,y1)-(x2,y2)Next iEnd'----------------------------------
tbasic.orgPolar.txt1 tbasic 1.1 1.2 tbasic 1.3 1.4 1.5 1.6 2 tbasic 2.1 2.2 2.3 2.4 3 3.1 Cls3.2 PSet3.3 Line3.4 Circle3.5 Paint3.6 GLocate GPrint4 4.1 4.2 4.3 4.4 4.5 4.6