how to draw smooth curve through N points using javascript HTML5 canvas?

后端 未结 11 718
时光说笑
时光说笑 2020-11-22 16:40

For a drawing application, I\'m saving the mouse movement coordinates to an array then drawing them with lineTo. The resulting line is not smooth. How can I produce a sing

11条回答
  •  半阙折子戏
    2020-11-22 17:36

    I decide to add on, rather than posting my solution to another post. Below are the solution that I build, may not be perfect, but so far the output are good.

    Important: it will pass through all the points!

    If you have any idea, to make it better, please share to me. Thanks.

    Here are the comparison of before after:

    Save this code to HTML to test it out.

        
        
        
        	Your browser does not support the HTML5 canvas tag.
        	
        
        

提交回复
热议问题