Microsoft Small Basic

Program Listing: GGK772
' TechNet Guru Medals
' Version 0.2
' Copyright © 2016 Nonki Takahashi. The MIT License.
' Last Update 2016-01-06
' Program ID NRS907-2
' 2016-01-06 13:56:35 Ninja generated by Shapes 2.2b.
'
' Reference
' [1] James D. Foley, Andries Van Dam "Fundamentals of Interactive Computer Graphics" 1982
'
GraphicsWindow.Title = "TechNet Guru Medals 0.2"
UNDEFINED = "N/A"
colors = "1=Gold;2=Silver;3=#AC6B25;" ' bronze
di = 120 ' diameter
SB_Workaround()
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.BrushColor = "Black"
tbox = Controls.AddTextBox(10, 10)
Controls.SetTextBoxText(tbox, di)
Controls.SetSize(tbox, 50, 22)
Controls.AddButton("Draw", 72, 8)
GraphicsWindow.FontName = "Trebuchet MS"
DrawMedals()
' initialize shapes
Shapes_Init()
' add shapes
scale = di / 200
angle = 0
iMin = 1
iMax = 72
Shapes_Add()
x = 30 + (4 - 1) * (di + 20)
y = 50
Shapes_Move()
Controls.ButtonClicked = OnButtonClicked
While "True"
If buttonClicked Then
di = Controls.GetTextBoxText(tbox)
DrawMedals()
scale = di / 200
Shapes_Remove()
Shapes_Add()
x = 30 + (4 - 1) * (di + 20)
y = 50
Shapes_Move()
buttonClicked = "False"
Else
Program.Delay(msWait)
EndIf
EndWhile
Sub OnButtonClicked
buttonClicked = "True"
EndSub
Sub DrawMedals
GraphicsWindow.BrushColor = "White"
gw = GraphicsWindow.Width
gh = GraphicsWindow.Height
GraphicsWindow.FillRectangle(0, 0, gw, gh)
GraphicsWindow.FontSize = 20 * di / 100
th = 8 * di / 100
For i = 1 To 3
x0 = 30 + (i - 1) * (di + 20)
y0 = 50
GraphicsWindow.BrushColor = colors[i]
color = GraphicsWindow.BrushColor
SB_ColorWorkaround()
Color_RGBtoHSL()
lsave = lightness
ra = (di - 1) / 2 ' radius
x1 = x0 + ra
y1 = y0 + ra
For a = 0 To 360 Step 2
_a = Math.GetRadians(a)
x3 = x1 + ra * Math.Sin(_a)
y3 = y1 - ra * Math.Cos(_a)
If 0 < a Then
GraphicsWindow.FillTriangle(x1, y1, x2, y2, x3, y3)
If 90 < a And a < 270 Then
lightness = Math.Abs(lightness - 0.2)
Color_HSLtoRGB()
GraphicsWindow.BrushColor = color
GraphicsWindow.FillTriangle(x2, y2, x3, y3, x2, y2 + th)
GraphicsWindow.FillTriangle(x3, y3, x2, y2 + th, x3, y3 + th)
EndIf
EndIf
n = 3
lightness = lsave - (Math.Abs(Math.Remainder(_a + Math.Pi / 4, Math.Pi / n) - Math.Pi / (n * 2)) / (Math.Pi / 2)) * lsave
Color_HSLtoRGB()
GraphicsWindow.BrushColor = color
_a = Math.GetRadians(a - 2)
x2 = x1 + ra * Math.Sin(_a)
y2 = y1 - ra * Math.Cos(_a)
EndFor
GraphicsWindow.BrushColor = colors[i]
color = GraphicsWindow.BrushColor
SB_ColorWorkaround()
Color_RGBtoHSL()
lightness = lsave * 0.2
Color_HSLtoRGB()
GraphicsWindow.BrushColor = color
GraphicsWindow.DrawText(x0 + 16 * di / 100, y0 + 27 * di / 100, "TnWiki")
GraphicsWindow.DrawText(x0 + 26 * di / 100, y0 + 47 * di / 100, "Guru")
lightness = lsave * 0.8
Color_HSLtoRGB()
GraphicsWindow.BrushColor = color
GraphicsWindow.DrawText(x0 + 17 * di / 100, y0 + 28 * di / 100, "TnWiki")
GraphicsWindow.DrawText(x0 + 27 * di / 100, y0 + 48 * di / 100, "Guru")
EndFor
EndSub
Sub Color_ColorToRGB
' Color | Convert Color to RGB
' param color - "#rrggbb"
' return r, g, b - [0, 255]
sr = Text.GetSubText(color, 2, 2)
sg = Text.GetSubText(color, 4, 2)
sb = Text.GetSubText(color, 6, 2)
hex = sr
Math_Hex2Dec()
r = dec
hex = sg
Math_Hex2Dec()
g = dec
hex = sb
Math_Hex2Dec()
b = dec
EndSub
Sub Color_HSLtoRGB
' Color | Convert HSL to RGB
' param hue - [0, 360) or UNDEFINED
' param lightness - [0, 1]
' param saturation - [0, 1]
' return color - "#rrggbb"
If lightness <= 0.5 Then
n2 = lightness * (1 + saturation)
Else
n2 = lightness + saturation - lightness * saturation
EndIf
n1 = 2 * lightness - n2
If saturation = 0 Then
r = Math.Round(lightness * 255)
g = Math.Round(lightness * 255)
b = Math.Round(lightness * 255)
Else
h = hue + 120
Color_Value()
r = value
h = hue
Color_Value()
g = value
h = hue - 120
Color_Value()
b = value
EndIf
color = GraphicsWindow.GetColorFromRGB(r, g, b)
EndSub
Sub Color_Value
' Color | Function value
' param n1, n2
' param h - [-120, 480)
' return value - 0..255
If h >= 360 Then
h = h - 360
EndIF
If h < 0 Then
h = h + 360
EndIF
If h < 60 Then
v = n1 + (n2 - n1) * h / 60
ElseIf h < 180 Then
v = n2
ElseIf h < 240 Then
v = n1 + (n2 - n1) * (240 - h) / 60
Else
v = n1
EndIf
value = Math.Round(v * 255)
EndSub
Sub Color_RGBtoHSL
' Color | Convert RGB to HSL
' param color - "#rrggbb"
' return hue - [0, 360) or UNDEFINED
' return lightness - (0, 1)
' return saturation - (0, 1)
Color_ColorToRGB()
' r = r / 255 ' occurs Math.Max() bug
r = Math.Round(r / 255 * 10000) / 10000
' g = g / 255 ' occurs Math.Max() bug
g = Math.Round(g / 255 * 10000) / 10000
' b = b / 255 ' occurs Math.Max() bug
b = Math.Round(b / 255 * 10000) / 10000
max = Math.Max(r, g)
max = Math.Max(max, b)
min = Math.Min(r, g)
min = Math.Min(min, b)
lightness = (max + min) / 2
If max = min Then ' rR = rG = rB
saturation = 0
hue = UNDEFINED
Else
If lightness <= 0.5 Then
saturation = (max - min) / (max + min)
Else
saturation = (max - min) / (2 - max - min)
EndIf
rc = (max - r) / (max - min)
gc = (max - g) / (max - min)
bc = (max - b) / (max - min)
If r = max Then ' between Yellow and Magenta
hue = bc - gc
ElseIf g = max Then ' between Cyan and Yellow
hue = 2 + rc - bc
ElseIf b = max Then ' between Magenta and Cyan
hue = 4 + gc - rc
Else
TextWindow.WriteLine("Error:")
TextWindow.WriteLine("max=" + max)
TextWindow.WriteLine("r=" + r + ",sr=" + sr)
TextWindow.WriteLine("g=" + g + ",sg=" + sg)
TextWindow.WriteLine("b=" + b + ",sb=" + sb)
EndIf
hue = hue * 60
If hue < 0 Then
hue = hue + 360
EndIf
EndIf
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 Math_Hex2Dec
' Math | Convert hexadecimal to decimal
' param hex
' return dec
dec = 0
len = Text.GetLength(hex)
For p = 1 To len
dec = dec * 16 + Text.GetIndexOf("0123456789ABCDEF", Text.GetSubText(hex, p, 1)) - 1
EndFor
EndSub
Sub SB_ColorWorkaround
' Small Basic | Color workaround for Silverlight
' param color
' return color
If Text.GetLength(color) = 9 Then
color = "#" + Text.GetSubTextToEnd(color, 4)
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_Init
' Shapes | Initialize shapes data
' return shX, shY - current position of shapes
' return shape - array of shapes
shX = 195 ' x offset
shY = 130 ' y offset
shape = ""
shape[1] = "func=rect;x=143;y=18;width=26;height=11;angle=335;bc=#666666;pw=0;"
shape[2] = "func=rect;x=165;y=13;width=25;height=11;bc=#666666;pw=0;"
shape[3] = "func=rect;x=147;y=34;width=24;height=10;bc=#666666;pw=0;"
shape[4] = "func=rect;x=168;y=31;width=24;height=10;angle=344;bc=#666666;pw=0;"
shape[5] = "func=ell;x=55;y=83;width=82;height=95;bc=#000000;pw=0;"
shape[6] = "func=rect;x=15;y=91;width=17;height=38;angle=157;bc=#666666;pc=#000000;pw=2;"
shape[7] = "func=ell;x=42;y=198;width=26;height=45;angle=79;bc=#000000;pw=0;"
shape[8] = "func=ell;x=119;y=200;width=26;height=45;angle=283;bc=#000000;pw=0;"
shape[9] = "func=rect;x=142;y=124;width=17;height=38;angle=43;bc=#666666;pc=#000000;pw=2;"
shape[10] = "func=tri;x=78;y=91;x1=18;y1=0;x2=0;y2=38;x3=36;y3=38;angle=180;bc=#666666;pw=0;"
shape[11] = "func=ell;x=134;y=83;width=31;height=61;angle=306;bc=#000000;pw=0;"
shape[12] = "func=ell;x=34;y=86;width=31;height=61;angle=53;bc=#000000;pw=0;"
shape[13] = "func=rect;x=62;y=179;width=17;height=33;angle=13;bc=#666666;pc=#000000;pw=2;"
shape[14] = "func=rect;x=111;y=179;width=17;height=33;angle=353;bc=#666666;pc=#000000;pw=2;"
shape[15] = "func=ell;x=57;y=149;width=37;height=51;angle=6;bc=#000000;pw=0;"
shape[16] = "func=ell;x=98;y=145;width=37;height=51;angle=350;bc=#000000;pw=0;"
shape[17] = "func=ell;x=47;y=0;width=104;height=96;bc=#000000;pw=0;"
shape[18] = "func=rect;x=59;y=38;width=76;height=32;bc=#F6D8A7;pw=0;"
shape[19] = "func=ell;x=74;y=44;width=13;height=17;bc=#000000;pw=0;"
shape[20] = "func=ell;x=109;y=44;width=13;height=17;bc=#000000;pw=0;"
shape[21] = "func=rect;x=58;y=26;width=78;height=14;bc=#666666;pw=0;"
shape[22] = "func=rect;x=79;y=29;width=35;height=9;bc=#999999;pw=0;"
shape[23] = "func=line;x=16;y=95;x1=0;y1=0;x2=9;y2=4;pc=#000000;pw=2;"
shape[24] = "func=line;x=13;y=101;x1=0;y1=0;x2=18;y2=8;pc=#000000;pw=2;"
shape[25] = "func=line;x=17;y=110;x1=0;y1=0;x2=15;y2=5;pc=#000000;pw=2;"
shape[26] = "func=line;x=138;y=145;x1=0;y1=0;x2=1;y2=12;pc=#000000;pw=2;"
shape[27] = "func=line;x=142;y=140;x1=0;y1=0;x2=3;y2=18;pc=#000000;pw=2;"
shape[28] = "func=line;x=148;y=134;x1=0;y1=0;x2=2;y2=18;pc=#000000;pw=2;"
shape[29] = "func=line;x=153;y=129;x1=3;y1=20;x2=0;y2=0;pc=#000000;pw=2;"
shape[30] = "func=line;x=161;y=128;x1=0;y1=0;x2=0;y2=13;pc=#000000;pw=2;"
shape[31] = "func=line;x=75;y=180;x1=0;y1=0;x2=5;y2=12;pc=#000000;pw=2;"
shape[32] = "func=line;x=69;y=180;x1=0;y1=0;x2=8;y2=17;pc=#000000;pw=2;"
shape[33] = "func=line;x=64;y=186;x1=0;y1=0;x2=11;y2=22;pc=#000000;pw=2;"
shape[34] = "func=line;x=63;y=198;x1=0;y1=0;x2=5;y2=11;pc=#000000;pw=2;"
shape[35] = "func=line;x=119;y=180;x1=0;y1=0;x2=7;y2=8;pc=#000000;pw=2;"
shape[36] = "func=line;x=111;y=181;x1=0;y1=0;x2=15;y2=13;pc=#000000;pw=2;"
shape[37] = "func=line;x=111;y=190;x1=0;y1=0;x2=17;y2=13;pc=#000000;pw=2;"
shape[38] = "func=line;x=112;y=201;x1=0;y1=0;x2=14;y2=10;pc=#000000;pw=2;"
shape[39] = "func=line;x=19;y=117;x1=0;y1=0;x2=13;y2=6;pc=#000000;pw=2;"
shape[40] = "func=line;x=13;y=94;x1=4;y1=0;x2=0;y2=11;pc=#000000;pw=2;"
shape[41] = "func=line;x=17;y=94;x1=6;y1=0;x2=0;y2=16;pc=#000000;pw=2;"
shape[42] = "func=line;x=21;y=103;x1=6;y1=0;x2=0;y2=17;pc=#000000;pw=2;"
shape[43] = "func=line;x=22;y=110;x1=10;y1=0;x2=0;y2=17;pc=#000000;pw=2;"
shape[44] = "func=line;x=30;y=118;x1=4;y1=0;x2=0;y2=8;pc=#000000;pw=2;"
shape[45] = "func=line;x=153;y=130;x1=0;y1=1;x2=9;y2=0;pc=#000000;pw=2;"
shape[46] = "func=line;x=153;y=133;x1=14;y1=2;x2=0;y2=0;pc=#000000;pw=2;"
shape[47] = "func=line;x=140;y=142;x1=0;y1=3;x2=21;y2=0;pc=#000000;pw=2;"
shape[48] = "func=line;x=136;y=148;x1=0;y1=3;x2=19;y2=0;pc=#000000;pw=2;"
shape[49] = "func=line;x=138;y=155;x1=0;y1=1;x2=12;y2=0;pc=#000000;pw=2;"
shape[50] = "func=line;x=64;y=180;x1=0;y1=5;x2=13;y2=0;pc=#000000;pw=2;"
shape[51] = "func=line;x=64;y=183;x1=0;y1=7;x2=17;y2=0;pc=#000000;pw=2;"
shape[52] = "func=line;x=63;y=191;x1=0;y1=8;x2=15;y2=0;pc=#000000;pw=2;"
shape[53] = "func=line;x=60;y=197;x1=0;y1=10;x2=17;y2=0;pc=#000000;pw=2;"
shape[54] = "func=line;x=68;y=205;x1=0;y1=3;x2=7;y2=0;pc=#000000;pw=2;"
shape[55] = "func=line;x=112;y=180;x1=8;y1=0;x2=0;y2=10;pc=#000000;pw=2;"
shape[56] = "func=line;x=112;y=183;x1=13;y1=0;x2=0;y2=16;pc=#000000;pw=2;"
shape[57] = "func=line;x=114;y=192;x1=11;y1=0;x2=0;y2=12;pc=#000000;pw=2;"
shape[58] = "func=line;x=115;y=197;x1=11;y1=0;x2=0;y2=15;pc=#000000;pw=2;"
shape[59] = "func=line;x=121;y=205;x1=6;y1=0;x2=0;y2=4;pc=#000000;pw=2;"
shape[60] = "func=ell;x=119;y=143;width=30;height=29;bc=#F6D8A7;pc=#000000;pw=2;"
shape[61] = "func=ell;x=0;y=74;width=29;height=29;bc=#F6D8A7;pc=#000000;pw=2;"
shape[62] = "func=ell;x=20;y=72;width=11;height=20;bc=#F6D8A7;pc=#000000;pw=2;"
shape[63] = "func=line;x=76;y=91;x1=0;y1=8;x2=12;y2=0;pc=#000000;pw=2;"
shape[64] = "func=line;x=80;y=92;x1=0;y1=13;x2=17;y2=0;pc=#000000;pw=2;"
shape[65] = "func=line;x=84;y=93;x1=0;y1=20;x2=22;y2=0;pc=#000000;pw=2;"
shape[66] = "func=line;x=89;y=98;x1=0;y1=22;x2=23;y2=0;pc=#000000;pw=2;"
shape[67] = "func=line;x=92;y=114;x1=0;y1=12;x2=13;y2=0;pc=#000000;pw=2;"
shape[68] = "func=line;x=106;y=91;x1=0;y1=0;x2=7;y2=12;pc=#000000;pw=2;"
shape[69] = "func=line;x=98;y=92;x1=0;y1=0;x2=14;y2=12;pc=#000000;pw=2;"
shape[70] = "func=line;x=93;y=94;x1=0;y1=0;x2=13;y2=15;pc=#000000;pw=2;"
shape[71] = "func=line;x=84;y=92;x1=0;y1=0;x2=23;y2=30;pc=#000000;pw=2;"
shape[72] = "func=line;x=79;y=98;x1=0;y1=0;x2=24;y2=27;pc=#000000;pw=2;"
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