2017-03-23 109 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官方文档的补充......也许。