Microsoft Small Basic

Program Listing: HPL140
' chibi:bit
' Copyright © Nonki Takahashi. The MIT License.
' 2017-08-28 16:15:18 Shapes generated by Shapes 2.3b.

SB_Workaround()
LF = Text.GetCharacter(10)
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.Title = "chibi:bit"
' initialize shapes
Shapes_Init()
' add shapes
scale = 1
angle = 0
iMin = 1
iMax = 115
Shapes_Add()
FindLEDs()
img = "" + LF
img = img + " . # # # . " + LF
img = img + " # . . . # " + LF
img = img + " # . . . # " + LF
img = img + " # . . . # " + LF
img = img + " . # # # . " + LF
ShowLEDs()
x = 2
y = 2
OnLED()
Program.Delay(1000)
OffLED()

Sub FindLEDs
For i = iMin To iMax
shp = shape[i]
If Text.StartsWith(shp["name"], "LED ") Then
name = shp["name"]
x = Text.GetSubText(name, 5, 1)
y = Text.GetSubText(name, 7, 1)
objLED[x][y] = shp["obj"]
EndIf
EndFor
EndSub
Sub ShowLEDs
p = 1
y = 0
x = 0
While p <= Text.GetLength(img)
c = Text.GetSubText(img, p, 1)
If c = "." Then
Shapes.HideShape(objLED[x][y])
ElseIf c = "#" Then
Shapes.ShowShape(objLED[x][y])
EndIf
If Text.IsSubText(".#", c) THen
x = x + 1
If 4 < x Then
x = 0
y = y + 1
EndIf
EndIf
p = p + 1
EndWhile
EndSub
Sub OnLED
Shapes.ShowShape(objLED[x][y])
EndSub
Sub OffLED
Shapes.HideShape(objLED[x][y])
EndSub

