Removed Offset and refactored

This commit is contained in:
Paracelsus-Rose 2023-01-10 15:30:20 -05:00
parent fc15982b93
commit f21226bfa7
No known key found for this signature in database
GPG key ID: FAF65C0792F4524E
3 changed files with 10 additions and 20 deletions

View file

@ -226,34 +226,32 @@ func arrowheadMarker(isTarget bool, id string, connection d2target.Connection) s
}
case d2target.FilledCircleArrowhead:
attrs := fmt.Sprintf(`class="connection" fill="%s" stroke-width="%d"`, connection.Stroke, connection.StrokeWidth)
offset := 4.0 + float64(connection.StrokeWidth*2)
if isTarget {
path = fmt.Sprintf(`<circle %s cx="%f" cy="%f" r="%f"/>`,
attrs,
offset+11, height/2,
offset*1.2,
width/2+5, height/2,
width/3,
)
} else {
path = fmt.Sprintf(`<circle %s cx="%f" cy="%f" r="%f"/>`,
attrs,
offset+1, height/2,
offset*1.2,
width/2-5, height/2,
width/3,
)
}
case d2target.CircleArrowhead:
attrs := fmt.Sprintf(`class="connection" fill="white" stroke="%s" stroke-width="%d"`, connection.Stroke, connection.StrokeWidth)
offset := 4.0 + float64(connection.StrokeWidth*2)
if isTarget {
path = fmt.Sprintf(`<circle %s cx="%f" cy="%f" r="%f"/>`,
attrs,
offset+12, height/2,
offset*1.2,
width/2+5, height/2,
width/3.2,
)
} else {
path = fmt.Sprintf(`<circle %s cx="%f" cy="%f" r="%f"/>`,
attrs,
offset+4, height/2,
offset*1.2,
width/2-5, height/2,
width/3.2,
)
}
@ -310,14 +308,6 @@ func arrowheadMarker(isTarget bool, id string, connection d2target.Connection) s
refX = width/8 + 0.6*strokeWidth
}
width *= 1.1
case d2target.CircleArrowhead:
if isTarget {
refX = width - 0.6*strokeWidth
} else {
refX = width/8 + 0.6*strokeWidth
}
width *= 1.1
default:
if isTarget {
refX = width - 1.5*strokeWidth

View file

@ -39,7 +39,7 @@ width="491" height="577" viewBox="-102 -102 491 577"><style type="text/css">
svgEl.setAttribute("height", height * ratio - 16);
}
});
]]></script><g id="a"><g class="shape" ><rect x="0" y="0" width="113" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="56.500000" y="66.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">a</text></g><g id="b"><g class="shape" ><rect x="0" y="247" width="113" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="56.500000" y="313.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">b</text></g><g id="c"><g class="shape" ><rect x="174" y="0" width="113" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="230.500000" y="66.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">c</text></g><g id="d"><g class="shape" ><rect x="173" y="247" width="114" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="230.000000" y="313.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">d</text></g><g id="(a &lt;-&gt; b)[0]"><marker id="mk-2353508688" markerWidth="30.800000" markerHeight="30.000000" refX="4.700000" refY="15.000000" viewBox="0.000000 0.000000 30.800000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="white" stroke="#0D32B2" stroke-width="2" cx="12.000000" cy="15.000000" r="9.600000"/> </marker><marker id="mk-3979614975" markerWidth="30.800000" markerHeight="30.000000" refX="26.800000" refY="15.000000" viewBox="0.000000 0.000000 30.800000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="white" stroke="#0D32B2" stroke-width="2" cx="20.000000" cy="15.000000" r="9.600000"/> </marker><path d="M 56.500000 130.000000 C 56.500000 174.400000 56.500000 198.700000 56.500000 243.500000" class="connection" style="fill:none;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" marker-start="url(#mk-2353508688)" marker-end="url(#mk-3979614975)" mask="url(#1982561420)"/><text class="text-italic" x="57.000000" y="192.000000" style="text-anchor:middle;font-size:16px;fill:#676C7E">circle</text></g><g id="(c &lt;-&gt; d)[0]"><marker id="mk-174437403" markerWidth="28.000000" markerHeight="30.000000" refX="3.000000" refY="15.000000" viewBox="0.000000 0.000000 28.000000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="#0D32B2" stroke-width="2" cx="9.000000" cy="15.000000" r="9.600000"/> </marker><marker id="mk-211976278" markerWidth="28.000000" markerHeight="30.000000" refX="25.000000" refY="15.000000" viewBox="0.000000 0.000000 28.000000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="#0D32B2" stroke-width="2" cx="19.000000" cy="15.000000" r="9.600000"/> </marker><path d="M 230.000000 130.000000 C 230.000000 174.400000 230.000000 198.700000 230.000000 243.500000" class="connection" style="fill:none;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" marker-start="url(#mk-174437403)" marker-end="url(#mk-211976278)" mask="url(#1982561420)"/><text class="text-italic" x="230.500000" y="192.000000" style="text-anchor:middle;font-size:16px;fill:#676C7E">filled-circle</text></g><mask id="1982561420" maskUnits="userSpaceOnUse" x="-100" y="-100" width="491" height="577">
]]></script><g id="a"><g class="shape" ><rect x="0" y="0" width="113" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="56.500000" y="66.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">a</text></g><g id="b"><g class="shape" ><rect x="0" y="247" width="113" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="56.500000" y="313.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">b</text></g><g id="c"><g class="shape" ><rect x="174" y="0" width="113" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="230.500000" y="66.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">c</text></g><g id="d"><g class="shape" ><rect x="173" y="247" width="114" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="230.000000" y="313.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">d</text></g><g id="(a &lt;-&gt; b)[0]"><marker id="mk-2353508688" markerWidth="28.000000" markerHeight="30.000000" refX="3.000000" refY="15.000000" viewBox="0.000000 0.000000 28.000000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="white" stroke="#0D32B2" stroke-width="2" cx="9.000000" cy="15.000000" r="8.750000"/> </marker><marker id="mk-3979614975" markerWidth="28.000000" markerHeight="30.000000" refX="25.000000" refY="15.000000" viewBox="0.000000 0.000000 28.000000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="white" stroke="#0D32B2" stroke-width="2" cx="19.000000" cy="15.000000" r="8.750000"/> </marker><path d="M 56.500000 130.000000 C 56.500000 174.400000 56.500000 198.700000 56.500000 243.500000" class="connection" style="fill:none;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" marker-start="url(#mk-2353508688)" marker-end="url(#mk-3979614975)" mask="url(#1982561420)"/><text class="text-italic" x="57.000000" y="192.000000" style="text-anchor:middle;font-size:16px;fill:#676C7E">circle</text></g><g id="(c &lt;-&gt; d)[0]"><marker id="mk-174437403" markerWidth="28.000000" markerHeight="30.000000" refX="3.000000" refY="15.000000" viewBox="0.000000 0.000000 28.000000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="#0D32B2" stroke-width="2" cx="9.000000" cy="15.000000" r="9.333333"/> </marker><marker id="mk-211976278" markerWidth="28.000000" markerHeight="30.000000" refX="25.000000" refY="15.000000" viewBox="0.000000 0.000000 28.000000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="#0D32B2" stroke-width="2" cx="19.000000" cy="15.000000" r="9.333333"/> </marker><path d="M 230.000000 130.000000 C 230.000000 174.400000 230.000000 198.700000 230.000000 243.500000" class="connection" style="fill:none;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" marker-start="url(#mk-174437403)" marker-end="url(#mk-211976278)" mask="url(#1982561420)"/><text class="text-italic" x="230.500000" y="192.000000" style="text-anchor:middle;font-size:16px;fill:#676C7E">filled-circle</text></g><mask id="1982561420" maskUnits="userSpaceOnUse" x="-100" y="-100" width="491" height="577">
<rect x="-100" y="-100" width="491" height="577" fill="white"></rect>
<rect x="39.000000" y="176.000000" width="36" height="21" fill="black"></rect>
<rect x="194.000000" y="176.000000" width="73" height="21" fill="black"></rect>

