[英]Drawing an empty polygon given a set of points on a Map Overylay (Android 2.1)
I've set of n
points and I want to draw a n-sided
polygon using these points. 我设置了
n
个点,我想用这些点绘制一个n-sided
多边形。
I tried using android.graphics.path (please see below). 我尝试使用android.graphics.path(请参见下文)。
Path path = new Path();
Vertex currVtx;
for (int j = 0; j < vertices.size(); j++) {
currVtx = vertices.get(j);
if (!currVtx.hasLatLong())
continue;
Point currentScreenPoint = getScreenPointFromGeoPoint(
currVtx, mapview);
if (j == 0)
path.moveTo(currentScreenPoint.x, currentScreenPoint.y);
// vertex.
else
path.lineTo(currentScreenPoint.x, currentScreenPoint.y);
}
Currently I'm getting a solid (filled with the color of the canvas) polygon with this code. 目前,我正在使用此代码获得一个实体(填充了画布的颜色)多边形。 Is there a way that I can get an unfilled polygon.
有没有办法可以得到一个未填充的多边形。 There is an alternative to
android.graphics.Path
android.graphics.Path
还有一个替代方案
Thanks. 谢谢。
Define a Paint object: 定义Paint对象:
Paint mPaint = new Paint();
mPaint.setStrokeWidth(2); //2 pixel line width
mPaint.setColor(0xFF097286); //tealish with no transparency
mPaint.setStyle(Paint.Style.STROKE); //stroked, aka a line with no fill
mPaint.setAntiAlias(true); // no jagged edges, etc.
Then draw the path with: 然后绘制路径:
yourCanvas.drawPath(path,mPaint);
You can look up the paint documentation but there are tons of options to control how its drawn. 你可以查看油漆文档,但有很多选项可以控制它的绘制方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.