Drawing a smooth curve with the mouse.
Unfortunately, this is not so easy if you want to stay faithful to the artists who planned the line.
It includes recording the entire course of the mouse. When the stroke is completed, reduce the number of points to the limit of detail (set by the artist), then apply the bezier smoothing function to the remaining points.
This can be done when the stroke is drawn, but for some devices it may become too large if the line becomes very long. Since the decrease in line detail appears at all points when a smooth line is displayed, some people do not like how it changes slightly as the line becomes longer.
Demo
The code below shows a solution that I found useful.
- Use the left button to draw with one-button smoothing.
- Use the right button to draw with live smoothing (blue line).
- Middle mouse button to clear.
Use the two sliders at the top to set the amount of smoothing and the amount of detail. Left-click to pull the bar, the original line is displayed. When the mouse is released, the line is then simplified, smoothed and added to the background image.
var canvas = document.getElementById("canV"); var ctx = canvas.getContext("2d");
.canC { width:1000px; height:500px; border:1px black solid;}
<canvas class="canC" id="canV" width=1000 height=500></canvas>
Blindman67
source share