Microsoft Small Basic

Program Listing: NLF834-0
' Draco / Quadrantids
' Version 0.2
' りゅう / しぶんぎ座流星群
' Copyright © 2017 Nonki Takahashi. The MIT License.
' Program ID NLF834-0
' Update 2017-04-18
'
' Reference:
' http://en.wikipedia.org/wiki/List_of_stars_in_Draco

SB_Workaround()

title = "Quadrantids"
Init()
' initialize shapes
Shapes_Init()
' add shapes
scale = 1
angle = 0
iMin = 1
iMax = 134
Shapes_Add()
r = 500 ' [px]
delay = 100 ' [ms]
Cal_Init()
InitStars()
ra = radiant["ra"]
dec = radiant["dec"]
Mapping()
rot = ra
tilt = dec + 15
GraphicsWindow.Title = title + " | RA=" + (Math.Round(ra * 100) / 100) + "h Dec=" + dec + "°"
DrawRA()
DrawDec()
DrawStars()
DrawCalendar()
DrawMeteorShower()
While "True"
If keyDown Then
If key = "Right" Then
rot = rot + 0.25
If 24 <= rot Then
rot = rot - 24
EndIf
ElseIf key = "Left" Then
rot = rot - 0.25
If rot < 0 Then
rot = rot + 24
EndIf
ElseIf key = "Up" Then
If tilt <= 85 Then
tilt = tilt + 5
EndIf
ElseIf key = "Down" Then
If -85 <= tilt Then
tilt = tilt - 5
EndIf
ElseIf key = "Add" Then
r = r * 1.2
ElseIf key = "Subtract" Then
r = r / 1.2
EndIf
GraphicsWindow.Title = title + " RA=" + rot + "h Dec=" + tilt + "°"
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.FillRectangle(0, 0, gw, gh)
DrawRA()
DrawDec()
DrawStars()
keyDown = "False"
EndIf
Program.Delay(delay)
EndWhile

Sub DrawDec
GraphicsWindow.PenWidth = 1
GraphicsWindow.PenColor = "#666666"
For dec = -80 To 80 Step 10
For ra = 0 To 24 Step 0.2
Mapping()
If 0 < ra Then
DrawLine()
EndIf
xLast = x
yLast = y
zLast = z
EndFor
EndFor
EndSub

Sub DrawRA
GraphicsWindow.PenWidth = 1
GraphicsWindow.PenColor = "#666666"
For ra = 0 To 23
For dec = -90 To 90 Step 5
Mapping()
If -90 < dec Then
DrawLine()
EndIf
xLast = x
yLast = y
zLast = z
EndFor
EndFor
EndSub

Sub DrawCalendar
GraphicsWindow.BrushColor = "White"
If silverlight Then
Program.Delay(msWait)
EndIf
GraphicsWindow.FontSize = 30
txt = Shapes.AddText(months[month])
Shapes.Move(txt, monthX, monthY)
If silverlight Then
Program.Delay(msWait)
EndIf
GraphicsWindow.FontSize = 40
txt = Shapes.AddText(year)
Shapes.Move(txt, monthX, monthY + 30)
sBuf = year + "," + month
Command_GetArgs()
iYear = sArg[1]
if iYear = "" Then
Goto lEnd
Endif
If Math.Remainder(iYear, 4) = 0 And Math.Remainder(iYear, 100) > 0 Or Math.Remainder(iYear, 400) = 0 Then
iDoM[2] = iDoM[2] + 1
Endif
iNoL = Math.Floor((iYear - 1) / 4) - Math.Floor((iYear - 1) / 100) + Math.Floor((iYear - 1) / 400) ' number of leap year
iWoY = Math.Remainder((iYear + iNoL), 7) ' week of year
iMonth = sArg[2]
If iMonth = "" Then
iM0 = 1
iM1 = 12
Else
iM0 = iMonth
iM1 = iMonth
Endif
iDoY = 0 ' days of year
iNoM = 1 ' number of month
For iM = iM0 To iM1
While iNoM < iM
iDoY = iDoY + iDoM[iNoM]
iNoM = iNoM + 1
EndWhile
Cal_DrawMonth()
EndFor
lEnd:
EndSub

Sub DrawLine
visible = "False"
If 0 <= z And 0 <= zLast Then
If 0 <= x And x < gw And 0 <= y And y < gh Then
visible = "True"
ElseIf 0 <= xLast And xLast < gw And 0 <= yLast And yLast < gh Then
visible = "True"
EndIf
EndIf
If visible Then
GraphicsWindow.DrawLine(xLast, yLast, x, y)
EndIf
EndSub

Sub DrawMeteorShower
ra = radiant["RA"]
dec = radiant["Dec"]
Mapping()
rx = x
ry = y
GraphicsWindow.PenWidth = 1
GraphicsWindow.PenColor = "White"
While "True"
Program.Delay(2000)
angle = Math.GetRandomNumber(360)
_a = Math.GetRadians(angle)
r1 = Math.GetRandomNumber(100) + 50
r2 = r1 * 2.5
x1 = rx + r1 * Math.Sin(_a)
y1 = ry - r1 * Math.Cos(_a)
x2 = rx + r2 * Math.Sin(_a)
y2 = ry - r2 * Math.Cos(_a)
meteor = Shapes.AddLine(x1, y1, x2, y2)
For op = 100 To 0 Step -5
Shapes.SetOpacity(meteor, op)
Program.Delay(50)
EndFor
Shapes.Remove(meteor)
EndWhile
EndSub

