Skip to content

Commit d135307

Browse files
committed
added samples
1 parent adaebd4 commit d135307

File tree

3 files changed

+142
-0
lines changed

3 files changed

+142
-0
lines changed

graphics 4/circ.bas

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
REM SmallBASIC
2+
REM created: 13/08/2019
3+
option predef load modules
4+
import android
5+
6+
android.sensor_on(0)
7+
randomize ticks
8+
x=xmax/2
9+
y=ymax/2
10+
np=60
11+
gap=7
12+
ar=[]
13+
14+
func mk(n)
15+
local r
16+
r.co=rgb(90-n,90-n,n)'rnd*15
17+
r.p1=rnd*360
18+
r.p2=rnd*360
19+
r.dr=iff(n mod 2==1,1,0)
20+
r.s=rnd*900
21+
r.n=n+5
22+
return r
23+
end
24+
25+
sub sh(i,of,ac)
26+
local r,s,e,j
27+
j=iff(ar[i].dr==1, of, -of)
28+
s=rad(ar[i].p1+j+ar[i].s)
29+
e=rad(ar[i].p2+j+ar[i].s)
30+
r=ar[i].n*gap
31+
arc x,y,r,s,e,1,ar[i].co
32+
if i==ac then
33+
arc x,y,r+1,s,e,1,ar[i].co
34+
arc x,y,r-1,s,e,1,ar[i].co
35+
arc x,y,r+2,s,e,1,ar[i].co
36+
arc x,y,r-2,s,e,1,ar[i].co
37+
endif
38+
end
39+
40+
for i = 0 to np - 1
41+
ar<<mk(i)
42+
next i
43+
44+
of=0
45+
ac=10
46+
nn=1
47+
t=10
48+
while 1
49+
of=(of+10) mod 360
50+
nn=(nn+1) mod (np-1)
51+
s=android.sensor
52+
x+=s.y*100
53+
y+=s.x*100
54+
if x<0 then x=0
55+
if x>xmax then x=xmax
56+
if y<0 then y=0
57+
if y>ymax then y=ymax
58+
if ac>0 and s.y*s.x < 0 then ac-=1
59+
if ac<np-1 and s.y*s.x > 0 then ac+=1
60+
' if ac==0 then exit loop
61+
cls
62+
'print ac+ " "+s.z
63+
for i = 0 to np-1
64+
sh(i,of,ac)
65+
next i
66+
67+
showpage
68+
delay t
69+
wend
70+
71+

index.bas

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ print cat(3) + "SmallBASIC featured samples" + cat(0)
1818
dim frm
1919
frm.inputs << bn("5000", "[Android] Stopit")
2020
frm.inputs << bn("5001", "[Android] Silly words")
21+
frm.inputs << bn("5004", "[Android] Circle slider")
2122
frm.inputs << bn("1407", "3d rotating cube with message [harixxx]") 'nice one harixxx!
2223
frm.inputs << bn("1613", "NIM [jsalai]")
2324
frm.inputs << bn("1409", "Mastermind [MGA & Johnno]")

mathematics/func.bas

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
REM SmallBASIC
2+
REM created: 11/08/2019
3+
4+
func yfn(x)
5+
return x^2
6+
' return log(sin(x))
7+
' return log(x)
8+
' return sin(x)*(tan(x)+.1)
9+
' return 1/(cos(x)+.001)
10+
' return atan(x)*tan(x+.001)
11+
'return -3*x-5
12+
' return iff(x==0, 0, 1/x)*12
13+
end
14+
15+
xm=xmax/2
16+
ym=ymax/2
17+
tw=30
18+
th=30
19+
xn=int(xm/tw)
20+
yn=int(ym/th)
21+
xw=xm/xn
22+
yh=ym/yn
23+
thh=th/2
24+
tww=tw/4
25+
grey=rgb(60,60,90)
26+
27+
for x = 0 to xn
28+
xleg(x)
29+
xleg(-x)
30+
next j
31+
32+
for y = 0 to yn
33+
yleg(y)
34+
yleg(-y)
35+
next j
36+
37+
line xm,0,xm,ymax,15
38+
line 0,ym,xmax,ym,15
39+
40+
sub xleg(x)
41+
local px = xpx(x)
42+
line px, 0, px, ymax, grey
43+
end
44+
45+
sub yleg(y)
46+
local py = ypx(y)
47+
line 0, py, xmax, py, grey
48+
end
49+
50+
func xpx(x)
51+
return xm + x * xw
52+
end
53+
54+
func ypx(y)
55+
return ym + y * yh
56+
end
57+
58+
sub plotx
59+
local px,py,x,y,po
60+
po=[]
61+
for x = -xn to xn
62+
y =- yfn(x)
63+
64+
po << [xpx(x),ypx(y)]
65+
next x
66+
drawpoly po color 2
67+
end
68+
69+
plotx
70+

0 commit comments

Comments
 (0)