Last active
May 18, 2020 08:44
-
-
Save nonkit/7d271ce5f55b21056450c8e44f1a7732 to your computer and use it in GitHub Desktop.
Small Basic Pseudo Shapes Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Shapes_CalcRotateZoomPos | |
' Shapes | calculate position for rotated and zoomed 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 | |
' param ["scale"] - zoom scale | |
' 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) * param["scale"] | |
y = r * Math.Sin(a * Math.Pi / 180) * param["scale"] | |
_cx = x + param["cx"] | |
_cy = y + param["cy"] | |
x = _cx - param["width"] / 2 | |
y = _cy - param["height"] / 2 | |
EndSub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Shapes_Convert | |
' Shapes | Convert virtual function to function | |
' return iMax | |
iMax = Array.GetItemCount(shape) | |
For i = 1 To iMax | |
shp = shape[i] | |
If shp["func"] = "hex" Then | |
If shp["name"] = "" Then | |
shp["name"] = "Hexagon" | |
EndIf | |
For j = iMax To i + 1 Step -1 | |
shape[j + 8] = shape[j] | |
EndFor | |
_x[1] = shp["x"] + shp["height"] * shp["ratio"] | |
_y[1] = shp["y"] | |
_x[2] = shp["x"] + shp["width"] - shp["height"] * shp["ratio"] | |
_y[2] = shp["y"] | |
_x[3] = shp["x"] + shp["width"] | |
_y[3] = shp["y"] + shp["height"] / 2 | |
_x[4] = shp["x"] + shp["width"] - shp["height"] * shp["ratio"] | |
_y[4] = shp["y"] + shp["height"] | |
_x[5] = shp["x"] + shp["height"] * shp["ratio"] | |
_y[5] = shp["y"] + shp["height"] | |
_x[6] = shp["x"] | |
_y[6] = shp["y"] + shp["height"] / 2 | |
For j = 1 To 6 | |
_x[j] = Math.Floor(_x[j] * 100) / 100 | |
_y[j] = Math.Floor(_y[j] * 100) / 100 | |
EndFor | |
_width = _y[5] - _y[1] | |
_height = _x[1] - _x[6] | |
x = (_x[1] + _x[6]) / 2 - _width / 2 | |
y = (_y[1] + _y[5]) / 2 - _height / 2 | |
_x1 = _width / 2 | |
_y2 = _height | |
_x3 = _width | |
_y3 = _height | |
angle = 270 | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateFill() | |
EndIf | |
shape[i] = "func=tri;x="+x+";y="+y+";x1="+_x1+";y1=0;x2=0;y2="+_y2+";x3="+_x3+";y3="+_y3+";pw=0;bc="+shp["bc"]+";angle="+angle+";name="+shp["name"]+";" | |
_width = _x[2] - _x[1] | |
_height = _y[5] - _y[1] | |
x = _x[1] | |
y = _y[1] | |
angle = 0 | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateFill() | |
EndIf | |
shape[i + 1] = "func=rect;x="+x+";y="+y+";width="+_width+";height="+_height+";pw=0;bc="+shp["bc"]+";angle="+angle+";name="+shp["name"]+";" | |
_width = _y[5] - _y[1] | |
_height = _x[1] - _x[6] | |
x = (_x[2] + _x[3]) / 2 - _width / 2 | |
y = (_y[2] + _y[4]) / 2 - _height / 2 | |
_x1 = _width / 2 | |
_y2 = _height | |
_x3 = _width | |
_y3 = _height | |
angle = 90 | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateFill() | |
EndIf | |
shape[i + 2] = "func=tri;x="+x+";y="+y+";x1="+_x1+";y1=0;x2=0;y2="+_y2+";x3="+_x3+";y3="+_y3+";pw=0;bc="+shp["bc"]+";angle="+angle+";name="+shp["name"]+";" | |
x = _x[1] | |
y = _y[1] + shp["pw"] / 2 | |
_width = _x[2] - _x[1] | |
_height = 0 | |
_x1 = 0 | |
_y1 = 0 | |
_x2 = _width | |
_y2 = _height | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateLine() | |
EndIf | |
shape[i + 3] = "func=line;x="+x+";y="+y+";x1="+_x1+";y1="+_y1+";x2="+_x2+";y2="+_y2+";pw="+shp["pw"]+";pc="+shp["pc"]+";name="+shp["name"]+";" | |
_width = _x[3] - _x[2] | |
_height = _y[3] - _y[2] | |
_a = Math.ArcTan(_width/_height) | |
x = _x[2] - shp["pw"] / 2 * Math.Cos(_a) | |
y = _y[2] + shp["pw"] / 2 * Math.Sin(_a) | |
_x1 = 0 | |
_y1 = 0 | |
_x2 = _width | |
_y2 = _height | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateLine() | |
EndIf | |
shape[i + 4] = "func=line;x="+x+";y="+y+";x1="+_x1+";y1="+_y1+";x2="+_x2+";y2="+_y2+";pw="+shp["pw"]+";pc="+shp["pc"]+";name="+shp["name"]+";" | |
_width = _x[3] - _x[4] | |
_height = _y[4] - _y[3] | |
_a = Math.ArcTan(_width/_height) | |
x = _x[4] - shp["pw"] / 2 * Math.Cos(_a) | |
y = _y[3] - shp["pw"] / 2 * Math.Sin(_a) | |
_x1 = 0 | |
_y1 = _height | |
_x2 = _width | |
_y2 = 0 | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateLine() | |
EndIf | |
shape[i + 5] = "func=line;x="+x+";y="+y+";x1="+_x1+";y1="+_y1+";x2="+_x2+";y2="+_y2+";pw="+shp["pw"]+";pc="+shp["pc"]+";name="+shp["name"]+";" | |
x = _x[5] | |
y = _y[5] - shp["pw"] / 2 | |
_width = _x[4] - _x[5] | |
_height = 0 | |
_x1 = 0 | |
_y1 = 0 | |
_x2 = _width | |
_y2 = _height | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateLine() | |
EndIf | |
shape[i + 6] = "func=line;x="+x+";y="+y+";x1="+_x1+";y1="+_y1+";x2="+_x2+";y2="+_y2+";pw="+shp["pw"]+";pc="+shp["pc"]+";name="+shp["name"]+";" | |
_width = _x[5] - _x[6] | |
_height = _y[5] - _y[6] | |
_a = Math.ArcTan(_width/_height) | |
x = _x[6] + shp["pw"] / 2 * Math.Cos(_a) | |
y = _y[6] - shp["pw"] / 2 * Math.Sin(_a) | |
_x1 = 0 | |
_y1 = 0 | |
_x2 = _width | |
_y2 = _height | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateLine() | |
EndIf | |
shape[i + 7] = "func=line;x="+x+";y="+y+";x1="+_x1+";y1="+_y1+";x2="+_x2+";y2="+_y2+";pw="+shp["pw"]+";pc="+shp["pc"]+";name="+shp["name"]+";" | |
_width = _x[1] - _x[6] | |
_height = _y[6] - _y[1] | |
_a = Math.ArcTan(_width/_height) | |
x = _x[6] + shp["pw"] / 2 * Math.Cos(_a) | |
y = _y[1] + shp["pw"] / 2 * Math.Sin(_a) | |
_x1 = 0 | |
_y1 = _height | |
_x2 = _width | |
_y2 = 0 | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateLine() | |
EndIf | |
shape[i + 8] = "func=line;x="+x+";y="+y+";x1="+_x1+";y1="+_y1+";x2="+_x2+";y2="+_y2+";pw="+shp["pw"]+";pc="+shp["pc"]+";name="+shp["name"]+";" | |
iMax = iMax + 8 | |
ElseIf shp["func"] = "trap" Then | |
If shp["name"] = "" Then | |
shp["name"] = "Trapezoid" | |
EndIf | |
For j = iMax To i + 1 Step -1 | |
shape[j + 6] = shape[j] | |
EndFor | |
_x[1] = shp["x"] + shp["height"] * shp["ratio"] | |
_y[1] = shp["y"] | |
_x[2] = shp["x"] + shp["width"] - shp["height"] * shp["ratio"] | |
_y[2] = shp["y"] | |
_x[3] = shp["x"] + shp["width"] | |
_y[3] = shp["y"] + shp["height"] | |
_x[4] = shp["x"] | |
_y[4] = shp["y"] + shp["height"] | |
_width = (_x[1] - _x[4]) * 2 | |
_height = _y[4] - _y[1] | |
x = _x[4] | |
y = _y[1] | |
_x1 = _width / 2 | |
_y2 = _height | |
_x3 = _width | |
_y3 = _height | |
angle = 0 | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateFill() | |
EndIf | |
shape[i] = "func=tri;x="+x+";y="+y+";x1="+_x1+";y1=0;x2=0;y2="+_y2+";x3="+_x3+";y3="+_y3+";angle="+angle+";pw=0;bc="+shp["bc"]+";name="+shp["name"]+";" | |
_width = _x[2] - _x[1] | |
_height = _y[4] - _y[1] | |
x = _x[1] | |
y = _y[1] | |
angle = 0 | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateFill() | |
EndIf | |
shape[i + 1] = "func=rect;x="+x+";y="+y+";width="+_width+";height="+_height+";angle="+angle+";pw=0;bc="+shp["bc"]+";name="+shp["name"]+";" | |
_width = (_x[3] - _x[2]) * 2 | |
_height = _y[3] - _y[2] | |
x = _x[2] - _width / 2 | |
y = _y[2] | |
_x1 = _width / 2 | |
_y2 = _height | |
_x3 = _width | |
_y3 = _height | |
angle = 0 | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateFill() | |
EndIf | |
shape[i + 2] = "func=tri;x="+x+";y="+y+";x1="+_x1+";y1=0;x2=0;y2="+_y2+";x3="+_x3+";y3="+_y3+";angle="+angle+";pw=0;bc="+shp["bc"]+";name="+shp["name"]+";" | |
_width = _x[2] - _x[1] | |
_height = _y[2] - _y[1] | |
x = _x[1] | |
y = _y[1] + shp["pw"] / 2 | |
_x1 = 0 | |
_y1 = 0 | |
_x2 = _width | |
_y2 = _height | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateLine() | |
EndIf | |
shape[i + 3] = "func=line;x="+x+";y="+y+";x1="+_x1+";y1="+_y1+";x2="+_x2+";y2="+_y2+";pw="+shp["pw"]+";pc="+shp["pc"]+";name="+shp["name"]+";" | |
_width = _x[3] - _x[2] | |
_height = _y[3] - _y[2] | |
_a = Math.ArcTan(_width/_height) | |
x = _x[2] - shp["pw"] / 2 * Math.Cos(_a) | |
y = _y[2] + shp["pw"] / 2 * Math.Sin(_a) | |
_x1 = 0 | |
_y1 = 0 | |
_x2 = _width | |
_y2 = _height | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateLine() | |
EndIf | |
shape[i + 4] = "func=line;x="+x+";y="+y+";x1="+_x1+";y1="+_y1+";x2="+_x2+";y2="+_y2+";pw="+shp["pw"]+";pc="+shp["pc"]+";name="+shp["name"]+";" | |
x = _x[4] | |
y = _y[4] - shp["pw"] / 2 | |
_width = _x[3] - _x[4] | |
_height = 0 | |
_x1 = 0 | |
_y1 = 0 | |
_x2 = _width | |
_y2 = _height | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateLine() | |
EndIf | |
shape[i + 5] = "func=line;x="+x+";y="+y+";x1="+_x1+";y1="+_y1+";x2="+_x2+";y2="+_y2+";pw="+shp["pw"]+";pc="+shp["pc"]+";name="+shp["name"]+";" | |
_width = _x[1] - _x[4] | |
_height = _y[4] - _y[1] | |
_a = Math.ArcTan(_width/_height) | |
x = _x[4] + shp["pw"] / 2 * Math.Cos(_a) | |
y = _y[1] + shp["pw"] / 2 * Math.Sin(_a) | |
_x1 = 0 | |
_y1 = _height | |
_x2 = _width | |
_y2 = 0 | |
If shp["angle"] <> 0 Then | |
Shapes_CalcRotateLine() | |
EndIf | |
shape[i + 6] = "func=line;x="+x+";y="+y+";x1="+_x1+";y1="+_y1+";x2="+_x2+";y2="+_y2+";pw="+shp["pw"]+";pc="+shp["pc"]+";name="+shp["name"]+";" | |
iMax = iMax + 6 | |
EndIf | |
EndFor | |
EndSub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Shapes_Dump | |
' Shapes | dump shapes data | |
order = "1=func;2=x;3=y;4=width;5=height;6=x1;7=y1;8=x2;9=y2;" | |
order = order + "10=x3;11=y3;12=text;13=fn;14=fs;15=fb;16=fi;" | |
order = order + "17=angle;18=pw;19=pc;20=bc;21=name;" | |
nOrder = Array.GetItemCount(order) | |
WQ = Text.GetCharacter(34) | |
LF = Text.GetCharacter(10) | |
gw = GraphicsWindow.Width | |
gh = GraphicsWindow.Height | |
GraphicsWindow.BrushColor = "Black" | |
GraphicsWindow.FontName = "Consolas" | |
GraphicsWindow.FontSize = 14 | |
tbox = Controls.AddMultiLineTextBox(gw / 2, 10) | |
Controls.SetSize(tbox, gw / 2 - 10, gh - 20) | |
buf = " shX = " + shX + " ' x offset" + LF | |
buf = buf + " shY = " + shY + " ' y offset" + LF | |
buf = buf + " shape = " + WQ + WQ + LF | |
For i = 1 To Array.GetItemCount(shape) | |
buf = buf + " shape[" + i + "] = " + WQ | |
shp = shape[i] | |
For j = 1 To nOrder | |
If shp[order[j]] <> "" Then | |
buf = buf + order[j] + "=" + shp[order[j]] + ";" | |
EndIf | |
EndFor | |
buf = buf + WQ + LF | |
EndFor | |
Controls.SetTextBoxText(tbox, buf) | |
Shapes.SetOpacity(tbox, 50) | |
EndSub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Shapes_Init | |
' Shapes | initialize sample shapes data | |
' return shX, shY - current position of shapes | |
' return shape - array of shapes | |
shX = 100 ' x offset | |
shY = 100 ' y offset | |
shape = "" | |
shape[1] = "func=tri;x=30;y=0;width=14;height=1;x1=7;y1=0;x2=0;y2=1;x3=14;y3=1;pw=0;bc=#F4501F;" | |
shape[2] = "func=tri;x=36;y=0;width=14;height=1;x1=7;y1=0;x2=0;y2=1;x3=14;y3=1;pw=0;bc=#7CB70A;" | |
shape[3] = "func=rect;x=37;y=0;width=3;height=1;pw=0;bc=#F4501F;" | |
shape[4] = "func=rect;x=40;y=0;width=3;height=1;pw=0;bc=#7CB70A;" | |
shape[5] = "func=tri;x=23;y=1;width=14;height=3;x1=7;y1=0;x2=0;y2=3;x3=14;y3=3;pw=0;bc=#F4501F;" | |
shape[6] = "func=tri;x=43;y=1;width=14;height=3;x1=7;y1=0;x2=0;y2=3;x3=14;y3=3;pw=0;bc=#7CB70A;" | |
shape[7] = "func=rect;x=30;y=1;width=10;height=3;pw=0;bc=#F4501F;" | |
shape[8] = "func=rect;x=40;y=1;width=10;height=3;pw=0;bc=#7CB70A;" | |
shape[9] = "func=tri;x=17;y=4;width=12;height=3;x1=6;y1=0;x2=0;y2=3;x3=12;y3=3;pw=0;bc=#F4501F;" | |
shape[10] = "func=tri;x=51;y=4;width=12;height=3;x1=6;y1=0;x2=0;y2=3;x3=12;y3=3;pw=0;bc=#7CB70A;" | |
shape[11] = "func=rect;x=23;y=4;width=17;height=3;pw=0;bc=#F4501F;" | |
shape[12] = "func=rect;x=40;y=4;width=17;height=3;pw=0;bc=#7CB70A;" | |
shape[13] = "func=tri;x=12;y=7;width=10;height=5;x1=5;y1=0;x2=0;y2=5;x3=10;y3=5;pw=0;bc=#F4501F;" | |
shape[14] = "func=tri;x=58;y=7;width=10;height=5;x1=5;y1=0;x2=0;y2=5;x3=10;y3=5;pw=0;bc=#7CB70A;" | |
shape[15] = "func=rect;x=17;y=7;width=23;height=5;pw=0;bc=#F4501F;" | |
shape[16] = "func=rect;x=40;y=7;width=23;height=5;pw=0;bc=#7CB70A;" | |
shape[17] = "func=tri;x=7;y=12;width=10;height=5;x1=5;y1=0;x2=0;y2=5;x3=10;y3=5;pw=0;bc=#F4501F;" | |
shape[18] = "func=tri;x=63;y=12;width=10;height=5;x1=5;y1=0;x2=0;y2=5;x3=10;y3=5;pw=0;bc=#7CB70A;" | |
shape[19] = "func=rect;x=12;y=12;width=28;height=5;pw=0;bc=#F4501F;" | |
shape[20] = "func=rect;x=40;y=12;width=28;height=5;pw=0;bc=#7CB70A;" | |
shape[21] = "func=tri;x=4;y=17;width=6;height=6;x1=3;y1=0;x2=0;y2=6;x3=6;y3=6;pw=0;bc=#F4501F;" | |
shape[22] = "func=tri;x=70;y=17;width=6;height=6;x1=3;y1=0;x2=0;y2=6;x3=6;y3=6;pw=0;bc=#7CB70A;" | |
shape[23] = "func=rect;x=7;y=17;width=33;height=6;pw=0;bc=#F4501F;" | |
shape[24] = "func=rect;x=40;y=17;width=33;height=6;pw=0;bc=#7CB70A;" | |
shape[25] = "func=tri;x=1;y=23;width=6;height=7;x1=3;y1=0;x2=0;y2=7;x3=6;y3=7;pw=0;bc=#F4501F;" | |
shape[26] = "func=tri;x=73;y=23;width=6;height=7;x1=3;y1=0;x2=0;y2=7;x3=6;y3=7;pw=0;bc=#7CB70A;" | |
shape[27] = "func=rect;x=4;y=23;width=36;height=7;pw=0;bc=#F4501F;" | |
shape[28] = "func=rect;x=40;y=23;width=36;height=7;pw=0;bc=#7CB70A;" | |
shape[29] = "func=tri;x=0;y=30;width=2;height=7;x1=1;y1=0;x2=0;y2=7;x3=2;y3=7;pw=0;bc=#F4501F;" | |
shape[30] = "func=tri;x=78;y=30;width=2;height=7;x1=1;y1=0;x2=0;y2=7;x3=2;y3=7;pw=0;bc=#7CB70A;" | |
shape[31] = "func=rect;x=1;y=30;width=39;height=7;pw=0;bc=#F4501F;" | |
shape[32] = "func=rect;x=40;y=30;width=39;height=7;pw=0;bc=#7CB70A;" | |
shape[33] = "func=rect;x=0;y=37;width=40;height=3;pw=0;bc=#F4501F;" | |
shape[34] = "func=rect;x=40;y=37;width=40;height=3;pw=0;bc=#7CB70A;" | |
shape[35] = "func=rect;x=0;y=40;width=40;height=3;angle=180;pw=0;bc=#03A3ED;" | |
shape[36] = "func=rect;x=40;y=40;width=40;height=3;angle=180;pw=0;bc=#FCB901;" | |
shape[37] = "func=tri;x=0;y=43;width=2;height=7;x1=1;y1=0;x2=0;y2=7;x3=2;y3=7;angle=180;pw=0;bc=#03A3ED;" | |
shape[38] = "func=tri;x=78;y=43;width=2;height=7;x1=1;y1=0;x2=0;y2=7;x3=2;y3=7;angle=180;pw=0;bc=#FCB901;" | |
shape[39] = "func=rect;x=1;y=43;width=39;height=7;angle=180;pw=0;bc=#03A3ED;" | |
shape[40] = "func=rect;x=40;y=43;width=39;height=7;angle=180;pw=0;bc=#FCB901;" | |
shape[41] = "func=tri;x=1;y=50;width=6;height=7;x1=3;y1=0;x2=0;y2=7;x3=6;y3=7;angle=180;pw=0;bc=#03A3ED;" | |
shape[42] = "func=tri;x=73;y=50;width=6;height=7;x1=3;y1=0;x2=0;y2=7;x3=6;y3=7;angle=180;pw=0;bc=#FCB901;" | |
shape[43] = "func=rect;x=4;y=50;width=36;height=7;angle=180;pw=0;bc=#03A3ED;" | |
shape[44] = "func=rect;x=40;y=50;width=36;height=7;angle=180;pw=0;bc=#FCB901;" | |
shape[45] = "func=tri;x=4;y=57;width=6;height=6;x1=3;y1=0;x2=0;y2=6;x3=6;y3=6;angle=180;pw=0;bc=#03A3ED;" | |
shape[46] = "func=tri;x=70;y=57;width=6;height=6;x1=3;y1=0;x2=0;y2=6;x3=6;y3=6;angle=180;pw=0;bc=#FCB901;" | |
shape[47] = "func=rect;x=7;y=57;width=33;height=6;angle=180;pw=0;bc=#03A3ED;" | |
shape[48] = "func=rect;x=40;y=57;width=33;height=6;angle=180;pw=0;bc=#FCB901;" | |
shape[49] = "func=tri;x=7;y=63;width=10;height=5;x1=5;y1=0;x2=0;y2=5;x3=10;y3=5;angle=180;pw=0;bc=#03A3ED;" | |
shape[50] = "func=tri;x=63;y=63;width=10;height=5;x1=5;y1=0;x2=0;y2=5;x3=10;y3=5;angle=180;pw=0;bc=#FCB901;" | |
shape[51] = "func=rect;x=12;y=63;width=28;height=5;angle=180;pw=0;bc=#03A3ED;" | |
shape[52] = "func=rect;x=40;y=63;width=28;height=5;angle=180;pw=0;bc=#FCB901;" | |
shape[53] = "func=tri;x=12;y=68;width=10;height=5;x1=5;y1=0;x2=0;y2=5;x3=10;y3=5;angle=180;pw=0;bc=#03A3ED;" | |
shape[54] = "func=tri;x=58;y=68;width=10;height=5;x1=5;y1=0;x2=0;y2=5;x3=10;y3=5;angle=180;pw=0;bc=#FCB901;" | |
shape[55] = "func=rect;x=17;y=68;width=23;height=5;angle=180;pw=0;bc=#03A3ED;" | |
shape[56] = "func=rect;x=40;y=68;width=23;height=5;angle=180;pw=0;bc=#FCB901;" | |
shape[57] = "func=tri;x=17;y=73;width=12;height=3;x1=6;y1=0;x2=0;y2=3;x3=12;y3=3;angle=180;pw=0;bc=#03A3ED;" | |
shape[58] = "func=tri;x=51;y=73;width=12;height=3;x1=6;y1=0;x2=0;y2=3;x3=12;y3=3;angle=180;pw=0;bc=#FCB901;" | |
shape[59] = "func=rect;x=23;y=73;width=17;height=3;angle=180;pw=0;bc=#03A3ED;" | |
shape[60] = "func=rect;x=40;y=73;width=17;height=3;angle=180;pw=0;bc=#FCB901;" | |
shape[61] = "func=tri;x=23;y=76;width=14;height=3;x1=7;y1=0;x2=0;y2=3;x3=14;y3=3;angle=180;pw=0;bc=#03A3ED;" | |
shape[62] = "func=tri;x=43;y=76;width=14;height=3;x1=7;y1=0;x2=0;y2=3;x3=14;y3=3;angle=180;pw=0;bc=#FCB901;" | |
shape[63] = "func=rect;x=30;y=76;width=10;height=3;angle=180;pw=0;bc=#03A3ED;" | |
shape[64] = "func=rect;x=40;y=76;width=10;height=3;angle=180;pw=0;bc=#FCB901;" | |
shape[65] = "func=tri;x=30;y=79;width=14;height=1;x1=7;y1=0;x2=0;y2=1;x3=14;y3=1;angle=180;pw=0;bc=#03A3ED;" | |
shape[66] = "func=tri;x=36;y=79;width=14;height=1;x1=7;y1=0;x2=0;y2=1;x3=14;y3=1;angle=180;pw=0;bc=#FCB901;" | |
shape[67] = "func=rect;x=37;y=79;width=3;height=1;angle=180;pw=0;bc=#03A3ED;" | |
shape[68] = "func=rect;x=40;y=79;width=3;height=1;angle=180;pw=0;bc=#FCB901;" | |
shape[69] = "func=tri;x=22;y=14;width=36;height=8;x1=18;y1=0;x2=0;y2=8;x3=36;y3=8;pw=0;bc=White;" | |
shape[70] = "func=tri;x=14;y=22;width=16;height=18;x1=8;y1=0;x2=0;y2=18;x3=16;y3=18;pw=0;bc=White;" | |
shape[71] = "func=tri;x=50;y=22;width=16;height=18;x1=8;y1=0;x2=0;y2=18;x3=16;y3=18;pw=0;bc=White;" | |
shape[72] = "func=rect;x=22;y=22;width=36;height=18;pw=0;bc=White;" | |
shape[73] = "func=tri;x=14;y=40;width=16;height=18;x1=8;y1=0;x2=0;y2=18;x3=16;y3=18;angle=180;pw=0;bc=White;" | |
shape[74] = "func=tri;x=50;y=40;width=16;height=18;x1=8;y1=0;x2=0;y2=18;x3=16;y3=18;angle=180;pw=0;bc=White;" | |
shape[75] = "func=rect;x=22;y=40;width=36;height=18;angle=180;pw=0;bc=White;" | |
shape[76] = "func=tri;x=22;y=58;width=36;height=8;x1=18;y1=0;x2=0;y2=8;x3=36;y3=8;angle=180;pw=0;bc=White;" | |
shape[77] = "func=tri;x=24;y=18;width=32;height=6;x1=16;y1=0;x2=0;y2=6;x3=32;y3=6;pw=0;bc=DimGray;" | |
shape[78] = "func=tri;x=18;y=24;width=12;height=16;x1=6;y1=0;x2=0;y2=16;x3=12;y3=16;pw=0;bc=DimGray;" | |
shape[79] = "func=tri;x=50;y=24;width=12;height=16;x1=6;y1=0;x2=0;y2=16;x3=12;y3=16;pw=0;bc=DimGray;" | |
shape[80] = "func=rect;x=24;y=24;width=32;height=16;pw=0;bc=DimGray;" | |
shape[81] = "func=tri;x=18;y=40;width=12;height=16;x1=6;y1=0;x2=0;y2=16;x3=12;y3=16;angle=180;pw=0;bc=DimGray;" | |
shape[82] = "func=tri;x=50;y=40;width=12;height=16;x1=6;y1=0;x2=0;y2=16;x3=12;y3=16;angle=180;pw=0;bc=DimGray;" | |
shape[83] = "func=rect;x=24;y=40;width=32;height=16;angle=180;pw=0;bc=DimGray;" | |
shape[84] = "func=tri;x=24;y=56;width=32;height=6;x1=16;y1=0;x2=0;y2=6;x3=32;y3=6;angle=180;pw=0;bc=DimGray;" | |
shape[85] = "func=tri;x=28;y=23;width=24;height=5;x1=12;y1=0;x2=0;y2=5;x3=24;y3=5;pw=0;bc=White;" | |
shape[86] = "func=tri;x=23;y=28;width=10;height=12;x1=5;y1=0;x2=0;y2=12;x3=10;y3=12;pw=0;bc=White;" | |
shape[87] = "func=tri;x=47;y=28;width=10;height=12;x1=5;y1=0;x2=0;y2=12;x3=10;y3=12;pw=0;bc=White;" | |
shape[88] = "func=rect;x=28;y=28;width=24;height=12;pw=0;bc=White;" | |
shape[89] = "func=tri;x=23;y=40;width=10;height=12;x1=5;y1=0;x2=0;y2=12;x3=10;y3=12;angle=180;pw=0;bc=White;" | |
shape[90] = "func=tri;x=47;y=40;width=10;height=12;x1=5;y1=0;x2=0;y2=12;x3=10;y3=12;angle=180;pw=0;bc=White;" | |
shape[91] = "func=rect;x=28;y=40;width=24;height=12;angle=180;pw=0;bc=White;" | |
shape[92] = "func=tri;x=28;y=52;width=24;height=5;x1=12;y1=0;x2=0;y2=5;x3=24;y3=5;angle=180;pw=0;bc=White;" | |
shape[93] = "func=line;x=0;y=40;width=16;height=0;x1=0;y1=0;x2=16;y2=0;pw=3.2;pc=White;" | |
shape[94] = "func=line;x=11.71;y=11.71;width=11.31;height=11.31;x1=0.00;y1=0.00;x2=11.31;y2=11.31;pw=3.2;pc=White;" | |
shape[95] = "func=line;x=40;y=0;width=0;height=16;x1=0;y1=0;x2=0;y2=16;pw=3.2;pc=White;" | |
shape[96] = "func=line;x=56.97;y=11.71;width=11.31;height=11.31;x1=11.31;y1=0.00;x2=0.00;y2=11.31;pw=3.2;pc=White;" | |
shape[97] = "func=line;x=64;y=39.99;width=16;height=0.00;x1=16;y1=0.00;x2=0;y2=0.00;pw=3.2;pc=White;" | |
shape[98] = "func=line;x=56.97;y=56.97;width=11.31;height=11.31;x1=11.31;y1=11.31;x2=0.00;y2=0.00;pw=3.2;pc=White;" | |
shape[99] = "func=line;x=40;y=64;width=0;height=16;x1=0;y1=16;x2=0;y2=0;pw=3.2;pc=White;" | |
shape[100] = "func=line;x=11.71;y=56.97;width=11.31;height=11.31;x1=0.00;y1=11.31;x2=11.31;y2=0.00;pw=3.2;pc=White;" | |
shape[101] = "func=line;x=0;y=40;width=16;height=0;x1=0;y1=0;x2=16;y2=0;pw=3.2;pc=White;" | |
shape[102] = "func=line;x=23.2;y=40;width=33.6;height=0;x1=0.0;y1=0;x2=33.6;y2=0;pw=5.6;pc=DimGray;" | |
shape[103] = "func=line;x=40;y=23.2;width=0;height=33.6;x1=0;y1=0.0;x2=0;y2=33.6;pw=14.4;pc=DimGray;" | |
shape[104] = "func=line;x=40;y=14.4;width=0;height=51.2;x1=0;y1=0.0;x2=0;y2=51.2;pw=3.2;pc=White;" | |
shape[105] = "func=line;x=31.2;y=35.6;width=8.8;height=0.0;x1=0.0;y1=0.0;x2=8.8;y2=0.0;pw=3.2;pc=White;" | |
shape[106] = "func=line;x=17.6;y=44.4;width=8.8;height=0.0;x1=0.0;y1=0.0;x2=8.8;y2=0.0;pw=3.2;pc=White;" | |
EndSub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Shapes_Line2Rect | |
' Shapes | convert line to rectangle | |
For i = 1 To Array.GetItemCount(shape) | |
shp = shape[i] | |
If shp["func"] = "line" Then | |
x1 = shp["x1"] | |
y1 = shp["y1"] | |
x2 = shp["x2"] | |
y2 = shp["y2"] | |
height = shp["pw"] | |
bc = shp["pc"] | |
x = x2 - x1 | |
y = y2 - y1 | |
Math_CartesianToPolar() | |
width = r | |
angle = a | |
xo = (x1 + x2) / 2 | |
yo = (y1 + y2) / 2 | |
x = xo - width / 2 | |
y = yo - height / 2 | |
shp["func"] = "rect" | |
shp["x1"] = "" | |
shp["y1"] = "" | |
shp["x2"] = "" | |
shp["y2"] = "" | |
shp["pw"] = "0" | |
shp["pc"] = "" | |
shp["x"] = Math.Round(x * 100) / 100 | |
shp["y"] = Math.Round(y * 100) / 100 | |
shp["width"] = Math.Round(width * 100) / 100 | |
shp["height"] = Math.Round(height * 100) / 100 | |
shp["bc"] = bc | |
shp["angle"] = Math.Round(angle * 100) / 100 | |
shape[i] = shp | |
EndIf | |
EndFor | |
EndSub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Shapes_Normalize | |
' Shapes | normalize shapes data | |
iMax = Array.GetItemCount(shape) | |
For i = 1 To iMax | |
shp = shape[i] | |
If Text.IsSubText("line|tri", shp["func"]) Then | |
xmin = shp["x1"] | |
ymin = shp["y1"] | |
If shp["x2"] < xmin Then | |
xmin = shp["x2"] | |
EndIf | |
If shp["y2"] < ymin Then | |
ymin = shp["y2"] | |
EndIf | |
If shp["func"] = "tri" Then | |
If shp["x3"] < xmin Then | |
xmin = shp["x3"] | |
EndIf | |
If shp["y3"] < ymin Then | |
ymin = shp["y3"] | |
EndIf | |
shp["x3"] = shp["x3"] - xmin | |
shp["y3"] = shp["y3"] - ymin | |
EndIf | |
shp["x"] = shp["x"] + xmin | |
shp["y"] = shp["y"] + ymin | |
shp["x1"] = shp["x1"] - xmin | |
shp["y1"] = shp["y1"] - ymin | |
shp["x2"] = shp["x2"] - xmin | |
shp["y2"] = shp["y2"] - ymin | |
shape[i] = shp | |
EndIf | |
EndFor | |
If 0 < iMax Then | |
shp = shape[1] | |
xmin = shp["x"] | |
ymin = shp["y"] | |
xmax = shp["x"] | |
ymax = shp["y"] | |
EndIf | |
For i = 2 To iMax | |
shp = shape[i] | |
If shp["x"] < xmin Then | |
xmin = shp["x"] | |
EndIf | |
If shp["y"] < ymin Then | |
ymin = shp["y"] | |
EndIf | |
If xmax < shp["x"] Then | |
xmax = shp["x"] | |
EndIf | |
If ymax < shp["y"] Then | |
ymax = shp["y"] | |
EndIf | |
EndFor | |
shX = shX + xmin | |
shY = shY + ymin | |
For i = 1 To iMax | |
shp = shape[i] | |
shp["x"] = shp["x"] - xmin | |
shp["y"] = shp["y"] - ymin | |
If shp["angle"] = 0 Then | |
shp["angle"] = "" | |
EndIf | |
shape[i] = shp | |
EndFor | |
EndSub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
revised
Shapes_CalcRotateZoomPos
as https://gist.github.com/nonkitMac/cb3125cf320342bdfe7bb71fabd81f67