画出一条波浪线会被修剪掉

时间:2017-03-23 19:27:16

标签: android path

在我的应用程序中,我画了一条波浪线来说明glissandos。

然而,部分“波浪”正在被修剪,如图中所示。 enter image description here

以下是我创建这条线的方法。

  1. 创建一条波浪形的“邮票”路径
  2. 创建一个PathDashPathEffect对象,传入'stamp'路径
  3. 为该行创建路径(moveTo和lineTo)
  4. 将绘画样式设置为STROKE
  5. 使用Paint.setPathEffect
  6. 设置波浪样式
  7. 绘制直线路径
  8. 由于Paint.setStrokeWidth对PathDashPathEffect对象没有影响,我无法用它来纠正这个问题。

    有谁知道为什么我的波浪线开始像这样被削减?

    更重要的是,如何解决这个问题?

    根据Al的请求,这是绘图代码:

    //----------------------------------------------------------
    // 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 :(得分:0)

好的,这是我为解决这个问题所做的工作。

看来pathdashpatheffect中存在一个错误,如果“line”从左上角到右下角,它将正确呈现。

但是,如果线条从左下角向右上升,它将会剪辑。

此问题的解决方案是设置与图章高度相对应的笔触宽度。

现在一切正常。

这可能是官方Google文档的补充......也许。

相关问题