Sub DrawStars
GraphicsWindow.PenWidth = 1
GraphicsWindow.PenColor = "MidnightBlue"
n = Array.GetItemCount(edge)
index = Array.GetAllIndices(edge)
For i = 1 To n
e = edge[index[i]]
m = Text.GetIndexOf(e, "-")
ra = star[Text.GetSubText(e, 1, m - 1)]["RA"]
dec = star[Text.GetSubText(e, 1, m - 1)]["Dec"]
Mapping()
x1 = x
y1 = y
z1 = z
ra = star[Text.GetSubTextToEnd(e, m + 1)]["RA"]
dec = star[Text.GetSubTextToEnd(e, m + 1)]["Dec"]
Mapping()
x2 = x
y2 = y
z2 = z
If connect[index[i]] <> "" Then
Shapes.Remove(connect[index[i]])
connect[index[i]] = ""
EndIf
visible = "False"
If 0 <= z1 And 0 <= z2 Then
If 0 <= x1 And x1 <= gw And 0 <= y1 And y1 <= gh Then
visible = "True"
ElseIf 0 <= x2 And x2 <= gw And 0 <= y2 And y2 <= gh Then
visible = "True"
EndIf
If visible Then
connect[index[i]] = Shapes.AddLine(x1, y1, x2, y2)
EndIf
EndIf
EndFor
GraphicsWindow.PenWidth = 0
GraphicsWindow.BrushColor = "White"
n = Array.GetItemCount(star)
index = Array.GetAllIndices(star)
For i = 1 To n
ra = star[index[i]]["ra"]
dec = star[index[i]]["dec"]
Mapping()
If ell[index[i]] <> "" Then
Shapes.Remove(ell[index[i]])
ell[index[i]] = ""
EndIf
If 0 <= z Then
mag = star[index[i]]["mag"]
d = 16 / mag
ell[index[i]] = Shapes.AddEllipse(d, d)
Shapes.Move(ell[index[i]], x - d / 2, y - d / 2)
EndIf
EndFor
EndSub

Sub Init
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.BackgroundColor = "Black"
ox = gw / 2
oy = gh * 0.4
rot = 0 ' rotation
tilt = 0
monthX = 40
monthY = gh - 150
calendarX = gw - 270
calendarY = gh - 150
year = 2017
month = 1
GraphicsWindow.KeyDown = OnKeyDown
EndSub

