Microsoft Small Basic

Program Listing: HKR115
' Train Sample - 0 Series Shinkansen
' Copyright © 2018 Nonki Takahashi. The MIT License.
' Challenge 2018-11
' Last update 2018-11-14

GraphicsWindow.Title = "0 Series Shinkansen"
SB_Workaround()
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.BackgroundColor = "#222222"
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FontName = "Trebuchet MS"
GraphicsWindow.FontSize = 50
ch = 50
cw = 352
caption = Shapes.AddText("Now Loading...")
Shapes.Move(caption, (gw - cw) / 2, (gh - 100 - ch) / 2)
scale = 1
' car #1
Shapes_Init_1()
If "True" Then
name = "Train 1"
Group_Add()
i = nGroup
grp = group[i]
x = grp["x"] + gw
tx[1] = x
y = grp["y"]
Group_Move()
tw[1] = grp["width"]
car = 2
Else
tx[0] = 15
tw[0] = 0
car = 1
EndIf
' car #2-15
If "True" Then
Shapes_Init_2()
For car = 2 To 15
name = "Train " + car
Group_Add()
i = nGroup
grp = group[i]
x = tx[car - 1] + tw[car - 1] + 10
tx[car] = x
y = grp["y"]
Group_Move()
tw[car] = grp["width"]
EndFor
Shapes_Init_1()
EndIf
' car #16
name = "Train " + car
Group_Add()
i = nGroup
grp = group[i]
x = tx[car - 1] + tw[car - 1] + 10
y = grp["y"]
Group_Move()
angle = 180
Group_Flip()
Shapes.Remove(caption)
GraphicsWindow.BackgroundColor = "SkyBlue"
Program.Delay(2000)
For j = 1 To 161
For i = 1 To car
grp = group[i]
x = grp["x"] - 80
y = grp["y"]
Group_Move()
EndFor
Program.Delay(10)
EndFor

Sub Group_Add
' Group | add shapes To a group
' param name - group name
' param shX, shY, origin of shape array
' param scale - scale of group
' param shape[] - shape array
' param nGroup - number of group
' return nGroup - updated number of group
' return group - group array
Stack.PushValue("local", i)
Stack.PushValue("local", x)
Stack.PushValue("local", y)
nGroup = nGroup + 1
grp = ""
grp["name"] = name
grp["x"] = shX
grp["y"] = shY
grp["angle"] = 0
grp["dir"] = 1
Shapes_CalcWidthAndHeight()
grp["width"] = shWidth
grp["height"] = shHeight
grp["cx"] = shWidth / 2
grp["cy"] = shHeight / 2
s = scale
grp["scale"] = s
For i = 1 To Array.GetItemCount(shape)
shp = shape[i]
GraphicsWindow.PenWidth = shp["pw"] * s
If shp["pw"] > 0 Then
GraphicsWindow.PenColor = shp["pc"]
EndIf
If Text.IsSubText("rect|ell|tri|text|btn", shp["func"]) Then
GraphicsWindow.BrushColor = shp["bc"]
EndIf
If Text.IsSubText("text|btn", shp["func"]) Then
If silverlight Then
fs = Math.Floor(shp["fs"] * 0.9)
Else
fs = shp["fs"]
EndIf
GraphicsWindow.FontSize = fs * s
GraphicsWindow.FontName = shp["fn"]
If shp["fb"] = "False" Then
GraphicsWindow.FontBold = "False"
Else
GraphicsWindow.FontBold = "True"
EndIf
EndIf
If shp["func"] = "rect" Then
shp["obj"] = Shapes.AddRectangle(shp["width"] * s, shp["height"] * s)
ElseIf shp["func"] = "ell" Then
shp["obj"] = Shapes.AddEllipse(shp["width"] * s, shp["height"] * s)
ElseIf shp["func"] = "tri" Then
shp["obj"] = Shapes.AddTriangle(shp["x1"] * s, shp["y1"] * s, shp["x2"] * s, shp["y2"] * s, shp["x3"] * s, shp["y3"] * s)
ElseIf shp["func"] = "line" Then
shp["obj"] = Shapes.AddLine(shp["x1"] * s, shp["y1"] * s, shp["x2"] * s, shp["y2"] * s)
ElseIf shp["func"] = "text" Then
shp["obj"] = Shapes.AddText(shp["text"])
EndIf
x = shp["x"]
y = shp["y"]
shp["rx"] = x
shp["ry"] = y
If silverlight And Text.IsSubText("tri|line", shp["func"]) Then
alpha = Math.GetRadians(shp["angle"])
SB_RotateWorkaround()
shp["wx"] = x
shp["wy"] = y
EndIf
If shp["func"] = "btn" Then
shp["obj"] = Controls.AddButton(shp["caption"], shX + x * s, shY + y * s)
Else
Shapes.Move(shp["obj"], shX + x * s, shY + y * s)
EndIf
If Text.IsSubText("rect|ell|tri|text", shp["func"]) And (shp["angle"] <> 0) And (shp["angle"] <> "") Then
Shapes.Rotate(shp["obj"], shp["angle"])
EndIf
shape[i] = shp
EndFor
grp["shape"] = shape
group[nGroup] = grp
y = Stack.PopValue("local")
x = Stack.PopValue("local")
i = Stack.PopValue("local")
EndSub

