Reputation: 2110
I have a canvas on which I'm drawing this figure, using array of points. How to fill it with a particular color?
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();
}
So basically what I want to do is to just fill the color along these points which are present in array. Any help on this??
Upvotes: 4
Views: 294