Sub InitStars
' Initialize stars in Draco
' index: Name of the star
' RA (Right ascension), Dec (Declination), Mag (Apparent magnitude),
' FD Flamsteed designation
star["γ Dra"] = "ra=17 56 36.38;dec=+51 29 20.2;mag=2.24;fd=33;"
star["η Dra"] = "ra=16 23 59.51;dec=+61 30 50.7;mag=2.73;fd=14;"
star["β Dra"] = "ra=17 30 25.98;dec=+52 18 04.9;mag=2.79;fd=23;"
star["δ Dra"] = "ra=19 12 33.15;dec=+67 39 40.7;mag=3.07;fd=57;"
star["ζ Dra"] = "ra=17 08 47.23;dec=+65 42 52.7;mag=3.17;fd=22;"
star["ι Dra"] = "ra=15 24 55.78;dec=+58 57 57.7;mag=3.29;fd=12;"
star["χ Dra"] = "ra=18 21 02.34;dec=+72 44 01.3;mag=3.55;fd=44;"
star["Thuban"] = "ra=14 04 23.43;dec=+64 22 32.9;mag=3.67;fd=11;" ' α
star["ξ Dra"] = "ra=17 53 31.63;dec=+56 52 20.8;mag=3.73;fd=32;"
star["λ Dra"] = "ra=11 31 24.29;dec=+69 19 52.0;mag=3.82;fd=1;"
star["ε Dra"] = "ra=19 48 10.21;dec=+70 16 04.2;mag=3.84;fd=63;"
star["κ Dra"] = "ra=12 33 29.04;dec=+69 47 17.6;mag=3.85;fd=5;"
star["θ Dra"] = "ra=16 01 53.70;dec=+58 33 52.0;mag=4.01;fd=13;"
star["φ Dra"] = "ra=18 20 45.44;dec=+71 20 15.8;mag=4.22;fd=43;"
star["HD 81817"] = "ra=09 37 05.35;dec=+81 19 35.1;mag=4.28;"
star["τ Dra"] = "ra=19 15 33.29;dec=+73 21 18.8;mag=4.45;fd=60;"
star["ρ Dra"] = "ra=20 02 49.05;dec=+67 52 24.4;mag=4.51;fd=67;"
star["ψ1 Dra A"] = "ra=17 41 56.31;dec=+72 08 58.2;mag=4.57;fd=31;"
star["CU Dra"] = "ra=13 51 25.94;dec=+64 43 23.8;mag=4.58;fd=10;"
star["π Dra"] = "ra=19 20 40.07;dec=+65 42 51.9;mag=4.60;fd=58;"
star["ο Dra"] = "ra=18 51 12.01;dec=+59 23 17.8;mag=4.63;fd=47;"
star["σ Dra"] = "ra=19 32 20.59;dec=+69 39 55.4;mag=4.67;fd=61;"
star["ω Dra"] = "ra=17 36 57.09;dec=+68 45 25.9;mag=4.77;fd=28;"
star["45 Dra"] = "ra=18 32 34.52;dec=+57 02 44.2;mag=4.77;fd=45;"
star["42 Dra"] = "ra=18 25 58.99;dec=+65 33 48.8;mag=4.82;fd=42;"
star["υ Dra"] = "ra=18 54 23.77;dec=+71 17 49.5;mag=4.82;fd=52;"
star["18 Dra"] = "ra=16 40 55.12;dec=+64 35 20.7;mag=4.84;fd=18;"
star["HD 151613"] = "ra=16 45 17.79;dec=+56 46 54.1;mag=4.84;"
star["HD 91190"] = "ra=10 35 05.59;dec=+75 42 46.7;mag=4.86;"
star["ν2 Dra"] = "ra=17 32 15.88;dec=+55 10 22.1;mag=4.86;fd=25;"
star["19 Dra"] = "ra=16 56 01.36;dec=+65 08 04.8;mag=4.88;fd=19;"
star["ν1 Dra"] = "ra=17 32 10.42;dec=+55 11 02.8;mag=4.89;fd=24;"
star["μ Dra A"] = "ra=17 05 20.18;dec=+54 28 11.5;mag=4.91;fd=21;"
star["HD 175535"] = "ra=18 53 13.54;dec=+50 42 29.8;mag=4.92;"
star["15 Dra"] = "ra=16 27 59.05;dec=+68 46 05.0;mag=4.94;fd=15;"
star["6 Dra"] = "ra=12 34 44.07;dec=+70 01 18.4;mag=4.95;fd=6;"
star["CL Dra"] = "ra=15 57 47.59;dec=+54 44 58.2;mag=4.96;"
star["39 Dra"] = "ra=18 23 54.65;dec=+58 48 02.1;mag=4.98;fd=39;"
star["36 Dra"] = "ra=18 13 53.36;dec=+64 23 49.9;mag=4.99;fd=36;"
star["54 Dra"] = "ra=19 13 55.16;dec=+57 42 18.9;mag=5.00;fd=54;"
star["CQ Dra"] = "ra=12 30 06.76;dec=+69 12 04.5;mag=5.01;fd=4;"
star["30 Dra"] = "ra=17 49 04.33;dec=+50 46 50.0;mag=5.02;fd=30;"
star["35 Dra"] = "ra=17 49 26.94;dec=+76 57 44.2;mag=5.02;fd=35;"
star["46 Dra"] = "ra=18 42 37.96;dec=+55 32 21.8;mag=5.03;fd=46;"
star["17 Dra"] = "ra=16 36 13.73;dec=+52 55 27.7;mag=5.07;fd=17;"
star["27 Dra"] = "ra=17 31 57.89;dec=+68 08 04.9;mag=5.07;fd=27;"
star["59 Dra"] = "ra=19 09 09.75;dec=+76 33 38.9;mag=5.11;fd=59;"
star["53 Dra"] = "ra=19 11 40.52;dec=+56 51 32.7;mag=5.13;fd=53;"
star["AF Dra"] = "ra=20 31 30.40;dec=+74 57 16.8;mag=5.18;fd=73;"
star["2 Dra"] = "ra=11 36 02.62;dec=+69 19 23.7;mag=5.19;fd=2;"
star["64 Dra"] = "ra=20 01 28.53;dec=+64 49 15.6;mag=5.22;fd=64;"
star["8 Dra"] = "ra=12 55 28.56;dec=+65 26 18.8;mag=5.23;fd=8;"
star["26 Dra"] = "ra=17 34 59.25;dec=+61 52 33.0;mag=5.23;fd=26;"
star["3 Dra"] = "ra=11 42 28.43;dec=+66 44 41.3;mag=5.32;fd=3;"
star["9 Dra"] = "ra=12 59 55.28;dec=+66 35 50.3;mag=5.37;fd=9;"
star["50 Dra"] = "ra=18 46 22.26;dec=+75 26 01.7;mag=5.37;fd=50;"
star["75 Dra"] = "ra=20 28 14.45;dec=+81 25 21.6;mag=5.38;fd=75;"
star["LV Dra"] = "ra=19 00 13.67;dec=+50 32 00.5;mag=5.39;"
star["51 Dra"] = "ra=19 04 55.17;dec=+53 23 47.8;mag=5.40;fd=51;"
star["66 Dra"] = "ra=20 05 32.73;dec=+61 59 42.9;mag=5.40;fd=66;"
star["7 Dra"] = "ra=12 47 34.34;dec=+66 47 25.1;mag=5.43;fd=7;"
star["ψ2 Dra"] = "ra=17 55 11.14;dec=+72 00 18.5;mag=5.43;fd=34;"
star["49 Dra"] = "ra=19 00 43.47;dec=+55 39 29.9;mag=5.51;fd=49;"
star["16 Dra"] = "ra=16 36 11.43;dec=+52 53 59.9;mag=5.53;fd=16;"
star["AC Dra"] = "ra=20 20 05.98;dec=+68 52 48.9;mag=5.59;"
star["48 Dra"] = "ra=18 56 45.08;dec=+57 48 54.0;mag=5.67;fd=48;"
star["68 Dra"] = "ra=20 11 34.74;dec=+62 04 42.1;mag=5.70;fd=68;"
star["DE Dra"] = "ra=20 19 36.70;dec=+62 15 26.7;mag=5.71;fd=71;"
star["41 Dra"] = "ra=18 00 09.07;dec=+80 00 13.7;mag=5.74;fd=41;"
star["DQ Dra"] = "ra=16 24 25.33;dec=+55 12 18.2;mag=5.75;"
star["76 Dra"] = "ra=20 42 35.10;dec=+82 31 52.0;mag=5.75;fd=76;"
star["μ Dra B"] = "ra=17 05 19.70;dec=+54 28 13.0;mag=5.80;fd=21;"
star["ψ1 Dra B"] = "ra=17 41 58.04;dec=+72 09 27.3;mag=5.81;fd=31;"
star["CX Dra"] = "ra=18 46 43.08;dec=+52 59 16.7;mag=5.91;"
star["HD 193664"] = "ra=20 17 30.63;dec=+66 51 10.7;mag=5.91;"
star["37 Dra"] = "ra=18 15 17.05;dec=+68 45 21.5;mag=5.96;fd=37;"
star["74 Dra"] = "ra=20 29 27.31;dec=+81 05 26.7;mag=5.96;fd=74;"
star["HD 139357"] = "ra=15 35 16.22;dec=+53 55 19.7;mag=5.97;"
star["HD 113337"] = "ra=13 01 47.15;dec=+63 36 36.6;mag=6.01;"
star["40 Dra"] = "ra=18 00 03.37;dec=+80 00 01.9;mag=6.11;fd=40;"
star["69 Dra"] = "ra=19 59 36.69;dec=+76 28 53.5;mag=6.20;fd=69;"
star["UX Dra"] = "ra=19 21 35.53;dec=+76 33 34.6;mag=6.22;"
star["DL Dra"] = "ra=14 42 03.16;dec=+61 15 43.2;mag=6.24;"
star["ER Dra"] = "ra=14 31 42.87;dec=+60 13 32.1;mag=6.26;"
star["55 Dra"] = "ra=19 09 45.80;dec=+65 58 42.4;mag=6.26;fd=55;"
star["65 Dra"] = "ra=20 02 20.16;dec=+64 38 03.8;mag=6.27;fd=65;"
star["DK Dra"] = "ra=12 15 41.51;dec=+72 33 04.5;mag=6.29;"
star["VW Dra"] = "ra=17 16 29.45;dec=+60 40 14.1;mag=6.32;"
star["CN Dra"] = "ra=19 46 44.66;dec=+68 26 16.8;mag=6.34;"
star["20 Dra"] = "ra=16 56 25.32;dec=+65 02 20.6;mag=6.40;fd=20;"
star["17 Dra"] = "ra=16 36 14.10;dec=+52 55 27.0;mag=6.53;fd=17;"
star["29 Dra"] = "ra=17 32 41.35;dec=+74 13 38.2;mag=6.61;fd=29;"
star["RY Dra"] = "ra=12 56 25.89;dec=+65 59 39.9;mag=6.63;"
star["HD 143105"] = "ra=15 53 37.0s;dec=+68 43 12″;mag=6.75;"
star["38 Dra"] = "ra=18 16 58.77;dec=+68 44 30.1;mag=6.79;fd=38;"
edge = "1=γ Dra-β Dra;2=β Dra-ν2 Dra;3=γ Dra-ξ Dra;4=ξ Dra-ν2 Dra;"
edge = edge + "5=ξ Dra-δ Dra;6=δ Dra-ε Dra;7=ε Dra-τ Dra;"
edge = edge + "8=τ Dra-χ Dra;9=χ Dra-ζ Dra;10=ζ Dra-η Dra;"
edge = edge + "11=η Dra-θ Dra;12=θ Dra-ι Dra;13=ι Dra-Thuban;"
edge = edge + "14=Thuban-κ Dra;15=κ Dra-λ Dra;"
radiant = "ra=15 20 00.00;dec=+49 00 00.0;"
EndSub

