{"version":3,"file":"bezier-js-D_d1xzui.js","sources":["../../node_modules/bezier-js/lib/utils.js","../../node_modules/bezier-js/lib/poly-bezier.js","../../node_modules/bezier-js/lib/normalise-svg.js","../../node_modules/bezier-js/lib/svg-to-beziers.js","../../node_modules/bezier-js/lib/bezier.js","../../node_modules/bezier-js/index.js"],"sourcesContent":["(function() {\n \"use strict\";\n\n // math-inlining.\n var abs = Math.abs,\n cos = Math.cos,\n sin = Math.sin,\n acos = Math.acos,\n atan2 = Math.atan2,\n sqrt = Math.sqrt,\n pow = Math.pow,\n // cube root function yielding real roots\n crt = function(v) {\n return v < 0 ? -pow(-v, 1 / 3) : pow(v, 1 / 3);\n },\n // trig constants\n pi = Math.PI,\n tau = 2 * pi,\n quart = pi / 2,\n // float precision significant decimal\n epsilon = 0.000001,\n // extremas used in bbox calculation and similar algorithms\n nMax = Number.MAX_SAFE_INTEGER || 9007199254740991,\n nMin = Number.MIN_SAFE_INTEGER || -9007199254740991,\n // a zero coordinate, which is surprisingly useful\n ZERO = { x: 0, y: 0, z: 0 };\n\n // Bezier utility functions\n var utils = {\n // Legendre-Gauss abscissae with n=24 (x_i values, defined at i=n as the roots of the nth order Legendre polynomial Pn(x))\n Tvalues: [\n -0.0640568928626056260850430826247450385909,\n 0.0640568928626056260850430826247450385909,\n -0.1911188674736163091586398207570696318404,\n 0.1911188674736163091586398207570696318404,\n -0.3150426796961633743867932913198102407864,\n 0.3150426796961633743867932913198102407864,\n -0.4337935076260451384870842319133497124524,\n 0.4337935076260451384870842319133497124524,\n -0.5454214713888395356583756172183723700107,\n 0.5454214713888395356583756172183723700107,\n -0.6480936519369755692524957869107476266696,\n 0.6480936519369755692524957869107476266696,\n -0.7401241915785543642438281030999784255232,\n 0.7401241915785543642438281030999784255232,\n -0.8200019859739029219539498726697452080761,\n 0.8200019859739029219539498726697452080761,\n -0.8864155270044010342131543419821967550873,\n 0.8864155270044010342131543419821967550873,\n -0.9382745520027327585236490017087214496548,\n 0.9382745520027327585236490017087214496548,\n -0.9747285559713094981983919930081690617411,\n 0.9747285559713094981983919930081690617411,\n -0.9951872199970213601799974097007368118745,\n 0.9951872199970213601799974097007368118745\n ],\n\n // Legendre-Gauss weights with n=24 (w_i values, defined by a function linked to in the Bezier primer article)\n Cvalues: [\n 0.1279381953467521569740561652246953718517,\n 0.1279381953467521569740561652246953718517,\n 0.1258374563468282961213753825111836887264,\n 0.1258374563468282961213753825111836887264,\n 0.121670472927803391204463153476262425607,\n 0.121670472927803391204463153476262425607,\n 0.1155056680537256013533444839067835598622,\n 0.1155056680537256013533444839067835598622,\n 0.1074442701159656347825773424466062227946,\n 0.1074442701159656347825773424466062227946,\n 0.0976186521041138882698806644642471544279,\n 0.0976186521041138882698806644642471544279,\n 0.086190161531953275917185202983742667185,\n 0.086190161531953275917185202983742667185,\n 0.0733464814110803057340336152531165181193,\n 0.0733464814110803057340336152531165181193,\n 0.0592985849154367807463677585001085845412,\n 0.0592985849154367807463677585001085845412,\n 0.0442774388174198061686027482113382288593,\n 0.0442774388174198061686027482113382288593,\n 0.0285313886289336631813078159518782864491,\n 0.0285313886289336631813078159518782864491,\n 0.0123412297999871995468056670700372915759,\n 0.0123412297999871995468056670700372915759\n ],\n\n arcfn: function(t, derivativeFn) {\n var d = derivativeFn(t);\n var l = d.x * d.x + d.y * d.y;\n if (typeof d.z !== \"undefined\") {\n l += d.z * d.z;\n }\n return sqrt(l);\n },\n\n compute: function(t, points, _3d) {\n // shortcuts\n if (t === 0) {\n return points[0];\n }\n\n var order = points.length-1;\n\n if (t === 1) {\n return points[order];\n }\n\n var p = points;\n var mt = 1 - t;\n\n // constant?\n if (order === 0) {\n return points[0];\n }\n\n // linear?\n if (order === 1) {\n ret = {\n x: mt * p[0].x + t * p[1].x,\n y: mt * p[0].y + t * p[1].y\n };\n if (_3d) {\n ret.z = mt * p[0].z + t * p[1].z;\n }\n return ret;\n }\n\n // quadratic/cubic curve?\n if (order < 4) {\n var mt2 = mt * mt,\n t2 = t * t,\n a,\n b,\n c,\n d = 0;\n if (order === 2) {\n p = [p[0], p[1], p[2], ZERO];\n a = mt2;\n b = mt * t * 2;\n c = t2;\n } else if (order === 3) {\n a = mt2 * mt;\n b = mt2 * t * 3;\n c = mt * t2 * 3;\n d = t * t2;\n }\n var ret = {\n x: a * p[0].x + b * p[1].x + c * p[2].x + d * p[3].x,\n y: a * p[0].y + b * p[1].y + c * p[2].y + d * p[3].y\n };\n if (_3d) {\n ret.z = a * p[0].z + b * p[1].z + c * p[2].z + d * p[3].z;\n }\n return ret;\n }\n\n // higher order curves: use de Casteljau's computation\n var dCpts = JSON.parse(JSON.stringify(points));\n while (dCpts.length > 1) {\n for (var i = 0; i < dCpts.length - 1; i++) {\n dCpts[i] = {\n x: dCpts[i].x + (dCpts[i + 1].x - dCpts[i].x) * t,\n y: dCpts[i].y + (dCpts[i + 1].y - dCpts[i].y) * t\n };\n if (typeof dCpts[i].z !== \"undefined\") {\n dCpts[i] = dCpts[i].z + (dCpts[i + 1].z - dCpts[i].z) * t;\n }\n }\n dCpts.splice(dCpts.length - 1, 1);\n }\n return dCpts[0];\n },\n\n computeWithRatios: function (t, points, ratios, _3d) {\n var mt = 1 - t, r = ratios, p = points, d;\n var f1 = r[0], f2 = r[1], f3 = r[2], f4 = r[3];\n\n // spec for linear\n f1 *= mt;\n f2 *= t;\n\n if (p.length === 2) {\n d = f1 + f2;\n return {\n x: (f1 * p[0].x + f2 * p[1].x)/d,\n y: (f1 * p[0].y + f2 * p[1].y)/d,\n z: !_3d ? false : (f1 * p[0].z + f2 * p[1].z)/d\n };\n }\n\n // upgrade to quadratic\n f1 *= mt;\n f2 *= 2 * mt;\n f3 *= t * t;\n\n if (p.length === 3) {\n d = f1 + f2 + f3;\n return {\n x: (f1 * p[0].x + f2 * p[1].x + f3 * p[2].x)/d,\n y: (f1 * p[0].y + f2 * p[1].y + f3 * p[2].y)/d,\n z: !_3d ? false : (f1 * p[0].z + f2 * p[1].z + f3 * p[2].z)/d\n };\n }\n\n // upgrade to cubic\n f1 *= mt;\n f2 *= 1.5 * mt;\n f3 *= 3 * mt;\n f4 *= t * t * t;\n\n if (p.length === 4) {\n d = f1 + f2 + f3 + f4;\n return {\n x: (f1 * p[0].x + f2 * p[1].x + f3 * p[2].x + f4 * p[3].x)/d,\n y: (f1 * p[0].y + f2 * p[1].y + f3 * p[2].y + f4 * p[3].y)/d,\n z: !_3d ? false : (f1 * p[0].z + f2 * p[1].z + f3 * p[2].z + f4 * p[3].z)/d\n };\n }\n },\n\n derive: function (points, _3d) {\n var dpoints = [];\n for (var p = points, d = p.length, c = d - 1; d > 1; d--, c--) {\n var list = [];\n for (var j = 0, dpt; j < c; j++) {\n dpt = {\n x: c * (p[j + 1].x - p[j].x),\n y: c * (p[j + 1].y - p[j].y)\n };\n if (_3d) {\n dpt.z = c * (p[j + 1].z - p[j].z);\n }\n list.push(dpt);\n }\n dpoints.push(list);\n p = list;\n }\n return dpoints;\n },\n\n between: function(v, m, M) {\n return (\n (m <= v && v <= M) ||\n utils.approximately(v, m) ||\n utils.approximately(v, M)\n );\n },\n\n approximately: function(a, b, precision) {\n return abs(a - b) <= (precision || epsilon);\n },\n\n length: function(derivativeFn) {\n var z = 0.5,\n sum = 0,\n len = utils.Tvalues.length,\n i,\n t;\n for (i = 0; i < len; i++) {\n t = z * utils.Tvalues[i] + z;\n sum += utils.Cvalues[i] * utils.arcfn(t, derivativeFn);\n }\n return z * sum;\n },\n\n map: function(v, ds, de, ts, te) {\n var d1 = de - ds,\n d2 = te - ts,\n v2 = v - ds,\n r = v2 / d1;\n return ts + d2 * r;\n },\n\n lerp: function(r, v1, v2) {\n var ret = {\n x: v1.x + r * (v2.x - v1.x),\n y: v1.y + r * (v2.y - v1.y)\n };\n if (!!v1.z && !!v2.z) {\n ret.z = v1.z + r * (v2.z - v1.z);\n }\n return ret;\n },\n\n pointToString: function(p) {\n var s = p.x + \"/\" + p.y;\n if (typeof p.z !== \"undefined\") {\n s += \"/\" + p.z;\n }\n return s;\n },\n\n pointsToString: function(points) {\n return \"[\" + points.map(utils.pointToString).join(\", \") + \"]\";\n },\n\n copy: function(obj) {\n return JSON.parse(JSON.stringify(obj));\n },\n\n angle: function(o, v1, v2) {\n var dx1 = v1.x - o.x,\n dy1 = v1.y - o.y,\n dx2 = v2.x - o.x,\n dy2 = v2.y - o.y,\n cross = dx1 * dy2 - dy1 * dx2,\n dot = dx1 * dx2 + dy1 * dy2;\n return atan2(cross, dot);\n },\n\n // round as string, to avoid rounding errors\n round: function(v, d) {\n var s = \"\" + v;\n var pos = s.indexOf(\".\");\n return parseFloat(s.substring(0, pos + 1 + d));\n },\n\n dist: function(p1, p2) {\n var dx = p1.x - p2.x,\n dy = p1.y - p2.y;\n return sqrt(dx * dx + dy * dy);\n },\n\n closest: function(LUT, point) {\n var mdist = pow(2, 63),\n mpos,\n d;\n LUT.forEach(function(p, idx) {\n d = utils.dist(point, p);\n if (d < mdist) {\n mdist = d;\n mpos = idx;\n }\n });\n return { mdist: mdist, mpos: mpos };\n },\n\n abcratio: function(t, n) {\n // see ratio(t) note on http://pomax.github.io/bezierinfo/#abc\n if (n !== 2 && n !== 3) {\n return false;\n }\n if (typeof t === \"undefined\") {\n t = 0.5;\n } else if (t === 0 || t === 1) {\n return t;\n }\n var bottom = pow(t, n) + pow(1 - t, n),\n top = bottom - 1;\n return abs(top / bottom);\n },\n\n projectionratio: function(t, n) {\n // see u(t) note on http://pomax.github.io/bezierinfo/#abc\n if (n !== 2 && n !== 3) {\n return false;\n }\n if (typeof t === \"undefined\") {\n t = 0.5;\n } else if (t === 0 || t === 1) {\n return t;\n }\n var top = pow(1 - t, n),\n bottom = pow(t, n) + top;\n return top / bottom;\n },\n\n lli8: function(x1, y1, x2, y2, x3, y3, x4, y4) {\n var nx =\n (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4),\n ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4),\n d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);\n if (d == 0) {\n return false;\n }\n return { x: nx / d, y: ny / d };\n },\n\n lli4: function(p1, p2, p3, p4) {\n var x1 = p1.x,\n y1 = p1.y,\n x2 = p2.x,\n y2 = p2.y,\n x3 = p3.x,\n y3 = p3.y,\n x4 = p4.x,\n y4 = p4.y;\n return utils.lli8(x1, y1, x2, y2, x3, y3, x4, y4);\n },\n\n lli: function(v1, v2) {\n return utils.lli4(v1, v1.c, v2, v2.c);\n },\n\n makeline: function(p1, p2) {\n var Bezier = require(\"./bezier\");\n var x1 = p1.x,\n y1 = p1.y,\n x2 = p2.x,\n y2 = p2.y,\n dx = (x2 - x1) / 3,\n dy = (y2 - y1) / 3;\n return new Bezier(\n x1,\n y1,\n x1 + dx,\n y1 + dy,\n x1 + 2 * dx,\n y1 + 2 * dy,\n x2,\n y2\n );\n },\n\n findbbox: function(sections) {\n var mx = nMax,\n my = nMax,\n MX = nMin,\n MY = nMin;\n sections.forEach(function(s) {\n var bbox = s.bbox();\n if (mx > bbox.x.min) mx = bbox.x.min;\n if (my > bbox.y.min) my = bbox.y.min;\n if (MX < bbox.x.max) MX = bbox.x.max;\n if (MY < bbox.y.max) MY = bbox.y.max;\n });\n return {\n x: { min: mx, mid: (mx + MX) / 2, max: MX, size: MX - mx },\n y: { min: my, mid: (my + MY) / 2, max: MY, size: MY - my }\n };\n },\n\n shapeintersections: function(\n s1,\n bbox1,\n s2,\n bbox2,\n curveIntersectionThreshold\n ) {\n if (!utils.bboxoverlap(bbox1, bbox2)) return [];\n var intersections = [];\n var a1 = [s1.startcap, s1.forward, s1.back, s1.endcap];\n var a2 = [s2.startcap, s2.forward, s2.back, s2.endcap];\n a1.forEach(function(l1) {\n if (l1.virtual) return;\n a2.forEach(function(l2) {\n if (l2.virtual) return;\n var iss = l1.intersects(l2, curveIntersectionThreshold);\n if (iss.length > 0) {\n iss.c1 = l1;\n iss.c2 = l2;\n iss.s1 = s1;\n iss.s2 = s2;\n intersections.push(iss);\n }\n });\n });\n return intersections;\n },\n\n makeshape: function(forward, back, curveIntersectionThreshold) {\n var bpl = back.points.length;\n var fpl = forward.points.length;\n var start = utils.makeline(back.points[bpl - 1], forward.points[0]);\n var end = utils.makeline(forward.points[fpl - 1], back.points[0]);\n var shape = {\n startcap: start,\n forward: forward,\n back: back,\n endcap: end,\n bbox: utils.findbbox([start, forward, back, end])\n };\n var self = utils;\n shape.intersections = function(s2) {\n return self.shapeintersections(\n shape,\n shape.bbox,\n s2,\n s2.bbox,\n curveIntersectionThreshold\n );\n };\n return shape;\n },\n\n getminmax: function(curve, d, list) {\n if (!list) return { min: 0, max: 0 };\n var min = nMax,\n max = nMin,\n t,\n c;\n if (list.indexOf(0) === -1) {\n list = [0].concat(list);\n }\n if (list.indexOf(1) === -1) {\n list.push(1);\n }\n for (var i = 0, len = list.length; i < len; i++) {\n t = list[i];\n c = curve.get(t);\n if (c[d] < min) {\n min = c[d];\n }\n if (c[d] > max) {\n max = c[d];\n }\n }\n return { min: min, mid: (min + max) / 2, max: max, size: max - min };\n },\n\n align: function(points, line) {\n var tx = line.p1.x,\n ty = line.p1.y,\n a = -atan2(line.p2.y - ty, line.p2.x - tx),\n d = function(v) {\n return {\n x: (v.x - tx) * cos(a) - (v.y - ty) * sin(a),\n y: (v.x - tx) * sin(a) + (v.y - ty) * cos(a)\n };\n };\n return points.map(d);\n },\n\n roots: function(points, line) {\n line = line || { p1: { x: 0, y: 0 }, p2: { x: 1, y: 0 } };\n var order = points.length - 1;\n var p = utils.align(points, line);\n var reduce = function(t) {\n return 0 <= t && t <= 1;\n };\n\n if (order === 2) {\n var a = p[0].y,\n b = p[1].y,\n c = p[2].y,\n d = a - 2 * b + c;\n if (d !== 0) {\n var m1 = -sqrt(b * b - a * c),\n m2 = -a + b,\n v1 = -(m1 + m2) / d,\n v2 = -(-m1 + m2) / d;\n return [v1, v2].filter(reduce);\n } else if (b !== c && d === 0) {\n return [(2*b - c)/(2*b - 2*c)].filter(reduce);\n }\n return [];\n }\n\n // see http://www.trans4mind.com/personal_development/mathematics/polynomials/cubicAlgebra.htm\n var pa = p[0].y,\n pb = p[1].y,\n pc = p[2].y,\n pd = p[3].y,\n d = -pa + 3 * pb - 3 * pc + pd,\n a = 3 * pa - 6 * pb + 3 * pc,\n b = -3 * pa + 3 * pb,\n c = pa;\n\n if (utils.approximately(d, 0)) {\n // this is not a cubic curve.\n if (utils.approximately(a, 0)) {\n // in fact, this is not a quadratic curve either.\n if (utils.approximately(b, 0)) {\n // in fact in fact, there are no solutions.\n return [];\n }\n // linear solution:\n return [-c / b].filter(reduce);\n }\n // quadratic solution:\n var q = sqrt(b * b - 4 * a * c),\n a2 = 2 * a;\n return [(q - b) / a2, (-b - q) / a2].filter(reduce);\n }\n\n // at this point, we know we need a cubic solution:\n\n a /= d;\n b /= d;\n c /= d;\n\n var p = (3 * b - a * a) / 3,\n p3 = p / 3,\n q = (2 * a * a * a - 9 * a * b + 27 * c) / 27,\n q2 = q / 2,\n discriminant = q2 * q2 + p3 * p3 * p3,\n u1,\n v1,\n x1,\n x2,\n x3;\n if (discriminant < 0) {\n var mp3 = -p / 3,\n mp33 = mp3 * mp3 * mp3,\n r = sqrt(mp33),\n t = -q / (2 * r),\n cosphi = t < -1 ? -1 : t > 1 ? 1 : t,\n phi = acos(cosphi),\n crtr = crt(r),\n t1 = 2 * crtr;\n x1 = t1 * cos(phi / 3) - a / 3;\n x2 = t1 * cos((phi + tau) / 3) - a / 3;\n x3 = t1 * cos((phi + 2 * tau) / 3) - a / 3;\n return [x1, x2, x3].filter(reduce);\n } else if (discriminant === 0) {\n u1 = q2 < 0 ? crt(-q2) : -crt(q2);\n x1 = 2 * u1 - a / 3;\n x2 = -u1 - a / 3;\n return [x1, x2].filter(reduce);\n } else {\n var sd = sqrt(discriminant);\n u1 = crt(-q2 + sd);\n v1 = crt(q2 + sd);\n return [u1 - v1 - a / 3].filter(reduce);\n }\n },\n\n droots: function(p) {\n // quadratic roots are easy\n if (p.length === 3) {\n var a = p[0],\n b = p[1],\n c = p[2],\n d = a - 2 * b + c;\n if (d !== 0) {\n var m1 = -sqrt(b * b - a * c),\n m2 = -a + b,\n v1 = -(m1 + m2) / d,\n v2 = -(-m1 + m2) / d;\n return [v1, v2];\n } else if (b !== c && d === 0) {\n return [(2 * b - c) / (2 * (b - c))];\n }\n return [];\n }\n\n // linear roots are even easier\n if (p.length === 2) {\n var a = p[0],\n b = p[1];\n if (a !== b) {\n return [a / (a - b)];\n }\n return [];\n }\n },\n\n curvature: function(t, points, _3d, kOnly) {\n var dpoints = utils.derive(points);\n var d1 = dpoints[0];\n var d2 = dpoints[1];\n var num, dnm, adk, dk, k=0, r=0;\n\n //\n // We're using the following formula for curvature:\n //\n // x'y\" - y'x\"\n // k(t) = ------------------\n // (x'² + y'²)^(3/2)\n //\n // from https://en.wikipedia.org/wiki/Radius_of_curvature#Definition\n //\n // With it corresponding 3D counterpart:\n //\n // sqrt( (y'z\" - y\"z')² + (z'x\" - z\"x')² + (x'y\" - x\"y')²)\n // k(t) = -------------------------------------------------------\n // (x'² + y'² + z'²)^(3/2)\n //\n\n var d = utils.compute(t, d1);\n var dd = utils.compute(t, d2);\n var qdsum = d.x*d.x + d.y*d.y;\n if (_3d) {\n num = sqrt(\n pow(d.y*dd.z - dd.y*d.z, 2) +\n pow(d.z*dd.x - dd.z*d.x, 2) +\n pow(d.x*dd.y - dd.x*d.y, 2)\n );\n dnm = pow(qdsum + d.z*d.z, 3/2);\n } else {\n num = d.x*dd.y - d.y*dd.x;\n dnm = pow(qdsum, 3/2);\n }\n\n if (num === 0 || dnm === 0) {\n return { k:0, r:0 };\n }\n\n k = num/dnm;\n r = dnm/num;\n\n // We're also computing the derivative of kappa, because\n // there is value in knowing the rate of change for the\n // curvature along the curve. And we're just going to\n // ballpark it based on an epsilon.\n if (!kOnly) {\n // compute k'(t) based on the interval before, and after it,\n // to at least try to not introduce forward/backward pass bias.\n var pk = utils.curvature(t-0.001, points, _3d, true).k;\n var nk = utils.curvature(t+0.001, points, _3d, true).k;\n dk = ((nk-k) + (k-pk))/2;\n adk = (abs(nk-k) + abs(k-pk))/2;\n }\n\n return { k: k, r: r, dk: dk, adk:adk, };\n },\n\n inflections: function(points) {\n if (points.length < 4) return [];\n\n // FIXME: TODO: add in inflection abstraction for quartic+ curves?\n\n var p = utils.align(points, { p1: points[0], p2: points.slice(-1)[0] }),\n a = p[2].x * p[1].y,\n b = p[3].x * p[1].y,\n c = p[1].x * p[2].y,\n d = p[3].x * p[2].y,\n v1 = 18 * (-3 * a + 2 * b + 3 * c - d),\n v2 = 18 * (3 * a - b - 3 * c),\n v3 = 18 * (c - a);\n\n if (utils.approximately(v1, 0)) {\n if (!utils.approximately(v2, 0)) {\n var t = -v3 / v2;\n if (0 <= t && t <= 1) return [t];\n }\n return [];\n }\n\n var trm = v2 * v2 - 4 * v1 * v3,\n sq = Math.sqrt(trm),\n d = 2 * v1;\n\n if (utils.approximately(d, 0)) return [];\n\n return [(sq - v2) / d, -(v2 + sq) / d].filter(function(r) {\n return 0 <= r && r <= 1;\n });\n },\n\n bboxoverlap: function(b1, b2) {\n var dims = [\"x\", \"y\"],\n len = dims.length,\n i,\n dim,\n l,\n t,\n d;\n for (i = 0; i < len; i++) {\n dim = dims[i];\n l = b1[dim].mid;\n t = b2[dim].mid;\n d = (b1[dim].size + b2[dim].size) / 2;\n if (abs(l - t) >= d) return false;\n }\n return true;\n },\n\n expandbox: function(bbox, _bbox) {\n if (_bbox.x.min < bbox.x.min) {\n bbox.x.min = _bbox.x.min;\n }\n if (_bbox.y.min < bbox.y.min) {\n bbox.y.min = _bbox.y.min;\n }\n if (_bbox.z && _bbox.z.min < bbox.z.min) {\n bbox.z.min = _bbox.z.min;\n }\n if (_bbox.x.max > bbox.x.max) {\n bbox.x.max = _bbox.x.max;\n }\n if (_bbox.y.max > bbox.y.max) {\n bbox.y.max = _bbox.y.max;\n }\n if (_bbox.z && _bbox.z.max > bbox.z.max) {\n bbox.z.max = _bbox.z.max;\n }\n bbox.x.mid = (bbox.x.min + bbox.x.max) / 2;\n bbox.y.mid = (bbox.y.min + bbox.y.max) / 2;\n if (bbox.z) {\n bbox.z.mid = (bbox.z.min + bbox.z.max) / 2;\n }\n bbox.x.size = bbox.x.max - bbox.x.min;\n bbox.y.size = bbox.y.max - bbox.y.min;\n if (bbox.z) {\n bbox.z.size = bbox.z.max - bbox.z.min;\n }\n },\n\n pairiteration: function(c1, c2, curveIntersectionThreshold) {\n var c1b = c1.bbox(),\n c2b = c2.bbox(),\n r = 100000,\n threshold = curveIntersectionThreshold || 0.5;\n if (\n c1b.x.size + c1b.y.size < threshold &&\n c2b.x.size + c2b.y.size < threshold\n ) {\n return [\n ((r * (c1._t1 + c1._t2) / 2) | 0) / r +\n \"/\" +\n ((r * (c2._t1 + c2._t2) / 2) | 0) / r\n ];\n }\n var cc1 = c1.split(0.5),\n cc2 = c2.split(0.5),\n pairs = [\n { left: cc1.left, right: cc2.left },\n { left: cc1.left, right: cc2.right },\n { left: cc1.right, right: cc2.right },\n { left: cc1.right, right: cc2.left }\n ];\n pairs = pairs.filter(function(pair) {\n return utils.bboxoverlap(pair.left.bbox(), pair.right.bbox());\n });\n var results = [];\n if (pairs.length === 0) return results;\n pairs.forEach(function(pair) {\n results = results.concat(\n utils.pairiteration(pair.left, pair.right, threshold)\n );\n });\n results = results.filter(function(v, i) {\n return results.indexOf(v) === i;\n });\n return results;\n },\n\n getccenter: function(p1, p2, p3) {\n var dx1 = p2.x - p1.x,\n dy1 = p2.y - p1.y,\n dx2 = p3.x - p2.x,\n dy2 = p3.y - p2.y;\n var dx1p = dx1 * cos(quart) - dy1 * sin(quart),\n dy1p = dx1 * sin(quart) + dy1 * cos(quart),\n dx2p = dx2 * cos(quart) - dy2 * sin(quart),\n dy2p = dx2 * sin(quart) + dy2 * cos(quart);\n // chord midpoints\n var mx1 = (p1.x + p2.x) / 2,\n my1 = (p1.y + p2.y) / 2,\n mx2 = (p2.x + p3.x) / 2,\n my2 = (p2.y + p3.y) / 2;\n // midpoint offsets\n var mx1n = mx1 + dx1p,\n my1n = my1 + dy1p,\n mx2n = mx2 + dx2p,\n my2n = my2 + dy2p;\n // intersection of these lines:\n var arc = utils.lli8(mx1, my1, mx1n, my1n, mx2, my2, mx2n, my2n),\n r = utils.dist(arc, p1),\n // arc start/end values, over mid point:\n s = atan2(p1.y - arc.y, p1.x - arc.x),\n m = atan2(p2.y - arc.y, p2.x - arc.x),\n e = atan2(p3.y - arc.y, p3.x - arc.x),\n _;\n // determine arc direction (cw/ccw correction)\n if (s < e) {\n // if s m || m > e) {\n s += tau;\n }\n if (s > e) {\n _ = e;\n e = s;\n s = _;\n }\n } else {\n // if e 2) {\n for (a = 0; a < alen; a += 2) {\n if (op === \"m\") {\n x += args[a];\n y += args[a + 1];\n } else {\n x = args[a];\n y = args[a + 1];\n }\n normalized += [\"L\",x,y,''].join(\" \");\n }\n }\n } else if (lop === \"l\") {\n // lineto commands\n for (a = 0; a < alen; a += 2) {\n if (op === \"l\") {\n x += args[a];\n y += args[a + 1];\n } else {\n x = args[a];\n y = args[a + 1];\n }\n normalized += [\"L\",x,y,''].join(\" \");\n }\n } else if (lop === \"h\") {\n for (a = 0; a < alen; a++) {\n if (op === \"h\") {\n x += args[a];\n } else {\n x = args[a];\n }\n normalized += [\"L\",x,y,''].join(\" \");\n }\n } else if (lop === \"v\") {\n for (a = 0; a < alen; a++) {\n if (op === \"v\") {\n y += args[a];\n } else {\n y = args[a];\n }\n normalized += [\"L\",x,y,''].join(\" \");\n }\n } else if (lop === \"q\") {\n // quadratic curveto commands\n for (a = 0; a < alen; a += 4) {\n if (op === \"q\") {\n cx = x + args[a];\n cy = y + args[a + 1];\n x += args[a + 2];\n y += args[a + 3];\n } else {\n cx = args[a];\n cy = args[a + 1];\n x = args[a + 2];\n y = args[a + 3];\n }\n normalized += [\"Q\",cx,cy,x,y,''].join(\" \");\n }\n } else if (lop === \"t\") {\n for (a = 0; a < alen; a += 2) {\n // reflect previous cx/cy over x/y\n cx = x + (x - cx);\n cy = y + (y - cy);\n // then get real end point\n if (op === \"t\") {\n x += args[a];\n y += args[a + 1];\n } else {\n x = args[a];\n y = args[a + 1];\n }\n normalized += [\"Q\",cx,cy,x,y,''].join(\" \");\n }\n } else if (lop === \"c\") {\n // cubic curveto commands\n for (a = 0; a < alen; a += 6) {\n if (op === \"c\") {\n cx = x + args[a];\n cy = y + args[a + 1];\n cx2 = x + args[a + 2];\n cy2 = y + args[a + 3];\n x += args[a + 4];\n y += args[a + 5];\n } else {\n cx = args[a];\n cy = args[a + 1];\n cx2 = args[a + 2];\n cy2 = args[a + 3];\n x = args[a + 4];\n y = args[a + 5];\n }\n normalized += [\"C\",cx,cy,cx2,cy2,x,y,''].join(\" \");\n }\n } else if (lop === \"s\") {\n for (a = 0; a < alen; a += 4) {\n // reflect previous cx2/cy2 over x/y\n cx = x + (x - cx2);\n cy = y + (y - cy2);\n // then get real control and end point\n if (op === \"s\") {\n cx2 = x + args[a];\n cy2 = y + args[a + 1];\n x += args[a + 2];\n y += args[a + 3];\n } else {\n cx2 = args[a];\n cy2 = args[a + 1];\n x = args[a + 2];\n y = args[a + 3];\n }\n normalized +=[\"C\",cx,cy,cx2,cy2,x,y,''].join(\" \");\n }\n } else if (lop === \"z\") {\n normalized += \"Z \";\n // not unimportant: path closing changes the current x/y coordinate\n x = sx;\n y = sy;\n }\n }\n return normalized.trim();\n}\n\nmodule.exports = normalizePath;\n","var normalise = require(\"./normalise-svg.js\");\n\nvar M = { x: false, y: false };\n\nfunction makeBezier(Bezier, term, values) {\n if (term === 'Z') return;\n if (term === 'M') {\n M = {x: values[0], y: values[1]};\n return;\n }\n // ES7: new Bezier(M.x, M.y, ...values)\n var cvalues = [false, M.x, M.y].concat(values);\n var PreboundConstructor = Bezier.bind.apply(Bezier, cvalues)\n var curve = new PreboundConstructor();\n var last = values.slice(-2);\n M = { x : last[0], y: last[1] };\n return curve;\n}\n\nfunction convertPath(Bezier, d) {\n var terms = normalise(d).split(\" \"),\n term,\n matcher = new RegExp(\"[MLCQZ]\", \"\"),\n segment,\n values,\n segments = [],\n ARGS = { \"C\": 6, \"Q\": 4, \"L\": 2, \"M\": 2};\n\n while (terms.length) {\n term = terms.splice(0,1)[0];\n if (matcher.test(term)) {\n values = terms.splice(0, ARGS[term]).map(parseFloat);\n segment = makeBezier(Bezier, term, values);\n if (segment) segments.push(segment);\n }\n }\n\n return new Bezier.PolyBezier(segments);\n}\n\nmodule.exports = convertPath;\n","/**\n A javascript Bezier curve library by Pomax.\n\n Based on http://pomax.github.io/bezierinfo\n\n This code is MIT licensed.\n**/\n(function() {\n \"use strict\";\n\n // math-inlining.\n var abs = Math.abs,\n min = Math.min,\n max = Math.max,\n cos = Math.cos,\n sin = Math.sin,\n acos = Math.acos,\n sqrt = Math.sqrt,\n pi = Math.PI,\n // a zero coordinate, which is surprisingly useful\n ZERO = { x: 0, y: 0, z: 0 };\n\n // quite needed\n var utils = require(\"./utils.js\");\n\n // only used for outlines atm.\n var PolyBezier = require(\"./poly-bezier.js\");\n\n /**\n * Bezier curve constructor. The constructor argument can be one of three things:\n *\n * 1. array/4 of {x:..., y:..., z:...}, z optional\n * 2. numerical array/8 ordered x1,y1,x2,y2,x3,y3,x4,y4\n * 3. numerical array/12 ordered x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4\n *\n */\n var Bezier = function(coords) {\n var args = coords && coords.forEach ? coords : [].slice.call(arguments);\n var coordlen = false;\n if (typeof args[0] === \"object\") {\n coordlen = args.length;\n var newargs = [];\n args.forEach(function(point) {\n [\"x\", \"y\", \"z\"].forEach(function(d) {\n if (typeof point[d] !== \"undefined\") {\n newargs.push(point[d]);\n }\n });\n });\n args = newargs;\n }\n var higher = false;\n var len = args.length;\n if (coordlen) {\n if (coordlen > 4) {\n if (arguments.length !== 1) {\n throw new Error(\n \"Only new Bezier(point[]) is accepted for 4th and higher order curves\"\n );\n }\n higher = true;\n }\n } else {\n if (len !== 6 && len !== 8 && len !== 9 && len !== 12) {\n if (arguments.length !== 1) {\n throw new Error(\n \"Only new Bezier(point[]) is accepted for 4th and higher order curves\"\n );\n }\n }\n }\n var _3d =\n (!higher && (len === 9 || len === 12)) ||\n (coords && coords[0] && typeof coords[0].z !== \"undefined\");\n this._3d = _3d;\n var points = [];\n for (var idx = 0, step = _3d ? 3 : 2; idx < len; idx += step) {\n var point = {\n x: args[idx],\n y: args[idx + 1]\n };\n if (_3d) {\n point.z = args[idx + 2];\n }\n points.push(point);\n }\n this.order = points.length - 1;\n this.points = points;\n var dims = [\"x\", \"y\"];\n if (_3d) dims.push(\"z\");\n this.dims = dims;\n this.dimlen = dims.length;\n\n (function(curve) {\n var order = curve.order;\n var points = curve.points;\n var a = utils.align(points, { p1: points[0], p2: points[order] });\n for (var i = 0; i < a.length; i++) {\n if (abs(a[i].y) > 0.0001) {\n curve._linear = false;\n return;\n }\n }\n curve._linear = true;\n })(this);\n\n this._t1 = 0;\n this._t2 = 1;\n this.update();\n };\n\n var svgToBeziers = require(\"./svg-to-beziers\");\n\n /**\n * turn an svg d attribute into a sequence of Bezier segments.\n */\n Bezier.SVGtoBeziers = function(d) {\n return svgToBeziers(Bezier, d);\n };\n\n function getABC(n, S, B, E, t) {\n if (typeof t === \"undefined\") {\n t = 0.5;\n }\n var u = utils.projectionratio(t, n),\n um = 1 - u,\n C = {\n x: u * S.x + um * E.x,\n y: u * S.y + um * E.y\n },\n s = utils.abcratio(t, n),\n A = {\n x: B.x + (B.x - C.x) / s,\n y: B.y + (B.y - C.y) / s\n };\n return { A: A, B: B, C: C };\n }\n\n Bezier.quadraticFromPoints = function(p1, p2, p3, t) {\n if (typeof t === \"undefined\") {\n t = 0.5;\n }\n // shortcuts, although they're really dumb\n if (t === 0) {\n return new Bezier(p2, p2, p3);\n }\n if (t === 1) {\n return new Bezier(p1, p2, p2);\n }\n // real fitting.\n var abc = getABC(2, p1, p2, p3, t);\n return new Bezier(p1, abc.A, p3);\n };\n\n Bezier.cubicFromPoints = function(S, B, E, t, d1) {\n if (typeof t === \"undefined\") {\n t = 0.5;\n }\n var abc = getABC(3, S, B, E, t);\n if (typeof d1 === \"undefined\") {\n d1 = utils.dist(B, abc.C);\n }\n var d2 = d1 * (1 - t) / t;\n\n var selen = utils.dist(S, E),\n lx = (E.x - S.x) / selen,\n ly = (E.y - S.y) / selen,\n bx1 = d1 * lx,\n by1 = d1 * ly,\n bx2 = d2 * lx,\n by2 = d2 * ly;\n // derivation of new hull coordinates\n var e1 = { x: B.x - bx1, y: B.y - by1 },\n e2 = { x: B.x + bx2, y: B.y + by2 },\n A = abc.A,\n v1 = { x: A.x + (e1.x - A.x) / (1 - t), y: A.y + (e1.y - A.y) / (1 - t) },\n v2 = { x: A.x + (e2.x - A.x) / t, y: A.y + (e2.y - A.y) / t },\n nc1 = { x: S.x + (v1.x - S.x) / t, y: S.y + (v1.y - S.y) / t },\n nc2 = {\n x: E.x + (v2.x - E.x) / (1 - t),\n y: E.y + (v2.y - E.y) / (1 - t)\n };\n // ...done\n return new Bezier(S, nc1, nc2, E);\n };\n\n var getUtils = function() {\n return utils;\n };\n\n Bezier.getUtils = getUtils;\n\n Bezier.PolyBezier = PolyBezier;\n\n Bezier.prototype = {\n getUtils: getUtils,\n valueOf: function() {\n return this.toString();\n },\n toString: function() {\n return utils.pointsToString(this.points);\n },\n toSVG: function(relative) {\n if (this._3d) return false;\n var p = this.points,\n x = p[0].x,\n y = p[0].y,\n s = [\"M\", x, y, this.order === 2 ? \"Q\" : \"C\"];\n for (var i = 1, last = p.length; i < last; i++) {\n s.push(p[i].x);\n s.push(p[i].y);\n }\n return s.join(\" \");\n },\n setRatios: function(ratios) {\n if (ratios.length !== this.points.length) {\n throw new Error(\"incorrect number of ratio values\");\n }\n this.ratios = ratios;\n this._lut = []; // invalidate any precomputed LUT\n },\n verify: function() {\n var print = this.coordDigest();\n if (print !== this._print) {\n this._print = print;\n this.update();\n }\n },\n coordDigest: function() {\n return this.points.map(function(c,pos) {\n return '' + pos + c.x + c.y + (c.z?c.z:0);\n }).join('');\n },\n update: function(newprint) {\n // invalidate any precomputed LUT\n this._lut = [];\n this.dpoints = utils.derive(this.points, this._3d);\n this.computedirection();\n },\n computedirection: function() {\n var points = this.points;\n var angle = utils.angle(points[0], points[this.order], points[1]);\n this.clockwise = angle > 0;\n },\n length: function() {\n return utils.length(this.derivative.bind(this));\n },\n _lut: [],\n getLUT: function(steps) {\n this.verify();\n steps = steps || 100;\n if (this._lut.length === steps) {\n return this._lut;\n }\n this._lut = [];\n // We want a range from 0 to 1 inclusive, so\n // we decrement and then use <= rather than <:\n steps--;\n for (var t = 0; t <= steps; t++) {\n this._lut.push(this.compute(t / steps));\n }\n return this._lut;\n },\n on: function(point, error) {\n error = error || 5;\n var lut = this.getLUT(),\n hits = [],\n c,\n t = 0;\n for (var i = 0; i < lut.length; i++) {\n c = lut[i];\n if (utils.dist(c, point) < error) {\n hits.push(c);\n t += i / lut.length;\n }\n }\n if (!hits.length) return false;\n return (t /= hits.length);\n },\n project: function(point) {\n // step 1: coarse check\n var LUT = this.getLUT(),\n l = LUT.length - 1,\n closest = utils.closest(LUT, point),\n mdist = closest.mdist,\n mpos = closest.mpos;\n\n // step 2: fine check\n var ft,\n t,\n p,\n d,\n t1 = (mpos - 1) / l,\n t2 = (mpos + 1) / l,\n step = 0.1 / l;\n mdist += 1;\n for (t = t1, ft = t; t < t2 + step; t += step) {\n p = this.compute(t);\n d = utils.dist(point, p);\n if (d < mdist) {\n mdist = d;\n ft = t;\n }\n }\n p = this.compute(ft);\n p.t = ft;\n p.d = mdist;\n return p;\n },\n get: function(t) {\n return this.compute(t);\n },\n point: function(idx) {\n return this.points[idx];\n },\n compute: function(t) {\n if (this.ratios) return utils.computeWithRatios(t, this.points, this.ratios, this._3d);\n return utils.compute(t, this.points, this._3d, this.ratios);\n },\n raise: function() {\n var p = this.points,\n np = [p[0]],\n i,\n k = p.length,\n pi,\n pim;\n for (var i = 1; i < k; i++) {\n pi = p[i];\n pim = p[i - 1];\n np[i] = {\n x: (k - i) / k * pi.x + i / k * pim.x,\n y: (k - i) / k * pi.y + i / k * pim.y\n };\n }\n np[k] = p[k - 1];\n return new Bezier(np);\n },\n derivative: function(t) {\n var mt = 1 - t,\n a,\n b,\n c = 0,\n p = this.dpoints[0];\n if (this.order === 2) {\n p = [p[0], p[1], ZERO];\n a = mt;\n b = t;\n }\n if (this.order === 3) {\n a = mt * mt;\n b = mt * t * 2;\n c = t * t;\n }\n var ret = {\n x: a * p[0].x + b * p[1].x + c * p[2].x,\n y: a * p[0].y + b * p[1].y + c * p[2].y\n };\n if (this._3d) {\n ret.z = a * p[0].z + b * p[1].z + c * p[2].z;\n }\n return ret;\n },\n curvature: function(t) {\n return utils.curvature(t, this.points, this._3d);\n },\n inflections: function() {\n return utils.inflections(this.points);\n },\n normal: function(t) {\n return this._3d ? this.__normal3(t) : this.__normal2(t);\n },\n __normal2: function(t) {\n var d = this.derivative(t);\n var q = sqrt(d.x * d.x + d.y * d.y);\n return { x: -d.y / q, y: d.x / q };\n },\n __normal3: function(t) {\n // see http://stackoverflow.com/questions/25453159\n var r1 = this.derivative(t),\n r2 = this.derivative(t + 0.01),\n q1 = sqrt(r1.x * r1.x + r1.y * r1.y + r1.z * r1.z),\n q2 = sqrt(r2.x * r2.x + r2.y * r2.y + r2.z * r2.z);\n r1.x /= q1;\n r1.y /= q1;\n r1.z /= q1;\n r2.x /= q2;\n r2.y /= q2;\n r2.z /= q2;\n // cross product\n var c = {\n x: r2.y * r1.z - r2.z * r1.y,\n y: r2.z * r1.x - r2.x * r1.z,\n z: r2.x * r1.y - r2.y * r1.x\n };\n var m = sqrt(c.x * c.x + c.y * c.y + c.z * c.z);\n c.x /= m;\n c.y /= m;\n c.z /= m;\n // rotation matrix\n var R = [\n c.x * c.x,\n c.x * c.y - c.z,\n c.x * c.z + c.y,\n c.x * c.y + c.z,\n c.y * c.y,\n c.y * c.z - c.x,\n c.x * c.z - c.y,\n c.y * c.z + c.x,\n c.z * c.z\n ];\n // normal vector:\n var n = {\n x: R[0] * r1.x + R[1] * r1.y + R[2] * r1.z,\n y: R[3] * r1.x + R[4] * r1.y + R[5] * r1.z,\n z: R[6] * r1.x + R[7] * r1.y + R[8] * r1.z\n };\n return n;\n },\n hull: function(t) {\n var p = this.points,\n _p = [],\n pt,\n q = [],\n idx = 0,\n i = 0,\n l = 0;\n q[idx++] = p[0];\n q[idx++] = p[1];\n q[idx++] = p[2];\n if (this.order === 3) {\n q[idx++] = p[3];\n }\n // we lerp between all points at each iteration, until we have 1 point left.\n while (p.length > 1) {\n _p = [];\n for (i = 0, l = p.length - 1; i < l; i++) {\n pt = utils.lerp(t, p[i], p[i + 1]);\n q[idx++] = pt;\n _p.push(pt);\n }\n p = _p;\n }\n return q;\n },\n split: function(t1, t2) {\n // shortcuts\n if (t1 === 0 && !!t2) {\n return this.split(t2).left;\n }\n if (t2 === 1) {\n return this.split(t1).right;\n }\n\n // no shortcut: use \"de Casteljau\" iteration.\n var q = this.hull(t1);\n var result = {\n left:\n this.order === 2\n ? new Bezier([q[0], q[3], q[5]])\n : new Bezier([q[0], q[4], q[7], q[9]]),\n right:\n this.order === 2\n ? new Bezier([q[5], q[4], q[2]])\n : new Bezier([q[9], q[8], q[6], q[3]]),\n span: q\n };\n\n // make sure we bind _t1/_t2 information!\n result.left._t1 = utils.map(0, 0, 1, this._t1, this._t2);\n result.left._t2 = utils.map(t1, 0, 1, this._t1, this._t2);\n result.right._t1 = utils.map(t1, 0, 1, this._t1, this._t2);\n result.right._t2 = utils.map(1, 0, 1, this._t1, this._t2);\n\n // if we have no t2, we're done\n if (!t2) {\n return result;\n }\n\n // if we have a t2, split again:\n t2 = utils.map(t2, t1, 1, 0, 1);\n var subsplit = result.right.split(t2);\n return subsplit.left;\n },\n extrema: function() {\n var dims = this.dims,\n result = {},\n roots = [],\n p,\n mfn;\n dims.forEach(\n function(dim) {\n mfn = function(v) {\n return v[dim];\n };\n p = this.dpoints[0].map(mfn);\n result[dim] = utils.droots(p);\n if (this.order === 3) {\n p = this.dpoints[1].map(mfn);\n result[dim] = result[dim].concat(utils.droots(p));\n }\n result[dim] = result[dim].filter(function(t) {\n return t >= 0 && t <= 1;\n });\n roots = roots.concat(result[dim].sort(utils.numberSort));\n }.bind(this)\n );\n roots = roots.sort(utils.numberSort).filter(function(v, idx) {\n return roots.indexOf(v) === idx;\n });\n result.values = roots;\n return result;\n },\n bbox: function() {\n var extrema = this.extrema(),\n result = {};\n this.dims.forEach(\n function(d) {\n result[d] = utils.getminmax(this, d, extrema[d]);\n }.bind(this)\n );\n return result;\n },\n overlaps: function(curve) {\n var lbbox = this.bbox(),\n tbbox = curve.bbox();\n return utils.bboxoverlap(lbbox, tbbox);\n },\n offset: function(t, d) {\n if (typeof d !== \"undefined\") {\n var c = this.get(t);\n var n = this.normal(t);\n var ret = {\n c: c,\n n: n,\n x: c.x + n.x * d,\n y: c.y + n.y * d\n };\n if (this._3d) {\n ret.z = c.z + n.z * d;\n }\n return ret;\n }\n if (this._linear) {\n var nv = this.normal(0);\n var coords = this.points.map(function(p) {\n var ret = {\n x: p.x + t * nv.x,\n y: p.y + t * nv.y\n };\n if (p.z && n.z) {\n ret.z = p.z + t * nv.z;\n }\n return ret;\n });\n return [new Bezier(coords)];\n }\n var reduced = this.reduce();\n return reduced.map(function(s) {\n if (s._linear) {\n return s.offset(t)[0];\n }\n return s.scale(t);\n });\n },\n simple: function() {\n if (this.order === 3) {\n var a1 = utils.angle(this.points[0], this.points[3], this.points[1]);\n var a2 = utils.angle(this.points[0], this.points[3], this.points[2]);\n if ((a1 > 0 && a2 < 0) || (a1 < 0 && a2 > 0)) return false;\n }\n var n1 = this.normal(0);\n var n2 = this.normal(1);\n var s = n1.x * n2.x + n1.y * n2.y;\n if (this._3d) {\n s += n1.z * n2.z;\n }\n var angle = abs(acos(s));\n return angle < pi / 3;\n },\n reduce: function() {\n var i,\n t1 = 0,\n t2 = 0,\n step = 0.01,\n segment,\n pass1 = [],\n pass2 = [];\n // first pass: split on extrema\n var extrema = this.extrema().values;\n if (extrema.indexOf(0) === -1) {\n extrema = [0].concat(extrema);\n }\n if (extrema.indexOf(1) === -1) {\n extrema.push(1);\n }\n\n for (t1 = extrema[0], i = 1; i < extrema.length; i++) {\n t2 = extrema[i];\n segment = this.split(t1, t2);\n segment._t1 = t1;\n segment._t2 = t2;\n pass1.push(segment);\n t1 = t2;\n }\n\n // second pass: further reduce these segments to simple segments\n pass1.forEach(function(p1) {\n t1 = 0;\n t2 = 0;\n while (t2 <= 1) {\n for (t2 = t1 + step; t2 <= 1 + step; t2 += step) {\n segment = p1.split(t1, t2);\n if (!segment.simple()) {\n t2 -= step;\n if (abs(t1 - t2) < step) {\n // we can never form a reduction\n return [];\n }\n segment = p1.split(t1, t2);\n segment._t1 = utils.map(t1, 0, 1, p1._t1, p1._t2);\n segment._t2 = utils.map(t2, 0, 1, p1._t1, p1._t2);\n pass2.push(segment);\n t1 = t2;\n break;\n }\n }\n }\n if (t1 < 1) {\n segment = p1.split(t1, 1);\n segment._t1 = utils.map(t1, 0, 1, p1._t1, p1._t2);\n segment._t2 = p1._t2;\n pass2.push(segment);\n }\n });\n return pass2;\n },\n scale: function(d) {\n var order = this.order;\n var distanceFn = false;\n if (typeof d === \"function\") {\n distanceFn = d;\n }\n if (distanceFn && order === 2) {\n return this.raise().scale(distanceFn);\n }\n\n // TODO: add special handling for degenerate (=linear) curves.\n var clockwise = this.clockwise;\n var r1 = distanceFn ? distanceFn(0) : d;\n var r2 = distanceFn ? distanceFn(1) : d;\n var v = [this.offset(0, 10), this.offset(1, 10)];\n var o = utils.lli4(v[0], v[0].c, v[1], v[1].c);\n if (!o) {\n throw new Error(\"cannot scale this curve. Try reducing it first.\");\n }\n // move all points by distance 'd' wrt the origin 'o'\n var points = this.points,\n np = [];\n\n // move end points by fixed distance along normal.\n [0, 1].forEach(\n function(t) {\n var p = (np[t * order] = utils.copy(points[t * order]));\n p.x += (t ? r2 : r1) * v[t].n.x;\n p.y += (t ? r2 : r1) * v[t].n.y;\n }.bind(this)\n );\n\n if (!distanceFn) {\n // move control points to lie on the intersection of the offset\n // derivative vector, and the origin-through-control vector\n [0, 1].forEach(\n function(t) {\n if (this.order === 2 && !!t) return;\n var p = np[t * order];\n var d = this.derivative(t);\n var p2 = { x: p.x + d.x, y: p.y + d.y };\n np[t + 1] = utils.lli4(p, p2, o, points[t + 1]);\n }.bind(this)\n );\n return new Bezier(np);\n }\n\n // move control points by \"however much necessary to\n // ensure the correct tangent to endpoint\".\n [0, 1].forEach(\n function(t) {\n if (this.order === 2 && !!t) return;\n var p = points[t + 1];\n var ov = {\n x: p.x - o.x,\n y: p.y - o.y\n };\n var rc = distanceFn ? distanceFn((t + 1) / order) : d;\n if (distanceFn && !clockwise) rc = -rc;\n var m = sqrt(ov.x * ov.x + ov.y * ov.y);\n ov.x /= m;\n ov.y /= m;\n np[t + 1] = {\n x: p.x + rc * ov.x,\n y: p.y + rc * ov.y\n };\n }.bind(this)\n );\n return new Bezier(np);\n },\n outline: function(d1, d2, d3, d4) {\n d2 = typeof d2 === \"undefined\" ? d1 : d2;\n var reduced = this.reduce(),\n len = reduced.length,\n fcurves = [],\n bcurves = [],\n p,\n alen = 0,\n tlen = this.length();\n\n var graduated = typeof d3 !== \"undefined\" && typeof d4 !== \"undefined\";\n\n function linearDistanceFunction(s, e, tlen, alen, slen) {\n return function(v) {\n var f1 = alen / tlen,\n f2 = (alen + slen) / tlen,\n d = e - s;\n return utils.map(v, 0, 1, s + f1 * d, s + f2 * d);\n };\n }\n\n // form curve oulines\n reduced.forEach(function(segment) {\n slen = segment.length();\n if (graduated) {\n fcurves.push(\n segment.scale(linearDistanceFunction(d1, d3, tlen, alen, slen))\n );\n bcurves.push(\n segment.scale(linearDistanceFunction(-d2, -d4, tlen, alen, slen))\n );\n } else {\n fcurves.push(segment.scale(d1));\n bcurves.push(segment.scale(-d2));\n }\n alen += slen;\n });\n\n // reverse the \"return\" outline\n bcurves = bcurves\n .map(function(s) {\n p = s.points;\n if (p[3]) {\n s.points = [p[3], p[2], p[1], p[0]];\n } else {\n s.points = [p[2], p[1], p[0]];\n }\n return s;\n })\n .reverse();\n\n // form the endcaps as lines\n var fs = fcurves[0].points[0],\n fe = fcurves[len - 1].points[fcurves[len - 1].points.length - 1],\n bs = bcurves[len - 1].points[bcurves[len - 1].points.length - 1],\n be = bcurves[0].points[0],\n ls = utils.makeline(bs, fs),\n le = utils.makeline(fe, be),\n segments = [ls]\n .concat(fcurves)\n .concat([le])\n .concat(bcurves),\n slen = segments.length;\n\n return new PolyBezier(segments);\n },\n outlineshapes: function(d1, d2, curveIntersectionThreshold) {\n d2 = d2 || d1;\n var outline = this.outline(d1, d2).curves;\n var shapes = [];\n for (var i = 1, len = outline.length; i < len / 2; i++) {\n var shape = utils.makeshape(\n outline[i],\n outline[len - i],\n curveIntersectionThreshold\n );\n shape.startcap.virtual = i > 1;\n shape.endcap.virtual = i < len / 2 - 1;\n shapes.push(shape);\n }\n return shapes;\n },\n intersects: function(curve, curveIntersectionThreshold) {\n if (!curve) return this.selfintersects(curveIntersectionThreshold);\n if (curve.p1 && curve.p2) {\n return this.lineIntersects(curve);\n }\n if (curve instanceof Bezier) {\n curve = curve.reduce();\n }\n return this.curveintersects(\n this.reduce(),\n curve,\n curveIntersectionThreshold\n );\n },\n lineIntersects: function(line) {\n var mx = min(line.p1.x, line.p2.x),\n my = min(line.p1.y, line.p2.y),\n MX = max(line.p1.x, line.p2.x),\n MY = max(line.p1.y, line.p2.y),\n self = this;\n return utils.roots(this.points, line).filter(function(t) {\n var p = self.get(t);\n return utils.between(p.x, mx, MX) && utils.between(p.y, my, MY);\n });\n },\n selfintersects: function(curveIntersectionThreshold) {\n var reduced = this.reduce();\n // \"simple\" curves cannot intersect with their direct\n // neighbour, so for each segment X we check whether\n // it intersects [0:x-2][x+2:last].\n var i,\n len = reduced.length - 2,\n results = [],\n result,\n left,\n right;\n for (i = 0; i < len; i++) {\n left = reduced.slice(i, i + 1);\n right = reduced.slice(i + 2);\n result = this.curveintersects(left, right, curveIntersectionThreshold);\n results = results.concat(result);\n }\n return results;\n },\n curveintersects: function(c1, c2, curveIntersectionThreshold) {\n var pairs = [];\n // step 1: pair off any overlapping segments\n c1.forEach(function(l) {\n c2.forEach(function(r) {\n if (l.overlaps(r)) {\n pairs.push({ left: l, right: r });\n }\n });\n });\n // step 2: for each pairing, run through the convergence algorithm.\n var intersections = [];\n pairs.forEach(function(pair) {\n var result = utils.pairiteration(\n pair.left,\n pair.right,\n curveIntersectionThreshold\n );\n if (result.length > 0) {\n intersections = intersections.concat(result);\n }\n });\n return intersections;\n },\n arcs: function(errorThreshold) {\n errorThreshold = errorThreshold || 0.5;\n var circles = [];\n return this._iterate(errorThreshold, circles);\n },\n _error: function(pc, np1, s, e) {\n var q = (e - s) / 4,\n c1 = this.get(s + q),\n c2 = this.get(e - q),\n ref = utils.dist(pc, np1),\n d1 = utils.dist(pc, c1),\n d2 = utils.dist(pc, c2);\n return abs(d1 - ref) + abs(d2 - ref);\n },\n _iterate: function(errorThreshold, circles) {\n var t_s = 0,\n t_e = 1,\n safety;\n // we do a binary search to find the \"good `t` closest to no-longer-good\"\n do {\n safety = 0;\n\n // step 1: start with the maximum possible arc\n t_e = 1;\n\n // points:\n var np1 = this.get(t_s),\n np2,\n np3,\n arc,\n prev_arc;\n\n // booleans:\n var curr_good = false,\n prev_good = false,\n done;\n\n // numbers:\n var t_m = t_e,\n prev_e = 1,\n step = 0;\n\n // step 2: find the best possible arc\n do {\n prev_good = curr_good;\n prev_arc = arc;\n t_m = (t_s + t_e) / 2;\n step++;\n\n np2 = this.get(t_m);\n np3 = this.get(t_e);\n\n arc = utils.getccenter(np1, np2, np3);\n\n //also save the t values\n arc.interval = {\n start: t_s,\n end: t_e\n };\n\n var error = this._error(arc, np1, t_s, t_e);\n curr_good = error <= errorThreshold;\n\n done = prev_good && !curr_good;\n if (!done) prev_e = t_e;\n\n // this arc is fine: we can move 'e' up to see if we can find a wider arc\n if (curr_good) {\n // if e is already at max, then we're done for this arc.\n if (t_e >= 1) {\n // make sure we cap at t=1\n arc.interval.end = prev_e = 1;\n prev_arc = arc;\n // if we capped the arc segment to t=1 we also need to make sure that\n // the arc's end angle is correct with respect to the bezier end point.\n if (t_e > 1) {\n var d = {\n x: arc.x + arc.r * cos(arc.e),\n y: arc.y + arc.r * sin(arc.e)\n };\n arc.e += utils.angle({ x: arc.x, y: arc.y }, d, this.get(1));\n }\n break;\n }\n // if not, move it up by half the iteration distance\n t_e = t_e + (t_e - t_s) / 2;\n } else {\n // this is a bad arc: we need to move 'e' down to find a good arc\n t_e = t_m;\n }\n } while (!done && safety++ < 100);\n\n if (safety >= 100) {\n break;\n }\n\n // console.log(\"L835: [F] arc found\", t_s, prev_e, prev_arc.x, prev_arc.y, prev_arc.s, prev_arc.e);\n\n prev_arc = prev_arc ? prev_arc : arc;\n circles.push(prev_arc);\n t_s = prev_e;\n } while (t_e < 1);\n return circles;\n }\n };\n\n module.exports = Bezier;\n})();\n","module.exports = require('./lib/bezier');\n"],"names":["abs","cos","sin","acos","atan2","sqrt","pow","crt","v","pi","tau","quart","epsilon","nMax","nMin","ZERO","utils","t","derivativeFn","d","l","points","_3d","order","p","mt","ret","mt2","t2","a","b","c","dCpts","i","ratios","r","f1","f2","f3","f4","dpoints","list","j","dpt","m","M","precision","z","sum","len","ds","de","ts","te","d1","d2","v2","v1","s","obj","o","dx1","dy1","dx2","dy2","cross","dot","pos","p1","p2","dx","dy","LUT","point","mdist","mpos","idx","n","bottom","top","x1","y1","x2","y2","x3","y3","x4","y4","nx","ny","p3","p4","Bezier","require$$0","sections","mx","my","MX","MY","bbox","s1","bbox1","s2","bbox2","curveIntersectionThreshold","intersections","a1","a2","l1","l2","iss","forward","back","bpl","fpl","start","end","shape","self","curve","min","max","line","tx","ty","reduce","m1","m2","pa","pb","pc","pd","q","q2","discriminant","u1","mp3","mp33","cosphi","phi","crtr","t1","sd","kOnly","num","dnm","adk","dk","k","dd","qdsum","pk","nk","v3","trm","sq","b1","b2","dims","dim","_bbox","c1","c2","c1b","c2b","threshold","cc1","cc2","pairs","pair","results","dx1p","dy1p","dx2p","dy2p","mx1","my1","mx2","my2","mx1n","my1n","mx2n","my2n","arc","e","_","utilsModule","PolyBezier","curves","offset","polyBezierModule","normalizePath","instructions","instructionLength","instruction","op","lop","args","alen","sx","sy","x","y","cx","cy","cx2","cy2","normalized","normaliseSvg","normalise","makeBezier","term","values","cvalues","PreboundConstructor","last","convertPath","terms","matcher","segment","segments","ARGS","svgToBeziers","require$$1","coords","coordlen","newargs","higher","step","require$$2","getABC","S","B","E","u","um","C","A","abc","selen","lx","ly","bx1","by1","bx2","by2","e1","e2","nc1","nc2","getUtils","relative","print","newprint","angle","steps","error","lut","hits","closest","ft","np","pim","r1","r2","q1","R","_p","pt","result","subsplit","roots","mfn","extrema","lbbox","tbbox","nv","reduced","n1","n2","pass1","pass2","distanceFn","clockwise","ov","rc","d3","d4","fcurves","bcurves","tlen","graduated","linearDistanceFunction","slen","fs","fe","bs","be","ls","le","outline","shapes","left","right","errorThreshold","circles","np1","ref","t_s","t_e","safety","np2","np3","prev_arc","curr_good","prev_good","done","t_m","prev_e","bezierModule","bezierJs"],"mappings":"0aAAC,UAAW,CAIV,IAAIA,EAAM,KAAK,IACbC,EAAM,KAAK,IACXC,EAAM,KAAK,IACXC,EAAO,KAAK,KACZC,EAAQ,KAAK,MACbC,EAAO,KAAK,KACZC,EAAM,KAAK,IAEXC,EAAM,SAASC,EAAG,CAChB,OAAOA,EAAI,EAAI,CAACF,EAAI,CAACE,EAAG,EAAI,CAAC,EAAIF,EAAIE,EAAG,EAAI,CAAC,CAC9C,EAEDC,EAAK,KAAK,GACVC,EAAM,EAAID,EACVE,EAAQF,EAAK,EAEbG,EAAU,KAEVC,EAAO,OAAO,kBAAoB,iBAClCC,EAAO,OAAO,kBAAoB,kBAElCC,EAAO,CAAE,EAAG,EAAG,EAAG,EAAG,EAAG,CAAG,EAGzBC,EAAQ,CAEV,QAAS,CAC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