2017-01-13 28 views
-1

編輯如何內紅色矩形

這裏提出這個多邊形是小提琴 - https://jsfiddle.net/Ldvj15dk/1/

誰不工作創造了這個樹圖,現在我需要如下顯示移動這個多邊形這名僱員..但我不確定這樣做的最簡單方法是什麼...

我應該做些什麼改變來將這個多邊形轉換成三角形,如圖片中所示?

<svg width="100%" height="510"> 
 
\t <g transform="translate(650,150)"> 
 
\t \t <g transform="translate(0,100)"> 
 
\t \t \t <g> 
 
\t \t \t \t <rect x="-150" y="-14.9" width="300" height="30" style="fill: blue"/> 
 
\t \t \t \t <text dx="-135" dy="0.3" text-anchor="start" style="fill: white"> 
 
\t \t \t \t \t <tspan x="-10" dy="0.3em">Test Node</tspan> 
 
\t \t \t \t </text> 
 
\t \t \t </g><g> 
 
\t \t \t \t <rect x="125" y="-15" width="25" height="30" style="fill: red;"/> 
 
\t \t \t \t <polygon points="9.7,8.814 9.7,8.902 8.15,8.082 8.15,6.31 6.912,6.31 6.912,3.98 8.975,3.98 8.975,0 4.025,0 4.025,3.98 6.088,3.98 6.088,6.31 4.85,6.31 4.85,8.104 3.3,8.916 3.3,8.814 0,8.814 0,12 3.3,12 3.3,9.82 4.85,9.01 4.85,9.494 8.15,9.494 8.15,8.99 9.7,9.811 9.7,12 13,12 13,8.814 " style="fill: yellow;"/> 
 
\t \t \t </g> 
 
\t \t </g> 
 
\t </g> 
 
</svg>

我想使它看起來像這樣,

http://image.prntscr.com/image/0b3cdab34bbc4fc5a27ffaa3f67ceb43.png

+0

[拖拽元素和Resizables在SVG(的可能的複製http://stackoverflow.com/questions/3614200/draggables-and-resizables -in-svg) –

+0

是的,這是可能的。 – ntgCleaner

+0

由於OP請求對非現場資源提出建議,因此被標記爲脫離主題。 – Jayx

回答

1

的最簡單和最懶的解決方案是簡單地轉換多邊形到所需的位置。下面是(使用幻數)的一個例子:

<svg width="100%" height="200"> 
 
\t <g transform="translate(150,50)"> 
 
\t \t <g transform="translate(0,0)"> 
 
\t \t \t <g> 
 
\t \t \t \t <rect x="-150" y="-14.9" width="300" height="30" style="fill: blue"/> 
 
\t \t \t \t <text dx="-135" dy="0.3" text-anchor="start" style="fill: white"> 
 
\t \t \t \t \t <tspan x="-10" dy="0.3em">Test Node</tspan> 
 
\t \t \t \t </text> 
 
\t \t \t </g><g> 
 
\t \t \t \t <rect x="125" y="-15" width="25" height="30" style="fill: red;"/> 
 
\t \t \t \t <polygon transform="translate(130,-4)" points="9.7,8.814 9.7,8.902 8.15,8.082 8.15,6.31 6.912,6.31 6.912,3.98 8.975,3.98 8.975,0 4.025,0 4.025,3.98 6.088,3.98 6.088,6.31 4.85,6.31 4.85,8.104 3.3,8.916 3.3,8.814 0,8.814 0,12 3.3,12 3.3,9.82 4.85,9.01 4.85,9.494 8.15,9.494 8.15,8.99 9.7,9.811 9.7,12 13,12 13,8.814 " style="fill: yellow;"/> 
 
\t \t \t </g> 
 
\t \t </g> 
 
\t </g> 
 
</svg>