Sub Group_Flip
' Group | Flip a group
' param group[i] - group To flip
' param angle - To flip
' return group[i] - flipped group
Stack.PushValue("local", angle)
Stack.PushValue("local", j)
grp = group[i]
gx = grp["x"]
gy = grp["y"]
shape = grp["shape"]
n = Array.GetItemCount(shape)
angle = Math.Remainder(angle, 360)
If angle < 0 Then
angle = angle + 360
EndIf
If (angle <= 90) Or (270 < angle) Then
sign = 1
Else
sign = -1
EndIf
If (grp["flip"] <= 90) Or (270 < grp["flip"]) Then
lastSign = 1
Else
lastSign = -1
EndIf
_a = Math.GetRadians(angle)
scaleX = Math.Cos(_a)
For j = 1 To n
shp = shape[j]
Shapes.Zoom(shp["obj"], Math.Abs(scaleX), 1)
cx = shp["x"] + shp["width"] / 2
fx = (cx - grp["cx"]) * scaleX + grp["cx"]
_rx = fx - shp["width"] / 2
shp["rx"] = _rx
Shapes.Move(shp["obj"], _rx + gx, shp["y"] + gy)
If sign <> lastSign Then
If shp["angle"] <> "" Then
shp["angle"] = -shp["angle"]
Shapes.Rotate(shp["obj"], shp["angle"])
EndIf
If shp["func"] = "line" Then
Stack.PushValue("local", angle)
If sign = -1 Then
dx = shp["x2"] - shp["x1"]
dy = shp["y2"] - shp["y1"]
If dx = 0 Then
angle = 0
Else
_a = Math.ArcTan(dy / dx)
angle = Math.GetDegrees(_a)
EndIf
Else
angle = 0
EndIf
Shapes.Rotate(shp["obj"], -2 * angle)
angle = Stack.PopValue("local")
EndIf
EndIf
shape[j] = shp
EndFor
grp["flip"] = angle
grp["shape"] = shape
group[i] = grp
j = Stack.PopValue("local")
angle = Stack.PopValue("local")
EndSub