Sub Mapping
' param ra - right asension [h]
' param rot - rotation [h]
' param dec - declination [deg]
' param tilt - tilt [deg]
' param r - radius [px]
' return x, y - position in the graphics window [px]
' return z - visible if 0 <= z
If Text.IsSubText(ra, " ") Then
_ra = Text.GetSubText(ra, 1, 2)
_ra = _ra + Text.GetSubText(ra, 4, 2) / 60
_ra = _ra + Text.GetSubText(ra, 7, 5) / 3600
ra = _ra
EndIf
If Text.IsSubText(dec, " ") Then
_dec = Text.GetSubText(dec, 2, 2)
_dec = _dec + Text.GetSubText(dec, 5, 2) / 60
_dec = _dec + Text.GetSubText(dec, 8, 5) / 3600
_dec = _dec * Text.Append(Text.GetSubText(dec, 1, 1), "1")
dec = _dec
EndIf
φ = Math.GetRadians((ra - rot) * 15)
θ = Math.GetRadians(dec)
x = ox - r * Math.Sin(φ) * Math.Cos(θ)
y = oy - r * Math.Sin(θ)
z = r * Math.Cos(φ) * Math.Cos(θ)
If tilt <> 0 Then
_z = z
_y = y - oy
τ = Math.GetRadians(tilt)
z = Math.Cos(τ) * _z - Math.Sin(τ) * _y
y = oy + Math.Sin(τ) * _z + Math.Cos(τ) * _y
EndIf
EndSub

