Drawing a Curve
![Canvas Canvas](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoDPaVzw5lkyAz-X4it7rF5DW4tGsP5EHQHqr8oRNp0pHpZc4moupTJU0ugRYAz4xaVWBVXhLU3fW67wkNH3Shnpd5867rQwyJxx_W-Rwi88p6FuxrR-13f2OQUCjKyNRRguSmlQ/h120/canvaslogo.png)
Bezier curves are determined by specifying one or two control points and a destination point. The call to quadraticCurveTo() takes a single control point, while bezierCurveTo() takes two.
context.quadraticCurveTo(cpx, cpy, x, y);
context.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
The starting point for the curve is always determined by the current pen position, similar to how lineTo() works. The destination point is simply the ending point of where you are drawing the curve to. The control points determine the shape of the curve; they do so by determining where tangents to the curve at the starting point and destination points intersect. See an example below:
context.quadraticCurveTo(0, 200, 200, 200);
![](http://1.bp.blogspot.com/-xe7RJ_CImbQ/Uh7PAw3zkNI/AAAAAAAAAYM/QZxgXER83n0/s1600/digg.png)
![](http://2.bp.blogspot.com/-qU9hOSgAAGg/Uh7PBkw5nXI/AAAAAAAAAYg/F3RH2FdUcUM/s1600/tech.png)
![](http://2.bp.blogspot.com/-SIE_cDNZwJo/Uh7QZns3f9I/AAAAAAAAAY8/_RgdI2_Yjuc/s1600/delicious.png)
![](http://3.bp.blogspot.com/-_SeXttyPxVw/Uh7PBUZ_xSI/AAAAAAAAAYY/WNUWXOgi9ZA/s1600/stumble.png)
![](http://4.bp.blogspot.com/-2L7TvTK8Spo/Uh7PBNnVSUI/AAAAAAAAAYc/wDUiY4QNFt0/s1600/red.png)
![](http://4.bp.blogspot.com/-7BJsLYGlmFs/Uh7PA66dlKI/AAAAAAAAAYI/YLZgf4eDolE/s1600/fb.png)
![](http://2.bp.blogspot.com/-AAPfGKZ58CE/Uh7PA1IFwAI/AAAAAAAAAYw/hu9jFLzr61Q/s1600/pin.png)
No comments :
Post a Comment