4
我有一個畫布,我正在繪製這個圖,使用點數組。如何用特定顏色填充它?
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
RectF oval = new RectF(90, 100, 200, 300);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.RED);
paint.setStrokeWidth(5f);
// canvas.drawRect(oval, paint);
//canvas.drawArc(oval, 30f, 100f, true, paint);
float [] pts = {0,200,
120,140,120,140,
180,20,180,20,
260,100,260,100,
350,20,350,20,
410,140,410,140,
530,200,530,200,
410,260,410,260,
350,380,350,380,
260,300,260,300,
180,380,180,380,
120,260,120,260,
0,200
};
//canvas.drawPoints(pts, paint);
canvas.drawLines(pts, paint);
//RectF tail = new RectF(0f, 50f, 200f,100f);
//canvas.drawArc(tail, 0f, 50f, true, paint);
//canvas.drawRoundRect(oval, 20f, 20f, paint);
invalidate();
}
所以基本上我想要做的就是填充顏色沿這些點存在於數組中。對此有何幫助?
嘗試應用樣式'Paint' ...'paint.setStyle(Paint.Style.FILL);' –
遺憾地說,但它不是working.Any其他建議? – Pankaj
什麼這些點代表?矩形或三角形或類似的東西?您可以顯示的圖像,它是如何繪製後看起來喜歡? –