Microsoft Small Basic

Program Listing: PPF232
' Hina Dolls
' Copyright © 2015 Nonki Takahashi. The MIT License.
' 2015-02-27 0:46:30 Shapes generated by Shapes 2.1b.
'
GraphicsWindow.Title = "Hina Dolls"
SB_Workaround()
gw = 598
gh = 428
GraphicsWindow.BackgroundColor = "PeachPuff"
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.BrushColor = "#CC0000"
GraphicsWindow.FillRectangle(0, 400, gw, gh - 400)
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.FillRectangle(20, 380, (gw - 60) / 2, 20)
GraphicsWindow.FillRectangle(gw / 2 + 10, 380, (gw - 60) / 2, 20)
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(30, 350, (gw - 100) / 2, 30)
GraphicsWindow.FillRectangle(gw / 2 + 20, 350, (gw - 100) / 2, 30)
color = "1=OliveDrab;2=SaddleBrown;3=CadetBlue;4=Sienna;5=OliveDrab;"
color = color + "6=RosyBrown;7=OliveDrab;8=SaddleBrown;9=CadetBlue;"
color = color + "10=Sienna;11=OliveDrab;12=RosyBrown;13=OliveDrab;"
color = color + "14=SaddleBrown;15=CadetBlue;"
w = (gw - 104) / 30
x0 = 34
For i = 1 To 15
x = x0 + (i - 1) * w
GraphicsWindow.BrushColor = color[i]
GraphicsWindow.FillRectangle(x, 350, w - 4, 30)
EndFor
x0 = gw / 2 + 24
For i = 1 To 15
x = x0 + (i - 1) * w
GraphicsWindow.BrushColor = color[i]
GraphicsWindow.FillRectangle(x, 350, w - 4, 30)
EndFor
' initialize shapes
Shapes_Init()
' add shapes
scale = 0.5
angle = 0
iMin = 1
iMax = 94
Shapes_Add()
x = 314
y = 170
Shapes_Move()
iMin = 101
iMax = 146
Shapes_Add()
x = 20
y = 104
Shapes_Move()
Sub Shapes_Init
' Shapes | Initialize shapes data
' return shX, shY - current position of shapes
' return shape - array of shapes
shX = 48 ' x offset
shY = 40 ' y offset
shape = ""
shape[1] = "func=ell;x=0;y=243;width=528;height=110;bc=#E5CD71;pc=#D41616;pw=2;"
shape[2] = "func=ell;x=167;y=35;width=194;height=136;bc=#000000;pw=0;"
shape[3] = "func=rect;x=146;y=104;width=249;height=93;bc=PeachPuff;pw=0;"
shape[4] = "func=ell;x=167;y=80;width=194;height=50;bc=#000000;pw=0;"
shape[5] = "func=tri;x=216;y=112;x1=46;y1=0;x2=0;y2=56;x3=93;y3=56;bc=#F3E4D3;pw=0;"
shape[6] = "func=ell;x=227;y=57;width=70;height=82;bc=#FAF3EB;pw=0;"
shape[7] = "func=tri;x=253;y=53;x1=8;y1=0;x2=0;y2=20;x3=17;y3=20;angle=180;bc=#000000;pw=0;"
shape[8] = "func=rect;x=244;y=32;width=37;height=22;bc=#DEC04A;pw=0;"
shape[9] = "func=ell;x=258;y=0;width=8;height=36;bc=#DEC04A;pw=0;"
shape[10] = "func=ell;x=247;y=7;width=8;height=36;angle=326;bc=#DEC04A;pw=0;"
shape[11] = "func=ell;x=270;y=6;width=8;height=36;angle=36;bc=#DEC04A;pw=0;"
shape[12] = "func=ell;x=234;y=96;width=18;height=8;bc=#000000;pw=0;"
shape[13] = "func=ell;x=271;y=95;width=18;height=8;bc=#000000;pw=0;"
shape[14] = "func=tri;x=254;y=122;x1=8;y1=0;x2=0;y2=5;x3=17;y3=5;angle=177;bc=#D41616;pw=0;"
shape[15] = "func=rect;x=239;y=135;width=29;height=70;angle=317;bc=#FFFFFF;pc=#939393;pw=1;"
shape[16] = "func=rect;x=257;y=136;width=29;height=70;angle=43;bc=#FFFFFF;pc=#939393;pw=1;"
shape[17] = "func=rect;x=208;y=169;width=77;height=13;angle=64;bc=#EE9A5D;pc=#EA4C34;pw=2;"
shape[18] = "func=rect;x=238;y=169;width=77;height=13;angle=300;bc=#EE9A5D;pc=#EA4C34;pw=2;"
shape[19] = "func=rect;x=168;y=180;width=124;height=54;angle=68;bc=#E5CD71;pc=#D41616;pw=2;"
shape[20] = "func=rect;x=229;y=181;width=124;height=54;angle=296;bc=#E5CD71;pc=#D41616;pw=2;"
shape[21] = "func=tri;x=127;y=148;x1=52;y1=0;x2=0;y2=94;x3=105;y3=94;angle=8;bc=#ED5050;pc=#D41616;pw=2;"
shape[22] = "func=tri;x=293;y=150;x1=52;y1=0;x2=0;y2=91;x3=105;y3=91;angle=353;bc=#ED5050;pc=#D41616;pw=2;"
shape[23] = "func=ell;x=169;y=282;width=184;height=84;bc=#EA3939;pc=#D41616;pw=2;"
shape[24] = "func=rect;x=118;y=234;width=33;height=42;angle=4;bc=#EE5D5D;pc=#D41616;pw=2;"
shape[25] = "func=rect;x=374;y=234;width=33;height=42;angle=353;bc=#EE5D5D;pc=#D41616;pw=2;"
shape[26] = "func=tri;x=76;y=292;x1=81;y1=0;x2=0;y2=85;x3=163;y3=85;angle=177;bc=#E5CD71;pc=#D41616;pw=2;"
shape[27] = "func=tri;x=279;y=293;x1=81;y1=0;x2=0;y2=85;x3=163;y3=85;angle=185;bc=#E5CD71;pc=#D41616;pw=2;"
shape[28] = "func=tri;x=286;y=283;x1=78;y1=0;x2=0;y2=77;x3=156;y3=77;angle=185;bc=#EE9A5D;pc=#D41616;pw=2;"
shape[29] = "func=tri;x=80;y=280;x1=79;y1=0;x2=0;y2=79;x3=159;y3=79;angle=177;bc=#EE9A5D;pc=#D41616;pw=2;"
shape[30] = "func=tri;x=289;y=284;x1=67;y1=0;x2=0;y2=69;x3=135;y3=69;angle=185;bc=#EBC0B2;pc=#D41616;pw=2;"
shape[31] = "func=tri;x=80;y=279;x1=73;y1=0;x2=0;y2=74;x3=146;y3=74;angle=177;bc=#EBC0B2;pc=#D41616;pw=2;"
shape[32] = "func=rect;x=194;y=143;width=42;height=186;angle=354;bc=#EE5D5D;pc=#D41616;pw=2;"
shape[33] = "func=rect;x=286;y=144;width=42;height=185;angle=8;bc=#EE5D5D;pc=#D41616;pw=2;"
shape[34] = "func=rect;x=235;y=246;width=50;height=86;bc=#FFFFFF;pc=#D41616;pw=2;"
shape[35] = "func=line;x=0;y=0;x1=260;y1=276;x2=206.96;y2=222.96;pc=Khaki;pw=2;"
shape[36] = "func=rect;x=202.59;y=197.96;width=8.74;height=50;angle=-45;bc=#99EEEE;pw=0;"
shape[37] = "func=tri;x=205.68;y=194.87;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=135;bc=#99EEEE;pw=0;"
shape[38] = "func=tri;x=199.49;y=201.06;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=135;bc=#99EEEE;pw=0;"
shape[39] = "func=line;x=0;y=0;x1=260;y1=276;x2=216.98;y2=214.56;pc=Khaki;pw=2;"
shape[40] = "func=rect;x=212.6;y=189.56;width=8.74;height=50;angle=-35;bc=#99DDDD;pw=0;"
shape[41] = "func=tri;x=216.19;y=187.05;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=145;bc=#99DDDD;pw=0;"
shape[42] = "func=tri;x=209.02;y=192.07;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=145;bc=#99DDDD;pw=0;"
shape[43] = "func=line;x=0;y=0;x1=260;y1=276;x2=228.3;y2=208.02;pc=Khaki;pw=2;"
shape[44] = "func=rect;x=223.92;y=183.02;width=8.74;height=50;angle=-25;bc=#99EEEE;pw=0;"
shape[45] = "func=tri;x=227.89;y=181.17;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=155;bc=#99EEEE;pw=0;"
shape[46] = "func=tri;x=219.96;y=184.87;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=155;bc=#99EEEE;pw=0;"
shape[47] = "func=line;x=0;y=0;x1=260;y1=276;x2=240.58;y2=203.55;pc=Khaki;pw=2;"
shape[48] = "func=rect;x=236.21;y=178.55;width=8.74;height=50;angle=-15;bc=#99DDDD;pw=0;"
shape[49] = "func=tri;x=240.43;y=177.42;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=165;bc=#99DDDD;pw=0;"
shape[50] = "func=tri;x=231.98;y=179.68;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=165;bc=#99DDDD;pw=0;"
shape[51] = "func=line;x=0;y=0;x1=260;y1=276;x2=253.46;y2=201.28;pc=Khaki;pw=2;"
shape[52] = "func=rect;x=249.08;y=176.28;width=8.74;height=50;angle=-5;bc=#99EEEE;pw=0;"
shape[53] = "func=tri;x=253.44;y=175.9;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=175;bc=#99EEEE;pw=0;"
shape[54] = "func=tri;x=244.73;y=176.66;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=175;bc=#99EEEE;pw=0;"
shape[55] = "func=line;x=0;y=0;x1=260;y1=276;x2=266.53;y2=201.28;pc=Khaki;pw=2;"
shape[56] = "func=rect;x=262.16;y=176.28;width=8.74;height=50;angle=5;bc=#99DDDD;pw=0;"
shape[57] = "func=tri;x=266.52;y=176.66;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=185;bc=#99DDDD;pw=0;"
shape[58] = "func=tri;x=257.8;y=175.9;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=185;bc=#99DDDD;pw=0;"
shape[59] = "func=line;x=0;y=0;x1=260;y1=276;x2=279.41;y2=203.55;pc=Khaki;pw=2;"
shape[60] = "func=rect;x=275.03;y=178.55;width=8.74;height=50;angle=15;bc=#99EEEE;pw=0;"
shape[61] = "func=tri;x=279.26;y=179.68;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=195;bc=#99EEEE;pw=0;"
shape[62] = "func=tri;x=270.81;y=177.42;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=195;bc=#99EEEE;pw=0;"
shape[63] = "func=line;x=0;y=0;x1=260;y1=276;x2=291.69;y2=208.02;pc=Khaki;pw=2;"
shape[64] = "func=rect;x=287.32;y=183.02;width=8.74;height=50;angle=25;bc=#99DDDD;pw=0;"
shape[65] = "func=tri;x=291.28;y=184.87;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=205;bc=#99DDDD;pw=0;"
shape[66] = "func=tri;x=283.35;y=181.17;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=205;bc=#99DDDD;pw=0;"
shape[67] = "func=line;x=0;y=0;x1=260;y1=276;x2=303.01;y2=214.56;pc=Khaki;pw=2;"
shape[68] = "func=rect;x=298.64;y=189.56;width=8.74;height=50;angle=35;bc=#99EEEE;pw=0;"
shape[69] = "func=tri;x=302.22;y=192.07;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=215;bc=#99EEEE;pw=0;"
shape[70] = "func=tri;x=295.06;y=187.05;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=215;bc=#99EEEE;pw=0;"
shape[71] = "func=line;x=0;y=0;x1=260;y1=276;x2=313.03;y2=222.96;pc=Khaki;pw=2;"
shape[72] = "func=rect;x=308.65;y=197.96;width=8.74;height=50;angle=45;bc=#99DDDD;pw=0;"
shape[73] = "func=tri;x=311.75;y=201.06;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=225;bc=#99DDDD;pw=0;"
shape[74] = "func=tri;x=305.56;y=194.87;x1=4.37;y1=0;x2=0;y2=50;x3=8.74;y3=50;angle=225;bc=#99DDDD;pw=0;"
shape[75] = "func=ell;x=176;y=247;width=68;height=24;angle=352;bc=#FAF3EB;pw=0;"
shape[76] = "func=ell;x=277;y=247;width=68;height=24;angle=7;bc=#FAF3EB;pw=0;"
shape[77] = "func=ell;x=25;y=269;width=184;height=85;angle=347;bc=#EE5D5D;pc=#D41616;pw=2;"
shape[78] = "func=ell;x=321;y=271;width=174;height=83;angle=13;bc=#EE5D5D;pc=#D41616;pw=2;"
shape[79] = "func=rect;x=152;y=241;width=46;height=50;angle=6;bc=#EE9A5D;pc=#D41616;pw=2;"
shape[80] = "func=rect;x=323;y=242;width=46;height=50;angle=353;bc=#EE9A5D;pc=#D41616;pw=2;"
shape[81] = "func=rect;x=333;y=239;width=46;height=50;angle=352;bc=#E5CD71;pc=#D41616;pw=2;"
shape[82] = "func=rect;x=142;y=238;width=46;height=50;angle=6;bc=#E5CD71;pc=#D41616;pw=2;"
shape[83] = "func=ell;x=49;y=288;width=154;height=44;angle=349;bc=#EE9A5D;pc=#D41616;pw=2;"
shape[84] = "func=ell;x=317;y=287;width=154;height=44;angle=8;bc=#EE9A5D;pc=#D41616;pw=2;"
shape[85] = "func=rect;x=63;y=302;width=141;height=13;angle=347;bc=#D41616;pc=#D41616;pw=2;"
shape[86] = "func=rect;x=318;y=302;width=141;height=13;angle=10;bc=#D41616;pc=#D41616;pw=2;"
shape[87] = "func=rect;x=291;y=266;width=54;height=13;angle=82;bc=#D41616;pc=#D41616;pw=2;"
shape[88] = "func=rect;x=176;y=265;width=54;height=13;angle=277;bc=#D41616;pc=#D41616;pw=2;"
shape[89] = "func=rect;x=66;y=304;width=139;height=8;angle=347;bc=#E5CD71;pw=;"
shape[90] = "func=rect;x=320;y=304;width=136;height=9;angle=10;bc=#E5CD71;pw=;"
shape[91] = "func=rect;x=179;y=266;width=47;height=8;angle=277;bc=#E5CD71;pw=;"
shape[92] = "func=rect;x=293;y=269;width=52;height=9;angle=82;bc=#E5CD71;pw=;"
shape[93] = "func=ell;x=234;y=92;width=18;height=8;bc=#FAF3EB;pw=0;"
shape[94] = "func=ell;x=271;y=91;width=18;height=8;bc=#FAF3EB;pw=0;"
shape[101] = "func=rect;x=258;y=0;width=28;height=154;bc=#939393;pc=#000000;pw=4;"
shape[102] = "func=ell;x=228;y=230;width=14;height=21;bc=#FAF3EB;pw=0;"
shape[103] = "func=ell;x=299;y=230;width=14;height=21;bc=#FAF3EB;pw=0;"
shape[104] = "func=tri;x=166;y=282;x1=50;y1=0;x2=0;y2=148;x3=101;y3=148;angle=114;bc=#858419;pc=#9D4B10;pw=2;"
shape[105] = "func=tri;x=279;y=284;x1=51;y1=0;x2=0;y2=140;x3=103;y3=140;angle=243;bc=#858419;pc=#9D4B10;pw=2;"
shape[106] = "func=tri;x=171;y=278;x1=100;y1=0;x2=0;y2=220;x3=200;y3=220;angle=179;bc=#A8A61F;pc=#9D4B10;pw=2;"
shape[107] = "func=ell;x=232;y=177;width=79;height=76;bc=#000000;pw=0;"
shape[108] = "func=ell;x=236;y=194;width=70;height=82;bc=#FAF3EB;pc=#000000;pw=2;"
shape[109] = "func=ell;x=245;y=232;width=18;height=8;bc=#000000;pw=0;"
shape[110] = "func=ell;x=280;y=231;width=18;height=8;bc=#000000;pw=0;"
shape[111] = "func=tri;x=263;y=258;x1=8;y1=0;x2=0;y2=5;x3=17;y3=5;angle=177;bc=#EB863D;pw=0;"
shape[112] = "func=ell;x=171;y=410;width=210;height=87;bc=#858419;pc=#9D4B10;pw=2;"
shape[113] = "func=rect;x=127;y=370;width=33;height=42;angle=4;bc=#A8A61F;pc=#9D4B10;pw=2;"
shape[114] = "func=rect;x=383;y=370;width=33;height=42;angle=353;bc=#A8A61F;pc=#9D4B10;pw=2;"
shape[115] = "func=ell;x=0;y=411;width=199;height=72;angle=340;bc=#A8A61F;pc=#9D4B10;pw=2;"
shape[116] = "func=ell;x=338;y=412;width=203;height=65;angle=14;bc=#A8A61F;pc=#9D4B10;pw=2;"
shape[117] = "func=ell;x=245;y=228;width=18;height=8;bc=#FAF3EB;pw=0;"
shape[118] = "func=ell;x=280;y=227;width=18;height=8;bc=#FAF3EB;pw=0;"
shape[119] = "func=ell;x=244;y=188;width=54;height=19;bc=#000000;pc=#000000;pw=2;"
shape[120] = "func=ell;x=253;y=142;width=37;height=56;bc=#000000;pc=#000000;pw=2;"
shape[121] = "func=rect;x=236;y=169;width=70;height=6;bc=#000000;pc=#000000;pw=2;"
shape[122] = "func=rect;x=242;y=279;width=59;height=124;bc=#A8A61F;pc=#9D4B10;pw=2;"
shape[123] = "func=rect;x=246;y=273;width=52;height=16;bc=#A8A61F;pc=#9D4B10;pw=2;"
shape[124] = "func=ell;x=229;y=276;width=44;height=16;angle=340;bc=#00A8A61F;pc=#000000;pw=2;"
shape[125] = "func=ell;x=271;y=276;width=44;height=16;angle=16;bc=#00A8A61F;pc=#000000;pw=2;"
shape[126] = "func=line;x=253;y=282;x1=17;y1=0;x2=0;y2=60;pc=#000000;pw=2;"
shape[127] = "func=line;x=271;y=280;x1=0;y1=0;x2=20;y2=64;pc=#000000;pw=2;"
shape[128] = "func=rect;x=217;y=389;width=109;height=36;bc=#858419;pc=#9D4B10;pw=2;"
shape[129] = "func=rect;x=263;y=292;width=17;height=121;bc=#E5C88F;pc=#9D4B10;pw=2;"
shape[130] = "func=ell;x=199;y=380;width=68;height=24;angle=352;bc=#FAF3EB;pw=0;"
shape[131] = "func=ell;x=275;y=379;width=68;height=24;angle=7;bc=#FAF3EB;pw=0;"
shape[132] = "func=rect;x=247;y=419;width=50;height=86;bc=#D1DDC0;pc=#9D4B10;pw=2;"
shape[133] = "func=rect;x=161;y=375;width=46;height=50;angle=6;bc=#EE9A5D;pc=#D41616;pw=2;"
shape[134] = "func=rect;x=332;y=378;width=46;height=50;angle=353;bc=#EE9A5D;pc=#D41616;pw=2;"
shape[135] = "func=rect;x=342;y=375;width=46;height=50;angle=352;bc=#A8A61F;pc=#9D4B10;pw=2;"
shape[136] = "func=rect;x=151;y=374;width=46;height=50;angle=6;bc=#A8A61F;pc=#9D4B10;pw=2;"
shape[137] = "func=ell;x=323;y=422;width=154;height=44;angle=11;bc=#858419;pc=#9D4B10;pw=2;"
shape[138] = "func=rect;x=300;y=402;width=54;height=13;angle=82;bc=#71223A;pc=#71223A;pw=2;"
shape[139] = "func=ell;x=63;y=425;width=154;height=44;angle=347;bc=#858419;pc=#9D4B10;pw=2;"
shape[140] = "func=rect;x=74;y=440;width=141;height=13;angle=347;bc=#71223A;pc=#71223A;pw=2;"
shape[141] = "func=rect;x=185;y=400;width=54;height=13;angle=277;bc=#71223A;pc=#71223A;pw=2;"
shape[142] = "func=rect;x=324;y=438;width=141;height=13;angle=10;bc=#71223A;pc=#71223A;pw=2;"
shape[143] = "func=rect;x=76;y=442;width=139;height=8;angle=347;bc=#000000;pw=;"
shape[144] = "func=rect;x=188;y=405;width=47;height=8;angle=277;bc=#000000;pw=;"
shape[145] = "func=rect;x=301;y=406;width=52;height=9;angle=82;bc=#000000;pw=;"
shape[146] = "func=rect;x=327;y=440;width=136;height=9;angle=10;bc=#000000;pw=;"
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
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