Try ( fiddle ):
function draw() { var ctx = document.getElementById('canvas').getContext('2d'); ctx.fillStyle = "red"; ctx.beginPath(); var start = [20, 100]; var end = [120, 100]; var above = Math.random()*80+20;
This uses quadraticCurveTo to draw a quadratic curve, taking two points into account and calculating a random control point from 20 to 100 pixels above the middle of the curve.
If you want a square to have a specific arc length (which sounds like you could from a question), we can do some math . The length of the quadratic arc (parabola) is equal to:

We have an equation, so produce the derivative:

So, if we define this as u (x), Wolfram alpha gives us :

So, for specific x1 and x2, we could work out the equivalent values โโof u (x), and then the integral.
Drawing a common quadratic point using a control point involves transforming the equation into vertex shape, as you can see on this manual page . It would be wise to repeat the math with this equation for a start and get a new equation for "u" in the right terms.
source share