Sub Group_Move
' Group | Move a group
' param group[i] - group To move
' param x, y - position To move
' return group[i] - updated group
Stack.PushValue("local", j)
grp = group[i]
s = grp["scale"]
grp["x"] = x
grp["y"] = y
shape = grp["shape"]
n = Array.GetItemCount(shape)
For j = 1 To n
shp = shape[j]
If silverlight And Text.IsSubText("tri|line", shp["func"]) Then
_x = shp["wx"]
_y = shp["wy"]
Else
_x = shp["rx"]
_y = shp["ry"]
EndIf
_w2 = shp["width"] / 2
_h2 = shp["height"] / 2
Shapes.Move(shp["obj"], grp["x"] + (_x - _w2) * s + _w2, grp["y"] + (_y - _h2) * s + _h2)
EndFor
group[i] = grp
j = Stack.PopValue("local")
EndSub

Sub Shapes_CalcWidthAndHeight
' Shapes | Calculate total width and height of shapes
' param shape[] - shape array
' return shWidth, shHeight - total size of shapes
For i = 1 To Array.GetItemCount(shape)
shp = shape[i]
If shp["func"] = "tri" Or shp["func"] = "line" Then
xmin = shp["x1"]
xmax = shp["x1"]
ymin = shp["y1"]
ymax = shp["y1"]
If shp["x2"] < xmin Then
xmin = shp["x2"]
EndIf
If xmax < shp["x2"] Then
xmax = shp["x2"]
EndIf
If shp["y2"] < ymin Then
ymin = shp["y2"]
EndIf
If ymax < shp["y2"] Then
ymax = shp["y2"]
EndIf
If shp["func"] = "tri" Then
If shp["x3"] < xmin Then
xmin = shp["x3"]
EndIf
If xmax < shp["x3"] Then
xmax = shp["x3"]
EndIf
If shp["y3"] < ymin Then
ymin = shp["y3"]
EndIf
If ymax < shp["y3"] Then
ymax = shp["y3"]
EndIf
EndIf
shp["width"] = xmax - xmin
shp["height"] = ymax - ymin
EndIf
If i = 1 Then
shWidth = shp["x"] + shp["width"]
shHeight = shp["y"] + shp["height"]
Else
If shWidth < shp["x"] + shp["width"] Then
shWidth = shp["x"] + shp["width"]
EndIf
If shHeight < shp["y"] + shp["height"] Then
shHeight = shp["y"] + shp["height"]
EndIf
EndIf
shape[i] = shp
EndFor
EndSub