Before

Width:  |  Height:  |  Size: 470 KiB

After

Width:  |  Height:  |  Size: 470 KiB

View file

@ -39,7 +39,7 @@ width="451" height="677" viewBox="-90 -90 451 677"><style type="text/css">
svgEl.setAttribute("height", height * ratio - 16);
}
});
]]></script><g id="a"><g class="shape" ><rect x="12" y="12" width="113" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="68.500000" y="78.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">a</text></g><g id="b"><g class="shape" ><rect x="12" y="359" width="113" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="68.500000" y="425.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">b</text></g><g id="c"><g class="shape" ><rect x="145" y="12" width="113" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="201.500000" y="78.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">c</text></g><g id="d"><g class="shape" ><rect x="145" y="359" width="114" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="202.000000" y="425.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">d</text></g><g id="(a &lt;-&gt; b)[0]"><marker id="mk-2353508688" markerWidth="30.800000" markerHeight="30.000000" refX="4.700000" refY="15.000000" viewBox="0.000000 0.000000 30.800000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="white" stroke="#0D32B2" stroke-width="2" cx="12.000000" cy="15.000000" r="9.600000"/> </marker><marker id="mk-3979614975" markerWidth="30.800000" markerHeight="30.000000" refX="26.800000" refY="15.000000" viewBox="0.000000 0.000000 30.800000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="white" stroke="#0D32B2" stroke-width="2" cx="20.000000" cy="15.000000" r="9.600000"/> </marker><path d="M 68.500000 142.000000 L 68.500000 355.000000" class="connection" style="fill:none;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" marker-start="url(#mk-2353508688)" marker-end="url(#mk-3979614975)" mask="url(#3604360783)"/><text class="text-italic" x="69.000000" y="254.000000" style="text-anchor:middle;font-size:16px;fill:#676C7E">circle</text></g><g id="(c &lt;-&gt; d)[0]"><marker id="mk-174437403" markerWidth="28.000000" markerHeight="30.000000" refX="3.000000" refY="15.000000" viewBox="0.000000 0.000000 28.000000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="#0D32B2" stroke-width="2" cx="9.000000" cy="15.000000" r="9.600000"/> </marker><marker id="mk-211976278" markerWidth="28.000000" markerHeight="30.000000" refX="25.000000" refY="15.000000" viewBox="0.000000 0.000000 28.000000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="#0D32B2" stroke-width="2" cx="19.000000" cy="15.000000" r="9.600000"/> </marker><path d="M 202.000000 142.000000 L 202.000000 355.000000" class="connection" style="fill:none;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" marker-start="url(#mk-174437403)" marker-end="url(#mk-211976278)" mask="url(#3604360783)"/><text class="text-italic" x="202.500000" y="254.000000" style="text-anchor:middle;font-size:16px;fill:#676C7E">filled-circle</text></g><mask id="3604360783" maskUnits="userSpaceOnUse" x="-100" y="-100" width="451" height="677">
]]></script><g id="a"><g class="shape" ><rect x="12" y="12" width="113" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="68.500000" y="78.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">a</text></g><g id="b"><g class="shape" ><rect x="12" y="359" width="113" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="68.500000" y="425.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">b</text></g><g id="c"><g class="shape" ><rect x="145" y="12" width="113" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="201.500000" y="78.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">c</text></g><g id="d"><g class="shape" ><rect x="145" y="359" width="114" height="126" style="fill:#F7F8FE;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" /></g><text class="text-bold" x="202.000000" y="425.000000" style="text-anchor:middle;font-size:16px;fill:#0A0F25">d</text></g><g id="(a &lt;-&gt; b)[0]"><marker id="mk-2353508688" markerWidth="28.000000" markerHeight="30.000000" refX="3.000000" refY="15.000000" viewBox="0.000000 0.000000 28.000000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="white" stroke="#0D32B2" stroke-width="2" cx="9.000000" cy="15.000000" r="8.750000"/> </marker><marker id="mk-3979614975" markerWidth="28.000000" markerHeight="30.000000" refX="25.000000" refY="15.000000" viewBox="0.000000 0.000000 28.000000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="white" stroke="#0D32B2" stroke-width="2" cx="19.000000" cy="15.000000" r="8.750000"/> </marker><path d="M 68.500000 142.000000 L 68.500000 355.000000" class="connection" style="fill:none;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" marker-start="url(#mk-2353508688)" marker-end="url(#mk-3979614975)" mask="url(#3604360783)"/><text class="text-italic" x="69.000000" y="254.000000" style="text-anchor:middle;font-size:16px;fill:#676C7E">circle</text></g><g id="(c &lt;-&gt; d)[0]"><marker id="mk-174437403" markerWidth="28.000000" markerHeight="30.000000" refX="3.000000" refY="15.000000" viewBox="0.000000 0.000000 28.000000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="#0D32B2" stroke-width="2" cx="9.000000" cy="15.000000" r="9.333333"/> </marker><marker id="mk-211976278" markerWidth="28.000000" markerHeight="30.000000" refX="25.000000" refY="15.000000" viewBox="0.000000 0.000000 28.000000 30.000000" orient="auto" markerUnits="userSpaceOnUse"> <circle class="connection" fill="#0D32B2" stroke-width="2" cx="19.000000" cy="15.000000" r="9.333333"/> </marker><path d="M 202.000000 142.000000 L 202.000000 355.000000" class="connection" style="fill:none;stroke:#0D32B2;opacity:1.000000;stroke-width:2;" marker-start="url(#mk-174437403)" marker-end="url(#mk-211976278)" mask="url(#3604360783)"/><text class="text-italic" x="202.500000" y="254.000000" style="text-anchor:middle;font-size:16px;fill:#676C7E">filled-circle</text></g><mask id="3604360783" maskUnits="userSpaceOnUse" x="-100" y="-100" width="451" height="677">
<rect x="-100" y="-100" width="451" height="677" fill="white"></rect>
<rect x="51.000000" y="238.000000" width="36" height="21" fill="black"></rect>
<rect x="166.000000" y="238.000000" width="73" height="21" fill="black"></rect>

Before

Width:  |  Height:  |  Size: 470 KiB

After

Width:  |  Height:  |  Size: 470 KiB