Sub Shapes_Init
' Shapes | Initialize shapes data
' return shX, shY - current position of shapes
' return shape - array of shapes
shX = 210 ' x offset
shY = 130 ' y offset
shape = ""
shape[1] = "func=rect;x=8;y=0;width=150;height=8;bc=#006666;pw=0;name=top;"
shape[2] = "func=ell;x=0;y=0;width=16;height=16;bc=#006666;pw=0;name=corner;"
shape[3] = "func=ell;x=150;y=0;width=16;height=16;bc=#006666;pw=0;name=corner;"
shape[4] = "func=rect;x=0;y=8;width=166;height=110;bc=#006666;pw=0;name=board;"
shape[5] = "func=text;x=168;y=177;text=chibi:bit;fs=20;fn=Trebuchet MS;bc=#000000;"
shape[6] = "func=line;x=0;y=26;x1=0;y1=0;x2=68;y2=0;pc=#FFFFFF;pw=3;name=line;"
shape[7] = "func=line;x=98;y=26;x1=0;y1=0;x2=68;y2=0;pc=#FFFFFF;pw=3;name=line;"
shape[8] = "func=ell;x=77;y=26;width=14;height=14;bc=Transparent;pc=#FFFFFF;pw=3;name=mouth;"
shape[9] = "func=rect;x=69;y=18;width=28;height=17;bc=#006666;pw=0;name=mouth;"
shape[10] = "func=ell;x=68;y=20;width=12;height=12;bc=Transparent;pc=#FFFFFF;pw=3;name=eye;"
shape[11] = "func=ell;x=88;y=20;width=12;height=12;bc=Transparent;pc=#FFFFFF;pw=3;name=eye;"
shape[12] = "func=line;x=77;y=12;x1=0;y1=9;x2=8;y2=0;pc=#FFFFFF;pw=3;name=switch;"
shape[13] = "func=rect;x=56;y=47;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[14] = "func=rect;x=56;y=49;width=4;height=7;bc=#FF0000;pw=0;name=LED 0,0;"
shape[15] = "func=rect;x=56;y=60;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[16] = "func=rect;x=56;y=62;width=4;height=7;bc=#FF0000;pw=0;name=LED 0,1;"
shape[17] = "func=rect;x=56;y=73;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[18] = "func=rect;x=56;y=75;width=4;height=7;bc=#FF0000;pw=0;name=LED 0,2;"
shape[19] = "func=rect;x=56;y=86;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[20] = "func=rect;x=56;y=88;width=4;height=7;bc=#FF0000;pw=0;name=LED 0,3;"
shape[21] = "func=rect;x=56;y=99;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[22] = "func=rect;x=56;y=101;width=4;height=7;bc=#FF0000;pw=0;name=LED 0,4;"
shape[23] = "func=rect;x=69;y=47;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[24] = "func=rect;x=69;y=49;width=4;height=7;bc=#FF0000;pw=0;name=LED 1,0;"
shape[25] = "func=rect;x=69;y=60;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[26] = "func=rect;x=69;y=62;width=4;height=7;bc=#FF0000;pw=0;name=LED 1,1;"
shape[27] = "func=rect;x=69;y=73;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[28] = "func=rect;x=69;y=75;width=4;height=7;bc=#FF0000;pw=0;name=LED 1,2;"
shape[29] = "func=rect;x=69;y=86;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[30] = "func=rect;x=69;y=88;width=4;height=7;bc=#FF0000;pw=0;name=LED 1,3;"
shape[31] = "func=rect;x=69;y=99;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[32] = "func=rect;x=69;y=101;width=4;height=7;bc=#FF0000;pw=0;name=LED 1,4;"
shape[33] = "func=rect;x=82;y=47;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[34] = "func=rect;x=82;y=49;width=4;height=7;bc=#FF0000;pw=0;name=LED 2,0;"
shape[35] = "func=rect;x=82;y=60;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[36] = "func=rect;x=82;y=62;width=4;height=7;bc=#FF0000;pw=0;name=LED 2,1;"
shape[37] = "func=rect;x=82;y=73;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[38] = "func=rect;x=82;y=75;width=4;height=7;bc=#FF0000;pw=0;name=LED 2,2;"
shape[39] = "func=rect;x=82;y=86;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[40] = "func=rect;x=82;y=88;width=4;height=7;bc=#FF0000;pw=0;name=LED 2,3;"
shape[41] = "func=rect;x=82;y=99;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[42] = "func=rect;x=82;y=101;width=4;height=7;bc=#FF0000;pw=0;name=LED 2,4;"
shape[43] = "func=rect;x=95;y=47;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[44] = "func=rect;x=95;y=49;width=4;height=7;bc=#FF0000;pw=0;name=LED 3,0;"
shape[45] = "func=rect;x=95;y=60;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[46] = "func=rect;x=95;y=62;width=4;height=7;bc=#FF0000;pw=0;name=LED 3,1;"
shape[47] = "func=rect;x=95;y=73;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[48] = "func=rect;x=95;y=75;width=4;height=7;bc=#FF0000;pw=0;name=LED 3,2;"
shape[49] = "func=rect;x=95;y=86;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[50] = "func=rect;x=95;y=88;width=4;height=7;bc=#FF0000;pw=0;name=LED 3,3;"
shape[51] = "func=rect;x=95;y=99;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[52] = "func=rect;x=95;y=101;width=4;height=7;bc=#FF0000;pw=0;name=LED 3,4;"
shape[53] = "func=rect;x=108;y=47;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[54] = "func=rect;x=108;y=49;width=4;height=7;bc=#FF0000;pw=0;name=LED 4,0;"
shape[55] = "func=rect;x=108;y=60;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[56] = "func=rect;x=108;y=62;width=4;height=7;bc=#FF0000;pw=0;name=LED 4,1;"
shape[57] = "func=rect;x=108;y=73;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[58] = "func=rect;x=108;y=75;width=4;height=7;bc=#FF0000;pw=0;name=LED 4,2;"
shape[59] = "func=rect;x=108;y=86;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[60] = "func=rect;x=108;y=88;width=4;height=7;bc=#FF0000;pw=0;name=LED 4,3;"
shape[61] = "func=rect;x=108;y=99;width=4;height=11;bc=#666666;pw=0;name=LED;"
shape[62] = "func=rect;x=108;y=101;width=4;height=7;bc=#FF0000;pw=0;name=LED 4,4;"
shape[63] = "func=rect;x=6;y=60;width=18;height=18;bc=#808080;pw=0;name=button A;"
shape[64] = "func=ell;x=10;y=64;width=10;height=10;bc=#000000;pw=0;name=button A;"
shape[65] = "func=rect;x=142;y=60;width=18;height=18;bc=#808080;pw=0;name=button B;"
shape[66] = "func=ell;x=146;y=64;width=10;height=10;bc=#000000;pw=0;name=button B;"
shape[67] = "func=rect;x=0;y=130;width=166;height=8;bc=#006666;pw=0;name=bottom;"
shape[68] = "func=rect;x=8;y=138;width=150;height=8;bc=#006666;pw=0;name=bottom;"
shape[69] = "func=ell;x=0;y=130;width=16;height=16;bc=#006666;pw=0;name=corner;"
shape[70] = "func=ell;x=150;y=130;width=16;height=16;bc=#006666;pw=0;name=corner;"
shape[71] = "func=rect;x=0;y=118;width=6;height=12;bc=#006666;pw=0;name=gap;"
shape[72] = "func=rect;x=17;y=118;width=22;height=12;bc=#006666;pw=0;name=gap;"
shape[73] = "func=rect;x=50;y=118;width=27;height=12;bc=#006666;pw=0;name=gap;"
shape[74] = "func=rect;x=88;y=118;width=27;height=12;bc=#006666;pw=0;name=gap;"
shape[75] = "func=rect;x=126;y=118;width=22;height=12;bc=#006666;pw=0;name=gap;"
shape[76] = "func=rect;x=160;y=118;width=6;height=12;bc=#006666;pw=0;name=gap;"
shape[77] = "func=ell;x=3;y=114;width=18;height=18;bc=Transparent;pc=#BFA95A;pw=4;"
shape[78] = "func=rect;x=6;y=128;width=11;height=18;bc=#BFA95A;pw=0;name=port 0;"
shape[79] = "func=ell;x=36;y=114;width=18;height=18;bc=Transparent;pc=#BFA95A;pw=4;"
shape[80] = "func=rect;x=39;y=128;width=11;height=18;bc=#BFA95A;pw=0;name=port 1;"
shape[81] = "func=ell;x=74;y=114;width=18;height=18;bc=Transparent;pc=#BFA95A;pw=4;"
shape[82] = "func=rect;x=77;y=128;width=11;height=18;bc=#BFA95A;pw=0;name=port 2;"
shape[83] = "func=ell;x=112;y=114;width=18;height=18;bc=Transparent;pc=#BFA95A;pw=4;"
shape[84] = "func=rect;x=115;y=128;width=11;height=18;bc=#BFA95A;pw=0;name=port 3V;"
shape[85] = "func=ell;x=145;y=114;width=18;height=18;bc=Transparent;pc=#BFA95A;pw=4;"
shape[86] = "func=rect;x=148;y=128;width=11;height=18;bc=#BFA95A;pw=0;name=port GND;"
shape[87] = "func=text;x=12;y=40;text=A;fs=12;fn=Trebuchet MS;bc=#FFFFFF;"
shape[88] = "func=text;x=148;y=40;text=B;fs=12;fn=Trebuchet MS;bc=#FFFFFF;"
shape[89] = "func=text;x=10;y=134;text=0;fs=6;fn=Trebuchet MS;bc=#000000;"
shape[90] = "func=text;x=43;y=134;text=1;fs=6;fn=Trebuchet MS;bc=#000000;"
shape[91] = "func=text;x=81;y=134;text=2;fs=6;fn=Trebuchet MS;bc=#000000;"
shape[92] = "func=text;x=117;y=134;text=3V;fs=6;fn=Trebuchet MS;bc=#000000;"
shape[93] = "func=text;x=148;y=134;text=GND;fs=6;fn=Trebuchet MS;bc=#000000;"
shape[94] = "func=rect;x=1;y=130;width=3;height=13;bc=#BFA95A;pw=0;"
shape[95] = "func=rect;x=19;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[96] = "func=rect;x=24;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[97] = "func=rect;x=29;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[98] = "func=rect;x=34;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[99] = "func=rect;x=52;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[100] = "func=rect;x=57;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[101] = "func=rect;x=62;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[102] = "func=rect;x=67;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[103] = "func=rect;x=72;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[104] = "func=rect;x=90;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[105] = "func=rect;x=95;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[106] = "func=rect;x=100;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[107] = "func=rect;x=105;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[108] = "func=rect;x=110;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[109] = "func=rect;x=128;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[110] = "func=rect;x=133;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[111] = "func=rect;x=138;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[112] = "func=rect;x=143;y=130;width=3;height=16;bc=#BFA95A;pw=0;"
shape[113] = "func=rect;x=161;y=130;width=3;height=13;bc=#BFA95A;pw=0;"
shape[114] = "func=tri;x=0.879;y=142.379;x1=2.121;y1=0;x2=0;y2=2.121;x3=4.242;y3=2.121;bc=#BFA95A;pw=0;angle=45;"
shape[115] = "func=tri;x=159.879;y=142.379;x1=2.121;y1=0;x2=0;y2=2.121;x3=4.242;y3=2.121;bc=#BFA95A;pw=0;angle=-45;"
EndSub
Sub Math_CartesianToPolar
' Math | convert cartesian coodinate to polar coordinate
' param x, y - cartesian coordinate
' return r, a - polar coordinate
r = Math.SquareRoot(x * x + y * y)
If x = 0 And y > 0 Then
a = 90 ' [degree]
ElseIf x = 0 And y < 0 Then
a = -90
ElseIf x = 0 Then
a = 0
Else
a = Math.ArcTan(y / x) * 180 / Math.Pi
EndIf
If x < 0 Then
a = a + 180
ElseIf x > 0 And y < 0 Then
a = a + 360
EndIf
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
Sub Shapes_Add
' Shapes | add shapes as shapes data
' param iMin, iMax - shape indices to add
' param shape - array of shapes
' param scale - 1 if same scale
' return shWidth, shHeight - total size of shapes
' return shAngle - current angle of shapes
Stack.PushValue("local", i)
Stack.PushValue("local", x)
Stack.PushValue("local", y)
Shapes_CalcWidthAndHeight()
s = scale
For i = iMin To iMax
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", shp["func"]) Then
GraphicsWindow.BrushColor = shp["bc"]
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
If silverlight Then
fs = Math.Floor(shp["fs"] * 0.9)
Else
fs = shp["fs"]
EndIf
GraphicsWindow.FontSize = fs * s
GraphicsWindow.FontName = shp["fn"]
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
Shapes.Move(shp["obj"], shX + x * s, shY + y * s)
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
shAngle = 0
y = Stack.PopValue("local")
x = Stack.PopValue("local")
i = Stack.PopValue("local")
EndSub
Sub Shapes_CalcRotatePos
' Shapes | Calculate position for rotated shape
' param["x"], param["y"] - position of a shape
' param["width"], param["height"] - size of a shape
' param ["cx"], param["cy"] - center of rotation
' param ["angle"] - rotate angle
' return x, y - rotated position of a shape
_cx = param["x"] + param["width"] / 2
_cy = param["y"] + param["height"] / 2
x = _cx - param["cx"]
y = _cy - param["cy"]
Math_CartesianToPolar()
a = a + param["angle"]
x = r * Math.Cos(a * Math.Pi / 180)
y = r * Math.Sin(a * Math.Pi / 180)
_cx = x + param["cx"]
_cy = y + param["cy"]
x = _cx - param["width"] / 2
y = _cy - param["height"] / 2
EndSub
Sub Shapes_CalcWidthAndHeight
' Shapes | Calculate total width and height of shapes
' param iMin, iMax - shape indices to add
' return shWidth, shHeight - total size of shapes
For i = iMin To iMax
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_Move
' Shapes | Move shapes
' param iMin, iMax - shape indices to add
' param shape - array of shapes
' param scale - to zoom
' param x, y - position to move
' return shX, shY - new position of shapes
Stack.PushValue("local", i)
s = scale
shX = x
shY = y
For i = iMin To iMax
shp = shape[i]
If silverlight And Text.IsSubText("tri|line", shp["func"]) Then
_x = shp["wx"]
_y = shp["wy"]
Else
_x = shp["rx"]
_y = shp["ry"]
EndIf
Shapes.Move(shp["obj"], shX + _x * s, shY + _y * s)
EndFor
i = Stack.PopValue("local")
EndSub
Sub Shapes_Remove
' Shapes | Remove shapes
' param iMin, iMax - shapes indices to remove
' param shape - array of shapes
Stack.PushValue("local", i)
For i = iMin To iMax
shp = shape[i]
Shapes.Remove(shp["obj"])
EndFor
i = Stack.PopValue("local")
EndSub
Sub Shapes_Rotate
' Shapes | Rotate shapes
' param iMin, iMax - shapes indices to rotate
' param shape - array of shapes
' param cx, cy - rotation center
' param scale - to zoom
' param angle - to rotate
Stack.PushValue("local", i)
Stack.PushValue("local", x)
Stack.PushValue("local", y)
s = scale
param["angle"] = angle
If cx <> "" Then
param["cx"] = cx
Else
cx = "" ' to avoid syntax error
param["cx"] = shWidth / 2
EndIf
If cy <> "" Then
param["cy"] = cy
Else
cy = "" ' to avoid syntax error
param["cy"] = shHeight / 2
EndIf
For i = iMin To iMax
shp = shape[i]
param["x"] = shp["x"]
param["y"] = shp["y"]
param["width"] = shp["width"]
param["height"] = shp["height"]
Shapes_CalcRotatePos()
shp["rx"] = x
shp["ry"] = y
If silverlight And Text.IsSubText("tri|line", shp["func"]) Then
alpha = Math.GetRadians(angle + shp["angle"])
SB_RotateWorkAround()
shp["wx"] = x
shp["wy"] = y
EndIf
Shapes.Move(shp["obj"], shX + x * s, shY + y * s)
Shapes.Rotate(shp["obj"], angle + shp["angle"])
shape[i] = shp
EndFor
y = Stack.PopValue("local")
x = Stack.PopValue("local")
i = Stack.PopValue("local")
EndSub