2017-03-23 41 views
0

在我的應用程序中,我繪製了一條波浪線來說明滑音。繪製一條波浪線可以修剪

但是,正如圖像中所見,「波浪」的一部分正在被截斷。 enter image description here

這是我如何創建線。

  1. 創建一個波浪「戳」路徑
  2. 創建PathDashPathEffect對象,傳遞「郵票」路徑
  3. 設置繪圖方式到行(的moveTo和LineTo等)創建路徑中風
  4. 設置波浪風格Paint.setPathEffect
  5. 劃清界線路徑

由於Paint.setStrokeWidth對PathDashPathEffect對象不起作用,因此我無法使用它來更正此問題。

有誰知道爲什麼我的波浪線的開始越來越像這樣剪輯?

更重要的是,如何解決這個問題?


繼鋁的各種要求,這裏是繪圖代碼:

//---------------------------------------------------------- 
// creation of the wave stamp 
m_StampPath = new Path(); 
m_StampPath.moveTo(0.0f, 6.86f * fScaling); 
m_StampPath.cubicTo(10.29f * fScaling, -1.68f * fScaling, 
        10.99f * fScaling, -1.40f * fScaling, 
        17.29f * fScaling, 2.66f * fScaling); 
m_StampPath.cubicTo(21.91f * fScaling, 6.86f * fScaling, 
        24.08f * fScaling, 6.72f * fScaling, 
        28.56f * fScaling, 2.66f * fScaling); 
m_StampPath.lineTo(28.56f * fScaling, 4.76f * fScaling); 
m_StampPath.cubicTo(17.78f * fScaling, 13.44f * fScaling, 
        17.08f * fScaling, 12.25f * fScaling, 
        11.90f * fScaling, 8.33f * fScaling); 
m_StampPath.cubicTo(6.37f * fScaling, 4.41f * fScaling, 
        4.62f * fScaling, 4.76f * fScaling, 
        0.0f, 8.96f * fScaling); 
m_StampPath.lineTo(0.0f, 6.86f * fScaling); 

fStampOffset = 23.5f * fScaling; 
m_fTextOffset = -8.96f * fScaling; 
m_WavyLine = new PathDashPathEffect(m_StampPath, fStampOffset, 0.0f, PathDashPathEffect.Style.MORPH); 

//-------------------------------------------------------- 
// drawing the line 
m_GlissandoPath = new Path(); 
m_GlissandoPath.moveTo(m_ptStart.x, m_ptStart.y); 
m_GlissandoPath.lineTo(m_ptEnd.x, m_ptEnd.y); 

oldStyle = pt.getStyle(); 
pt.setStyle(Paint.Style.STROKE); 
cv.drawPath(m_GlissandoPath, pt); 

// remove the path effect 
pt.setPathEffect(null); 
+1

您應該顯示執行繪圖的代碼。 –

回答

0

好吧,這裏是我做了什麼來解決這個問題。

看來pathdashpatheffect中存在一個錯誤,因爲如果「行」從左上到右下,它將正確呈現。

但是,如果線從左下角向右上角,則會剪切。

解決此問題的方法是設置與郵票高度對應的筆觸寬度。

現在所有正常工作。

這可能是Google官方文檔的補充......也許。