Microsoft Small Basic

Program Listing: TFN794-0
' Walkman 0.2a
' Copyright (c) 2013 Nonki Takahashi. All rights reserved.
'
' History:
' 0.2a 2013-07-07 Changed for Silverlight. (TFN794-0)
' 0.1a 2013-07-05 Created. (TFN794)
'
SB_Workaround()
fh = 10 ' floor height [cm]
gh = GraphicsWindow.Height ' window height [cm]
gw = GraphicsWindow.Width ' window width [cm]
GraphicsWindow.BrushColor = "Gray"
GraphicsWindow.FillRectangle(0, gh - fh, gw, fh)
man["x"] = gw - 100
man = man + "head=24;neck=12;body=48;ab=-10;j1=48;j3=0;"
man = man + "l11=36;l12=36;l13=9;l14=12;"
man = man + "a11=-10;a12=30;a13=10;a14=-10;"
man = man + "l31=48;l32=48;l33=21;l34=7;"
man = man + "a31=10;a32=-20;a33=100;a34=0;"
man["y"] = gh - fh - 100
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.PenColor = "Black"
man["oHead"] = Shapes.AddEllipse(man["head"], man["head"])
len = man["body"] + man["neck"] + man["head"] / 2
x0 = man["x"]
y0 = man["y"] - len
_ab = Math.GetRadians(man["ab"])
x = x0 + len * Math.Sin(_ab)
y = y0 - len * (Math.Cos(_ab) - 1)
Shapes.Move(man["oHead"], x - man["head"] / 2, y - man["head"] / 2)
len = man["body"]
man["oBody"] = Shapes.AddLine(0, 0, 0, len)
y0 = man["y"] - len
x = x0 + (len/2) * Math.Sin(_ab)
y = y0 - (len/2) * (Math.Cos(_ab) - 1)
If silverlight Then
alpha = _ab
SB_RotateWorkaround()
EndIf
Shapes.Move(man["oBody"], x, y)
Shapes.Rotate(man["oBody"], man["ab"])
For j = 1 To 3 Step 2
x0 = man["x"] + man["j"+j] * Math.Sin(_ab)
man["x"+j+0] = x0
y0 = man["y"] - man["j"+j] * Math.Cos(_ab)
man["y"+j+0] = y0
a = man["ab"]
For i = 1 To 4
len = man["l"+j+i]
man["oL"+j+i] = Shapes.AddLine(0, 0, 0, len)
a = a + man["a"+j+i]
_a = Math.GetRadians(a)
x = x0 - (len/2) * Math.Sin(_a)
y = y0 + (len/2) * (Math.Cos(_a) - 1)
If silverlight Then
alpha = _a
SB_RotateWorkaround()
EndIf
Shapes.Move(man["oL"+j+i], x, y)
Shapes.Rotate(man["oL"+j+i], a)
x0 = x0 - len * Math.Sin(_a)
y0 = y0 + len * Math.Cos(_a)
EndFor
EndFor
Sub SB_RotateWorkaround
' Small Basic | Rotate line workaround for Silverlight
' param x, y - original coordinate
' param len - length of the line
' param alpha - angle [radian]
' returns x, y - workaround coordinate
x1 = -Math.Floor(Math.Abs(0 - 0) / 2)
y1 = -Math.Floor(Math.Abs(0 - len) / 2)
ox = x - x1
oy = y - y1
x = x1 * Math.Cos(alpha) - y1 * Math.Sin(alpha) + ox
y = x1 * Math.Sin(alpha) + y1 * Math.Cos(alpha) + oy
EndSub
Sub SB_Workaround
' Small Basic | Workaround for Silverlight
' returns silverlight - "True" if in remote
color = GraphicsWindow.GetPixel(0, 0)
If Text.GetLength(color) > 7 Then
silverlight = "True"
msWait = 300
Else
silverlight = "False"
EndIf
EndSub