Sub OnKeyDown
keyDown = "True"
key = GraphicsWindow.LastKey
EndSub

Sub Cal_Init
' Calendar | Initialize days of month
WQ = Text.GetCharacter(34)
CRLF = Text.GetCharacter(13) + Text.GetCharacter(10)
iDoM = "1=31;2=28;3=31;4=30;5=31;6=30;7=31;8=31;9=30;10=31;11=30;12=31;"
months = "1=January;2=February;3=March;4=April;5=May;6=June;7=July;"
months = months + "8=August;9=September;10=October;11=November;12=December;"
symbols = "1=♑;2=♒;3=♓;4=♈;5=♉;6=♊;7=♋;8=♌;9=♍;10=♎;11=♏;12=♐;"
EndSub

Sub Cal_DrawMonth
' Calendar | Print month
' param iM - month
' param iDoY - days of year
' param iWoY - week of year
If silverlight Then
Program.Delay(msWait)
EndIf
GraphicsWindow.FontSize = 16
GraphicsWindow.FontName = "Consolas"
iW = Math.Remainder((iDoY + iWoY), 7)
line = "SUN MON TUE WED THU FRI SAT" + CRLF
iWoM = 0
While iWoM < iW
line = line + " "
iWoM = iWoM + 1
EndWhile
For iD = 1 To iDoM[iM]
If iD < 10 Then
line = line + " " + iD + " "
Else
line = line + " " + iD + " "
EndIf
If Math.Remainder(iWoM, 7) = 6 Then
line = line + CRLF
EndIf
iWoM = iWoM + 1
EndFor
If Math.Remainder(iWoM, 7) > 0 Then
line = line + CRLF
EndIf
cal = Shapes.AddText(line)
Shapes.Move(cal, calendarX, calendarY)
EndSub

Sub Command_GetArgs
' Command line | Get arguments
' param sBuf - input buffer
' return sArg[] - arguments
' return iN - number of arguments
iP = 1 ' buffer pointer
iN = 1 ' number of args
iC = Text.GetIndexOf(sBuf, ",") ' index of comma
While iC > iP
sArg[iN] = Text.GetSubText(sBuf, iP, iC - iP)
iP = iC + 1
iN = iN + 1
iC = Text.GetIndexOf(sBuf, ",")
EndWhile
iE = Text.GetLength(sBuf) + 1 ' end of buffer
sArg[iN] = Text.GetSubText(sBuf, iP, iE - iP)
EndSub

