2013-08-23 53 views
1

enter image description here增加中風寬度使用PathDashPathEffect

在圖像中的最後一行是使用PathDashPathEffect繪製繪製。我用下面的代碼來繪製這一行。

mPaint = new Paint(); 
     mPaint.setAntiAlias(true); 
     mPaint.setDither(true); 
     mPaint.setColor(color); 
     //  mPaint.setAlpha(120); 
     mPaint.setStyle(Paint.Style.STROKE); 
     mPaint.setStrokeJoin(Paint.Join.ROUND); 
     mPaint.setStrokeCap(Paint.Cap.ROUND); 
     mPaint.setStrokeWidth(6.0f); 

     cornerpatheffect = new CornerPathEffect(10); 
     pathdashpath = new PathDashPathEffect(makePathDash(), 10, 3, 
       PathDashPathEffect.Style.MORPH); 
     patheffect = new ComposePathEffect(cornerpatheffect, pathdashpath); 
     mPaint.setPathEffect(pathdashpath); 


private Path makePathDash() { 
     Path p = new Path(); 
     p.moveTo(-6, 9/2); 
     p.lineTo(6,9/2); 
     p.lineTo(6,9/2-1); 
     p.lineTo(-6, 9/2-1); 
     p.close(); 
     p.moveTo(-6, -(9/2)); 
     p.lineTo(6,-(9/2)); 
     p.lineTo(6, -(9/2-1)); 
     p.lineTo(-6, -(9/2-1)); 
     return p; 
    } 

有什麼辦法可以增加兩條線的筆觸寬度。對於您的信息,setstrokewidth方法不適用於PathDashPathEffect。任何人都可以請幫我嗎?

回答

0

我不知道如果你仍然需要的答案,

是的,你只需要改變的座標如下:

private Path makePathDash() { 
     Path p = new Path(); 
     p.moveTo(-6, 9/2); 
     p.lineTo(6,9/2); 
     p.lineTo(6,9/2-2); 
     p.lineTo(-6, 9/2-2); 
     p.close(); 
     p.moveTo(-6, -(9/2)); 
     p.lineTo(6,-(9/2)); 
     p.lineTo(6, -(9/2-2)); 
     p.lineTo(-6, -(9/2-2)); 
     return p; 
    } 

和變化(-2)至(-3)有更厚的...