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=RSH103' /> </object>
' Serpens 0.1
' Copyright (c) 2013 Nonki Takahashi. All rights reserved.
'
' History:
' 0.1 2013/01/03 Created. ()
' 0.0 2013/01/03 16:42:32 Generated by Shapes 1.5
'
' Reference:
' http://en.wikipedia.org/wiki/List_of_stars_in_Serpens
'
GraphicsWindow
.
Title
=
"Serpens 0.1"
GraphicsWindow
.
BackgroundColor
=
"Black"
InitStars
(
)
num
=
Array
.
GetItemCount
(
edge
)
index
=
Array
.
GetAllIndices
(
edge
)
Shapes_Init
(
)
' initialize shapes
scale
=
1
Shapes_Draw
(
)
' draw shapes
angle
=
0
GraphicsWindow
.
PenWidth
=
20
GraphicsWindow
.
PenColor
=
"#002200"
GraphicsWindow
.
BrushColor
=
"#002200"
For
i
=
1
To
num
e
=
edge
[
index
[
i
]
]
m
=
Text
.
GetIndexOf
(
e
,
"-"
)
ra
=
ser
[
Text
.
GetSubText
(
e
,
1
,
m
-
1
)
]
[
"RA"
]
dec
=
ser
[
Text
.
GetSubText
(
e
,
1
,
m
-
1
)
]
[
"Dec"
]
RADec2XY
(
)
x1
=
x
y1
=
y
ra
=
ser
[
Text
.
GetSubTextToEnd
(
e
,
m
+
1
)
]
[
"RA"
]
dec
=
ser
[
Text
.
GetSubTextToEnd
(
e
,
m
+
1
)
]
[
"Dec"
]
RADec2XY
(
)
x2
=
x
y2
=
y
GraphicsWindow
.
DrawLine
(
x1
,
y1
,
x2
,
y2
)
GraphicsWindow
.
FillEllipse
(
x2
-
10
,
y2
-
10
,
20
,
20
)
EndFor
DrawGrids
(
)
GraphicsWindow
.
PenWidth
=
1
GraphicsWindow
.
PenColor
=
"Green"
For
i
=
1
To
num
e
=
edge
[
index
[
i
]
]
m
=
Text
.
GetIndexOf
(
e
,
"-"
)
ra
=
ser
[
Text
.
GetSubText
(
e
,
1
,
m
-
1
)
]
[
"RA"
]
dec
=
ser
[
Text
.
GetSubText
(
e
,
1
,
m
-
1
)
]
[
"Dec"
]
RADec2XY
(
)
x1
=
x
y1
=
y
ra
=
ser
[
Text
.
GetSubTextToEnd
(
e
,
m
+
1
)
]
[
"RA"
]
dec
=
ser
[
Text
.
GetSubTextToEnd
(
e
,
m
+
1
)
]
[
"Dec"
]
RADec2XY
(
)
x2
=
x
y2
=
y
GraphicsWindow
.
DrawLine
(
x1
,
y1
,
x2
,
y2
)
EndFor
num
=
Array
.
GetItemCount
(
ser
)
index
=
Array
.
GetAllIndices
(
ser
)
GraphicsWindow
.
BrushColor
=
"White"
For
i
=
1
To
num
ra
=
ser
[
index
[
i
]
]
[
"RA"
]
dec
=
ser
[
index
[
i
]
]
[
"Dec"
]
RADec2XY
(
)
mag
=
ser
[
index
[
i
]
]
[
"Mag"
]
d
=
20
/
mag
GraphicsWindow
.
FillEllipse
(
x
-
d
/
2
,
y
-
d
/
2
,
d
,
d
)
EndFor
GraphicsWindow
.
BrushColor
=
"White"
GraphicsWindow
.
FontSize
=
30
GraphicsWindow
.
DrawText
(
40
,
50
,
"A Happy New Year"
)
GraphicsWindow
.
FontSize
=
40
GraphicsWindow
.
DrawText
(
40
,
90
,
"2013"
)
' end of main
Sub
DrawGrids
GraphicsWindow
.
PenWidth
=
1
GraphicsWindow
.
PenColor
=
"Gray"
y1
=
0
y2
=
GraphicsWindow
.
Height
For
ra
=
15
To
19
RADec2XY
(
)
GraphicsWindow
.
DrawLine
(
x
,
y1
,
x
,
y2
)
EndFor
x1
=
0
x2
=
GraphicsWindow
.
Width
For
dec
=
-
20
To
20
Step
10
If
dec
>
0
Then
dec
=
Text
.
Append
(
"+"
,
Math
.
Abs
(
dec
)
)
EndIf
RADec2XY
(
)
GraphicsWindow
.
DrawLine
(
x1
,
y
,
x2
,
y
)
EndFor
EndSub
Sub
RADec2XY
x
=
Text
.
GetSubText
(
ra
,
1
,
2
)
x
=
x
+
Text
.
GetSubText
(
ra
,
4
,
2
)
/
60
x
=
x
+
Text
.
GetSubText
(
ra
,
7
,
5
)
/
3600
x
=
610
-
(
x
-
15
)
*
3600
/
24
y
=
Text
.
GetSubText
(
dec
,
2
,
2
)
y
=
y
+
Text
.
GetSubText
(
dec
,
5
,
2
)
/
60
y
=
y
+
Text
.
GetSubText
(
dec
,
8
,
5
)
/
3600
y
=
y
*
Text
.
Append
(
Text
.
GetSubText
(
dec
,
1
,
1
)
,
"1"
)
y
=
250
-
y
*
3600
/
360
EndSub
Sub
InitStars
' index: Flamsteed designation
' RA (Right ascension), Dec (Declination), Mag (Apparent magnitude)
ser
[
24
]
=
"name=α Ser;RA=15 44 16.00;Dec=+06 25 31.9;Mag=2.63;"
ser
[
28
]
=
"name=β Ser;RA=15 46 11.21;Dec=+15 25 18.9;Mag=3.65;"
ser
[
41
]
=
"name=γ Ser;RA=15 56 26.99;Dec=+15 39 53.0;Mag=3.85;"
ser
[
13
]
=
"name=δ Ser A;RA=15 34 48.19;Dec=+10 32 19.9;Mag=3.80;"
ser
[
37
]
=
"name=ε Ser;RA=15 50 48.89;Dec=+04 28 39.3;Mag=3.71;"
ser
[
35
]
=
"name=κ Ser;RA=15 48 44.41;Dec=+18 08 30.4;Mag=4.09;"
ser
[
32
]
=
"name=μ Ser;RA=15 49 37.27;Dec=-03 25 48.5;Mag=3.54;"
ser
[
"1o"
]
=
"name=δ Oph;RA=16 14 20.77;Dec=-03 41 38.3;Mag=2.73;"
ser
[
"2o"
]
=
"name=ε Oph;RA=16 18 19.24;Dec=-04 41 33.4;Mag=3.23;"
ser
[
"13o"
]
=
"name=ζ Oph;RA=16 37 09.53;Dec=-10 34 01.7;Mag=2.54;"
ser
[
"35o"
]
=
"name=η Oph;RA=17 10 22.66;Dec=-15 43 30.5;Mag=2.43;"
ser
[
56
]
=
"name=ο Ser;RA=17 41 24.92;Dec=-12 52 30.6;Mag=4.24;"
ser
[
58
]
=
"name=η Ser;RA=18 21 18.92;Dec=-02 53 49.6;Mag=3.23;"
ser
[
63
]
=
"name=θ2 Ser;RA=18 56 14.61;Dec=+04 12 07.4;Mag=4.98;"
edge
=
"5=28-35;7=35-41;6=41-28;2=28-13;1=13-24;3=24-37;4=37-32;"
edge
=
edge
+
"8=32-1o;9=1o-2o;10=2o-13o;11=13o-35o;12=35o-56;"
edge
=
edge
+
"13=56-58;14=58-63;"
EndSub
Sub
Shapes_Init
' Shapes | Initialize shapes data
' return shX, shY - current position of shapes
' return shape - array of shapes
shX
=
356
' x offset
shY
=
44
' y offset
shape
=
""
shape
[
1
]
=
"func=ell;x=47;y=0;width=99;height=64;bc=#002200;pw=0;"
shape
[
2
]
=
"func=tri;x=0;y=20;x1=51;y1=0;x2=0;y2=25;x3=103;y3=25;bc=#000000;pw=0;"
shape
[
3
]
=
"func=ell;x=91;y=11;width=21;height=22;bc=#000000;pw=0;"
EndSub
Sub
Shapes_Draw
' Shapes | Draw shapes as shapes data
' param shape - array of shapes
' param scale - to zoom
' return nShapes - number of shapes
' return shAngle - current angle of shapes
Stack
.
PushValue
(
"local"
,
i
)
nShapes
=
Array
.
GetItemCount
(
shape
)
s
=
scale
For
i
=
1
To
nShapes
GraphicsWindow
.
PenWidth
=
shape
[
i
]
[
"pw"
]
*
s
If
shape
[
i
]
[
"pw"
]
>
0
Then
GraphicsWindow
.
PenColor
=
shape
[
i
]
[
"pc"
]
EndIf
If
shape
[
i
]
[
"func"
]
=
"rect"
Then
GraphicsWindow
.
BrushColor
=
shape
[
i
]
[
"bc"
]
GraphicsWindow
.
FillRectangle
(
shX
+
shape
[
i
]
[
"x"
]
*
s
,
shY
+
shape
[
i
]
[
"y"
]
*
s
,
shape
[
i
]
[
"width"
]
*
s
,
shape
[
i
]
[
"height"
]
*
s
)
ElseIf
shape
[
i
]
[
"func"
]
=
"ell"
Then
GraphicsWindow
.
BrushColor
=
shape
[
i
]
[
"bc"
]
GraphicsWindow
.
FillEllipse
(
shX
+
shape
[
i
]
[
"x"
]
*
s
,
shY
+
shape
[
i
]
[
"y"
]
*
s
,
shape
[
i
]
[
"width"
]
*
s
,
shape
[
i
]
[
"height"
]
*
s
)
ElseIf
shape
[
i
]
[
"func"
]
=
"tri"
Then
GraphicsWindow
.
BrushColor
=
shape
[
i
]
[
"bc"
]
GraphicsWindow
.
FillTriangle
(
shX
+
shape
[
i
]
[
"x"
]
*
s
+
shape
[
i
]
[
"x1"
]
*
s
,
shY
+
shape
[
i
]
[
"y"
]
*
s
+
shape
[
i
]
[
"y1"
]
*
s
,
shX
+
shape
[
i
]
[
"x"
]
*
s
+
shape
[
i
]
[
"x2"
]
*
s
,
shY
+
shape
[
i
]
[
"y"
]
*
s
+
shape
[
i
]
[
"y2"
]
*
s
,
shX
+
shape
[
i
]
[
"x"
]
*
s
+
shape
[
i
]
[
"x3"
]
*
s
,
shY
+
shape
[
i
]
[
"y"
]
*
s
+
shape
[
i
]
[
"y3"
]
*
s
)
ElseIf
shape
[
i
]
[
"func"
]
=
"line"
Then
GraphicsWindow
.
DrawLine
(
shX
+
shape
[
i
]
[
"x1"
]
*
s
,
shY
+
shape
[
i
]
[
"y1"
]
*
s
,
shX
+
shape
[
i
]
[
"x2"
]
*
s
,
shY
+
shape
[
i
]
[
"y2"
]
*
s
)
EndIf
shape
[
i
]
[
"rx"
]
=
shape
[
i
]
[
"x"
]
shape
[
i
]
[
"ry"
]
=
shape
[
i
]
[
"y"
]
EndFor
shAngle
=
0
i
=
Stack
.
PopValue
(
"local"
)
EndSub
Copyright (c) Microsoft Corporation. All rights reserved.