2012-07-27 71 views
6

我在地點之間畫了一條線。其成功吸引了。當我們看到地圖時,當下一個拖影的前景看起來,畫線看起來像是像素化的。如何合併線?在android上的地點之間繪製平滑線

enter image description here

我的代碼是在這裏,

@Override 
public void draw(Canvas canvas, MapView mapview, boolean shadow) { 
    super.draw(canvas, mapview, shadow); 
    if(! routeIsActive) return; 

    mapview.getProjection().toPixels(locpoint, pp);  // Converts GeoPoint to screen pixels 

    int xoff = 0; 
    int yoff = 0; 
    int oldx = pp.x; 
    int oldy = pp.y; 
    int newx = oldx + xoff; 
    int newy = oldy + yoff; 

    paint.setAntiAlias(true); 
    paint.setDither(true); 
      paint.setStrokeWidth(7); 
    for(int i=0; i<numberRoutePoints-1; i++) 
    { 
     switch(routeMode.get(i)) 
     { 
     case 0: 
      paint.setColor(Color.parseColor("#666666")); 
      break; 
     case 1: 
      paint.setColor(Color.parseColor("#0EA7D6")); 
      break; 
     case 2: 
      paint.setColor(Color.parseColor("#654321")); 
      break; 
     case 3: 
      paint.setColor(Color.parseColor("#123456")); 
      break; 
     } 

     mapview.getProjection().toPixels(routePoints.get(i), pold); 
     oldx = pold.x; 
     oldy = pold.y; 
     mapview.getProjection().toPixels(routePoints.get(i+1), pnew); 
     newx = pnew.x; 
     newy = pnew.y; 

     canvas.drawLine(oldx, oldy, newx, newy, paint); 
    } 

} 

回答

3

你應該改變噴漆的對象的風格是這樣的:

paint.setStrokeCap(Cap.ROUND); 
+0

Hi @AndyRes。多謝,夥計。它的工作正常。 – RVG 2012-07-27 13:50:19

2

如果繪製在開始一個圓圈,每一行的末尾(圓直徑必須行高),我認爲它會這樣的伎倆也許畫布的drawRoundRect可以做得很好

相關問題