Microsoft Small Basic
Program Listing:
Embed this in your website
<object id='sbapp' data='data:application/x-silverlight-2,' type='application/x-silverlight-2' width='640' height='480'> <param name='source' value='http://smallbasic.com/program/ClientBin/SBWeb.xap'/> <param name='onError' value='onSilverlightError' /> <param name='background' value='white' /> <param name='minRuntimeVersion' value='3.0.40624.0' /> <param name='autoUpgrade' value='true' /> <param name='initParams' value='programId=LVF292' /> </object>
' Challenge of the month Feb 2013 Shape of butterfly 2013/02/04 By NaochanON
GUI
(
)
move
(
)
Sub
move
X1
=
100
+
Math
.
GetRandomNumber
(
500
)
Y1
=
100
+
Math
.
GetRandomNumber
(
100
)
For
i
=
1
to
NMAX
shapes
.
Animate
(
shape
[
i
]
,
shapes
.
GetLeft
(
shape
[
i
]
)
+
(
X1
-
x0
)
,
shapes
.
GetTop
(
shape
[
i
]
)
+
(
Y1
-
Y0
)
,
3000
)
endfor
EndSub
Sub
GUI
GraphicsWindow
.
BackgroundColor
=
"#FFFFF0"
GraphicsWindow
.
Hide
(
)
'--------------------------------- Left wing -------------------------------------------------------------------------
GraphicsWindow
.
BrushColor
=
"#0000CD"
'Navy" '#1E90FF" ' 1E90FF 4682B4 #4682B4
GraphicsWindow
.
PenColor
=
"#0000CD"
GraphicsWindow
.
Width
=
900
GraphicsWindow
.
Height
=
600
shape
[
1
]
=
Shapes
.
AddEllipse
(
20
,
140
)
Shapes
.
Move
(
shape
[
1
]
,
15
,
0
)
shapes
.
Rotate
(
shape
[
1
]
,
-
20
)
shape
[
2
]
=
Shapes
.
AddTriangle
(
0
,
0
,
60
,
0
,
52
,
140
)
shape
[
3
]
=
Shapes
.
AddTriangle
(
60
,
0
,
132
,
60
,
52
,
140
)
shape
[
4
]
=
Shapes
.
AddTriangle
(
132
,
60
,
52
,
140
,
180
,
140
)
shape
[
5
]
=
Shapes
.
AddTriangle
(
180
,
140
,
92
,
140
,
148
,
212
)
shape
[
6
]
=
Shapes
.
AddTriangle
(
92
,
140
,
60
,
172
,
148
,
212
)
shape
[
7
]
=
Shapes
.
AddTriangle
(
60
,
172
,
128
,
292
,
148
,
212
)
shape
[
8
]
=
Shapes
.
AddTriangle
(
60
,
172
,
68
,
252
,
128
,
292
)
shape
[
9
]
=
Shapes
.
AddEllipse
(
16
,
80
)
Shapes
.
Move
(
shape
[
9
]
,
68
,
252
)
shapes
.
Rotate
(
shape
[
9
]
,
30
)
'----------------------------------------------------------------------------------------------------------
GraphicsWindow
.
BrushColor
=
"Red"
GraphicsWindow
.
PenColor
=
"Red"
shape
[
10
]
=
Shapes
.
AddLine
(
164
,
12
,
180
,
72
)
shape
[
13
]
=
Shapes
.
AddEllipse
(
8
,
8
)
Shapes
.
Move
(
shape
[
13
]
,
172
,
68
)
'----------------------------------------------------------------------------------------------------------
GraphicsWindow
.
BrushColor
=
"Yellow"
GraphicsWindow
.
PenColor
=
"Yellow"
shape
[
14
]
=
Shapes
.
AddEllipse
(
16
,
16
)
Shapes
.
Move
(
shape
[
14
]
,
20
,
4
)
shape
[
15
]
=
Shapes
.
AddEllipse
(
24
,
24
)
Shapes
.
Move
(
shape
[
15
]
,
24
,
28
)
shape
[
16
]
=
Shapes
.
AddEllipse
(
24
,
24
)
Shapes
.
Move
(
shape
[
16
]
,
36
,
68
)
shape
[
17
]
=
Shapes
.
AddEllipse
(
16
,
16
)
Shapes
.
Move
(
shape
[
17
]
,
56
,
104
)
shape
[
18
]
=
Shapes
.
AddEllipse
(
8
,
8
)
Shapes
.
Move
(
shape
[
18
]
,
80
,
120
)
shape
[
19
]
=
Shapes
.
AddRectangle
(
8
,
8
)
Shapes
.
Move
(
shape
[
19
]
,
72
,
174
)
shapes
.
Rotate
(
shape
[
19
]
,
45
)
shape
[
20
]
=
Shapes
.
AddRectangle
(
16
,
16
)
Shapes
.
Move
(
shape
[
20
]
,
80
,
208
)
shapes
.
Rotate
(
shape
[
20
]
,
45
)
shape
[
21
]
=
Shapes
.
AddRectangle
(
16
,
16
)
Shapes
.
Move
(
shape
[
21
]
,
96
,
240
)
shapes
.
Rotate
(
shape
[
21
]
,
45
)
shape
[
22
]
=
Shapes
.
AddRectangle
(
10
,
10
)
Shapes
.
Move
(
shape
[
22
]
,
118
,
268
)
shapes
.
Rotate
(
shape
[
22
]
,
45
)
shape
[
27
]
=
Shapes
.
AddEllipse
(
12
,
12
)
Shapes
.
Move
(
shape
[
27
]
,
72
,
284
)
'----------------------------------------------------------------------------------------------------------
GraphicsWindow
.
BrushColor
=
"Khaki"
GraphicsWindow
.
PenColor
=
"Khaki"
shape
[
23
]
=
Shapes
.
AddEllipse
(
12
,
80
)
Shapes
.
Move
(
shape
[
23
]
,
105
,
42
)
shapes
.
Rotate
(
shape
[
23
]
,
-
50
)
shape
[
24
]
=
Shapes
.
AddEllipse
(
8
,
60
)
Shapes
.
Move
(
shape
[
24
]
,
110
,
80
)
shapes
.
Rotate
(
shape
[
24
]
,
-
74
)
shape
[
25
]
=
Shapes
.
AddEllipse
(
8
,
48
)
Shapes
.
Move
(
shape
[
25
]
,
128
,
128
)
shapes
.
Rotate
(
shape
[
25
]
,
66
)
shape
[
26
]
=
Shapes
.
AddEllipse
(
8
,
60
)
Shapes
.
Move
(
shape
[
26
]
,
144
,
148
)
shapes
.
Rotate
(
shape
[
26
]
,
33
)
'--------------------------------- Right wing ---------------------------------------------------------------
GraphicsWindow
.
BrushColor
=
"#0000CD"
'Navy" '#1E90FF" ' 1E90FF 4682B4 #4682B4
GraphicsWindow
.
PenColor
=
"#0000CD"
GraphicsWindow
.
Width
=
1000
GraphicsWindow
.
Height
=
700
shape
[
31
]
=
Shapes
.
AddEllipse
(
20
,
140
)
Shapes
.
Move
(
shape
[
31
]
,
368
-
15
-
20
,
0
)
shapes
.
Rotate
(
shape
[
31
]
,
20
)
shape
[
32
]
=
Shapes
.
AddTriangle
(
368
,
0
,
368
-
60
,
0
,
368
-
52
,
140
)
shape
[
33
]
=
Shapes
.
AddTriangle
(
368
-
60
,
0
,
368
-
132
,
60
,
368
-
52
,
140
)
shape
[
34
]
=
Shapes
.
AddTriangle
(
368
-
132
,
60
,
368
-
52
,
140
,
368
-
180
,
140
)
shape
[
35
]
=
Shapes
.
AddTriangle
(
368
-
180
,
140
,
368
-
92
,
140
,
368
-
148
,
212
)
shape
[
36
]
=
Shapes
.
AddTriangle
(
368
-
92
,
140
,
368
-
60
,
172
,
368
-
148
,
212
)
shape
[
37
]
=
Shapes
.
AddTriangle
(
368
-
60
,
172
,
368
-
128
,
292
,
368
-
148
,
212
)
shape
[
38
]
=
Shapes
.
AddTriangle
(
368
-
60
,
172
,
368
-
68
,
252
,
368
-
128
,
292
)
shape
[
39
]
=
Shapes
.
AddEllipse
(
16
,
80
)
Shapes
.
Move
(
shape
[
39
]
,
368
-
68
-
8
,
252
)
shapes
.
Rotate
(
shape
[
39
]
,
-
30
)
'----------------------------------------------------------------------------------------------------------
GraphicsWindow
.
BrushColor
=
"Red"
GraphicsWindow
.
PenColor
=
"Red"
shape
[
40
]
=
Shapes
.
AddLine
(
368
-
164
,
12
,
368
-
180
,
72
)
shape
[
43
]
=
Shapes
.
AddEllipse
(
8
,
8
)
Shapes
.
Move
(
shape
[
43
]
,
368
-
172
-
8
,
68
)
'----------------------------------------------------------------------------------------------------------
GraphicsWindow
.
BrushColor
=
"Yellow"
GraphicsWindow
.
PenColor
=
"Yellow"
shape
[
44
]
=
Shapes
.
AddEllipse
(
16
,
16
)
Shapes
.
Move
(
shape
[
44
]
,
368
-
20
-
16
,
4
)
shape
[
45
]
=
Shapes
.
AddEllipse
(
24
,
24
)
Shapes
.
Move
(
shape
[
45
]
,
368
-
24
-
24
,
28
)
shape
[
46
]
=
Shapes
.
AddEllipse
(
24
,
24
)
Shapes
.
Move
(
shape
[
46
]
,
368
-
36
-
24
,
68
)
shape
[
47
]
=
Shapes
.
AddEllipse
(
16
,
16
)
Shapes
.
Move
(
shape
[
47
]
,
368
-
56
-
16
,
104
)
shape
[
48
]
=
Shapes
.
AddEllipse
(
8
,
8
)
Shapes
.
Move
(
shape
[
48
]
,
368
-
80
-
8
,
120
)
shape
[
49
]
=
Shapes
.
AddRectangle
(
8
,
8
)
Shapes
.
Move
(
shape
[
49
]
,
368
-
72
-
8
,
174
)
shapes
.
Rotate
(
shape
[
49
]
,
-
45
)
shape
[
50
]
=
Shapes
.
AddRectangle
(
16
,
16
)
Shapes
.
Move
(
shape
[
50
]
,
368
-
80
-
16
,
208
)
shapes
.
Rotate
(
shape
[
50
]
,
-
45
)
shape
[
51
]
=
Shapes
.
AddRectangle
(
16
,
16
)
Shapes
.
Move
(
shape
[
51
]
,
368
-
96
-
16
,
240
)
shapes
.
Rotate
(
shape
[
51
]
,
-
45
)
shape
[
52
]
=
Shapes
.
AddRectangle
(
10
,
10
)
Shapes
.
Move
(
shape
[
52
]
,
368
-
118
-
10
,
268
)
shapes
.
Rotate
(
shape
[
52
]
,
-
45
)
shape
[
57
]
=
Shapes
.
AddEllipse
(
12
,
12
)
Shapes
.
Move
(
shape
[
57
]
,
368
-
72
-
6
,
284
)
'----------------------------------------------------------------------------------------------------------
GraphicsWindow
.
BrushColor
=
"Khaki"
GraphicsWindow
.
PenColor
=
"Khaki"
shape
[
53
]
=
Shapes
.
AddEllipse
(
12
,
80
)
Shapes
.
Move
(
shape
[
53
]
,
368
-
105
-
6
,
42
)
shapes
.
Rotate
(
shape
[
53
]
,
50
)
shape
[
54
]
=
Shapes
.
AddEllipse
(
8
,
60
)
Shapes
.
Move
(
shape
[
54
]
,
368
-
110
-
4
,
80
)
shapes
.
Rotate
(
shape
[
54
]
,
74
)
shape
[
55
]
=
Shapes
.
AddEllipse
(
8
,
48
)
Shapes
.
Move
(
shape
[
55
]
,
368
-
128
-
4
,
128
)
shapes
.
Rotate
(
shape
[
55
]
,
-
66
)
shape
[
56
]
=
Shapes
.
AddEllipse
(
8
,
60
)
Shapes
.
Move
(
shape
[
56
]
,
368
-
144
-
4
,
148
)
shapes
.
Rotate
(
shape
[
56
]
,
-
33
)
'----------------------------------------------------------------------------------------------------------
GraphicsWindow
.
BrushColor
=
"#9ACD32"
' FF8C00 9ACD32 CD853F
GraphicsWindow
.
PenColor
=
"Gray"
shape
[
11
]
=
Shapes
.
AddEllipse
(
24
,
80
)
Shapes
.
Move
(
shape
[
11
]
,
172
,
68
)
shape
[
12
]
=
Shapes
.
AddEllipse
(
28
,
88
)
Shapes
.
Move
(
shape
[
12
]
,
172
,
136
)
'----------------------------------------------------------------------------------------------------------
X0
=
100
+
Math
.
GetRandomNumber
(
500
)
Y0
=
500
+
Math
.
GetRandomNumber
(
1000
)
NMAX
=
60
For
i
=
1
to
NMAX
shapes
.
Move
(
shape
[
i
]
,
shapes
.
GetLeft
(
shape
[
i
]
)
+
X0
,
shapes
.
GetTop
(
shape
[
i
]
)
+
Y0
)
endfor
GraphicsWindow
.
Show
(
)
EndSub
Copyright (c) Microsoft Corporation. All rights reserved.