Sub Shapes_Init
' Shapes | Initialize shapes data
' return shX, shY - current position of shapes
' return shape - array of shapes
shX = 68 ' x offset
shY = 7 ' y offset
shape = ""
shape[1] = "func=ell;x=66;y=237;width=15;height=15;bc=#CC3300;pw=0;"
shape[2] = "func=ell;x=97;y=221;width=15;height=16;bc=#CC3300;pw=0;"
shape[3] = "func=rect;x=23;y=124;width=45;height=14;angle=334;bc=#CC3300;pw=0;"
shape[4] = "func=rect;x=65;y=128;width=45;height=14;angle=17;bc=#CC3300;pw=0;"
shape[5] = "func=rect;x=240;y=154;width=45;height=14;angle=47;bc=#CC3300;pw=0;"
shape[6] = "func=rect;x=276;y=160;width=45;height=14;angle=354;bc=#CC3300;pw=0;"
shape[7] = "func=rect;x=13;y=142;width=14;height=28;angle=351;bc=#CC3300;pw=0;"
shape[8] = "func=rect;x=100;y=138;width=14;height=28;bc=#CC3300;pw=0;"
shape[9] = "func=rect;x=226;y=141;width=14;height=28;angle=37;bc=#CC3300;pw=0;"
shape[10] = "func=rect;x=316;y=172;width=14;height=28;bc=#CC3300;pw=0;"
shape[11] = "func=ell;x=9;y=133;width=21;height=21;bc=#CC3300;pw=0;"
shape[12] = "func=ell;x=95;y=131;width=21;height=21;bc=#CC3300;pw=0;"
shape[13] = "func=ell;x=233;y=135;width=21;height=21;bc=#CC3300;pw=0;"
shape[14] = "func=ell;x=313;y=154;width=21;height=21;bc=#CC3300;pw=0;"
shape[15] = "func=ell;x=12;y=166;width=21;height=15;bc=#CC3300;pw=0;"
shape[16] = "func=ell;x=96;y=163;width=21;height=15;bc=#CC3300;pw=0;"
shape[17] = "func=ell;x=211;y=161;width=21;height=15;bc=#CC3300;pw=0;"
shape[18] = "func=ell;x=310;y=193;width=21;height=15;bc=#CC3300;pw=0;"
shape[19] = "func=tri;x=14;y=174;x1=5;y1=0;x2=0;y2=31;x3=11;y3=31;angle=182;bc=#CC3300;pw=0;"
shape[20] = "func=tri;x=96;y=174;x1=5;y1=0;x2=0;y2=31;x3=11;y3=31;angle=182;bc=#CC3300;pw=0;"
shape[21] = "func=tri;x=207;y=166;x1=5;y1=0;x2=0;y2=31;x3=11;y3=31;angle=206;bc=#CC3300;pw=0;"
shape[22] = "func=tri;x=309;y=201;x1=5;y1=0;x2=0;y2=31;x3=11;y3=31;angle=182;bc=#CC3300;pw=0;"
shape[23] = "func=tri;x=0;y=168;x1=5;y1=0;x2=0;y2=31;x3=11;y3=31;angle=229;bc=#CC3300;pw=0;"
shape[24] = "func=tri;x=83;y=165;x1=5;y1=0;x2=0;y2=31;x3=11;y3=31;angle=229;bc=#CC3300;pw=0;"
shape[25] = "func=tri;x=198;y=158;x1=5;y1=0;x2=0;y2=31;x3=11;y3=31;angle=249;bc=#CC3300;pw=0;"
shape[26] = "func=tri;x=297;y=195;x1=5;y1=0;x2=0;y2=31;x3=11;y3=31;angle=234;bc=#CC3300;pw=0;"
shape[27] = "func=tri;x=27;y=168;x1=5;y1=0;x2=0;y2=31;x3=11;y3=31;angle=144;bc=#CC3300;pw=0;"
shape[28] = "func=tri;x=111;y=167;x1=5;y1=0;x2=0;y2=31;x3=11;y3=31;angle=145;bc=#CC3300;pw=0;"
shape[29] = "func=tri;x=226;y=163;x1=5;y1=0;x2=0;y2=31;x3=11;y3=31;angle=140;bc=#CC3300;pw=0;"
shape[30] = "func=tri;x=325;y=200;x1=5;y1=0;x2=0;y2=31;x3=11;y3=31;angle=141;bc=#CC3300;pw=0;"
shape[31] = "func=ell;x=40.9;y=165.17;width=39.66;height=39.66;bc=#CC3300;pw=0;"
shape[32] = "func=ell;x=40.01;y=148.26;width=39.33;height=39.33;bc=#CC3300;pw=0;"
shape[33] = "func=ell;x=39.33;y=132.27;width=39;height=39;bc=#CC3300;pw=0;"
shape[34] = "func=ell;x=38.89;y=117.19;width=38.66;height=38.66;bc=#CC3300;pw=0;"
shape[35] = "func=ell;x=38.69;y=103.03;width=38.33;height=38.33;bc=#CC3300;pw=0;"
shape[36] = "func=ell;x=38.76;y=89.79;width=38;height=38;bc=#CC3300;pw=0;"
shape[37] = "func=ell;x=39.11;y=77.47;width=37.66;height=37.66;bc=#CC3300;pw=0;"
shape[38] = "func=ell;x=39.76;y=66.07;width=37.33;height=37.33;bc=#CC3300;pw=0;"
shape[39] = "func=ell;x=40.73;y=55.59;width=37;height=37;bc=#CC3300;pw=0;"
shape[40] = "func=ell;x=42.04;y=46.04;width=36.66;height=36.66;bc=#CC3300;pw=0;"
shape[41] = "func=ell;x=43.69;y=37.4;width=36.33;height=36.33;bc=#CC3300;pw=0;"
shape[42] = "func=ell;x=45.72;y=29.69;width=36;height=36;bc=#CC3300;pw=0;"
shape[43] = "func=ell;x=48.14;y=22.9;width=35.66;height=35.66;bc=#CC3300;pw=0;"
shape[44] = "func=ell;x=50.96;y=17.04;width=35.33;height=35.33;bc=#CC3300;pw=0;"
shape[45] = "func=ell;x=54.2;y=12.1;width=35;height=35;bc=#CC3300;pw=0;"
shape[46] = "func=ell;x=57.88;y=8.09;width=34.66;height=34.66;bc=#CC3300;pw=0;"
shape[47] = "func=ell;x=62.01;y=5.01;width=34.33;height=34.33;bc=#CC3300;pw=0;"
shape[48] = "func=ell;x=66.62;y=2.85;width=34;height=34;bc=#CC3300;pw=0;"
shape[49] = "func=ell;x=71.72;y=1.63;width=33.66;height=33.66;bc=#CC3300;pw=0;"
shape[50] = "func=ell;x=77.33;y=1.33;width=33.33;height=33.33;bc=#CC3300;pw=0;"
shape[51] = "func=ell;x=83.34;y=2.62;width=33;height=33;bc=#CC3300;pw=0;"
shape[52] = "func=ell;x=88.79;y=6.58;width=32.66;height=32.66;bc=#CC3300;pw=0;"
shape[53] = "func=ell;x=93.76;y=12.9;width=32.33;height=32.33;bc=#CC3300;pw=0;"
shape[54] = "func=ell;x=98.35;y=21.3;width=32;height=32;bc=#CC3300;pw=0;"
shape[55] = "func=ell;x=102.63;y=31.47;width=31.66;height=31.66;bc=#CC3300;pw=0;"
shape[56] = "func=ell;x=106.7;y=43.13;width=31.33;height=31.33;bc=#CC3300;pw=0;"
shape[57] = "func=ell;x=110.63;y=55.99;width=31;height=31;bc=#CC3300;pw=0;"
shape[58] = "func=ell;x=114.52;y=69.73;width=30.66;height=30.66;bc=#CC3300;pw=0;"
shape[59] = "func=ell;x=118.44;y=84.08;width=30.33;height=30.33;bc=#CC3300;pw=0;"
shape[60] = "func=ell;x=122.5;y=98.75;width=30;height=30;bc=#CC3300;pw=0;"
shape[61] = "func=ell;x=126.76;y=113.42;width=29.66;height=29.66;bc=#CC3300;pw=0;"
shape[62] = "func=ell;x=131.31;y=127.82;width=29.33;height=29.33;bc=#CC3300;pw=0;"
shape[63] = "func=ell;x=136.25;y=141.64;width=29;height=29;bc=#CC3300;pw=0;"
shape[64] = "func=ell;x=141.65;y=154.6;width=28.66;height=28.66;bc=#CC3300;pw=0;"
shape[65] = "func=ell;x=147.61;y=166.39;width=28.33;height=28.33;bc=#CC3300;pw=0;"
shape[66] = "func=ell;x=154.2;y=176.73;width=28;height=28;bc=#CC3300;pw=0;"
shape[67] = "func=ell;x=161.52;y=185.32;width=27.66;height=27.66;bc=#CC3300;pw=0;"
shape[68] = "func=ell;x=169.64;y=191.87;width=27.33;height=27.33;bc=#CC3300;pw=0;"
shape[69] = "func=ell;x=178.66;y=196.08;width=27;height=27;bc=#CC3300;pw=0;"
shape[70] = "func=ell;x=188.66;y=197.66;width=26.66;height=26.66;bc=#CC3300;pw=0;"
shape[71] = "func=ell;x=197.85;y=196.16;width=26.33;height=26.33;bc=#CC3300;pw=0;"
shape[72] = "func=ell;x=207.07;y=193.21;width=26;height=26;bc=#CC3300;pw=0;"
shape[73] = "func=ell;x=216.32;y=188.94;width=25.66;height=25.66;bc=#CC3300;pw=0;"
shape[74] = "func=ell;x=225.59;y=183.48;width=25.33;height=25.33;bc=#CC3300;pw=0;"
shape[75] = "func=ell;x=234.87;y=176.95;width=25;height=25;bc=#CC3300;pw=0;"
shape[76] = "func=ell;x=244.15;y=169.47;width=24.66;height=24.66;bc=#CC3300;pw=0;"
shape[77] = "func=ell;x=253.42;y=161.19;width=24.33;height=24.33;bc=#CC3300;pw=0;"
shape[78] = "func=ell;x=262.67;y=152.21;width=24;height=24;bc=#CC3300;pw=0;"
shape[79] = "func=ell;x=271.89;y=142.67;width=23.66;height=23.66;bc=#CC3300;pw=0;"
shape[80] = "func=ell;x=281.08;y=132.7;width=23.33;height=23.33;bc=#CC3300;pw=0;"
shape[81] = "func=ell;x=290.22;y=122.42;width=23;height=23;bc=#CC3300;pw=0;"
shape[82] = "func=ell;x=299.31;y=111.97;width=22.66;height=22.66;bc=#CC3300;pw=0;"
shape[83] = "func=ell;x=308.34;y=101.45;width=22.33;height=22.33;bc=#CC3300;pw=0;"
shape[84] = "func=ell;x=317.29;y=91.01;width=22;height=22;bc=#CC3300;pw=0;"
shape[85] = "func=ell;x=326.16;y=80.77;width=21.66;height=21.66;bc=#CC3300;pw=0;"
shape[86] = "func=ell;x=334.94;y=70.86;width=21.33;height=21.33;bc=#CC3300;pw=0;"
shape[87] = "func=ell;x=343.63;y=61.39;width=21;height=21;bc=#CC3300;pw=0;"
shape[88] = "func=ell;x=352.2;y=52.51;width=20.66;height=20.66;bc=#CC3300;pw=0;"
shape[89] = "func=ell;x=360.66;y=44.34;width=20.33;height=20.33;bc=#CC3300;pw=0;"
shape[90] = "func=ell;x=369;y=37;width=20;height=20;bc=#CC3300;pw=0;"
shape[91] = "func=tri;x=83;y=201;x1=1;y1=0;x2=0;y2=2;x3=2;y3=2;bc=#CC3300;pw=0;"
shape[92] = "func=tri;x=62;y=206;x1=5;y1=0;x2=0;y2=12;x3=10;y3=12;angle=68;bc=#666666;pw=0;"
shape[93] = "func=tri;x=66;y=217;x1=5;y1=0;x2=0;y2=12;x3=10;y3=12;angle=68;bc=#666666;pw=0;"
shape[94] = "func=tri;x=71;y=227;x1=5;y1=0;x2=0;y2=12;x3=10;y3=12;angle=68;bc=#666666;pw=0;"
shape[95] = "func=tri;x=69;y=210;x1=5;y1=0;x2=0;y2=12;x3=10;y3=12;angle=229;bc=#666666;pw=0;"
shape[96] = "func=tri;x=78;y=219;x1=5;y1=0;x2=0;y2=12;x3=10;y3=12;angle=229;bc=#666666;pw=0;"
shape[97] = "func=tri;x=86;y=229;x1=5;y1=0;x2=0;y2=12;x3=10;y3=12;angle=229;bc=#666666;pw=0;"
shape[98] = "func=ell;x=58;y=181;width=17;height=16;bc=#000000;pw=0;"
shape[99] = "func=tri;x=68;y=150;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=86;bc=#CC0000;pw=0;"
shape[100] = "func=tri;x=65;y=131;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=86;bc=#CC0000;pw=0;"
shape[101] = "func=tri;x=62;y=109;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=86;bc=#CC0000;pw=0;"
shape[102] = "func=tri;x=59;y=86;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=86;bc=#CC0000;pw=0;"
shape[103] = "func=tri;x=57;y=62;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=86;bc=#CC0000;pw=0;"
shape[104] = "func=tri;x=57;y=38;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=95;bc=#CC0000;pw=0;"
shape[105] = "func=tri;x=59;y=16;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=111;bc=#CC0000;pw=0;"
shape[106] = "func=tri;x=70;y=3;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=140;bc=#CC0000;pw=0;"
shape[107] = "func=tri;x=101;y=0;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=53;bc=#CC0000;pw=0;"
shape[108] = "func=tri;x=115;y=16;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=58;bc=#CC0000;pw=0;"
shape[109] = "func=tri;x=126;y=35;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=73;bc=#CC0000;pw=0;"
shape[110] = "func=tri;x=134;y=55;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=73;bc=#CC0000;pw=0;"
shape[111] = "func=tri;x=140;y=78;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=73;bc=#CC0000;pw=0;"
shape[112] = "func=tri;x=146;y=99;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=73;bc=#CC0000;pw=0;"
shape[113] = "func=tri;x=152;y=120;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=73;bc=#CC0000;pw=0;"
shape[114] = "func=tri;x=159;y=140;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=73;bc=#CC0000;pw=0;"
shape[115] = "func=tri;x=169;y=166;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=57;bc=#CC0000;pw=0;"
shape[116] = "func=tri;x=181;y=182;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=34;bc=#CC0000;pw=0;"
shape[117] = "func=tri;x=195;y=190;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=3;bc=#CC0000;pw=0;"
shape[118] = "func=tri;x=216;y=183;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=330;bc=#CC0000;pw=0;"
shape[119] = "func=tri;x=232;y=170;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=317;bc=#CC0000;pw=0;"
shape[120] = "func=tri;x=247;y=156;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=317;bc=#CC0000;pw=0;"
shape[121] = "func=tri;x=264;y=143;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=317;bc=#CC0000;pw=0;"
shape[122] = "func=tri;x=281;y=126;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=308;bc=#CC0000;pw=0;"
shape[123] = "func=tri;x=296;y=110;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=308;bc=#CC0000;pw=0;"
shape[124] = "func=tri;x=309;y=94;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=308;bc=#CC0000;pw=0;"
shape[125] = "func=tri;x=322;y=78;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=308;bc=#CC0000;pw=0;"
shape[126] = "func=tri;x=335;y=63;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=308;bc=#CC0000;pw=0;"
shape[127] = "func=tri;x=349;y=48;x1=8;y1=0;x2=0;y2=12;x3=16;y3=12;angle=308;bc=#CC0000;pw=0;"
shape[128] = "func=tri;x=50;y=148;x1=5;y1=0;x2=0;y2=19;x3=10;y3=19;angle=348;bc=#CC0000;pw=0;"
shape[129] = "func=tri;x=38;y=154;x1=5;y1=0;x2=0;y2=19;x3=10;y3=19;angle=321;bc=#CC0000;pw=0;"
shape[130] = "func=tri;x=29;y=166;x1=5;y1=0;x2=0;y2=19;x3=10;y3=19;angle=296;bc=#CC0000;pw=0;"
shape[131] = "func=tri;x=64;y=183;x1=5;y1=0;x2=0;y2=13;x3=10;y3=13;angle=251;bc=#006144;pw=0;"
shape[132] = "func=ell;x=60;y=179;width=26;height=11;angle=84;bc=#CC3300;pw=0;"
shape[133] = "func=rect;x=79;y=189;width=15;height=48;angle=317;bc=#CC3300;pw=0;"
shape[134] = "func=rect;x=57;y=196;width=12;height=52;angle=338;bc=#CC3300;pw=0;"
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