Sub Shapes_Init_1
' Shapes | Initialize shapes data
' return shX, shY - current position of shapes
' return shape - array of shapes
shX = 95 ' x offset
shY = 296 ' y offset
shape = ""
shape[1] = "func=tri;x=121;y=1;x1=6;y1=0;x2=0;y2=8;x3=13;y3=8;pw=0;bc=#D9D9D9;name=Isosceles Triangle 1;"
shape[2] = "func=rect;x=128;y=1;width=6;height=8;pw=0;bc=#D9D9D9;name=Rectangle 2;"
shape[3] = "func=ell;x=128;y=0;width=14;height=2;pw=0;bc=#D9D9D9;name=Ellipse 5;"
shape[4] = "func=rect;x=85;y=19;width=56;height=8;pw=0;bc=#FFFFFF;name=Rectangle 1036;"
shape[5] = "func=tri;x=61;y=13;x1=23;y1=0;x2=0;y2=28;x3=47;y3=28;pw=1;pc=#D9D9D9;bc=#F2F2F2;name=Isosceles Triangle 1030;"
shape[6] = "func=ell;x=2;y=38;width=133;height=77;pw=0;bc=#FFFFFF;name=Oval 4;"
shape[7] = "func=rect;x=94;y=26;width=667;height=69;pw=0;bc=#FFFFFF;name=Rectangle 6;"
shape[8] = "func=ell;x=81;y=7;width=122;height=18;pw=0;bc=#FFFFFF;name=Oval 12;"
shape[9] = "func=rect;x=142;y=7;width=615;height=17;pw=0;bc=#D9D9D9;name=Rectangle 14;"
shape[10] = "func=rect;x=320;y=106;width=140;height=14;pw=0;bc=#262626;name=Rectangle 13;"
shape[11] = "func=rect;x=472;y=106;width=16;height=12;pw=0;bc=#262626;name=Rectangle 15;"
shape[12] = "func=rect;x=189;y=106;width=29;height=14;pw=0;bc=#262626;name=Rectangle 16;"
shape[13] = "func=rect;x=237;y=106;width=21;height=14;pw=0;bc=#262626;name=Rectangle 17;"
shape[14] = "func=rect;x=276;y=106;width=31;height=14;pw=0;bc=#262626;name=Rectangle 18;"
shape[15] = "func=rect;x=68;y=104;width=95;height=13;pw=0;bc=#262626;name=Rectangle 19;"
shape[16] = "func=rect;x=599;y=104;width=95;height=13;pw=0;bc=#262626;name=Rectangle 21;"
shape[17] = "func=ell;x=142;y=106;width=25;height=25;pw=0;bc=#404040;name=Oval 22;"
shape[18] = "func=ell;x=68;y=106;width=25;height=25;pw=0;bc=#404040;name=Oval 23;"
shape[19] = "func=ell;x=595;y=106;width=25;height=25;pw=0;bc=#404040;name=Oval 24;"
shape[20] = "func=ell;x=675;y=106;width=25;height=25;pw=0;bc=#404040;name=Oval 26;"
shape[21] = "func=rect;x=10;y=96;width=747;height=14;pw=0;bc=#002060;name=Rectangle 27;"
shape[22] = "func=rect;x=140;y=23;width=617;height=3;pw=0;bc=#002060;name=Rectangle 20;"
shape[23] = "func=tri;x=0;y=96;x1=9;y1=0;x2=0;y2=28;x3=19;y3=28;pw=0;bc=#002060;name=Isosceles Triangle 28;"
shape[24] = "func=rect;x=9;y=107;width=45;height=17;pw=0;bc=#002060;name=Rectangle 30;"
shape[25] = "func=ell;x=17;y=69;width=12;height=12;pw=1;pc=#BFBFBF;bc=#A6A6A6;name=Oval 1023;"
shape[26] = "func=ell;x=93;y=42;width=50;height=23;angle=335.9578;pw=0;bc=#002060;name=Oval 1024;"
shape[27] = "func=rect;x=132;y=38;width=629;height=30;pw=0;bc=#002060;name=Rectangle 1026;"
shape[28] = "func=tri;x=103;y=38;x1=31;y1=0;x2=0;y2=30;x3=62;y3=30;pw=0;bc=#002060;name=Isosceles Triangle 1027;"
shape[29] = "func=rect;x=130;y=35;width=17;height=53;pw=1;pc=#A6A6A6;bc=Transparent;name=Rectangle 1028;"
shape[30] = "func=rect;x=158;y=34;width=18;height=57;pw=1;pc=#A6A6A6;bc=Transparent;name=Rectangle 37;"
shape[31] = "func=rect;x=637;y=31;width=18;height=57;pw=1;pc=#A6A6A6;bc=Transparent;name=Rectangle 38;"
shape[32] = "func=tri;x=22;y=103;x1=31;y1=0;x2=0;y2=21;x3=62;y3=21;angle=180;pw=0;bc=#002060;name=Isosceles Triangle 1029;"
shape[33] = "func=rect;x=114;y=25;width=9;height=10;pw=1;pc=#D9D9D9;bc=#F2F2F2;name=Rectangle 1031;"
shape[34] = "func=rect;x=203;y=43;width=17;height=19;pw=0;bc=#F2F2F2;name=Rectangle 1032;"
shape[35] = "func=rect;x=227;y=43;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 43;"
shape[36] = "func=rect;x=285;y=43;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 44;"
shape[37] = "func=rect;x=342;y=43;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 45;"
shape[38] = "func=rect;x=399;y=43;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 46;"
shape[39] = "func=rect;x=457;y=43;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 47;"
shape[40] = "func=rect;x=514;y=43;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 48;"
shape[41] = "func=rect;x=572;y=43;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 49;"
shape[42] = "func=rect;x=162;y=40;width=10;height=19;pw=0;bc=#F2F2F2;name=Rectangle 1033;"
shape[43] = "func=rect;x=640;y=40;width=10;height=19;pw=0;bc=#F2F2F2;name=Rectangle 51;"
shape[44] = "func=rect;x=136;y=44;width=5;height=19;pw=0;bc=#F2F2F2;name=Rectangle 1034;"
shape[45] = "func=rect;x=144;y=15;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 1035;"
shape[46] = "func=rect;x=232;y=14;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 54;"
shape[47] = "func=rect;x=288;y=14;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 55;"
shape[48] = "func=rect;x=344;y=14;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 56;"
shape[49] = "func=rect;x=400;y=14;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 57;"
shape[50] = "func=rect;x=466;y=14;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 58;"
shape[51] = "func=rect;x=519;y=14;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 59;"
shape[52] = "func=rect;x=572;y=14;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 60;"
shape[53] = "func=rect;x=692;y=14;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 61;"
shape[54] = "func=rect;x=64;y=38;width=30;height=9;angle=354.8378;pw=0;bc=#FFFFFF;name=Rectangle 1037;"
shape[55] = "func=line;x=81;y=18;x1=0;y1=0;x2=11;y2=2;pw=1;pc=#D9D9D9;bc=#000000;name=Straight Connector 1039;"
shape[56] = "func=tri;x=99;y=13;x1=3;y1=0;x2=0;y2=23;x3=6;y3=23;angle=90;pw=0;bc=#F2F2F2;name=Isosceles Triangle 1046;"
shape[57] = "func=rect;x=93;y=25;width=21;height=11;pw=0;bc=#F2F2F2;name=Rectangle 1047;"
shape[58] = "func=line;x=92;y=21;x1=0;y1=0;x2=22;y2=4;pw=1;pc=#D9D9D9;bc=#000000;name=Straight Connector 1049;"
shape[59] = "func=line;x=88;y=22;x1=0;y1=14;x2=11;y2=0;pw=1;pc=#D9D9D9;bc=#000000;name=Straight Connector 1051;"
shape[60] = "func=line;x=64;y=37;x1=0;y1=1;x2=25;y2=0;pw=1;pc=#D9D9D9;bc=#000000;name=Straight Connector 1053;"
shape[61] = "func=line;x=89;y=35;x1=0;y1=1;x2=25;y2=0;pw=1;pc=#D9D9D9;bc=#000000;name=Straight Connector 31;"
EndSub

