I have a requirement to create bezier curve in my project. For that purpose I am drawing a view with paint, but the problem is that I am not getting the exact shape for my need as mentioned in the picture below. So kindly help me with your solutions and changes or modifications in my code. Thanks in advance.
Code I am using to create Bezier Curve:
public class DrawView extends View {
public DrawView (Context context) {
super (context);
}
protected void onDraw (Canvas canvas) {
super.onDraw (canvas);
Paint pLine = new Paint () {{
setStyle (Paint.Style.STROKE);
setAntiAlias (true);
setStrokeWidth (1.5f);
setColor (Color.RED); // Line color
}};
Paint pLineBorder = new Paint () {{
setStyle (Paint.Style.STROKE);
setAntiAlias (true);
setStrokeWidth (3.0f);
setStrokeCap (Cap.ROUND);
setColor (Color.RED); // Darker version of the color
}};
Path p = new Path ();
Point mid = new Point ();
// ...
Point start =new Point (30,90);
Point end =new Point (canvas.getWidth ()-30,140);
mid.set ((start.x + end.x) / 2, (start.y + end.y) / 2);
// Draw line connecting the two points:
p.reset ();
p.moveTo (start.x, start.y);
p.quadTo ((start.x + mid.x) / 2, start.y, mid.x, mid.y);
p.quadTo ((mid.x + end.x) / 2, end.y, end.x, end.y);
canvas.drawPath (p, pLineBorder);
canvas.drawPath (p, pLine);
}
}
MainActivity
public class MainActivity extends Activity {
private DrawView drawView;
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
drawView = new DrawView (this);
setContentView (drawView);
}
}
My Actual Need:
Output which I am getting: