Microsoft Small Basic

Program Listing: ZHP577-0
Wid = 200
DrawHeart()
CalcArea()
Controls.TextTyped = TextEnter

Sub DrawHeart
GraphicsWindow.Clear()
GraphicsWindow.PenWidth = 0
GraphicsWindow.BrushColor = "Blue"
Txt = Shapes.AddText("")
Shapes.Move(Txt,10,10)
TB = Controls.AddMultiLineTextBox(GraphicsWindow.Width-170,10)
Controls.SetSize(TB,160,22)
GraphicsWindow.BrushColor = "Red"
C1 = Shapes.AddEllipse(Wid/2,Wid/2)
C2 = Shapes.AddEllipse(Wid/2,Wid/2)
S1 = Shapes.AddRectangle(Wid/2,Wid/2)
GraphicsWindow.BrushColor = "White"
C3 = Shapes.AddEllipse(Wid/2,Wid/2)
C4 = Shapes.AddEllipse(Wid/2,Wid/2)
Shapes.Move(C1,GraphicsWindow.Width/2-Wid/2,GraphicsWindow.Height/2-Wid/2)
Shapes.Move(C2,GraphicsWindow.Width/2,GraphicsWindow.Height/2-Wid/2)
Shapes.Move(S1,GraphicsWindow.Width/2-Wid/4,GraphicsWindow.Height/2-Wid/4)
Shapes.Move(C3,GraphicsWindow.Width/2-Wid/2,GraphicsWindow.Height/2)
Shapes.Move(C4,GraphicsWindow.Width/2,GraphicsWindow.Height/2)
EndSub

Sub CalcArea
Area = Math.Round(Wid*Wid-(2*Wid*Wid/16)*Math.Pi-3*((Wid/2)*(Wid/2)-Math.Pi*(Wid/4)*(Wid/4)))
Shapes.SetText(Txt,"The area of the heart will be "+Area+" square pixels.")
EndSub

Sub TextEnter
If Text.IsSubText(Controls.GetTextBoxText(TB),Text.GetCharacter(10)) Then
Wid = Controls.GetTextBoxText(TB)
DrawHeart()
CalcArea()
EndIf
EndSub