B
B
Blunker2017-06-11 21:46:03
Canvas
Blunker, 2017-06-11 21:46:03

How to draw a curved line?

How to draw a line in js canvas like this?
curve-1.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2017-06-11
@sergiks

A Bezier curve or, if it is a graph of some function, a large number of short straight line segments.
A similar bezier curve ( fiddle ):

var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");

ctx.lineWidth = 3;
ctx.strokeStyle = "green";
ctx.beginPath();
ctx.moveTo(4,4);
ctx.bezierCurveTo(160, 330, 160, 330, 316, 4);
ctx.stroke();

ee7a4912ebf14335a3245c7481b6d9cc.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question