2016-04-20 18 views
0

例如,有一張圖片顯示一條線上有一些短線陣列。
enter image description here
我知道我可以爲這樣的代碼:如何讓Android path對SVG模式產生影響

mPaint.setColor(context.getResources().getColor(R.color.MAIN_CONTOUR_LINE_YELLOW)); 
mPaint.setStyle(Paint.Style.STROKE); 
Path effectPath = new Path(); 
      effectPath.addRect(0,0.75f,0.21f,0.75f, 
        Path.Direction.CCW); 
      mPaint.setPathEffect(
        new PathDashPathEffect(
          effectPath, 0.96f, 0, 
          PathDashPathEffect.Style.MORPH)); 

stemPaint.setColor(context.getResources().getColor(R.color.MAIN_CONTOUR_LINE_YELLOW)); 
    stemPaint.setStyle(Paint.Style.STROKE);//the stem line 

所以我們可以看到,我們還沒有實際計算,每一個短線位於。但在一個特定的專業繪圖軟件,圖片輸出爲SVG,這裏是我打開它作爲文本

<polyline fill="none" stroke="#D47A00" stroke-width="1.05" stroke-linejoin="bevel" stroke-miterlimit="10" points="253,412.9 
340.8,396.8 343,445.5 "/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="254" y1="412.7" x2="254.4" y2="415"/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="255.9" y1="412.3" x2="256.3" y2="414.6"/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="257.9" y1="412" x2="258.3" y2="414.2"/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="259.8" y1="411.6" x2="260.2" y2="413.9"/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="261.8" y1="411.3" x2="262.1" y2="413.5"/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="263.7" y1="410.9" x2="264.1" y2="413.2"/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="265.7" y1="410.5" x2="266.1" y2="412.8"/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="267.6" y1="410.2" x2="268" y2="412.5"/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="269.6" y1="409.8" x2="270" y2="412.1"/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="271.5" y1="409.5" x2="271.9" y2="411.7"/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="273.5" y1="409.1" x2="273.9" y2="411.4"/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="275.4" y1="408.7" x2="275.8" y2="411"/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="277.4" y1="408.4" x2="277.8" y2="410.7"/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="279.3" y1="408" x2="279.7" y2="410.3"/> 
<line fill="none" stroke="#D47A00" stroke-width="0.6" stroke-linejoin="bevel" stroke-miterlimit="10" x1="281.3" y1="407.7" x2="281.7" y2="409.9"/> 

<line>比上面居然超過2或3次,我在這裏將其刪除。 我已經知道<polyline>是幹線,我知道<path>與它的l,m,c字符的手段。
那麼,我如何讓效果路徑轉換爲svg文件和相反?

回答

0

你已經擁有的是關於你能做的最好的。

但是,您可以通過添加偏移線和應用適當的破折號模式來進行僞裝。這雖然不是一個很好的通用解決方案。

<svg viewBox="0 0 100 60"> 
 
    <polyline fill="none" stroke="#D47A00" stroke-width="1.05" stroke-linejoin="bevel" stroke-miterlimit="10" points="3,22.9 
 
90.8,6.8 93,55.5 "/> 
 
    <polyline fill="none" stroke="#D47A00" stroke-width="4" points="3,20.9 
 
90.8,4.8" stroke-dasharray="0 1 0.5 1"/> 
 
    <polyline fill="none" stroke="#D47A00" stroke-width="4" points="92.8,5.8 95,55.5 " stroke-dasharray="0 1 0.5 1"/> 
 
</svg>

+0

它看起來像我以前PathEffect didnt任何意義,我終於去計算每一個短線或點一個接一個。 –

+0

無論如何,非常感謝我的回答(雖然我真的不想接受它。順便說一下!你知道我該如何建立一個標準的svg文件格式,or.ai,.eps,.tiff。 –

+0

我我不知道你的意思是「建立一個文件格式」 –

相關問題