src/third_party/specimenTools/lib/bower_components/Atem-Pen-Case/lib/tools/decomposeSuperSegments.js
/**
     * Split the SuperBezier described by 'points' into a list of regular
     * bezier segments. The 'points' argument must be a list with length
     * 3 or greater, containing [x, y] coordinates. The last point is the
     * destination on-curve point, the rest of the points are off-curve points.
     * The start point should not be supplied.
     *
     * This function returns a list of [pt1, pt2, pt3] lists, which each
     * specify a regular curveto-style bezier segment.
     */
Split the SuperBezier described by 'points' into a list of regular
bezier segments. The 'points' argument must be a list with length
3 or greater, containing [x, y] coordinates. The last point is the
destination on-curve point, the rest of the points are off-curve points.
The start point should not be supplied.

This function returns a list of [pt1, pt2, pt3] lists, which each
specify a regular curveto-style bezier segment.
Split the SuperBezier described by ' points ' into a list of regular bezier segments . The ' points ' argument must be a list with length 3 or greater containing [ x y ] coordinates . The last point is the destination on - curve point the rest of the points are off - curve points . The start point should not be supplied . This function returns a list of [ pt1 pt2 pt3 ] lists which each specify a regular curveto - style bezier segment .
function decomposeSuperBezierSegment(points) {
        var n = points.length - 1,
            bezierSegments = [],
            pt1 = points[0],
            pt2 = null,
            pt3 = null,
            i, j, nDivisions, factor, temp1, temp2, temp;
        assert(n > 1, 'Expecting at least 3 Points here');
        for (i=2;i<=n;i++)
        {
            nDivisions = Math.min(i, 3, n - i + 2);
            for (j=1;j<nDivisions;j++)
            {
                factor = j / nDivisions;
                temp1 = points[i-1];
                temp2 = points[i-2];
                temp = [
                    temp2[0] + factor * (temp1[0] - temp2[0]),
                    temp2[1] + factor * (temp1[1] - temp2[1])
                ];
                if (pt2 === null) {
                    pt2 = temp;
                } else {
                    pt3 = [
                        0.5 * (pt2[0] + temp[0]),
                        0.5 * (pt2[1] + temp[1])
                    ];
                    bezierSegments.push([pt1, pt2, pt3]);
                    pt1 = temp;
                    pt2 = null;
                    pt3 = null;
                }
            }
        }
        bezierSegments.push([pt1, points[points.length-2], points[points.length-1]]);
        return bezierSegments;
    }
function decomposeSuperBezierSegment ( points ) { var n = points . length - 1 , bezierSegments = [ ] , pt1 = points [ 0 ] , pt2 = null , pt3 = null , i , j , nDivisions , factor , temp1 , temp2 , temp ; assert ( n > 1 , 'Expecting at least 3 Points here' ) ; for ( i = 2 ; i <= n ; i ++ ) { nDivisions = Math . min ( i , 3 , n - i + 2 ) ; for ( j = 1 ; j < nDivisions ; j ++ ) { factor = j / nDivisions ; temp1 = points [ i - 1 ] ; temp2 = points [ i - 2 ] ; temp = [ temp2 [ 0 ] + factor * ( temp1 [ 0 ] - temp2 [ 0 ] ) , temp2 [ 1 ] + factor * ( temp1 [ 1 ] - temp2 [ 1 ] ) ] ; if ( pt2 === null ) { pt2 = temp ; } else { pt3 = [ 0.5 * ( pt2 [ 0 ] + temp [ 0 ] ) , 0.5 * ( pt2 [ 1 ] + temp [ 1 ] ) ] ; bezierSegments . push ( [ pt1 , pt2 , pt3 ] ) ; pt1 = temp ; pt2 = null ; pt3 = null ; } } } bezierSegments . push ( [ pt1 , points [ points . length - 2 ] , points [ points . length - 1 ] ] ) ; return bezierSegments ; }
Split the SuperBezier described by 'points' into a list of regular
 bezier segments.
Split the SuperBezier described by ' points ' into a list of regular bezier segments .
// calculate points in between control points. // used to be d = float(nDivisions) in the python source but // in js all numbers are float and there is no integer division // thing like in the older versions of python: //    e.g. 2 / 3 = 0 but 2 / 3.0 = 0.6666666666666666 // so I'll use nDivision throughout