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=NDG956' /> </object>
'Challenge of the Month -- February 2013
'Small Challenge 2
'Copyright (c) Math Man 2013
width
=
GraphicsWindow
.
Width
height
=
GraphicsWindow
.
Height
scale
=
0.8
InitEllipses
(
)
DrawButterfly
(
)
Sub
InitEllipses
ellipse
[
1
]
=
"pen=Black;brush=Orange;x="
+
(
width
/
3
-
70
*
scale
)
+
";y="
+
(
height
/
8
*
5
-
160
*
scale
)
+
";width="
+
(
140
*
scale
)
+
";height="
+
(
320
*
scale
)
+
";angle=60;"
ellipse
[
2
]
=
"pen=Black;brush=Orange;x="
+
(
width
/
3
-
70
*
scale
)
+
";y="
+
(
height
/
8
*
3
-
160
*
scale
)
+
";width="
+
(
140
*
scale
)
+
";height="
+
(
320
*
scale
)
+
";angle=120;"
ellipse
[
3
]
=
"pen=Black;brush=Orange;x="
+
(
width
/
3
*
2
-
70
*
scale
)
+
";y="
+
(
height
/
8
*
5
-
160
*
scale
)
+
";width="
+
(
140
*
scale
)
+
";height="
+
(
320
*
scale
)
+
";angle=120;"
ellipse
[
4
]
=
"pen=Black;brush=Orange;x="
+
(
width
/
3
*
2
-
70
*
scale
)
+
";y="
+
(
height
/
8
*
3
-
160
*
scale
)
+
";width="
+
(
140
*
scale
)
+
";height="
+
(
320
*
scale
)
+
";angle=60;"
ellipse
[
5
]
=
"pen=Black;brush=Black;x="
+
(
width
/
3
-
50
*
scale
)
+
";y="
+
(
height
/
8
*
5
-
170
*
scale
)
+
";width="
+
(
70
*
scale
)
+
";height="
+
(
70
*
scale
)
ellipse
[
6
]
=
"pen=Black;brush=Black;x="
+
(
width
/
3
*
2
-
30
*
scale
)
+
";y="
+
(
height
/
8
*
5
-
170
*
scale
)
+
";width="
+
(
70
*
scale
)
+
";height="
+
(
70
*
scale
)
'ellipse[2] = "pen=;brush=;x=;y=;width=;height="+";angle=135;"
'ellipse[3] = "pen=;brush=;x=;y=;width=;height="+";angle=135;"
'ellipse[4] = "pen=;brush=;x=;y=;width=;height="+";angle=45;"
'ellipse[5] = "pen=;brush=;x=;y=;width=;height="+";angle=45;"
'ellipse[6] = "pen=;brush=;x=;y=;width=;height="+";angle=45;"
ellipse
[
7
]
=
"pen=Black;brush=Black;x="
+
(
width
/
2
-
25
*
scale
)
+
";y="
+
(
height
/
2
-
150
*
scale
)
+
";width="
+
(
50
*
scale
)
+
";height="
+
(
300
*
scale
)
+
";angle=0"
ellipse
[
8
]
=
"pen=Black;brush=Black;x="
+
(
width
/
2
-
40
*
scale
)
+
";y="
+
(
height
/
2
-
150
*
scale
-
40
*
scale
)
+
";width="
+
(
80
*
scale
)
+
";height="
+
(
80
*
scale
)
+
";angle=0"
ellipse
[
9
]
=
"pen=Black;brush=Black;x="
+
(
width
/
2
-
50
*
scale
)
+
";y="
+
(
height
/
2
-
150
*
scale
-
40
*
scale
-
35
*
scale
)
+
";width="
+
(
10
*
scale
)
+
";height="
+
(
90
*
scale
)
+
";angle=140"
ellipse
[
10
]
=
"pen=Black;brush=Black;x="
+
(
width
/
2
+
40
*
scale
)
+
";y="
+
(
height
/
2
-
150
*
scale
-
40
*
scale
-
35
*
scale
)
+
";width="
+
(
10
*
scale
)
+
";height="
+
(
90
*
scale
)
+
";angle=40"
numEllipse
=
Array
.
GetItemCount
(
ellipse
)
EndSub
Sub
DrawButterfly
For
i
=
1
To
numEllipse
GraphicsWindow
.
PenWidth
=
4
GraphicsWindow
.
PenColor
=
ellipse
[
i
]
[
"pen"
]
GraphicsWindow
.
BrushColor
=
ellipse
[
i
]
[
"brush"
]
ellipse
[
i
]
[
"shape"
]
=
Shapes
.
AddEllipse
(
ellipse
[
i
]
[
"width"
]
,
ellipse
[
i
]
[
"height"
]
)
Shapes
.
Move
(
ellipse
[
i
]
[
"shape"
]
,
ellipse
[
i
]
[
"x"
]
,
ellipse
[
i
]
[
"y"
]
)
Shapes
.
Rotate
(
ellipse
[
i
]
[
"shape"
]
,
ellipse
[
i
]
[
"angle"
]
)
EndFor
EndSub
Copyright (c) Microsoft Corporation. All rights reserved.