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=SWQ275-3' /> </object>
' Heart 0.5
' Copyright (c) 2013 Nonki Takahashi. All rights reserved.
'
' History:
' 0.5 2013/02/13 Minor change. (SWQ275-3)
' 0.4 2013/02/13 Minor change. (SWQ275-2)
' 0.3 2013/02/13 Minor change. (SWQ275-1)
' 0.2 2013/02/13 Changed to use heart function. (SWQ275-0)
' 0.1 2013/02/02 Created. (SWQ275)
'
GraphicsWindow
.
Title
=
"Heart Function"
width
=
GraphicsWindow
.
Width
height
=
GraphicsWindow
.
Height
x0
=
width
/
2
y0
=
height
*
7
/
12
r
=
100
GraphicsWindow
.
PenColor
=
"LightGray"
GraphicsWindow
.
BrushColor
=
"LightGray"
caption
=
2
For
y
=
y0
-
2
*
r
To
y0
+
r
Step
r
GraphicsWindow
.
DrawLine
(
0
,
y
,
width
,
y
)
GraphicsWindow
.
DrawText
(
x0
+
2
,
y
,
caption
)
caption
=
caption
-
1
EndFor
caption
=
-
3
For
x
=
x0
-
3
*
r
To
x0
+
3
*
r
Step
r
len
=
Text
.
GetLength
(
caption
)
GraphicsWindow
.
DrawLine
(
x
,
0
,
x
,
height
)
GraphicsWindow
.
DrawText
(
x
-
10
-
(
len
-
1
)
*
5
,
y0
,
caption
)
caption
=
caption
+
1
EndFor
GraphicsWindow
.
BrushColor
=
"Black"
GraphicsWindow
.
DrawText
(
20
,
20
,
"x^2+(y-x^(2/3))^2=1"
)
GraphicsWindow
.
DrawText
(
20
,
40
,
"x=sinθ"
)
GraphicsWindow
.
DrawText
(
20
,
60
,
"y=cosθ+|sinθ|^(2/3)"
)
GraphicsWindow
.
DrawText
(
20
,
80
,
"S="
)
area
=
Shapes
.
AddText
(
"0"
)
Shapes
.
Move
(
area
,
37
,
80
)
GraphicsWindow
.
BrushColor
=
"#CC0000"
s
=
0
For
angle
=
0
To
360
Step
0.2
theta
=
Math
.
GetRadians
(
angle
)
x2
=
r
*
Math
.
Sin
(
theta
)
+
x0
y2
=
-
r
*
(
Math
.
Cos
(
theta
)
+
Math
.
Power
(
Math
.
Abs
(
Math
.
Sin
(
theta
)
)
,
2
/
3
)
)
+
y0
If
angle
>
0
Then
GraphicsWindow
.
FillTriangle
(
x0
,
y0
,
x1
,
y1
,
x2
,
y2
)
a
=
Math
.
SquareRoot
(
Math
.
Power
(
x0
-
x1
,
2
)
+
Math
.
Power
(
y0
-
y1
,
2
)
)
/
100
b
=
Math
.
SquareRoot
(
Math
.
Power
(
x1
-
x2
,
2
)
+
Math
.
Power
(
y1
-
y2
,
2
)
)
/
100
c
=
Math
.
SquareRoot
(
Math
.
Power
(
x2
-
x0
,
2
)
+
Math
.
Power
(
y2
-
y0
,
2
)
)
/
100
p
=
(
a
+
b
+
c
)
/
2
s
=
s
+
Math
.
SquareRoot
(
p
*
(
p
-
a
)
*
(
p
-
b
)
*
(
p
-
c
)
)
Shapes
.
SetText
(
area
,
s
)
EndIf
x1
=
x2
y1
=
y2
Program
.
Delay
(
100
)
EndFor
Copyright (c) Microsoft Corporation. All rights reserved.