js curve animation

Solutions on MaxInterview for js curve animation by the best coders in the world

showing results for - "js curve animation"
Octave
01 Jul 2016
1// Get x, y position along a bezier curve with 3 points
2// Input 3 vectors and a value between 0 and 1
3
4function animateCurve (start, curve, end, t) {
5const x1 = start.x + (curve.x - start.x) * t
6const y1 = start.y + (curve.y - start.y) * t
7const x2 = curve.x + (end.x - curve.x) * t
8const y2 = curve.y + (end.y - curve.y) * t
9
10const subPoints = [{ x: x1, y: y1 }, { x: x2, y: y2 }]
11
12const x = subPoints[0].x + (subPoints[1].x - subPoints[0].x) * t
13const y = subPoints[0].y + (subPoints[1].y - subPoints[0].y) * t
14
15return { x, y }
16}
queries leading to this page
js curve animationjs curve animation