Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphics on Android: path with smooth curves?

Tags:

android

I want to draw a chart for a function y=x^2 as follows:

enter image description here

but the curve is not smooth as it is a set of connected lines.

how can I make the curve smoother ?

thanks

like image 488
Mina Wissa Avatar asked Aug 15 '11 13:08

Mina Wissa


1 Answers

You should use Path.quadTo with only one Path. If you are already doing this then I suggest increasing the number of points on the graph.

Move to the beginning of the Path:

Path.moveTo(x, y)

in the middle:

Path.quadTo(lastX, lastY, (x + lastX)/2, (y + lastY)/2)

and at the end:

Path.lineTo(x, y)
like image 167
Che Jami Avatar answered Sep 30 '22 13:09

Che Jami