Answer the question
In order to leave comments, you need to log in
How to fill with color the area between lines in android?
There is code that creates two curved lines that extend from the left to the top. How can you fill with the right color the area that has formed between them, taking into account the fact that the lines can move?
public class DrawView extends View {
Paint paint;
Path path1 = new Path();
Path path2 = new Path();
public DrawView(Context context) {
super(context);
init();
}
public DrawView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public DrawView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
path1.reset();
path2.reset();
paint.setColor(Color.RED);
paint.setStrokeWidth(3);
path1.moveTo(0, 750);
path2.moveTo(0, 900);
path1.cubicTo(185, 250, 599, 177, 585, 0);
path2.cubicTo(350, 250, 750, 177, 900, 0);
canvas.drawPath(path1, paint);
canvas.drawPath(path2, paint);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question