Sub Shapes_Init_2
' Shapes | Initialize shapes data
' return shX, shY - current position of shapes
' return shape - array of shapes
shX = 0 ' x offset
shY = 303 ' y offset
shape = ""
shape[1] = "func=rect;x=0;y=19;width=746;height=69;pw=0;bc=#FFFFFF;name=Rectangle 6;"
shape[2] = "func=rect;x=4;y=0;width=738;height=17;pw=0;bc=#D9D9D9;name=Rectangle 14;"
shape[3] = "func=rect;x=313;y=98;width=140;height=14;pw=0;bc=#262626;name=Rectangle 13;"
shape[4] = "func=rect;x=465;y=98;width=16;height=12;pw=0;bc=#262626;name=Rectangle 15;"
shape[5] = "func=rect;x=183;y=98;width=29;height=14;pw=0;bc=#262626;name=Rectangle 16;"
shape[6] = "func=rect;x=231;y=98;width=21;height=14;pw=0;bc=#262626;name=Rectangle 17;"
shape[7] = "func=rect;x=269;y=98;width=31;height=14;pw=0;bc=#262626;name=Rectangle 18;"
shape[8] = "func=rect;x=61;y=97;width=95;height=13;pw=0;bc=#262626;name=Rectangle 19;"
shape[9] = "func=rect;x=592;y=97;width=95;height=13;pw=0;bc=#262626;name=Rectangle 21;"
shape[10] = "func=ell;x=135;y=98;width=25;height=25;pw=0;bc=#404040;name=Oval 22;"
shape[11] = "func=ell;x=61;y=98;width=25;height=25;pw=0;bc=#404040;name=Oval 23;"
shape[12] = "func=ell;x=588;y=98;width=25;height=25;pw=0;bc=#404040;name=Oval 24;"
shape[13] = "func=ell;x=668;y=98;width=25;height=25;pw=0;bc=#404040;name=Oval 26;"
shape[14] = "func=rect;x=4;y=89;width=738;height=14;pw=0;bc=#002060;name=Rectangle 27;"
shape[15] = "func=rect;x=4;y=16;width=738;height=3;pw=0;bc=#002060;name=Rectangle 20;"
shape[16] = "func=rect;x=0;y=31;width=746;height=30;pw=0;bc=#002060;name=Rectangle 1026;"
shape[17] = "func=rect;x=19;y=27;width=18;height=57;pw=1;pc=#A6A6A6;bc=Transparent;name=Rectangle 37;"
shape[18] = "func=rect;x=721;y=24;width=18;height=57;pw=1;pc=#A6A6A6;bc=Transparent;name=Rectangle 38;"
shape[19] = "func=rect;x=191;y=36;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 43;"
shape[20] = "func=rect;x=249;y=36;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 44;"
shape[21] = "func=rect;x=306;y=36;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 45;"
shape[22] = "func=rect;x=363;y=36;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 46;"
shape[23] = "func=rect;x=421;y=36;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 47;"
shape[24] = "func=rect;x=478;y=36;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 48;"
shape[25] = "func=rect;x=536;y=36;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 49;"
shape[26] = "func=rect;x=22;y=32;width=11;height=20;pw=1;pc=#D9D9D9;bc=#F2F2F2;name=Rectangle 1033;"
shape[27] = "func=rect;x=724;y=32;width=11;height=20;pw=1;pc=#D9D9D9;bc=#F2F2F2;name=Rectangle 51;"
shape[28] = "func=rect;x=137;y=7;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 1035;"
shape[29] = "func=rect;x=225;y=7;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 54;"
shape[30] = "func=rect;x=281;y=7;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 55;"
shape[31] = "func=rect;x=337;y=7;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 56;"
shape[32] = "func=rect;x=394;y=7;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 57;"
shape[33] = "func=rect;x=460;y=7;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 58;"
shape[34] = "func=rect;x=513;y=7;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 59;"
shape[35] = "func=rect;x=566;y=7;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 60;"
shape[36] = "func=rect;x=686;y=7;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 61;"
shape[37] = "func=rect;x=134;y=36;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 43;"
shape[38] = "func=rect;x=593;y=36;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 49;"
shape[39] = "func=rect;x=77;y=36;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 43;"
shape[40] = "func=rect;x=651;y=36;width=48;height=18;pw=0;bc=#F2F2F2;name=Rectangle 49;"
shape[41] = "func=rect;x=25;y=7;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 54;"
shape[42] = "func=rect;x=81;y=7;width=39;height=4;pw=0;bc=#7F7F7F;name=Rectangle 55;"
EndSub

Sub SB_RotateWorkaround
' Small Basic | Rotate workaround For Silverlight
' param shp - current shape
' param x, y - original coordinate
' param alpha - angle [radian]
' returns x, y - workaround coordinate
If shp["func"] = "tri" Then
x1 = -Math.Floor(shp["x3"] / 2)
y1 = -Math.Floor(shp["y3"] / 2)
ElseIf shp["func"] = "line" Then
x1 = -Math.Floor(Math.Abs(shp["x1"] - shp["x2"]) / 2)
y1 = -Math.Floor(Math.Abs(shp["y1"] - shp["y2"]) / 2)
EndIf
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