diff --git a/article.js b/article.js index 6c930165..c2067176 100644 --- a/article.js +++ b/article.js @@ -1 +1 @@ -(function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.BezierArticle=t():e.BezierArticle=t()})(this,function(){var e=Math.tan,n=Math.floor,t=Math.LOG10E,i=Math.log,o=Math.round,a=Math.pow,s=Math.atan2,l=Math.sin,u=Math.cos,v=Math.PI,f=Math.sqrt,d=Math.acos,w=Math.max,m=Math.min,r=Math.abs;return function(e){function t(a){if(n[a])return n[a].exports;var i=n[a]={i:a,l:!1,exports:{}};return e[a].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,a){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:a})},t.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=129)}([function(e,t,n){"use strict";var a=n(1),i=n(6),r=new i;e.exports=function(e,t){var n={getDefaultProps:function(){return{page:e,title:r.getTitle(e),handler:t}},render:function(){return r.getContent(e,this)}};return t&&Object.keys(t).forEach(function(e){n[e]=t[e]}),a.createClass(n)}},function(e,t,n){"use strict";(function(e){function a(){return null}function r(e){var t=e.nodeName,n=e.attributes;e.attributes={},t.defaultProps&&_(e.attributes,t.defaultProps),n&&_(e.attributes,n)}function o(e,t){var n,a,r;if(t){for(r in t)if(n=U.test(r))break;if(n)for(r in a=e.attributes={},t)t.hasOwnProperty(r)&&(a[U.test(r)?r.replace(/([A-Z0-9])/,"-$1").toLowerCase():r]=t[r])}}function s(e,t,a){var r=t&&t._preactCompatRendered&&t._preactCompatRendered.base;r&&r.parentNode!==t&&(r=null),r||(r=t.children[0]);for(var o=t.childNodes.length;o--;)t.childNodes[o]!==r&&t.removeChild(t.childNodes[o]);var s=n.i(G.render)(e,t,r);return t&&(t._preactCompatRendered=s&&(s._component||{base:s})),"function"==typeof a&&a(),s&&s._component||s}function l(e,t,a,i){var r=n.i(G.h)($,{context:e.context},t),o=s(r,a);return i&&i(o),o._component||o.base}function d(e){var t=e._preactCompatRendered&&e._preactCompatRendered.base;return!!(t&&t.parentNode===e)&&(n.i(G.render)(n.i(G.h)(a),e,t),!0)}function c(e){return g.bind(null,e)}function h(e,t){for(var n=t||0,a;nn?e:e+t[n%2]}),new u(t)):new u(t)},u.quadraticFromPoints=function(e,n,i,r){if("undefined"==typeof r&&(r=.5),0===r)return new u(n,n,i);if(1===r)return new u(e,n,n);var o=a(2,e,n,i,r);return new u(e,o.A,i)},u.cubicFromPoints=function(e,n,i,r,o){"undefined"==typeof r&&(r=.5);var s=a(3,e,n,i,r);"undefined"==typeof o&&(o=h.dist(n,s.C));var l=o*(1-r)/r,d=h.dist(e,i),c=(i.x-e.x)/d,m=(i.y-e.y)/d,p=o*c,g=o*m,f={x:n.x-p,y:n.y-g},w={x:n.x+l*c,y:n.y+l*m},y=s.A,v={x:y.x+(f.x-y.x)/(1-r),y:y.y+(f.y-y.y)/(1-r)},b={x:y.x+(w.x-y.x)/r,y:y.y+(w.y-y.y)/r},x={x:e.x+(v.x-e.x)/r,y:e.y+(v.y-e.y)/r},_={x:i.x+(b.x-i.x)/(1-r),y:i.y+(b.y-i.y)/(1-r)};return new u(e,x,_,i)};var p=function(){return h};u.getUtils=p,u.prototype={getUtils:p,valueOf:function(){return this.toString()},toString:function(){return h.pointsToString(this.points)},toSVG:function(){if(this._3d)return!1;for(var e=this.points,t=e[0].x,n=e[0].y,a=["M",t,n,2===this.order?"Q":"C"],r=1,o=e.length;rthis.order){var r=n*n,o=e*e,s=0,h,u,m;2===this.order?(t=[t[0],t[1],t[2],l],h=r,u=2*(n*e),m=o):3===this.order&&(h=r*n,u=3*(r*e),m=3*(n*o),s=e*o);var g={x:h*t[0].x+u*t[1].x+m*t[2].x+s*t[3].x,y:h*t[0].y+u*t[1].y+m*t[2].y+s*t[3].y};return this._3d&&(g.z=h*t[0].z+u*t[1].z+m*t[2].z+s*t[3].z),g}for(var f=JSON.parse(JSON.stringify(this.points));1=e}),n=n.concat(t[e].sort())}.bind(this)),n=n.sort().filter(function(e,t){return n.indexOf(e)===t}),t.values=n,t},bbox:function(){var e=this.extrema(),t={};return this.dims.forEach(function(n){t[n]=h.getminmax(this,n,e[n])}.bind(this)),t},overlaps:function(e){var t=this.bbox(),n=e.bbox();return h.bboxoverlap(t,n)},offset:function(e,t){if("undefined"!=typeof t){var a=this.get(e),i=this.normal(e),n={c:a,n:i,x:a.x+i.x*t,y:a.y+i.y*t};return this._3d&&(n.z=a.z+i.z*t),n}if(this._linear){var r=this.normal(0),o=this.points.map(function(t){var n={x:t.x+e*r.x,y:t.y+e*r.y};return t.z&&i.z&&(n.z=t.z+e*r.z),n});return[new u(o)]}var s=this.reduce();return s.map(function(t){return t.scale(e)})},simple:function(){if(3===this.order){var e=h.angle(this.points[0],this.points[3],this.points[1]),n=h.angle(this.points[0],this.points[3],this.points[2]);if(0n||0>e&&0=n;)for(n=e+a;n<=1+a;n+=a)if(d=i.split(e,n),!d.simple()){if(n-=a,t(e-n)e&&(d=i.split(e,1),d._t1=h.map(e,0,1,i._t1,i._t2),d._t2=i._t2,o.push(d))}),o},scale:function(e){var n=this.order,a=!1;if("function"==typeof e&&(a=e),a&&2===n)return this.raise().scale(a);var i=this.clockwise,r=a?a(0):e,l=a?a(1):e,d=[this.offset(0,10),this.offset(1,10)],c=h.lli4(d[0],d[0].c,d[1],d[1].c);if(!c)throw new Error("cannot scale this curve. Try reducing it first.");var o=this.points,g=[];return([0,1].forEach(function(e){var t=g[e*n]=h.copy(o[e*n]);t.x+=(e?l:r)*d[e].n.x,t.y+=(e?l:r)*d[e].n.y}.bind(this)),!a)?([0,1].forEach(function(e){if(2!==this.order||!e){var t=g[e*n],a=this.derivative(e),i={x:t.x+a.x,y:t.y+a.y};g[e+1]=h.lli4(t,i,c,o[e+1])}}.bind(this)),new u(g)):([0,1].forEach(function(r){if(2!==this.order||!r){var t=o[r+1],l={x:t.x-c.x,y:t.y-c.y},d=a?a((r+1)/n):e;a&&!i&&(d=-d);var h=s(l.x*l.x+l.y*l.y);l.x/=h,l.y/=h,g[r+1]={x:t.x+d*l.x,y:t.y+d*l.y}}}.bind(this)),new u(g))},outline:function(e,t,n,a){function i(t,n,e,a,i){return function(r){var o=n-t;return h.map(r,0,1,t+a/e*o,t+(a+i)/e*o)}}t="undefined"==typeof t?e:t;var r=this.reduce(),o=r.length,s=[],l=[],d=0,u=this.length(),m;r.forEach(function(r){_=r.length(),"undefined"!=typeof n&&"undefined"!=typeof a?(s.push(r.scale(i(e,n,u,d,_))),l.push(r.scale(i(-t,-a,u,d,_)))):(s.push(r.scale(e)),l.push(r.scale(-t))),d+=_}),l=l.map(function(e){return m=e.points,e.points=m[3]?[m[3],m[2],m[1],m[0]]:[m[2],m[1],m[0]],e}).reverse();var g=s[0].points[0],f=s[o-1].points[s[o-1].points.length-1],w=l[o-1].points[l[o-1].points.length-1],y=l[0].points[0],v=h.makeline(w,g),b=h.makeline(f,y),x=[v].concat(s).concat([b]).concat(l),_=x.length;return new c(x)},outlineshapes:function(e,t,n){t=t||e;for(var a=this.outline(e,t).curves,r=[],o=1,s=a.length,l;or++);if(100<=r)break;y=y?y:w,n.push(y),a=u}while(1>i);return n}},e.exports=u})()},function(e,t,n){(function(){"use strict";var o=r,i=u,t=l,c=s,h=f,m=a,g=function(e){return 0>e?-m(-e,1/3):m(e,1/3)},p=v,w=2*p,y=p/2,b=Number.MAX_SAFE_INTEGER,x=Number.MIN_SAFE_INTEGER,E={Tvalues:[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213],Cvalues:[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872],arcfn:function(e,t){var n=t(e),a=n.x*n.x+n.y*n.y;return"undefined"!=typeof n.z&&(a+=n.z*n.z),h(a)},between:function(e,t,n){return t<=e&&e<=n||E.approximately(e,t)||E.approximately(e,n)},approximately:function(e,t,n){return o(e-t)<=(n||1e-6)},length:function(e){var n=.5,a=0,r=E.Tvalues.length,o,s;for(o=0;or.x.min&&(t=r.x.min),n>r.y.min&&(n=r.y.min),ao&&(o=l[n]);return{min:r,mid:(r+o)/2,max:o,size:o-r}},align:function(e,n){var r=n.p1.x,o=n.p1.y,s=-c(n.p2.y-o,n.p2.x-r);return e.map(function(e){return{x:(e.x-r)*i(s)-(e.y-o)*t(s),y:(e.x-r)*t(s)+(e.y-o)*i(s)}})},roots:function(e,n){n=n||{p1:{x:0,y:0},p2:{x:1,y:0}};var o=e.length-1,s=E.align(e,n),l=function(e){return 0<=e&&1>=e};if(2==o){var u=s[0].y,m=s[1].y,f=s[2].y,y=u-2*m+f;if(0!==y){var v=-h(m*m-u*f),x=-u+m,_=-(v+x)/y,k=-(-v+x)/y;return[_,k].filter(l)}return m!==f&&0===y?[(2*m-f)/2*(m-f)].filter(l):[]}var C=s[0].y,S=s[1].y,z=s[2].y,T=s[3].y,y=-C+3*S-3*z+T,u=(3*C-6*S+3*z)/y,m=(-3*C+3*S)/y,f=C/y,s=(3*m-u*u)/3,P=s/3,B=(2*u*u*u-9*u*m+27*f)/27,N=B/2,L=N*N+P*P*P,I,_,A,j,D;if(0>L){var O=-s/3,q=h(O*O*O),r=-B/(2*q),t=-1>r?-1:1N?g(-N):-g(N),A=2*I-u/3,j=-I-u/3,[A,j].filter(l);var F=h(L);return I=g(-N+F),_=g(N+F),[I-_-u/3].filter(l)},droots:function(e){if(3===e.length){var t=e[0],n=e[1],i=e[2],r=t-2*n+i;if(0!==r){var o=-h(n*n-t*i),s=-t+n;return[-(o+s)/r,-(-o+s)/r]}return n!==i&&0===r?[(2*n-i)/(2*(n-i))]:[]}if(2===e.length){var t=e[0],n=e[1];return t===n?[]:[t/(t-n)]}},inflections:function(e){if(4>e.length)return[];var n=E.align(e,{p1:e[0],p2:e.slice(-1)[0]}),i=n[2].x*n[1].y,a=n[3].x*n[1].y,r=n[1].x*n[2].y,o=n[3].x*n[2].y,s=18*(-3*i+2*a+3*r-o),l=18*(3*i-a-3*r),c=18*(r-i);if(E.approximately(s,0)){if(!E.approximately(l,0)){var h=-c/l;if(0<=h&&1>=h)return[h]}return[]}var t=f(l*l-4*s*c),o=2*s;return E.approximately(o,0)?[]:[(t-l)/o,-(l+t)/o].filter(function(e){return 0<=e&&1>=e})},bboxoverlap:function(e,n){var a=["x","y"],r=a.length,s,c,h,u,m;for(s=0;s=m)return!1;return!0},expandbox:function(e,t){t.x.mine.x.max&&(e.x.max=t.x.max),t.y.max>e.y.max&&(e.y.max=t.y.max),t.z&&t.z.max>e.z.max&&(e.z.max=t.z.max),e.x.mid=(e.x.min+e.x.max)/2,e.y.mid=(e.y.min+e.y.max)/2,e.z&&(e.z.mid=(e.z.min+e.z.max)/2),e.x.size=e.x.max-e.x.min,e.y.size=e.y.max-e.y.min,e.z&&(e.z.size=e.z.max-e.z.min)},pairiteration:function(e,t,n){var a=e.bbox(),i=t.bbox(),r=n||.5;if(a.x.size+a.y.sizeT||T>m)&&(r+=w),r>m&&(P=m,m=r,r=P)):m=n.length;){for(var a=n.length,r=[1],o=1,s=a-1;o<=a;o++)r[o]=n[s][o-1]+n[s][o];r[a]=1,n.push(r)}return n[e][t]}function r(e,t){var n=e.x-t.x,a=e.y-t.y;return f(n*n+a*a)}function s(e){var t=[];return e.forEach(()=>t.push([])),e.forEach((e,n)=>e.forEach((e,a)=>t[a][n]=e)),t}function i(e,t){return e[t]}function l(e,t){for(var n=[],a=0,i=e.length;ae+h[n]*t;n[o][s]=d.reduce(u,0)}}return n}function c(e,t){var n=[];return e.forEach(e=>n.push([e[t]])),n}function h(e){for(var t=[],n=e;n--;)t[n]="0".repeat(e).split("").map(e=>parseInt(e));for(n=0;n{s[t]=e/l}),s}function m(e,t){return e.map(e=>a(e,t))}function p(e,t){t=t||e.length;for(var a=[],r=0;ra)throw new Error("degree must be at least 1 (linear)");if(a>m-1)throw new Error("degree must be less than or equal to point count - 1");if(!c)for(c=[],d=0;db)throw new Error("out of bounds");for(g=w[0];g=o[g]&&e<=o[g+1]);g++);var x=[];for(d=0;dg-a-1+f;d--)for(v=(e-o[d])/(o[d+a+1-f]-o[d]),p=0;p=a?(o&&(e.__index=s+1),l&&n&&n.clone?l.clone():l):(l=_.create(this.prototype),o&&(l.__read=!0),l=l.initialize.apply(l,0e.length&&(n=e.length);for(var s=0;sn?n:e}var o=[[.5773502691896257],[0,.7745966692414834],[.33998104358485626,.8611363115940526],[0,.5384693101056831,.906179845938664],[.2386191860831969,.6612093864662645,.932469514203152],[0,.4058451513773972,.7415311855993945,.9491079123427585],[.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],[0,.3242534234038089,.6133714327005904,.8360311073266358,.9681602395076261],[.14887433898163122,.4333953941292472,.6794095682990244,.8650633666889845,.9739065285171717],[0,.26954315595234496,.5190961292068118,.7301520055740494,.8870625997680953,.978228658146057],[.1252334085114689,.3678314989981802,.5873179542866175,.7699026741943047,.9041172563704749,.9815606342467192],[0,.2304583159551348,.44849275103644687,.6423493394403402,.8015780907333099,.9175983992229779,.9841830547185881],[.10805494870734367,.31911236892788974,.5152486363581541,.6872929048116855,.827201315069765,.9284348836635735,.9862838086968123],[0,.20119409399743451,.3941513470775634,.5709721726085388,.7244177313601701,.8482065834104272,.937273392400706,.9879925180204854],[.09501250983763744,.2816035507792589,.45801677765722737,.6178762444026438,.755404408355003,.8656312023878318,.9445750230732326,.9894009349916499]],s=[[1],[.8888888888888888,.5555555555555556],[.6521451548625461,.34785484513745385],[.5688888888888889,.47862867049936647,.23692688505618908],[.46791393457269104,.3607615730481386,.17132449237917036],[.4179591836734694,.3818300505051189,.27970539148927664,.1294849661688697],[.362683783378362,.31370664587788727,.22238103445337448,.10122853629037626],[.3302393550012598,.31234707704000286,.26061069640293544,.1806481606948574,.08127438836157441],[.29552422471475287,.26926671930999635,.21908636251598204,.1494513491505806,.06667134430868814],[.2729250867779006,.26280454451024665,.23319376459199048,.18629021092773426,.1255803694649046,.05566856711617366],[.24914704581340277,.2334925365383548,.20316742672306592,.16007832854334622,.10693932599531843,.04717533638651183],[.2325515532308739,.22628318026289723,.2078160475368885,.17814598076194574,.13887351021978725,.09212149983772845,.04048400476531588],[.2152638534631578,.2051984637212956,.18553839747793782,.15720316715819355,.12151857068790319,.08015808715976021,.03511946033175186],[.2025782419255613,.19843148532711158,.1861610000155622,.16626920581699392,.13957067792615432,.10715922046717194,.07036604748810812,.03075324199611727],[.1894506104550685,.18260341504492358,.16915651939500254,.14959598881657674,.12462897125553388,.09515851168249279,.062253523938647894,.027152459411754096]],l=r,h=f,u=a,m=1e-12,p=112e-18;return{TOLERANCE:1e-6,EPSILON:m,MACHINE_EPSILON:p,CURVETIME_EPSILON:4e-7,GEOMETRIC_EPSILON:2e-7,WINDING_EPSILON:2e-7,TRIGONOMETRIC_EPSILON:1e-7,CLIPPING_EPSILON:1e-7,KAPPA:4*(h(2)-1)/3,isZero:function(e){return e>=-m&&e<=m},integrate:function(e,t,a,r){for(var n=o[r-2],l=s[r-2],d=.5*(a-t),c=d+t,h=0,u=1&r?l[h++]*e(c):0,m;h>1;)m=d*n[h],u+=l[h++]*(e(c+m)+e(c-m));return d*u},findRoot:function(e,t,r,o,s,d,n){for(var c=0;c=s?.5*(o+s):m)}return r},solveQuadratic:function(r,o,s,d,g,f){var w=0,y=g-m,v=f+m,x=1/0,_=o,E,k;if(o/=-2,k=o*o-r*s,0!==k&&l(k)C){var S=u(10,l(n(i(C)*t)));isFinite(S)||(S=0),r*=S,o*=S,s*=S,k=o*o-r*s}}if(l(r)=-p){var z=0>k?0:h(k),T=o+(0>o?-z:z);0===T?(E=s/r,x=-E):(E=T/r,x=s/T)}return isFinite(E)&&(null==g||E>y&&Ey&&xS?-1:1,S=-C/n,T=0P*v);l(n)*v*v>l(c/v)&&(_=-c/v,b=(_-o)/v)}}var y=z.solveQuadratic(n,b,_,d,g,f);return isFinite(v)&&(0===y||v!==d[y-1])&&(null==g||v>g-m&&vn?-1:1this.width&&(this.x=l.x,this.width=-this.width),0>this.height&&(this.y=l.y,this.height=-this.height)}else{var d=N.read(arguments);this.width=d.width,this.height=d.height}r=arguments.__index}this.__read&&(this.__read=r)},set:function(e,t,n,a){return this.x=e,this.y=t,this.width=n,this.height=a,this},clone:function(){return new I(this.x,this.y,this.width,this.height)},equals:function(e){var t=_.isPlainValue(e)?I.read(arguments):e;return t===this||t&&this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height||!1},toString:function(){var e=S.instance;return"{ x: "+e.number(this.x)+", y: "+e.number(this.y)+", width: "+e.number(this.width)+", height: "+e.number(this.height)+" }"},_serialize:function(e){var t=e.formatter;return[t.number(this.x),t.number(this.y),t.number(this.width),t.number(this.height)]},getPoint:function(e){var t=e?P:B;return new t(this.x,this.y,this,"setPoint")},setPoint:function(){var e=P.read(arguments);this.x=e.x,this.y=e.y},getSize:function(e){var t=e?N:L;return new t(this.width,this.height,this,"setSize")},setSize:function(){var e=N.read(arguments);this._fixX&&(this.x+=(this.width-e.width)*this._fixX),this._fixY&&(this.y+=(this.height-e.height)*this._fixY),this.width=e.width,this.height=e.height,this._fixW=1,this._fixH=1},getLeft:function(){return this.x},setLeft:function(e){this._fixW||(this.width-=e-this.x),this.x=e,this._fixX=0},getTop:function(){return this.y},setTop:function(e){this._fixH||(this.height-=e-this.y),this.y=e,this._fixY=0},getRight:function(){return this.x+this.width},setRight:function(e){void 0!==this._fixX&&1!==this._fixX&&(this._fixW=0),this._fixW?this.x=e-this.width:this.width=e-this.x,this._fixX=1},getBottom:function(){return this.y+this.height},setBottom:function(e){void 0!==this._fixY&&1!==this._fixY&&(this._fixH=0),this._fixH?this.y=e-this.height:this.height=e-this.y,this._fixY=1},getCenterX:function(){return this.x+.5*this.width},setCenterX:function(e){this.x=e-.5*this.width,this._fixX=.5},getCenterY:function(){return this.y+.5*this.height},setCenterY:function(e){this.y=e-.5*this.height,this._fixY=.5},getCenter:function(e){var t=e?P:B;return new t(this.getCenterX(),this.getCenterY(),this,"setCenter")},setCenter:function(){var e=P.read(arguments);return this.setCenterX(e.x),this.setCenterY(e.y),this},getArea:function(){return this.width*this.height},isEmpty:function(){return 0===this.width||0===this.height},contains:function(e){return e&&void 0!==e.width||4==(Array.isArray(e)?e:arguments).length?this._containsRectangle(I.read(arguments)):this._containsPoint(P.read(arguments))},_containsPoint:function(e){var t=e.x,n=e.y;return t>=this.x&&n>=this.y&&t<=this.x+this.width&&n<=this.y+this.height},_containsRectangle:function(e){var t=e.x,n=e.y;return t>=this.x&&n>=this.y&&t+e.width<=this.x+this.width&&n+e.height<=this.y+this.height},intersects:function(){var e=I.read(arguments);return e.x+e.width>this.x&&e.y+e.height>this.y&&e.x=this.x&&e.y+e.height>=this.y&&e.x<=this.x+this.width&&e.y<=this.y+this.height},intersect:function(){var e=I.read(arguments),t=w(this.x,e.x),n=w(this.y,e.y),a=m(this.x+this.width,e.x+e.width),i=m(this.y+this.height,e.y+e.height);return new I(t,n,a-t,i-n)},unite:function(){var e=I.read(arguments),t=m(this.x,e.x),n=m(this.y,e.y),a=w(this.x+this.width,e.x+e.width),i=w(this.y+this.height,e.y+e.height);return new I(t,n,a-t,i-n)},include:function(){var e=P.read(arguments),t=m(this.x,e.x),n=m(this.y,e.y),a=w(this.x+this.width,e.x),i=w(this.y+this.height,e.y);return new I(t,n,a-t,i-n)},expand:function(){var e=N.read(arguments),t=e.width,n=e.height;return new I(this.x-t/2,this.y-n/2,this.width+t,this.height+n)},scale:function(e,t){return this.expand(this.width*e-this.width,this.height*(void 0===t?e:t)-this.height)}},_.each([["Top","Left"],["Top","Right"],["Bottom","Left"],["Bottom","Right"],["Left","Center"],["Top","Center"],["Right","Center"],["Bottom","Center"]],function(e,t){var n=e.join(""),a=/^[RL]/.test(n);4<=t&&(e[1]+=a?"Y":"X");var i=e[a?0:1],r=e[a?1:0],o="set"+n;this["get"+n]=function(e){var t=e?P:B;return new t(this["get"+i](),this["get"+r](),this,o)},this[o]=function(){var e=P.read(arguments);this["set"+i](e.x),this["set"+r](e.y)}},{beans:!0})),A=I.extend({initialize:function(e,t,n,a,i,r){this.set(e,t,n,a,!0),this._owner=i,this._setter=r},set:function(e,t,n,a,i){return this._x=e,this._y=t,this._width=n,this._height=a,i||this._owner[this._setter](this),this}},new function(){var e=I.prototype;return _.each(["x","y","width","height"],function(e){var t=_.capitalize(e),n="_"+e;this["get"+t]=function(){return this[n]},this["set"+t]=function(e){this[n]=e,this._dontNotify||this._owner[this._setter](this)}},_.each(["Point","Size","Center","Left","Top","Right","Bottom","CenterX","CenterY","TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],function(t){var n="set"+t;this[n]=function(){this._dontNotify=!0,e[n].apply(this,arguments),this._dontNotify=!1,this._owner[this._setter](this)}},{isSelected:function(){return this._owner._boundsSelected},setSelected:function(e){var t=this._owner;t.setSelected&&(t._boundsSelected=e,t.setSelected(e||0arguments.length?this._transformPoint(P.read(arguments)):this._transformCoordinates(e,t,n)},_transformPoint:function(e,t,n){var a=e.x,i=e.y;return t||(t=new P),t.set(a*this._a+i*this._b+this._tx,a*this._c+i*this._d+this._ty,n)},_transformCoordinates:function(e,t,n){for(var a=0,r=0;a<2*n;){var o=e[a++],s=e[a++];t[r++]=o*this._a+s*this._b+this._tx,t[r++]=o*this._c+s*this._d+this._ty}return t},_transformCorners:function(e){var t=e.x,n=e.y,a=t+e.width,i=n+e.height,r=[t,n,a,n,a,i,t,i];return this._transformCoordinates(r,r,4)},_transformBounds:function(e,t,n){for(var a=this._transformCorners(e),r=a.slice(0,2),o=r.slice(),s=2;8>s;s++){var l=a[s],d=1&s;lo[d]&&(o[d]=l)}return t||(t=new I),t.set(r[0],r[1],o[0]-r[0],o[1]-r[1],n)},inverseTransform:function(){return this._inverseTransform(P.read(arguments))},_getDeterminant:function(){var e=this._a*this._d-this._b*this._c;return isFinite(e)&&!z.isZero(e)&&isFinite(this._tx)&&isFinite(this._ty)?e:null},_inverseTransform:function(e,t,n){var a=this._getDeterminant();if(!a)return null;var i=e.x-this._tx,r=e.y-this._ty;return t||(t=new P),t.set((i*this._d-r*this._b)/a,(r*this._a-i*this._c)/a,n)},decompose:function(){var e=this._a,t=this._b,n=this._c,i=this._d;if(z.isZero(e*i-t*n))return null;var r=f(e*e+t*t);e/=r,t/=r;var o=e*n+t*i;n-=e*o,i-=t*o;var l=f(n*n+i*i);return n/=l,i/=l,o/=l,e*i=m?0:1<=m?1:m),new P(e+m*n,t+m*a)}},getSide:function(e,t,n,a,i,r,o,s){o||(n-=e,a-=t);var l=i-e,d=l*a-(r-t)*n;return 0!=d||s||(d=(l*n+l*n)/(n*n+a*a),0<=d&&1>=d&&(d=0)),0>d?-1:0n?r-t:t-r:((i-e)*a-(r-t)*n)/f(n*n+a*a)}}}),O=C.extend({_class:"Project",_list:"projects",_reference:"project",initialize:function(e){C.call(this,!0),this.layers=[],this._activeLayer=null,this.symbols=[],this._currentStyle=new oe(null,null,this),this._view=de.create(this,e||ye.getCanvas(1,1)),this._selectedItems={},this._selectedItemCount=0,this._updateVersion=0},_serialize:function(e,t){return _.serialize(this.layers,e,!0,t)},clear:function(){for(var e=this.layers.length-1;0<=e;e--)this.layers[e].remove();this.symbols=[]},isEmpty:function(){return 0===this.layers.length},remove:function e(){return!!e.base.call(this)&&(this._view&&this._view.remove(),!0)},getView:function(){return this._view},getCurrentStyle:function(){return this._currentStyle},setCurrentStyle:function(e){this._currentStyle.initialize(e)},getIndex:function(){return this._index},getOptions:function(){return this._scope.settings},getActiveLayer:function(){return this._activeLayer||new M({project:this})},getSelectedItems:function(){var e=[];for(var t in this._selectedItems){var n=this._selectedItems[t];n.isInserted()&&e.push(n)}return e},insertChild:function(e,t,n){return t instanceof M?(t._remove(!1,!0),_.splice(this.layers,[t],e,0),t._setProject(this,!0),this._changes&&t._changed(5),!this._activeLayer&&(this._activeLayer=t)):t instanceof V?(this._activeLayer||this.insertChild(e,new M(V.NO_INSERT))).insertChild(e,t,n):t=null,t},addChild:function(e,t){return this.insertChild(void 0,e,t)},_updateSelection:function(e){var t=e._id,n=this._selectedItems;e._selected?n[t]!==e&&(this._selectedItemCount++,n[t]=e):n[t]===e&&(this._selectedItemCount--,delete n[t])},selectAll:function(){for(var e=this.layers,t=0,n=e.length;t=e.subtract(a).divide(l).length)return new X(t,c,{name:_.hyphenate(n),point:a})}if(this._locked||!this._visible||this._guide&&!t.guides||this.isEmpty())return null;var a=this._matrix,r=t._totalMatrix,o=this.getView(),s=t._totalMatrix=r?r.chain(a):this.getGlobalMatrix().preConcatenate(o._matrix),l=t._tolerancePadding=new N(Z._getPenPadding(1,s.inverted())).multiply(w(t.tolerance,1e-6));if(e=a._inverseTransform(e),!this._children&&!this.getInternalRoughBounds().expand(l.multiply(2))._containsPoint(e))return null;var d=!(t.guides&&!this._guide||t.selected&&!this._selected||t.type&&t.type!==_.hyphenate(this._class)||t.class&&!(this instanceof t.class)),c=this,h;if(d&&(t.center||t.bounds)&&this._parent){var u=this.getInternalBounds();if(t.center&&(h=n("center","Center")),!h&&t.bounds)for(var m=["TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],p=0;8>p&&!h;p++)h=n("bounds",m[p])}var g=!h&&this._children;if(g)for(var f=this._getChildHitTestOptions(t),p=g.length-1;0<=p&&!h;p--)h=g[p]._hitTest(e,f);return!h&&d&&(h=this._hitTestSelf(e,t)),h&&h.point&&(h.point=a.transform(h.point)),t._totalMatrix=r,h},_getChildHitTestOptions:function(e){return e},_hitTestSelf:function(e,t){if(t.fill&&this.hasFill()&&this._contains(e))return new X("fill",this)},matches:function(e,t){function n(e,t){for(var a in e)if(e.hasOwnProperty(a)){var i=e[a],r=t[a];if(_.isPlainObject(i)&&_.isPlainObject(r)){if(!n(i,r))return!1;}else if(!_.equals(i,r))return!1}return!0}var a=typeof e;if("object"==a){for(var i in e)if(e.hasOwnProperty(i)&&!this.matches(i,e[i]))return!1;}else{if("function"==a)return e(this);var r=/^(empty|editable)$/.test(e)?this["is"+_.capitalize(e)]():"type"===e?_.hyphenate(this._class):this[e];if(/^(constructor|class)$/.test(e)){if(!(this instanceof t))return!1;}else if(t instanceof RegExp){if(!t.test(r))return!1;}else if("function"==typeof t){if(!t(r))return!1;}else if(_.isPlainObject(t)){if(!n(t,r))return!1;}else if(!_.equals(r,t))return!1}return!0},getItems:function(e){return V._getItems(this._children,e,this._matrix)},getItem:function(e){return V._getItems(this._children,e,this._matrix,null,!0)[0]||null},statics:{_getItems:function e(t,n,a,r,o){if(!r&&"object"==typeof n){var s=n.overlapping,d=n.inside,c=s||d,h=c&&I.read([c]);r={items:[],inside:!!d,overlapping:!!s,rect:h,path:s&&new Z.Rectangle({rectangle:h,insert:!1})},c&&(n=_.set({},n,{inside:!0,overlapping:!0}))}var u=r&&r.items,h=r&&r.rect;a=h&&(a||new D);for(var m=0,p=t&&t.length;mi:ac)&&this._canComposite(),p=t.pixelRatio||1,g,f,w;if(!m){var y=this.getStrokeBounds(a(l));if(!y.width||!y.height)return;w=t.offset,f=t.offset=y.getTopLeft().floor(),g=e,e=ye.getContext(y.getSize().ceil().add(1).multiply(p)),1!==p&&e.scale(p,p)}e.save();var v=n?n.chain(s):!this.getStrokeScaling(!0)&&a(l),b=!m&&t.clipItem,x=!v||b;if(m?(e.globalAlpha=c,u&&(e.globalCompositeOperation=d)):x&&e.translate(-f.x,-f.y),x&&(m?s:a(l)).applyToContext(e),b&&t.clipItem.draw(e,t.extend({clip:!0})),v){e.setTransform(p,0,0,p,0,0);var _=t.offset;_&&e.translate(-_.x,-_.y)}this._draw(e,t,v),e.restore(),r.pop(),t.clip&&!t.dontFinish&&e.clip(),m||(ve.process(d,e,g,c,f.subtract(w).multiply(p)),ye.release(e),t.offset=w)}}},_isUpdated:function(e){var t=this._parent;if(t instanceof J)return t._isUpdated(e);var n=this._updateVersion===e;return!n&&t&&t._visible&&t._isUpdated(e)&&(this._updateVersion=e,n=!0),n},_drawSelection:function(e,t,n,a,r){if((this._drawSelected||this._boundsSelected)&&this._isUpdated(r)){var o=this.getSelectedColor(!0)||this.getLayer().getSelectedColor(!0),s=t.chain(this.getGlobalMatrix(!0));if(e.strokeStyle=e.fillStyle=o?o.toCanvasStyle(e):"#009dec",this._drawSelected&&this._drawSelected(e,s,a),this._boundsSelected){var l=n/2,d=s._transformCorners(this.getInternalBounds());e.beginPath();for(var c=0;8>c;c++)e[0==c?"moveTo":"lineTo"](d[c],d[++c]);e.closePath(),e.stroke();for(var c=0;8>c;c++)e.fillRect(d[c]-l,d[++c]-l,n,n)}}},_canComposite:function(){return!1}},_.each(["down","drag","up","move"],function(e){this["removeOn"+_.capitalize(e)]=function(){var t={};return t[e]=!0,this.removeOn(t)}},{removeOn:function(e){for(var t in e)if(e[t]){var n="mouse"+t,a=this._project,i=a._removeSets=a._removeSets||{};i[n]=i[n]||{},i[n][this._id]=this}return this}})),G=V.extend({_class:"Group",_selectChildren:!0,_serializeFields:{children:[]},initialize:function(e){this._children=[],this._namedChildren={},this._initialize(e)||this.addChildren(Array.isArray(e)?e:arguments)},_changed:function e(t){e.base.call(this,t),1026&t&&(this._clipItem=void 0)},_getClipItem:function(){var e=this._clipItem;if(void 0===e){e=null;for(var t=0,n=this._children.length,a;to;o++){var s=new P(1&o?1:-1,1=n.subtract(a).divide(this._radius).getLength():t.base.call(this,n)}return .5>=n.divide(this.size).getLength()},_hitTestSelf:function n(a,i){var o=!1;if(this.hasStroke()){var s=this._type,l=this._radius,d=this.getStrokeWidth()+2*i.tolerance;if("rectangle"===s){var c=e(this,a,d);if(c){var h=a.subtract(c);o=2*r(h.getLength()-t(h,l))<=d}else{var u=new I(this._size).setCenter(0,0),m=u.expand(d),p=u.expand(-d);o=m._containsPoint(a)&&!p._containsPoint(a)}}else"ellipse"===s&&(l=t(a,l)),o=2*r(a.getLength()-l)<=d}return o?new X("stroke",this):n.base.apply(this,arguments)}}},{statics:new function(){function e(e,t,n,a,i){var r=new F(_.getNamed(i));return r._type=e,r._size=n,r._radius=a,r.translate(t)}return{Circle:function(){var t=P.readNamed(arguments,"center"),n=_.readNamed(arguments,"radius");return e("circle",t,new N(2*n),n,arguments)},Rectangle:function(){var t=I.readNamed(arguments,"rectangle"),n=N.min(N.readNamed(arguments,"radius"),t.getSize(!0).divide(2));return e("rectangle",t.getCenter(!0),t.getSize(!0),n,arguments)},Ellipse:function(){var t=F._readEllipse(arguments),n=t.radius;return e("ellipse",t.center,n.multiply(2),n,arguments)},_readEllipse:function(e){var t,n;if(_.hasNamed(e,"radius"))t=P.readNamed(e,"center"),n=N.readNamed(e,"radius");else{var a=I.readNamed(e,"rectangle");t=a.getCenter(!0),n=a.getSize(!0).divide(2)}return{center:t,radius:n}}}}}),R=V.extend({_class:"Raster",_applyMatrix:!1,_canApplyMatrix:!1,_boundsGetter:"getBounds",_boundsSelected:!0,_serializeFields:{crossOrigin:null,source:null},initialize:function(e,t){this._initialize(e,void 0!==t&&P.read(arguments,1))||("string"==typeof e?this.setSource(e):this.setImage(e)),this._size||(this._size=new N,this._loaded=!1)},_equals:function(e){return this.getSource()===e.getSource()},clone:function(e){var t=new R(V.NO_INSERT),n=this._image,a=this._canvas;if(n)t.setImage(n);else if(a){var i=ye.getCanvas(this._size);i.getContext("2d").drawImage(a,0,0),t.setImage(i)}return t._crossOrigin=this._crossOrigin,this._clone(t,e)},getSize:function(){var e=this._size;return new L(e?e.width:0,e?e.height:0,this,"setSize")},setSize:function(){var e=N.read(arguments);if(!e.equals(this._size))if(0g;g++)u[g]/=p;return p?ae.read(u):null},getPixel:function(){var e=P.read(arguments),t=this.getContext().getImageData(e.x,e.y,1,1).data;return new ae("rgb",[t[0]/255,t[1]/255,t[2]/255],t[3]/255)},setPixel:function(){var e=P.read(arguments),t=ae.read(arguments),n=t._convert("rgb"),a=t._alpha,i=this.getContext(!0),r=i.createImageData(1,1),o=r.data;o[0]=255*n[0],o[1]=255*n[1],o[2]=255*n[2],o[3]=null==a?255:255*a,i.putImageData(r,e.x,e.y)},createImageData:function(){var e=N.read(arguments);return this.getContext().createImageData(e.width,e.height)},getImageData:function(){var e=I.read(arguments);return e.isEmpty()&&(e=new I(this._size)),this.getContext().getImageData(e.x,e.y,e.width,e.height)},setImageData:function(e){var t=P.read(arguments,1);this.getContext(!0).putImageData(e,t.x,t.y)},_getBounds:function(e,t){var n=new I(this._size).setCenter(0,0);return t?t._transformBounds(n):n},_hitTestSelf:function(e){if(this._contains(e)){var t=this;return new X("pixel",t,{offset:e.add(t._size.divide(2)).round(),color:{get:function(){return t.getPixel(this.offset)}}})}},_draw:function(e){var t=this.getElement();t&&(e.globalAlpha=this._opacity,e.drawImage(t,-this._size.width/2,-this._size.height/2))},_canComposite:function(){return!0}}),W=V.extend({_class:"PlacedSymbol",_applyMatrix:!1,_canApplyMatrix:!1,_boundsGetter:{getBounds:"getStrokeBounds"},_boundsSelected:!0,_serializeFields:{symbol:null},initialize:function(e,t){this._initialize(e,void 0!==t&&P.read(arguments,1))||this.setSymbol(e instanceof q?e:new q(e))},_equals:function(e){return this._symbol===e._symbol},getSymbol:function(){return this._symbol},setSymbol:function(e){this._symbol=e,this._changed(9)},clone:function(e){var t=new W(V.NO_INSERT);return t.setSymbol(this._symbol),this._clone(t,e)},isEmpty:function(){return this._symbol._definition.isEmpty()},_getBounds:function(e,t,n){var a=this.symbol._definition;return a._getCachedBounds(e,t&&t.chain(a._matrix),n)},_hitTestSelf:function(e,t){var n=this._symbol._definition._hitTest(e,t);return n&&(n.item=this),n},_draw:function(e,t){this.symbol._definition.draw(e,t)}}),X=_.extend({_class:"HitResult",initialize:function(e,t,n){this.type=e,this.item=t,n&&(n.enumerable=!0,this.inject(n))},statics:{getOptions:function(e){return new _({type:null,tolerance:g.settings.hitTolerance,fill:!e,stroke:!e,segments:!e,handles:!1,ends:!1,center:!1,bounds:!1,guides:!1,selected:!1},e)}}}),H=_.extend({_class:"Segment",beans:!0,initialize:function(e,t,n,a,i,r){var o=arguments.length,s,l,d;0===o||(1===o?"point"in e?(s=e.point,l=e.handleIn,d=e.handleOut):s=e:2===o&&"number"==typeof e?s=arguments:3>=o?(s=e,l=t,d=n):(s=void 0===e?null:[e,t],l=void 0===n?null:[n,a],d=void 0===i?null:[i,r])),new U(s,this,"_point"),new U(l,this,"_handleIn"),new U(d,this,"_handleOut")},_serialize:function(e){return _.serialize(this.hasHandles()?[this._point,this._handleIn,this._handleOut]:this._point,e,!0)},_changed:function(e){var t=this._path;if(t){var n=t._curves,a=this._index,i;n&&((!e||e===this._point||e===this._handleIn)&&(i=0n;n+=2)t.push(new P(e[n],e[n+1]));return t},getLength:function(){return null==this._length&&(this._length=Q.getLength(this.getValues(),0,1)),this._length},getArea:function(){return Q.getArea(this.getValues())},getLine:function(){return new j(this._segment1._point,this._segment2._point)},getPart:function(e,t){return new Q(Q.getPart(this.getValues(),e,t))},getPartLength:function(e,t){return Q.getLength(this.getValues(),e,t)},getIntersections:function(e){return Q._getIntersections(this.getValues(),e&&e!==this?e.getValues():null,this,e,[],{})},_getParameter:function(e,t){return t?e:e&&e.curve===this?e.parameter:void 0===e&&void 0===t?.5:this.getParameterAt(e,0)},divide:function(e,t,n){var a=this._getParameter(e,t),i=4e-7,r=null;if(a>=i&&a<=1-i){var o=Q.subdivide(this.getValues(),a),s=o[0],l=o[1],d=n||this.hasHandles(),c=this._segment1,h=this._segment2,u=this._path;d&&(c._handleOut.set(s[2]-s[0],s[3]-s[1]),h._handleIn.set(l[4]-l[6],l[5]-l[7]));var m=s[6],p=s[7],g=new H(new P(m,p),d&&new P(s[4]-m,s[5]-p),d&&new P(l[2]-m,l[3]-p));u?(u.insert(c._index+1,g),r=this.getNext()):(this._segment2=g,r=new Q(g,h))}return r},split:function(e,t){return this._path?this._path.split(this._segment1._index,this._getParameter(e,t)):null},reversed:function(){return new Q(this._segment2.reversed(),this._segment1.reversed())},clearHandles:function(){this._segment1._handleOut.set(0,0),this._segment2._handleIn.set(0,0)},statics:{getValues:function(e,t,n){var a=e._point,i=e._handleOut,r=t._handleIn,o=t._point,s=[a._x,a._y,a._x+i._x,a._y+i._y,o._x+r._x,o._y+r._y,o._x,o._y];return n&&n._transformCoordinates(s,s,4),s},subdivide:function(e,n){var a=e[0],i=e[1],r=e[2],o=e[3],s=e[4],l=e[5],d=e[6],c=e[7];void 0===n&&(n=.5);var h=1-n,u=h*a+n*r,m=h*i+n*o,p=h*r+n*s,g=h*o+n*l,f=h*s+n*d,w=h*l+n*c,y=h*u+n*p,v=h*m+n*g,b=h*p+n*f,x=h*g+n*w,_=h*y+n*b,E=h*v+n*x;return[[a,i,u,m,y,v,_,E],[_,E,b,x,f,w,d,c]]},solveCubic:function(e,t,n,a,i,r){var o=e[t],s=e[t+2],l=e[t+4],d=e[t+6],h=3*(s-o),c=3*(l-s)-h;return z.solveCubic(d-o-h-c,c,h,o-n,a,i,r)},getParameterOf:function(e,n){var a=new P(e[0],e[1]),r=new P(e[6],e[7]),o=1e-12,s=n.isClose(a,o)?0:n.isClose(r,o)?1:null;if(null!==s)return s;for(var l=[n.x,n.y],d=[],h=2e-7,u=0,m;2>u;u++){m=Q.solveCubic(e,u,l[u],d,0,1);for(var p=0;p=a){var t=n.getDistance(Q.getPoint(e,a),!0);if(th?0:.999999999999n;if(a){var i=t;t=n,n=i}return 0n&&(e=Q.subdivide(e,(n-t)/(1-t))[0]),a?[e[6],e[7],e[4],e[5],e[2],e[3],e[0],e[1]]:e},hasHandles:function(e){var t=z.isZero;return!(t(e[0]-e[2])&&t(e[1]-e[3])&&t(e[4]-e[6])&&t(e[5]-e[7]))},isFlatEnough:function(e,t){var n=e[0],a=e[1],i=e[2],r=e[3],o=e[4],s=e[5],l=e[6],d=e[7],c=3*i-2*n-l,h=3*r-2*a-d,u=3*o-2*l-n,m=3*s-2*d-a;return w(c*c,u*u)+w(h*h,m*m)<10*t*t},getArea:function(e){var t=e[0],n=e[1],a=e[6],i=e[7],r=(e[2]+t)/2,o=(e[3]+n)/2,s=(e[4]+e[6])/2,l=(e[5]+e[7])/2;return 6*((t-r)*(o+n)+(r-s)*(l+o)+(s-a)*(i+l))/10},getBounds:function(e){for(var t=e.slice(0,2),n=t.slice(),a=[0,0],r=0;2>r;r++)Q._addBounds(e[r],e[r+2],e[r+4],e[r+6],r,0,t,n,a);return new I(t[0],t[1],n[0]-t[0],n[1]-t[1])},_addBounds:function(e,n,a,r,o,s,l,d,c){function h(e,t){var n=e-t,a=e+t;nd[o]&&(d[o]=a)}var m=z.solveQuadratic(3*(n-a)-e+r,2*(e+a)-4*n,n-e,c),p=4e-7;h(r,0);for(var g=0;g=i&&0>=r&&-1<=r}return!1},isLinear:function(e,t,n){var a=e.divide(3);return t.equals(a)&&n.negate().equals(a)}},function(e,t){this[t]=function(){var t=this._segment1,n=this._segment2;return e(n._point.subtract(t._point),t._handleOut,n._handleIn)},this.statics[t]=function(t){var n=t[0],a=t[1],i=t[6],r=t[7];return e(new P(i-n,r-a),new P(t[2]-n,t[3]-a),new P(t[4]-i,t[5]-r))}},{statics:{},hasHandles:function(){return!this._segment1._handleOut.isZero()||!this._segment2._handleIn.isZero()},isCollinear:function(e){return e&&this.isStraight()&&e.isStraight()&&this.getLine().isCollinear(e.getLine())},isHorizontal:function(){return this.isStraight()&&1e-7>r(this.getTangentAt(.5,!0).y)},isVertical:function(){return this.isStraight()&&1e-7>r(this.getTangentAt(.5,!0).x)}}),{beans:!1,getParameterAt:function(e,t){return Q.getParameterAt(this.getValues(),e,t)},getParameterOf:function(){return Q.getParameterOf(this.getValues(),P.read(arguments))},getLocationAt:function(e,n){var a=n?e:this.getParameterAt(e);return null!=a&&0<=a&&1>=a?new K(this,a):null},getLocationOf:function(){return this.getLocationAt(this.getParameterOf(P.read(arguments)),!0)},getOffsetOf:function(){var e=this.getLocationOf.apply(this,arguments);return e?e.getOffset():null},getNearestLocation:function(){var e=P.read(arguments),n=this.getValues(),a=Q.getNearestParameter(n,e),t=Q.getPoint(n,a);return new K(this,a,t,null,e.getDistance(t))},getNearestPoint:function(){return this.getNearestLocation.apply(this,arguments).getPoint()}},new function(){var e=["getPoint","getTangent","getNormal","getWeightedTangent","getWeightedNormal","getCurvature"];return _.each(e,function(e){this[e+"At"]=function(t,n){var a=this.getValues();return Q[e](a,n?t:Q.getParameterAt(a,t,0))}},{statics:{evaluateMethods:e}})},new function(){function e(e){var n=e[0],a=e[1],i=e[2],r=e[3],o=e[4],s=e[5],l=e[6],d=e[7];return function(e){var t=((9*(i-o)+3*(l-n))*e+(6*(n+o)-12*i))*e+3*(i-n),c=((9*(r-s)+3*(d-a))*e+(6*(a+s)-12*r))*e+3*(r-a);return f(t*t+c*c)}}function n(e,t){return w(2,m(16,x(32*r(t-e))))}function i(e,n,t,i){if(null==n||0>n||1g)){var b=ng?(w=3*(u-c),v=3*(m-h)):(w=(3*k*n+2*E)*n+_,v=(3*z*n+2*S)*n+C),i){0===w&&0===v&&(ng)&&(w=c-s,v=h-l);var T=f(w*w+v*v);T&&(w/=T,v/=T)}if(3===t){var B=a(w*w+v*v,3/2);w=0===B?0:(w*(6*z*n+2*S)-v*(6*k*n+2*E))/B,v=0}}}return 2===t?new P(v,-w):new P(w,v)}return{statics:{getLength:function(t,i,r){if(void 0===i&&(i=0),void 0===r&&(r=1),0===i&&1===r&&Q.isStraight(t)){var o=t[6]-t[0],s=t[7]-t[1];return f(o*o+s*s)}var l=e(t);return z.integrate(l,i,r,n(i,r))},getParameterAt:function(t,i,o){function s(e){return m+=z.integrate(h,o,e,n(o,e)),o=e,m-i}if(void 0===o&&(o=0>i?1:0),0===i)return o;var l=r,d=0l(i-u))return d?a:c;if(l(i)>u)return null;var m=0;return z.findRoot(s,h,o+i/u,c,a,32,1e-12)},getPoint:function(e,n){return i(e,n,0,!1)},getTangent:function(e,n){return i(e,n,1,!0)},getWeightedTangent:function(e,n){return i(e,n,1,!1)},getNormal:function(e,n){return i(e,n,2,!0)},getWeightedNormal:function(e,n){return i(e,n,2,!1)},getCurvature:function(e,n){return i(e,n,3,!1).x}}}},new function(){function e(e,t,n,a,i,r,o,s,l,d,c){var h=t.startConnected,u=t.endConnected,m=4e-7,p=1-m;if(null==i&&(i=Q.getParameterOf(n,r)),null!==i&&i>=(h?m:0)&&i<=(u?p:1)&&(null==l&&(l=Q.getParameterOf(o,d)),null!==l&&l>=(u?m:0)&&l<=(h?p:1))){var g=t.renormalize;if(g){var f=g(i,l);i=f[0],l=f[1]}var w=new K(a,i,r||Q.getPoint(n,i),c),y=new K(s,l,d||Q.getPoint(o,l),c),v=w.getPath()===y.getPath()&&w.getIndex()>y.getIndex(),b=v?y:w,x=t.include;w._intersection=y,y._intersection=w,(!x||x(b))&&K.insert(e,b,!0)}}function n(r,o,s,l,d,c,h,u,p,g,f,y,v){if(!(24<=++v)){var b=o[0],x=o[1],_=o[6],E=o[7],k=j.getSignedDistance,C=k(b,x,_,E,o[2],o[3]),S=k(b,x,_,E,o[4],o[5]),z=0g-p){var R=Q.subdivide(r,.5),W=M+(F-M)/2;n(o,R[0],l,s,d,c,p,g,M,W,G,!y,v),n(o,R[1],l,s,d,c,p,g,W,F,G,!y,v)}else{var R=Q.subdivide(o,.5),W=p+(g-p)/2;n(R[0],r,l,s,d,c,p,W,M,F,G,!y,v),n(R[1],r,l,s,d,c,W,g,M,F,G,!y,v)}}else if(1e-7>w(g-p,F-M)){var X=M+(F-M)/2,H=p+(g-p)/2;r=s.getValues(),o=l.getValues(),e(d,c,y?o:r,y?l:s,y?H:X,null,y?r:o,y?s:l,y?X:H,null)}else 1e-12l*d)c=[[i,r,s],[i,o,s]];else{var h=l/d;c=[2<=h?[i,r,s]:.5>=h?[i,o,s]:[i,r,o,s],[i,s]]}return 0>(l||d)?c.reverse():c}function i(e,n,a,i){return e[0][1]i?t(n,!1,i):e[0][0]}function t(e,t,n){for(var a=e[0][0],r=e[0][1],o=1,s=e.length;o=n:d<=n)return d===n?l:a+(n-r)*(l-a)/(d-r);a=l,r=d}return null}function o(t,n,a,r,o,d){for(var c=Q.isStraight(t),h=c?n:t,m=c?t:n,p=m[0],g=m[1],f=m[6],w=m[7],v=s(-(w-g),f-p),b=l(v),_=u(v),E=[],k=0;8>k;k+=2){var C=h[k]-p,x=h[k+1]-g;E.push(C*_-x*b,C*b+x*_)}for(var y=[],S=Q.solveCubic(E,1,0,y,0,1),k=0;kz.CURVETIME_EPSILON)&&e(o,d,t,a,L,c?N:P,n,r,I,c?P:N)}}}function d(t,n,a,i,r,o){var s=j.intersect(t[0],t[1],t[6],t[7],n[0],n[1],n[6],n[7]);s&&e(r,o,t,a,null,s,n,i,null,s)}return{statics:{_getIntersections:function(t,a,r,s,l,c){if(!a)return Q._getSelfIntersection(t,r,l,c);var h=t[0],u=t[1],p=t[6],g=t[7],f=a[0],y=a[1],v=a[6],b=a[7],x=(3*t[2]+h)/4,_=(3*t[3]+u)/4,E=(3*t[4]+p)/4,k=(3*t[5]+g)/4,C=(3*a[2]+f)/4,S=(3*a[3]+y)/4,z=(3*a[4]+v)/4,T=(3*a[5]+b)/4,B=m,N=w;if(!(N(h,x,E,p)>=B(f,C,z,v)&&B(h,x,E,p)<=N(f,C,z,v)&&N(u,_,k,g)>=B(y,S,T,b)&&B(u,_,k,g)<=N(y,S,T,b)))return l;if(!c.startConnected&&!c.endConnected){var L=Q.getOverlaps(t,a);if(L){for(var I=0,A;2>I;I++)A=L[I],e(l,c,t,r,A[0],null,a,s,A[1],null,!0);return l}}var j=Q.isStraight(t),D=Q.isStraight(a),O=j&&D,q=1e-12,V=l.length;if((O?d:j||D?o:n)(t,a,r,s,l,c,0,1,0,1,0,!1,0),O&&l.length>V)return l;var G=new P(h,u),M=new P(p,g),F=new P(f,y),R=new P(v,b);return G.isClose(F,q)&&e(l,c,t,r,0,G,a,s,0,F),!c.startConnected&&G.isClose(R,q)&&e(l,c,t,r,0,G,a,s,1,R),!c.endConnected&&M.isClose(F,q)&&e(l,c,t,r,1,M,a,s,0,F),M.isClose(R,q)&&e(l,c,t,r,1,M,a,s,1,R),l},_getSelfIntersection:function(e,t,n,a){var o=e[0],s=e[1],l=e[2],d=e[3],c=e[4],h=e[5],u=e[6],m=e[7],p=new j(o,s,u,m,!1),g=p.getSide(new P(l,d),!0),f=p.getSide(new P(c,h),!0);if(g===f){if(0<((o-c)*(d-m)+(l-u)*(h-s))*g)return n}var w=u-3*c+3*l-o,y=c-2*l+o,v=l-o,b=m-3*h+3*d-s,x=h-2*d+s,_=d-s,E=b*v-w*_;if(0>E*E-4*(b*y-w*x)*(x*v-y*_)){var k=[],C=z.solveCubic(w*w+b*b,3*(w*y+b*x),2*(y*y+x*x)+w*v+b*_,y*v+x*_,k,0,1),S;if(0B&&(B=N,S=k[T]);var L=Q.subdivide(e,S);a.endConnected=!0,a.renormalize=function(e,t){return[e*S,t*(1-S)+S]},Q._getIntersections(L[0],L[1],t,t,n,a)}}return n},getOverlaps:function(e,t){function n(e){var t=e[6]-e[0],n=e[7]-e[1];return t*t+n*n}var a=r,o=4e-7,s=2e-7,l=Q.isStraight(e),d=Q.isStraight(t),c=l&&d;if(c){var h=n(e)s||p.getDistance(new P(m[6],m[7]))>s)return null}else if(l^d)return null;for(var g=[e,t],f=[],w=0,y=0,v;2>w&&2>f.length;w+=0==y?0:1,y^=1){if(v=Q.getParameterOf(g[1^w],new P(g[w][0==y?0:6],g[w][0==y?1:7])),null!=v){var b=0==w?[y,v]:[v,y];(0===f.length||a(b[0]-f[0][0])>o&&a(b[1]-f[0][1])>o)&&f.push(b)}if(1==w&&0===f.length)break}if(2!==f.length)f=null;else if(!c){var x=Q.getPart(e,f[0][0],f[1][0]),_=Q.getPart(t,f[0][1],f[1][1]);(a(_[2]-x[2])>s||a(_[3]-x[3])>s||a(_[4]-x[4])>s||a(_[5]-x[5])>s)&&(f=null)}return f}}}}),K=_.extend({_class:"CurveLocation",beans:!0,initialize:function e(t,n,a,i,r){if(.9999996l||(l=s(this.getOffset()-e.getOffset()))t&&et&&e<=c||e>=-c&&e=i&&n<=r||a>=i&&a<=r)return!this.isTouching();var o=this.getCurve(),s=o.getPrevious(),l=t.getCurve(),d=l.getPrevious(),c=v;if(!s||!d)return!1;var h=s.getTangentAt(r,!0).negate().getAngleInRadians(),u=o.getTangentAt(i,!0).getAngleInRadians(),m=d.getTangentAt(r,!0).negate().getAngleInRadians(),p=l.getTangentAt(i,!0).getAngleInRadians();return e(m,h,u)^e(p,h,u)&&e(m,u,h)^e(p,u,h)},isOverlap:function(){return!!this._overlap}},_.each(Q.evaluateMethods,function(e){this[e]=function(){var t=this.getParameter(),n=this.getCurve();return null!=t&&n&&n[e+"At"](t,!0)}},{preserve:!0}),new function(){function e(e,t,n){function a(n,a){for(var r=n+a,s;-1<=r&&r<=o&&(s=e[(r%o+o)%o],!!t.getPoint().isClose(s.getPoint(),2e-7));r+=a)if(t.equals(s))return s;return null}for(var o=e.length,i=0,s=o-1;i<=s;){var d=i+s>>>1,c=e[d],h;if(n&&(h=t.equals(c)?c:a(d,-1)||a(d,1)))return t._overlap&&(h._overlap=h._intersection._overlap=!0),h;var u=t.getPath(),m=c.getPath(),p=u===m?t.getIndex()+t.getParameter()-(c.getIndex()+c.getParameter()):u._id-m._id;0>p?s=d-1:i=d+1}return e.splice(i,0,t),t}return{statics:{insert:e,expand:function(t){for(var n=t.slice(),a=0,r=t.length;a=1-a&&(e++,t--);var i=this.getCurves();if(0<=e&&e=a&&i[e++].divide(t,!0);var r=this.removeSegments(e,this._segments.length,!0),o;return this._closed?(this.setClosed(!1),o=this):(o=new Z(V.NO_INSERT),o.insertAbove(this,!0),this._clone(o)),o._add(r,0),this.addSegment(r[0]),o}return null},reverse:function(){this._segments.reverse();for(var e=0,t=this._segments.length;e=e.subtract(t).divide(n).length}function a(e,a,i){if(!t.selected||a.isSelected()){var r=e._point;if(a!==r&&(a=a.add(r)),n(a,p))return new X(i,l,{segment:e,point:a})}}function r(e,n){return(n||t.segments)&&a(e,e._point,"segment")||!n&&t.handles&&(a(e,e._handleIn,"handle-in")||a(e,e._handleOut,"handle-out"))}function o(e){_.add(e)}function s(t){if(("round"!==v||"round"!==b)&&(_=new Z({internal:!0,closed:!0}),u||0e)return o.getLocationAt(e-l)}return 0=a)){r&&(s=m(a,4),o+=2*m(a,s));for(var l=[],d=0;d=_.remain(arguments))d=a,a=P.read(arguments);else{var w=N.read(arguments);if(w.isZero())return this.lineTo(a);var b=_.read(arguments),s=!!_.read(arguments),E=!!_.read(arguments),g=n.add(a).divide(2),k=n.subtract(g).rotate(-b),C=k.x,S=k.y,y=r,T=y(w.width),B=y(w.height),L=T*T,I=B*B,A=C*C,O=S*S,q=f(A/L+O/I);if(1y(q)&&(q=0),0>q)throw new Error("Cannot create an arc with the given arguments");c=new P(T*S/B,-B*C/T).multiply((E===s?-1:1)*f(q)).rotate(b).add(g),p=new D().translate(c).rotate(b).scale(T,B),m=p._inverseTransform(n),h=m.getDirectedAngle(p._inverseTransform(a)),!s&&0h&&(h+=360)}if(d){var V=new j(n.add(d).divide(2),d.subtract(n).rotate(90),!0),G=new j(d.add(a).divide(2),a.subtract(d).rotate(90),!0),M=new j(n,a),F=M.getSide(d);if(c=V.intersect(G,!0),!c){if(!F)return this.lineTo(a);throw new Error("Cannot create an arc with the given arguments")}m=n.subtract(c),h=m.getDirectedAngle(a.subtract(c));var R=M.getSide(c);0===R?h=F*r(h):F===R&&(h+=0>h?360:-360)}for(var W=r(h),X=360<=W?4:x(W/90),U=h/X,Q=U*v/360,K=4/3*l(Q)/(1+u(Q)),z=[],Y=0;Y<=X;Y++){var k=a,Z=null;if(Yt;t++)Q._addBounds(c[t],c[t+4],d[t+2],d[t],t,r?r[t]:0,h,u,m);var n=c;c=d,d=n}var s=e[0];if(!s)return new I;for(var d=[,,,,,,],c=s._transformCoordinates(a,[,,,,,,],!1),h=c.slice(0,2),u=h.slice(),m=[,,],p=1,g=e.length;pd.getDirectedAngle(c)?-n:n;if(d.setLength(h),c.setLength(h),r&&(i(l),i(l.add(d))),"miter"===t){var u=new j(l.add(d),new P(-d.y,d.x),!0).intersect(new j(l.add(c),new P(-c.y,c.x),!0),!0);if(u&&l.getDistance(u)<=a&&(i(u),!r))return}r||i(l.add(d)),i(l.add(c))},_addSquareCap:function(e,t,n,a,i){var r=e._point,o=e.getLocation(),s=o.getNormal().multiply(n);i&&(a(r.subtract(s)),a(r.add(s))),"square"===t&&(r=r.add(s.rotate(0===o.getParameter()?-90:90))),a(r.add(s)),a(r.subtract(s))},getHandleBounds:function(e,t,n,a,r,o){for(var s=[,,,,,,],d=1/0,c=-d,h=d,u=c,m=0,p=e.length,l;mg;g+=2){var f=0==g?o:r,w=f?f[0]:0,v=f?f[1]:0,b=s[g],x=s[g+1],y=b-w,_=b+w,E=x-v,k=x+v;yc&&(c=_),Eu&&(u=k)}}return new I(d,h,c-d,u-h)},getRoughBounds:function(e,t,n,a){var i=n.hasStroke()?n.getStrokeWidth()/2:0,r=i;return 0s;s++)l=a[s],o[s]=new H(l._point.multiply(n).add(t),l._handleIn.multiply(n),l._handleOut.multiply(n));return e(o,!0,r)}var n=.5522847498307936,a=[new H([-1,0],[0,n],[0,-n]),new H([0,-1],[-n,0],[n,0]),new H([1,0],[0,-n],[0,n]),new H([0,1],[n,0],[-n,0])];return{Line:function(){return e([new H(P.readNamed(arguments,"from")),new H(P.readNamed(arguments,"to"))],!1,arguments)},Circle:function(){var e=P.readNamed(arguments,"center"),n=_.readNamed(arguments,"radius");return t(e,new N(n),arguments)},Rectangle:function(){var t=I.readNamed(arguments,"rectangle"),a=N.readNamed(arguments,"radius",0,{readNull:!0}),i=t.getBottomLeft(!0),r=t.getTopLeft(!0),o=t.getTopRight(!0),s=t.getBottomRight(!0),l;if(!a||a.isZero())l=[new H(i),new H(r),new H(o),new H(s)];else{a=N.min(a,t.getSize(!0).divide(2));var d=a.width,c=a.height,h=d*n,u=c*n;l=[new H(i.add(d,0),null,[-h,0]),new H(i.subtract(0,c),[0,u]),new H(r.add(0,c),null,[0,-u]),new H(r.add(d,0),[-h,0],null),new H(o.subtract(d,0),null,[h,0]),new H(o.add(0,c),[0,-u],null),new H(s.subtract(0,c),null,[0,u]),new H(s.subtract(d,0),[h,0])]}return e(l,!0,arguments)},RoundRectangle:"#Rectangle",Ellipse:function(){var e=F._readEllipse(arguments);return t(e.center,e.radius,arguments)},Oval:"#Ellipse",Arc:function(){var e=P.readNamed(arguments,"from"),t=P.readNamed(arguments,"through"),n=P.readNamed(arguments,"to"),a=_.getNamed(arguments),i=new Z(a&&!1===a.insert&&V.NO_INSERT);return i.moveTo(e),i.arcTo(t,n),i.set(a)},RegularPolygon:function(){for(var t=P.readNamed(arguments,"center"),n=_.readNamed(arguments,"sides"),a=_.readNamed(arguments,"radius"),r=!(n%3),o=new P(0,r?-a:a),s=r?-1:.5,l=Array(n),d=0;d1-n?p=h._segment2:(p=h.divide(u,!0,!0)._segment1,a&&r.push(p)),c._setSegment(p);var g=p._intersection,f=c._intersection;if(g){i(g,f);for(var w=g;w;)i(w._intersection,g),w=w._next}else p._intersection=f;s=h,d=m}for(var o=0,y=r.length;ob?b=T:T>m+s&&T<_&&(_=T);b=(b+m)/2,_=(_+m)/2,b>-Infinity&&(p=d(new P(u,b),n,!1,o)),_<1/0&&(g=d(new P(u,_),n,!1,o))}else for(var B=u-s,N=u+s,L=!1,E=0,k=n.length,I,A;E=C[1]&&m<=C[7]||m>=C[7]&&m<=C[1])&&1===Q.solveCubic(C,1,m,f,0,1)){var q=f[0];if(!(q>h&&L&&D.next!==n[E+1]||qh&&D.previous===I)){var t=Q.getPoint(C,q).x,x=Q.getTangent(C,q).y,V=!1;z.isZero(x)&&!Q.isStraight(C)||qx*Q.getTangent(D.previous.values,1).y||q>h&&0>x*Q.getTangent(D.next.values,0).y?o&&t>=B&&t<=N&&(++p,++g,V=!0):t<=B?(p+=O,V=!0):t>=N&&(g+=O,V=!0),D.previous!==n[E-1]&&(L=qf;f++){g=h*(f+1)/4;for(var w=0,y=l.length;wi?-1:1,previous:a,next:null};a&&(a.next=r),n.push(r),a=r}function t(a){if(0!==Q.getLength(a)){var i=a[1],r=a[3],o=a[5],s=a[7];if(Q.isStraight(a))e(a);else{var l=4e-7,d=[],c=z.solveQuadratic(3*(r-o)-i+s,2*(i+o)-4*r,r-i,d,l,1-l);if(0===c)e(a);else{d.sort();var n=d[0],h=Q.subdivide(a,n);e(h[0]),1=l[1]&&r<=l[7]||r>=l[7]&&r<=l[1])&&0h&&!Q.isFlatEnough(e,n||.25)){var r=Q.subdivide(e,.5),s=(a+i)/2;o(r[0],t,a,s),o(r[1],t,s,i)}else{var l=e[6]-e[0],u=e[7]-e[1],m=f(l*l+u*u);1e-6=e){this.index=n;var o=this.parts[n-1],s=o&&o.index==r.index?o.value:0,l=o?o.offset:0;return{value:s+(r.value-s)*(e-l)/(r.offset-l),index:r.index}}var r=this.parts[this.parts.length-1];return{value:1,index:r.index}},drawPart:function(e,t,n){t=this.getParameterAt(t),n=this.getParameterAt(n);for(var a=t.index,r;a<=n.index;a++)r=Q.getPart(this.curves[a],a==t.index?t.value:0,a==n.index?n.value:1),a==t.index&&e.moveTo(r[0],r[1]),e.bezierCurveTo.apply(e,r.slice(2))}},_.each(Q.evaluateMethods,function(e){this[e+"At"]=function(t,n){var a=this.getParameterAt(t);return Q[e](this.curves[a.index],a.value,n)}},{})),ee=_.extend({initialize:function(e,t){for(var n=this.points=[],a=e._segments,r=0,o=a.length,s,l;r=h;h++){var m=this.generateBezier(e,t,l,n,a),p=this.findMaxError(e,t,m,l);if(p.error=d)break;c=this.reparameterize(e,t,l,m),d=p.error}var g=this.points[u-1].subtract(this.points[u]),f=this.points[u].subtract(this.points[u+1]),y=g.add(f).divide(2).normalize();this.fitCubic(e,u,n,y),this.fitCubic(u,t,y.negate(),a)},addCurve:function(e){var t=this.segments[this.segments.length-1];t.setHandleOut(e[1].subtract(e[0])),this.segments.push(new H(e[3],e[2].subtract(e[3])))},generateBezier:function(e,n,a,o,s){for(var l=1e-12,d=this.points[e],c=this.points[n],h=[[0,0],[0,0]],m=[0,0],p=0;pl){var k=h[0][0]*m[1]-h[1][0]*m[0],C=m[0]*h[1][1]-m[1]*h[0][1];_=C/x,E=k/x}else{var S=h[0][0]+h[0][1],z=h[1][0]+h[1][1];_=r(S)>l?E=m[0]/S:r(z)>l?E=m[1]/z:E=0}var T=c.getDistance(d),P=l*T,B,N;if(_T*T&&(_=E=T/3,B=N=null)}return[d,d.add(B||o.normalize(_)),c.add(N||s.normalize(E)),c]},reparameterize:function(e,t,n,a){for(var r=e;r<=t;r++)n[r-e]=this.findRoot(a,this.points[r],n[r-e]);for(var r=1,o=n.length;r=s;s++)a[s]=e[s+1].subtract(e[s]).multiply(3);for(var s=0;1>=s;s++)o[s]=a[s+1].subtract(a[s]).multiply(2);var l=this.evaluate(3,e,n),d=this.evaluate(2,a,n),c=this.evaluate(1,o,n),h=l.subtract(t),u=d.dot(d)+h.dot(c);return 1e-6>r(u)?n:n-h.dot(d)/u},evaluate:function(e,n,a){for(var t=n.slice(),r=1;r<=e;r++)for(var o=0;o<=e-r;o++)t[o]=t[o].multiply(1-a).add(t[o+1].multiply(a));return t[0]},chordLengthParameterize:function(e,t){for(var n=[0],a=e+1;a<=t;a++)n[a-e]=n[a-e-1]+this.points[a].getDistance(this.points[a-1]);for(var a=1,r=t-e;a<=r;a++)n[a]/=n[r];return n},findMaxError:function(e,t,a,r){for(var o=n((t-e+1)/2),s=0,l=e+1;l=s&&(s=h,o=l)}return{error:s,index:o}}}),te=V.extend({_class:"TextItem",_boundsSelected:!0,_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsGetter:"getBounds",initialize:function(e){this._content="",this._lines=[];var t=e&&_.isPlainObject(e)&&void 0===e.x&&void 0===e.y;this._initialize(t&&e,!t&&P.read(arguments))},_equals:function(e){return this._content===e._content},_clone:function e(t,n,a){return t.setContent(this._content),e.base.call(this,t,n,a)},getContent:function(){return this._content},setContent:function(e){this._content=""+e,this._lines=this._content.split(/\r\n|\n|\r/mg),this._changed(265)},isEmpty:function(){return!this._content},getCharacterStyle:"#getStyle",setCharacterStyle:"#setStyle",getParagraphStyle:"#getStyle",setParagraphStyle:"#setStyle"}),ne=te.extend({_class:"PointText",initialize:function(){te.apply(this,arguments)},clone:function(e){return this._clone(new ne(V.NO_INSERT),e)},getPoint:function(){var e=this._matrix.getTranslation();return new B(e.x,e.y,this,"setPoint")},setPoint:function(){var e=P.read(arguments);this.translate(e.subtract(this._matrix.getTranslation()))},_draw:function(e){if(this._content){this._setStyles(e);var t=this._style,n=this._lines,a=t.getLeading(),r=e.shadowColor;e.font=t.getFontStyle(),e.textAlign=t.getJustification();for(var o=0,s=n.length;oa;a++)r=t[a+1],n[a]=parseInt(1==r.length?r+r:r,16)/255}else if(t=e.match(/^rgba?\((.*)\)$/)){n=t[1].split(",");for(var a=0,o=n.length,r;aa?r/255:r}else{var s=i[e];if(!s){l||(l=ye.getContext(1,1),l.globalCompositeOperation="copy"),l.fillStyle="rgba(0,0,0,0)",l.fillStyle=e,l.fillRect(0,0,1,1);var d=l.getImageData(0,0,1,1).data;s=i[e]=[d[0]/255,d[1]/255,d[2]/255]}n=s.slice()}return n}var t={gray:["gray"],rgb:["red","green","blue"],hsb:["hue","saturation","brightness"],hsl:["hue","saturation","lightness"],gradient:["gradient","origin","destination","highlight"]},a={},i={},r=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]],s={"rgb-hsb":function(e,t,n){var a=w(e,t,n),i=m(e,t,n),r=a-i,o=0==r?0:60*(a==e?(t-n)/r+(tc?r/(a+i):r/(2-a-i);return[d,l,c]},"hsl-rgb":function(e,t,n){if(e=(e/360%1+1)%1,0===t)return[n,n,n];for(var a=[e+1/3,e,e-1/3],r=.5>n?n*(1+t):n+t-n*t,o=2*n-r,s=[],l=0,d;3>l;l++)d=a[l],0>d&&(d+=1),16*d?o+6*(r-o)*d:1>2*d?r:2>3*d?o+6*((r-o)*(2/3-d)):o;return s},"rgb-gray":function(e,t,n){return[.2989*e+.587*t+.114*n]},"gray-rgb":function(e){return[e,e,e]},"gray-hsb":function(e){return[0,0,e]},"gray-hsl":function(e){return[0,0,e]},"gradient-rgb":function(){return[]},"rgb-gradient":function(){return[]}},l;return _.each(t,function(e,n){a[n]=[],_.each(e,function(e,i){var r=_.capitalize(e),o=/^(hue|saturation)$/.test(e),s=a[n][i]="gradient"===e?function(e){var t=this._components[0];return e=ie.read(Array.isArray(e)?e:arguments,0,{readNull:!0}),t!==e&&(t&&t._removeOwner(this),e&&e._addOwner(this)),e}:"gradient"===n?function(){return P.read(arguments,0,{readNull:"highlight"===e,clone:!0})}:function(e){return null==e||isNaN(e)?0:e};this["get"+r]=function(){return this._type===n||o&&/^hs[bl]$/.test(this._type)?this._components[i]:this._convert(n)[i]},this["set"+r]=function(e){this._type===n||o&&/^hs[bl]$/.test(this._type)||(this._components=this._convert(n),this._properties=t[n],this._type=n),this._components[i]=s.call(this,e),this._changed()}},this)},{_class:"Color",_readIndex:!0,initialize:function n(r){var o=Array.prototype.slice,s=arguments,d=0,c,h,u,m;Array.isArray(r)&&(s=r,r=s[0]);var p=null!=r&&typeof r;if("string"===p&&r in t&&(c=r,r=s[1],Array.isArray(r)?(h=r,u=s[2]):(this.__read&&(d=1),s=o.call(s,1),p=typeof r)),!h){if(m="number"===p?s:"object"===p&&null!=r.length?r:null,m){c||(c=3<=m.length?"rgb":"gray");var g=t[c].length;u=m[g],this.__read&&(d+=m===arguments?g+(null==u?0:1):1),m.length>g&&(m=o.call(m,0,g))}else if("string"===p)c="rgb",h=e(r),4===h.length&&(u=h[3],h.length--);else if("object"===p)if(r.constructor===n){if(c=r._type,h=r._components.slice(),u=r._alpha,"gradient"===c)for(var f=1,w=h.length,y;fe?0:1a&&n.push(0>a?0:a),e?"#"+(16777216+(n[0]<<16)+(n[1]<<8)+n[2]).toString(16).slice(1):(4==n.length?"rgba(":"rgb(")+n.join(",")+")"},toCanvasStyle:function(e){if(this._canvasStyle)return this._canvasStyle;if("gradient"!==this._type)return this._canvasStyle=this.toCSS();var t=this._components,n=t[0],a=n._stops,r=t[1],o=t[2],s;if(n._radial){var d=o.getDistance(r),c=t[3];if(c){var h=c.subtract(r);h.getLength()>d&&(c=r.add(h.normalize(d-.1)))}var u=c||r;s=e.createRadialGradient(u.x,u.y,0,r.x,r.y,d)}else s=e.createLinearGradient(r.x,r.y,o.x,o.y);for(var m=0,p=a.length,l;me.length)throw new Error("Gradient stop list needs to contain at least two stops.");this._stops=re.readAll(e,0,{clone:!0});for(var t=0,n=this._stops.length,a;ts;s++){var l=r[s],d=l?l+o:t;if(d in e){if(n)e[d]=a;else return e[d];break}}}return{getStyles:function(e){var t=e&&9!==e.nodeType?e.ownerDocument:e,n=t&&t.defaultView;return n&&n.getComputedStyle(e,"")},getBounds:function(e,t){var n=e.ownerDocument,a=n.body,i=n.documentElement,r;try{r=e.getBoundingClientRect()}catch(t){r={left:0,top:0,width:0,height:0}}var o=r.left-(i.clientLeft||a.clientLeft||0),s=r.top-(i.clientTop||a.clientTop||0);if(!t){var l=n.defaultView;o+=l.pageXOffset||i.scrollLeft||a.scrollLeft,s+=l.pageYOffset||i.scrollTop||a.scrollTop}return new I(o,s,r.width,r.height)},getViewportBounds:function(e){var t=e.ownerDocument,n=t.defaultView,a=t.documentElement;return new I(0,0,n.innerWidth||a.clientWidth,n.innerHeight||a.clientHeight)},getOffset:function(e,t){return se.getBounds(e,t).getPoint()},getSize:function(e){return se.getBounds(e,!0).getSize()},isInvisible:function(e){return se.getSize(e).equals(new N(0,0))},isInView:function(e){return!se.isInvisible(e)&&se.getViewportBounds(e).intersects(se.getBounds(e,!0))},getPrefixed:function(t,n){return e(t,n)},setPrefixed:function(t,n,a){if("object"==typeof n)for(var i in n)e(t,i,!0,n[i]);else e(t,n,!0,a)}}},le={add:function(e,t){for(var n in t)for(var a=t[n],r=n.split(/[\s,]+/g),o=0,s=r.length;oDate.now()-d,i=r=g,t=n=a=h,s=!f&&g;s&&!s.responds("mousedrag");)s=s._parent;break;case"mouseup":f=e(this,c,u,h,g,t),s&&(n&&!n.equals(h)&&e(this,"mousedrag",u,h,s,n),g!==s&&(a=h,e(this,"mousemove",u,h,g,a))),!f&&g&&g===i&&(d=Date.now(),e(this,l&&i.responds("doubleclick")?"doubleclick":"click",u,t,g),l=!1),i=s=null;break;case"mousemove":s&&(f=e(this,"mousedrag",u,h,s,n)),f||(g!==o&&(a=h),f=e(this,c,u,h,g,a)),n=a=h,g!==o&&(e(this,"mouseleave",u,h,o),o=g,e(this,"mouseenter",u,h,g));}return f}}}}),he=_.extend({_class:"Event",initialize:function(e){this.event=e},isPrevented:!1,isStopped:!1,preventDefault:function(){this.isPrevented=!0,this.event.preventDefault()},stopPropagation:function(){this.isStopped=!0,this.event.stopPropagation()},stop:function(){this.stopPropagation(),this.preventDefault()},getModifiers:function(){return me.modifiers}}),ue=he.extend({_class:"KeyEvent",initialize:function(e,t,n,a){he.call(this,a),this.type=e?"keydown":"keyup",this.key=t,this.character=n},toString:function(){return"{ type: '"+this.type+"', key: '"+this.key+"', character: '"+this.character+"', modifiers: "+this.getModifiers()+" }"}}),me=new function(){function e(n,s,l,d){var c=l?String.fromCharCode(l):"",h=t[s],u=h||c.toLowerCase(),m=n?"keydown":"keyup",p=de._focused,f=p&&p.isVisible()&&p._scope,w=f&&f.tool,y;if(r[u]=n,n?i[s]=l:delete i[s],h&&(y=_.camelize(h))in a){a[y]=n;var v=g.browser;if("command"===y&&v&&v.mac)if(n)o={};else{for(var b in o)b in i&&e(!1,b,o[b],d);o=null}}else n&&o&&(o[s]=l);w&&w.responds(m)&&(g=f,w.emit(m,new ue(n,u,c,d)),p&&p.update())}var t={8:"backspace",9:"tab",13:"enter",16:"shift",17:"control",18:"option",19:"pause",20:"caps-lock",27:"escape",32:"space",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",46:"delete",91:"command",93:"command",224:"command"},n={9:!0,13:!0,32:!0},a=new _({shift:!1,control:!1,option:!1,command:!1,capsLock:!1,space:!1}),i={},r={},o,s;return le.add(document,{keydown:function(i){var r=i.which||i.keyCode;r in t||a.command?e(!0,r,r in n||a.command?r:0,i):s=r},keypress:function(t){null!=s&&(e(!0,s,t.which||t.keyCode,t),s=null)},keyup:function(t){var n=t.which||t.keyCode;n in i&&e(!1,n,i[n],t)}}),le.add(window,{blur:function(t){for(var n in i)e(!1,n,i[n],t)}}),{modifiers:a,isDown:function(e){return!!r[e]}}},pe=he.extend({_class:"MouseEvent",initialize:function(e,t,n,a,i){he.call(this,t),this.type=e,this.point=n,this.target=a,this.delta=i},toString:function(){return"{ type: '"+this.type+"', point: "+this.point+", target: "+this.target+(this.delta?", delta: "+this.delta:"")+", modifiers: "+this.getModifiers()+" }"}}),ge=he.extend({_class:"ToolEvent",_item:null,initialize:function(e,t,n){this.tool=e,this.type=t,this.event=n},_choosePoint:function(e,t){return e?e:t?t.clone():null},getPoint:function(){return this._choosePoint(this._point,this.tool._point)},setPoint:function(e){this._point=e},getLastPoint:function(){return this._choosePoint(this._lastPoint,this.tool._lastPoint)},setLastPoint:function(e){this._lastPoint=e},getDownPoint:function(){return this._choosePoint(this._downPoint,this.tool._downPoint)},setDownPoint:function(e){this._downPoint=e},getMiddlePoint:function(){return!this._middlePoint&&this.tool._lastPoint?this.tool._point.add(this.tool._lastPoint).divide(2):this._middlePoint},setMiddlePoint:function(e){this._middlePoint=e},getDelta:function(){return!this._delta&&this.tool._lastPoint?this.tool._point.subtract(this.tool._lastPoint):this._delta},setDelta:function(e){this._delta=e},getCount:function(){return /^mouse(down|up)$/.test(this.type)?this.tool._downCount:this.tool._count},setCount:function(e){this.tool[/^mouse(down|up)$/.test(this.type)?"downCount":"count"]=e},getItem:function(){if(!this._item){var e=this.tool._scope.project.hitTest(this.getPoint());if(e){for(var t=e.item,n=t._parent;/^(Group|CompoundPath)$/.test(n._class);)t=n,n=n._parent;this._item=t}}return this._item},setItem:function(e){this._item=e},toString:function(){return"{ type: "+this.type+", point: "+this.getPoint()+", count: "+this.getCount()+", modifiers: "+this.getModifiers()+" }"}}),fe=C.extend({_class:"Tool",_list:"tools",_reference:"tool",_events:["onActivate","onDeactivate","onEditOptions","onMouseDown","onMouseUp","onMouseDrag","onMouseMove","onKeyDown","onKeyUp"],initialize:function(e){C.call(this),this._firstMove=!0,this._count=0,this._downCount=0,this._set(e)},getMinDistance:function(){return this._minDistance},setMinDistance:function(e){this._minDistance=e,null!=e&&null!=this._maxDistance&&e>this._maxDistance&&(this._maxDistance=e)},getMaxDistance:function(){return this._maxDistance},setMaxDistance:function(e){this._maxDistance=e,null!=this._minDistance&&null!=e&&ea)t=this._point.add(l.normalize(a));else if(o)return!1}if(r&&t.equals(this._point))return!1}return this._lastPoint=i&&"mousemove"==e?t:this._point,this._point=t,"mousedown"===e?(this._lastPoint=this._downPoint,this._downPoint=this._point,this._downCount++):"mouseup"===e?this._lastPoint=this._downPoint:void 0,(this._count=i?0:this._count+1,!0)},_fireEvent:function(e,t){var n=g.project._removeSets;if(n){"mouseup"===e&&(n.mousedrag=null);var a=n[e];if(a){for(var i in a){var r=a[i];for(var o in n){var s=n[o];s&&s!=a&&delete s[r._id]}r.remove()}n[e]=null}}return this.responds(e)&&this.emit(e,new ge(this,e,t))},_handleEvent:function(e,t,n){g=this._scope;var a=!1;switch(e){case"mousedown":this._updateEvent(e,t,null,null,!0,!1,!1),a=this._fireEvent(e,n);break;case"mousedrag":for(var i=!1,r=!1;this._updateEvent(e,t,this.minDistance,this.maxDistance,!1,i,r);)a=this._fireEvent(e,n)||a,i=!0,r=!0;break;case"mouseup":!t.equals(this._point)&&this._updateEvent("mousedrag",t,this.minDistance,this.maxDistance,!1,!1,!1)&&(a=this._fireEvent("mousedrag",n)),this._updateEvent(e,t,null,this.maxDistance,!1,!1,!1),a=this._fireEvent(e,n)||a,this._updateEvent(e,t,null,null,!0,!1,!1),this._firstMove=!0;break;case"mousemove":for(;this._updateEvent(e,t,this.minDistance,this.maxDistance,this._firstMove,!0,!1);)a=this._fireEvent(e,n)||a,this._firstMove=!1;}return a&&n.preventDefault(),a}}),we={request:function(e,t,n,a){a=void 0===a||a;var i=new(window.ActiveXObject||XMLHttpRequest)("Microsoft.XMLHTTP");return i.open(e.toUpperCase(),t,a),"overrideMimeType"in i&&i.overrideMimeType("text/plain"),i.onreadystatechange=function(){if(4===i.readyState){var e=i.status;if(0===e||200===e)n.call(i,i.responseText);else throw new Error("Could not load "+t+" (Error "+e+")")}},i.send(null)}},ye={canvases:[],getCanvas:function(e,t){var n;"object"==typeof e&&(t=e.height,e=e.width),n=this.canvases.length?this.canvases.pop():document.createElement("canvas");var a=n.getContext("2d");return n.width===e&&n.height===t?a.clearRect(0,0,e+1,t+1):(n.width=e,n.height=t),a.save(),n},getContext:function(e,t){return this.getCanvas(e,t).getContext("2d")},release:function(e){var t=e.canvas?e.canvas:e;t.getContext("2d").restore(),this.canvases.push(t)}},ve=new function(){function e(e,t,n){return .2989*e+.587*t+.114*n}function t(t,n,a,r){var s=r-e(t,n,a);x=t+s,E=n+s,k=a+s;var r=e(x,E,k),d=i(x,E,k),c=o(x,E,k);if(0>d){var h=r-d;x=r+(x-r)*r/h,E=r+(E-r)*r/h,k=r+(k-r)*r/h}if(255r[l]?(r[d]=(r[d]-r[l])*a/(r[s]-r[l]),r[s]=a):r[d]=r[s]=0,r[l]=0,x=r[0],E=r[1],k=r[2]}var i=m,o=w,s=r,d={multiply:function(){x=f*h/255,E=y*u/255,k=v*p/255},screen:function(){x=f+h-f*h/255,E=y+u-y*u/255,k=v+p-v*p/255},overlay:function(){x=128>f?2*f*h/255:255-2*(255-f)*(255-h)/255,E=128>y?2*y*u/255:255-2*(255-y)*(255-u)/255,k=128>v?2*v*p/255:255-2*(255-v)*(255-p)/255},"soft-light":function(){var e=h*f/255;x=e+f*(255-(255-f)*(255-h)/255-e)/255,e=u*y/255,E=e+y*(255-(255-y)*(255-u)/255-e)/255,e=p*v/255,k=e+v*(255-(255-v)*(255-p)/255-e)/255},"hard-light":function(){x=128>h?2*h*f/255:255-2*(255-h)*(255-f)/255,E=128>u?2*u*y/255:255-2*(255-u)*(255-y)/255,k=128>p?2*p*v/255:255-2*(255-p)*(255-v)/255},"color-dodge":function(){x=0===f?0:255===h?255:i(255,255*f/(255-h)),E=0===y?0:255===u?255:i(255,255*y/(255-u)),k=0===v?0:255===p?255:i(255,255*v/(255-p))},"color-burn":function(){x=255===f?255:0===h?0:o(0,255-255*(255-f)/h),E=255===y?255:0===u?0:o(0,255-255*(255-y)/u),k=255===v?255:0===p?0:o(0,255-255*(255-v)/p)},darken:function(){x=fh?f:h,E=y>u?y:u,k=v>p?v:p},difference:function(){x=f-h,0>x&&(x=-x),E=y-u,0>E&&(E=-E),k=v-p,0>k&&(k=-k)},exclusion:function(){x=f+h*(255-f-f)/255,E=y+u*(255-y-y)/255,k=v+p*(255-v-v)/255},hue:function(){a(h,u,p,n(f,y,v)),t(x,E,k,e(f,y,v))},saturation:function(){a(f,y,v,n(h,u,p)),t(x,E,k,e(f,y,v))},luminosity:function(){t(f,y,v,e(h,u,p))},color:function(){t(h,u,p,e(f,y,v))},add:function(){x=i(f+h,255),E=i(y+u,255),k=i(v+p,255)},subtract:function(){x=o(f-h,0),E=o(y-u,0),k=o(v-p,0)},average:function(){x=(f+h)/2,E=(y+u)/2,k=(v+p)/2},negation:function(){x=255-s(255-h-f),E=255-s(255-u-y),k=255-s(255-p-v)}},c=this.nativeModes=_.each(["source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","darker","copy","xor"],function(e){this[e]=!0},{}),l=ye.getContext(1,1),h,u,p,g,f,y,v,b,x,E,k;_.each(d,function(e,t){var n="darken"===t,a=!1;l.save();try{l.fillStyle=n?"#300":"#a00",l.fillRect(0,0,1,1),l.globalCompositeOperation=t,l.globalCompositeOperation===t&&(l.fillStyle=n?"#a00":"#300",l.fillRect(0,0,1,1),a=l.getImageData(0,0,1,1).data[0]===n?51:170)}catch(t){}l.restore(),c[t]=a}),ye.release(l),this.process=function(e,t,n,a,r){var o=t.canvas,s="normal"===e;if(s||c[e])n.save(),n.setTransform(1,0,0,1,0,0),n.globalAlpha=a,s||(n.globalCompositeOperation=e),n.drawImage(o,r.x,r.y),n.restore();else{var m=d[e];if(!m)return;for(var w=n.getImageData(r.x,r.y,o.width,o.height),_=w.data,C=t.getImageData(0,0,o.width,o.height).data,S=0,z=_.length;Sw&&(h["stop-opacity"]=w),n.appendChild(t("stop",h))}c(e,n,"color")}return"url(#"+n.id+")"}function l(t,n,a){var i={},r=!a&&t.getParent();return null!=t._name&&(i.id=t._name),_.each(be,function(e){var n=e.get,a=e.type,o=t[n]();if(e.exportFilter?e.exportFilter(t,o):!r||!_.equals(r[n](),o)){if("color"===a&&null!=o){var l=o.getAlpha();1>l&&(i[e.attribute+"-opacity"]=l)}i[e.attribute]=null==o?"none":"number"===a?g.number(o):"color"===a?o.gradient?s(o,t):o.toCSS(!0):"array"===a?o.join(","):"lookup"===a?e.toSVG[o]:o}}),1===i.opacity&&delete i.opacity,t._visible||(i.visibility="hidden"),e(n,i)}function d(e,t){return f||(f={ids:{},svgs:{}}),e&&f.svgs[t+"-"+e._id]}function c(e,t,n){f||d();var a=f.ids[n]=(f.ids[n]||0)+1;t.id=n+"-"+a,f.svgs[n+"-"+e._id]=t}function h(e,n){var a=e,r=null;if(f){for(var o in a="svg"===e.nodeName.toLowerCase()&&e,f.svgs)r||(!a&&(a=t("svg"),a.appendChild(e)),r=a.insertBefore(t("defs"),a.firstChild)),r.appendChild(f.svgs[o]);f=null}return n.asString?new XMLSerializer().serializeToString(a):a}function u(e,t,n){var a=p[e._class],i=a&&a(e,t);if(i){var r=t.onExport;r&&(i=r(e,i,t)||i);var o=JSON.stringify(e._data);o&&"{}"!==o&&"null"!==o&&i.setAttribute("data-paper-data",o)}return i&&l(e,i,n)}function m(e){return e||(e={}),g=new S(e.precision),e}var p={Group:a,Layer:a,Raster:function(e,a){var i=n(e._matrix,!0),r=e.getSize(),o=e.getImage();return i.x-=r.width/2,i.y-=r.height/2,i.width=r.width,i.height=r.height,i.href=!1===a.embedImages&&o&&o.src||e.toDataURL(),t("image",i)},Path:i,Shape:r,CompoundPath:function(e,a){var i=n(e._matrix),r=e.getPathData(null,a.precision);return r&&(i.d=r),t("path",i)},PlacedSymbol:o,PointText:function(e){var a=t("text",n(e._matrix,!0));return a.textContent=e._content,a}},g,f;V.inject({exportSVG:function(e){return e=m(e),h(u(this,e,!0),e)}}),O.inject({exportSVG:function(e){e=m(e);var a=this.layers,r=this.getView(),o=r.getViewSize(),s=t("svg",{x:0,y:0,width:o.width,height:o.height,version:"1.1",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"}),d=s,c=r._matrix;c.isIdentity()||(d=s.appendChild(t("g",n(c))));for(var p=0,g=a.length;pt.deltaY?1:-1)},componentDidMount:function(){var e=this.cvs=this.refs.sketch;e.addEventListener("keydown",this.keydownlisten),e.addEventListener("keyup",this.keyuplisten),e.addEventListener("keypress",this.keypresslisten),e.addEventListener("mousedown",this.mousedownlisten),e.addEventListener("mouseup",this.mouseuplisten),e.addEventListener("mousemove",this.mousemovelisten),this.props.scrolling&&e.addEventListener("wheel",this.wheellissten),this.setup()},componentWillUnmount:function(){var e=this.cvs=this.refs.sketch;e.removeEventListener("keydown",this.keydownlisten),e.removeEventListener("keyup",this.keyuplisten),e.removeEventListener("keypress",this.keypresslisten),e.removeEventListener("mousedown",this.mousedownlisten),e.removeEventListener("mouseup",this.mouseuplisten),e.removeEventListener("mousemove",this.mousemovelisten),this.props.scrolling&&e.removeEventListener("wheel",this.wheellissten)},drawCurve:function(e){e=e||this.points;var n=this.ctx,a=!!(0o;o+=.01)i=r(o,this.degree,e,this.knots,a),n.lineTo(i[0],i[1]);i=r(1,this.degree,e,this.knots,a),n.lineTo(i[0],i[1]),n.stroke(),n.closePath()},drawKnots:function(e){var t=this,n=this.knots,a=!!(0n.length-1-t.degree)){var i=r(o,t.degree,e,n,a,!1,!0);t.circle(i[0],i[1],3)}})},drawNodes:function(e){var t=this,n;this.stroke(150),this.nodes.forEach(function(a,o){try{n=r(a,t.degree,e,t.knots,!1,!1,!0),t.line(n[0],n[1],e[o][0],e[o++][1])}catch(t){console.error(t)}})},formKnots:function(e,t){if(t=!0===t,!t)return this.formUniformKnots(e);var n=e.length,a=[],r=n-this.degree,o;for(o=1;oe[t[1]]||n.push(a)}return n},formWeights:function(e){var t=[];return e.forEach(function(){return t.push(1)}),t},setDegree:function(e){this.degree+=e,this.knots=this.formKnots(this.points),this.nodes=this.formNodes(this.knots,this.points)},near:function(e,t,n){var a=e.x-t,i=e.y-n,r=f(a*a+i*i);return rt&&(this.weights[t]+=.1*e,0>this.weights[t]&&(this.weights[t]=0)),t=this.points.indexOf(this.cp,t+1),-1!==t&&this.weights.length>t&&(this.weights[t]+=.1*e,0>this.weights[t]&&(this.weights[t]=0)),this.redraw()}},setKeyboardValues:function(t){t.ctrlKey||t.metaKey||t.altKey||t.preventDefault(),this.key=t.key,this.keyCode=t.code},setMouseValues:function(t){var e=this.cvs.getBoundingClientRect();this.mouseX=t.clientX-e.left,this.mouseY=t.clientY-e.top},size:function(e,t){this.width=0|e,this.height=0|(t||e),this.cvs.width=this.width,this.cvs.height=this.height,this.ctx=this.cvs.getContext("2d")},redraw:function(){this.draw()},clear:function(){this.ctx.clearRect(0,0,this.width,this.height)},grid:function(e){e=(0|(e||10))+.5,this.stroke(200,200,220);for(var t=e;t=r)return null;return a.createElement("div",{key:"knot"+s},e,a.createElement("input",{type:"range",min:e,max:n,step:1,value:o,onChange:function(n){var e=t.state.weights;e[s]=n.target.value,i&&sr(t.mx-e.x)&&10>r(t.my-e.y)&&(t.movingPoint=!0,t.mp=e,t.mp_idx=n,t.cx=e.x,t.cy=e.y)}),this.props.onMouseDown&&this.props.onMouseDown(e,this),"setCapture"in e.target&&e.target.setCapture()},mouseMove:function(e){if(!this.props.static){this.down&&(this.dragging=!0);var t=!1;if(this.lpts.forEach(function(n){var a=e.offsetX,i=e.offsetY;10>r(a-n.x)&&10>r(i-n.y)&&(t=t||!0)}),this.cvs.style.cursor=t?"pointer":"default",this.hover={x:e.offsetX,y:e.offsetY},this.movingPoint)if(this.ox=e.offsetX-this.mx,this.oy=e.offsetY-this.my,this.mp.x=w(0,m(this.defaultWidth,this.cx+this.ox)),this.mp.y=w(0,m(this.defaultHeight,this.cy+this.oy)),this.curve.forEach){for(var n=0,a,o;n=a.length||5<=a.length){var i=e.getLUT(100),r=i[0];return void i.forEach(function(e,a){a&&(n.drawLine(r,e,t),r=e)})}var o=t.x+this.offset.x,s=t.y+this.offset.y;this.ctx.beginPath(),this.ctx.moveTo(a[0].x+o,a[0].y+s),3===a.length?this.ctx.quadraticCurveTo(a[1].x+o,a[1].y+s,a[2].x+o,a[2].y+s):4===a.length&&this.ctx.bezierCurveTo(a[1].x+o,a[1].y+s,a[2].x+o,a[2].y+s,a[3].x+o,a[3].y+s),this.ctx.stroke(),this.ctx.closePath()},drawLine:function(e,t,n){n=n||{x:0,y:0};var a=n.x+this.offset.x,i=n.y+this.offset.y;this.ctx.beginPath(),this.ctx.moveTo(e.x+a,e.y+i),this.ctx.lineTo(t.x+a,t.y+i),this.ctx.stroke()},drawPoint:function(e,t){this.drawCircle(e,1,t)},drawPoints:function(e,t){t=t||{x:0,y:0},e.forEach(function(e){this.drawCircle(e,0!==t.x||0!==t.y?1.5:3,t)}.bind(this))},drawArc:function(e,t){t=t||{x:0,y:0};var n=t.x+this.offset.x,a=t.y+this.offset.y;this.ctx.beginPath(),this.ctx.moveTo(e.x+n,e.y+a),this.ctx.arc(e.x+n,e.y+a,e.r,e.s,e.e),this.ctx.lineTo(e.x+n,e.y+a),this.ctx.fill(),this.ctx.stroke()},drawCircle:function(e,t,n){n=n||{x:0,y:0};var a=n.x+this.offset.x,i=n.y+this.offset.y;this.ctx.beginPath(),this.ctx.arc(e.x+a,e.y+i,t,0,2*v),this.ctx.stroke()},drawbbox:function(e,t){t=t||{x:0,y:0};var n=t.x+this.offset.x,a=t.y+this.offset.y;this.ctx.beginPath(),this.ctx.moveTo(e.x.min+n,e.y.min+a),this.ctx.lineTo(e.x.min+n,e.y.max+a),this.ctx.lineTo(e.x.max+n,e.y.max+a),this.ctx.lineTo(e.x.max+n,e.y.min+a),this.ctx.closePath(),this.ctx.stroke()},drawRect:function(e,t,n){n=n||{x:0,y:0};var a=n.x+this.offset.x,i=n.y+this.offset.y,r=e.x+a,o=e.y+i,s=t.x-e.x,l=t.y-e.y;this.ctx.beginPath(),this.ctx.moveTo(r,o),this.ctx.lineTo(r+s,o),this.ctx.lineTo(r+s,o+l),this.ctx.lineTo(r,o+l),this.ctx.closePath(),this.ctx.fill(),this.ctx.stroke()},drawPath:function(e,t){var n=this;t=t||{x:0,y:0};var a=t.x+this.offset.x,i=t.y+this.offset.y;this.ctx.beginPath(),e.forEach(function(e,t){return 0===t?n.ctx.moveTo(e.x+a,e.y+i):void n.ctx.lineTo(e.x+a,e.y+i)}),closed&&this.ctx.closePath(),this.ctx.fill(),this.ctx.stroke()},drawShape:function(e,t){t=t||{x:0,y:0};var n=t.x+this.offset.x,a=t.y+this.offset.y,i=e.forward.points.length-1;this.ctx.beginPath(),this.ctx.moveTo(n+e.startcap.points[0].x,a+e.startcap.points[0].y),this.ctx.lineTo(n+e.startcap.points[3].x,a+e.startcap.points[3].y),3===i?this.ctx.bezierCurveTo(n+e.forward.points[1].x,a+e.forward.points[1].y,n+e.forward.points[2].x,a+e.forward.points[2].y,n+e.forward.points[3].x,a+e.forward.points[3].y):this.ctx.quadraticCurveTo(n+e.forward.points[1].x,a+e.forward.points[1].y,n+e.forward.points[2].x,a+e.forward.points[2].y),this.ctx.lineTo(n+e.endcap.points[3].x,a+e.endcap.points[3].y),3===i?this.ctx.bezierCurveTo(n+e.back.points[1].x,a+e.back.points[1].y,n+e.back.points[2].x,a+e.back.points[2].y,n+e.back.points[3].x,a+e.back.points[3].y):this.ctx.quadraticCurveTo(n+e.back.points[1].x,a+e.back.points[1].y,n+e.back.points[2].x,a+e.back.points[2].y),this.ctx.closePath(),this.ctx.fill(),this.ctx.stroke()},text:function(e,t,n){n=n||{x:0,y:0},this.offset&&(n.x+=this.offset.x,n.y+=this.offset.y),this.ctx.fillText(e,t.x+n.x,t.y+n.y)},image:function(e,t){var n=this;t=t||{x:0,y:0},this.offset&&(t.x+=this.offset.x,t.y+=this.offset.y);var a=e.devicePixelRatio||1;e.loaded?this.ctx.drawImage(e,t.x,t.y,e.width/a,e.height/a):e.onload=function(){e.loaded=!0,n.ctx.drawImage(e,t.x,t.y,e.width/a,e.height/a)}},drawAxes:function(e,t,n,a,i,r,o,s){s=s||{x:0,y:0};var l=this.getPanelWidth();this.drawLine({x:e,y:e},{x:l-e,y:e},s),this.drawLine({x:e,y:e},{x:e,y:l-e},s),this.setFill("black"),this.text(t+" \u2192",{x:s.x+l/2,y:s.y+15}),this.text(n,{x:s.x+e,y:s.y+15}),this.text(a,{x:s.x+l-e,y:s.y+15}),this.text(i,{x:s.x+5,y:s.y+l/2-e}),this.text("\u2193",{x:s.x+5,y:s.y+l/2}),this.text(r,{x:s.x+4,y:s.y+e+5}),this.text(o,{x:s.x+2,y:s.y+l-e+10})}};a&&(window["Bezier Graphics API"]=s),e.exports=s},function(e,t,n){"use strict";var a=n(1),i=n(6),r=new i;e.exports=function(){return a.createElement("div",{className:"locale-switcher"},r.getContent("locale-switcher",this))}},function(e,t,n){"use strict";e.exports={LocaleSwitcher:n(30)}},function(e){"use strict";e.exports={onClick:function(e,t){t.t=t.curve.on({x:e.offsetX,y:e.offsetY},7),(.05>t.t||.95e.error&&(e.error=.1)}}},setupCircle:function(e){var t=new e.Bezier(70,70,140,40,240,130);e.setCurve(t)},setupQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t),e.error=.5},getCCenter:function(l,c,h,u){var p=h.x-c.x,g=h.y-c.y,f=u.x-h.x,w=u.y-h.y,y=p*o(n/2)-g*d(n/2),v=p*d(n/2)+g*o(n/2),b=f*o(n/2)-w*d(n/2),x=f*d(n/2)+w*o(n/2),_=(c.x+h.x)/2,E=(c.y+h.y)/2,k=(h.x+u.x)/2,C=(h.y+u.y)/2,S=l.utils.lli8(_,E,_+y,E+v,k,C,k+b,C+x),i=l.utils.dist(S,c),r=t(c.y-S.y,c.x-S.x),z=t(h.y-S.y,h.x-S.x),m=t(u.y-S.y,u.x-S.x),T;return rz||z>m)&&(r+=a),r>m&&(T=m,m=r,r=T)):m=n?1:0;e.reset(),e.setColor("transparent"),e.setFill("rgba(150,150,255, 0.4)");for(var c=t/n,h=c/2,u,m,p;he.steps&&(e.steps=1)}}},setupQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t),e.steps=10},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t),e.steps=16},draw:function(e,n){e.reset(),e.drawSkeleton(n);for(var a=n.getLUT(e.steps),r=1/e.steps,o=n.points[0],s=r,l;s<1+r;s+=r)l=n.get(m(s,1)),e.setColor("red"),e.drawLine(o,l),o=l;for(var d=n.length(),c=0,h=0,u,p,g;hn;n++)this.points.push({x:this.width/2+t*u(n/6*e),y:this.height/2+t*l(n/6*e)});this.points=this.points.concat(this.points.slice(0,3)),this.closed=this.degree,this.knots=this.formKnots(this.points),this.weights=this.formWeights(this.points),this.props.controller&&this.props.controller(this,this.knots,this.weights,this.closed),this.draw()},draw:function(){var e=this;this.clear(),this.grid(25);var t=this.points[0];this.points.forEach(function(a){e.stroke(200),e.line(a.x,a.y,t.x,t.y),t=a,e.stroke(0),e.circle(t.x,t.y,4)}),this.drawSplineData()},drawSplineData:function(){if(!(this.points.length<=this.degree)){var e=this.points.map(function(e){return[e.x,e.y]});this.drawCurve(e),this.drawKnots(e)}}}},function(e){"use strict";e.exports={degree:3,activeDistance:9,setup:function(){this.size(400,400);for(var e=2*v,t=0;t=a;a+=.01)i=(-a*a+2*a+3)/4,-10-400;a-=.01)r.push({x:t*o,y:t*s}),i=(-a*a+3*a)/3,e.drawLine({x:t*o,y:t*s},{x:t*a,y:t*i},n),o=a,s=i;r.push({x:t*o,y:t*s}),e.text("\u2190 Curve forms a loop at t = 0",{x:200-t+10,y:200-1.25*t}),e.setColor("transparent"),e.setFill("rgba(255,120,100,0.2)"),e.drawPath(r,n),r=[{x:-200,y:t},{x:200,y:t},{x:200,y:400},{x:-200,y:400}],e.setFill("rgba(0,200,0,0.2)"),e.drawPath(r,n),e.setColor("black"),e.setFill(e.getColor()),e.text("\u2190 Curve form has one inflection \u2192",{x:200-t,y:200+1.75*t}),e.text("\u2190 Plain curve \u2195",{x:200+t/2,y:400/6}),e.text("\u2195 Double inflection",{x:10,y:190}),e._map_image=e.toImage(),e._map_loaded=!0}}},function(e,t,n){"use strict";var a=n(52),i=n(0);e.exports=i("canonical",a)},function(e,t,n){"use strict";var a=n(0);e.exports=a("catmullconv")},function(e){"use strict";e.exports={statics:{keyHandlingOptions:{propName:"distance",values:{38:1,40:-1}}},setup:function(e){e.setPanelCount(3),e.lpts=[{x:56,y:153},{x:144,y:83},{x:188,y:185}],e.distance=0},convert:function(e,t,n,a){return[t,{x:t.x+(n.x-e.x)/3,y:t.y+(n.y-e.y)/3},{x:n.x-(a.x-t.x)/3,y:n.y-(a.y-t.y)/3},n]},draw:function(e){e.reset(),e.setColor("lightblue"),e.drawGrid(10,10);var t=e.lpts;e.setColor("black"),e.setFill("black"),t.forEach(function(t,n){e.drawCircle(t,3),e.text("point "+(n+1),t,{x:10,y:7})});var n=e.getPanelWidth(),a=e.getPanelHeight(),i={x:n,y:0};e.setColor("lightblue"),e.drawGrid(10,10,i),e.setColor("black"),e.drawLine({x:0,y:0},{x:0,y:a},i),t.forEach(function(t){e.drawCircle(t,3,i)});var r=t[0],o=t[1],s=t[2],l=s.x-r.x,d=s.y-r.y,c=f(l*l+d*d);l/=c,d/=c,e.drawLine(r,s,i);var h={x:r.x+(s.x-o.x)-e.distance*l,y:r.y+(s.y-o.y)-e.distance*d},u={x:r.x+(s.x-o.x)+e.distance*l,y:r.y+(s.y-o.y)+e.distance*d},m=e.utils.lli4(r,s,o,{x:(h.x+u.x)/2,y:(h.y+u.y)/2});e.setColor("blue"),e.drawCircle(m,3,i),e.drawLine(t[1],m,i),e.setColor("#666"),e.drawLine(m,h,i),e.drawLine(m,u,i),e.setFill("blue"),e.text("p0",h,{x:-20+i.x,y:i.y+2}),e.text("p4",u,{x:10+i.x,y:i.y+2}),e.setColor("red"),e.drawCircle(h,3,i),e.drawLine(o,h,i),e.drawLine(r,{x:r.x+(o.x-h.x)/5,y:r.y+(o.y-h.y)/5},i),e.setColor("#00FF00"),e.drawCircle(u,3,i),e.drawLine(o,u,i),e.drawLine(s,{x:s.x+(u.x-o.x)/5,y:s.y+(u.y-o.y)/5},i);var p=new e.Bezier(this.convert(h,r,o,s)),g=new e.Bezier(this.convert(r,o,s,u));e.setColor("lightgrey"),e.drawCurve(p,i),e.drawCurve(g,i),i.x+=n,e.setColor("lightblue"),e.drawGrid(10,10,i),e.setColor("black"),e.drawLine({x:0,y:0},{x:0,y:a},i),e.drawCurve(p,i),e.drawCurve(g,i),e.drawPoints(p.points,i),e.drawPoints(g.points,i),e.setColor("lightgrey"),e.drawLine(p.points[0],p.points[1],i),e.drawLine(p.points[2],g.points[1],i),e.drawLine(g.points[2],g.points[3],i)}}},function(e,t,n){"use strict";var a=n(55),i=n(0),r=n(2);e.exports=r(i("catmullmoulding",a))},function(e){"use strict";var t=l,n=u;e.exports={setup:function(e){e.w=e.getPanelWidth(),e.h=e.getPanelHeight(),e.pad=20,e.r=e.w/2-e.pad,e.mousePt=!1,e.angle=0;var t={x:e.w-e.pad,y:e.h/2};e.setCurve(new e.Bezier(t,t,t))},draw:function(e,t){e.reset(),e.setColor("lightgrey"),e.drawGrid(1,1),e.setColor("red"),e.drawCircle({x:e.w/2,y:e.h/2},e.r),e.setColor("transparent"),e.setFill("rgba(100,255,100,0.4)");var n={x:e.w/2,y:e.h/2,r:e.r,s:0>e.angle?e.angle:0,e:0>e.angle?0:e.angle};e.drawArc(n),e.setColor("black"),e.drawSkeleton(t),e.drawCurve(t)},onMouseMove:function(e,a){var i=e.offsetX-a.w/2,o=e.offsetY-a.h/2,l=s(o,i),d=a.curve.points,c=a.r,r=(n(l)-1)/t(l);d[1]={x:a.w/2+c*(n(l)-r*t(l)),y:a.w/2+c*(t(l)+r*n(l))},d[2]={x:a.w/2+a.r*n(l),y:a.w/2+a.r*t(l)},a.setCurve(new a.Bezier(d)),a.angle=l}}},function(e,t,n){"use strict";var a=n(57),i=n(0);e.exports=i("circles",a)},function(t){"use strict";var n=l,a=u;t.exports={setup:function(e){e.setSize(400,400),e.w=e.getPanelWidth(),e.h=e.getPanelHeight(),e.pad=80,e.r=e.w/2-e.pad,e.mousePt=!1,e.angle=0;var t={x:e.w-e.pad,y:e.h/2};e.setCurve(new e.Bezier(t,t,t,t))},guessCurve:function(e,t,n){var a={x:(e.x+n.x)/2,y:(e.y+n.y)/2},i={x:t.x+(t.x-a.x)/3,y:t.y+(t.y-a.y)/3},r=(n.x-e.x)/4,o=(n.y-e.y)/4,s={x:t.x-r,y:t.y-o},l={x:t.x+r,y:t.y+o},d={x:i.x+2*(s.x-i.x),y:i.y+2*(s.y-i.y)},c={x:i.x+2*(l.x-i.x),y:i.y+2*(l.y-i.y)},h={x:e.x+2*(d.x-e.x),y:e.y+2*(d.y-e.y)},u={x:n.x+2*(c.x-n.x),y:n.y+2*(c.y-n.y)};return[h,u]},draw:function(e,t){e.reset(),e.setColor("lightgrey"),e.drawGrid(1,1),e.setColor("rgba(255,0,0,0.4)"),e.drawCircle({x:e.w/2,y:e.h/2},e.r),e.setColor("transparent"),e.setFill("rgba(100,255,100,0.4)");var i={x:e.w/2,y:e.h/2,r:e.r,s:0>e.angle?e.angle:0,e:0>e.angle?0:e.angle};e.drawArc(i);var r={x:e.w/2+e.r*a(e.angle/2),y:e.w/2+e.r*n(e.angle/2)},o=t.points[0],s=t.points[3],l=this.guessCurve(o,r,s),d=new e.Bezier([o,l[0],l[1],s]);e.setColor("rgb(140,140,255)"),e.drawLine(d.points[0],d.points[1]),e.drawLine(d.points[1],d.points[2]),e.drawLine(d.points[2],d.points[3]),e.setColor("blue"),e.drawCurve(d),e.drawCircle(d.points[1],3),e.drawCircle(d.points[2],3),e.drawSkeleton(t),e.setColor("black"),e.drawLine(t.points[1],t.points[2]),e.drawCurve(t)},onMouseMove:function(t,i){var o=t.offsetX-i.w/2,l=t.offsetY-i.h/2;if(!(o>i.w/2)){var d=s(l,o);0>d&&(d=2*v+d);var c=i.curve.points,h=i.r,r=4*e(d/4)/3;c[1]={x:i.w/2+h,y:i.w/2+h*r},c[2]={x:i.w/2+i.r*(a(d)+r*n(d)),y:i.w/2+i.r*(n(d)-r*a(d))},c[3]={x:i.w/2+i.r*a(d),y:i.w/2+i.r*n(d)},i.setCurve(new i.Bezier(c)),i.angle=d}},drawCircle:function(e){e.setSize(325,325),e.reset();var t=e.getPanelWidth(),n=e.getPanelHeight(),a=t/2-60,i=.55228,r={x:-30,y:-15},o=new e.Bezier([{x:t/2+a,y:n/2},{x:t/2+a,y:n/2+i*a},{x:t/2+i*a,y:n/2+a},{x:t/2,y:n/2+a}]);e.setColor("lightgrey"),e.drawLine({x:0,y:n/2},{x:t+60,y:n/2},r),e.drawLine({x:t/2,y:0},{x:t/2,y:n+60},r);var s=o.points;e.setColor("red"),e.drawPoint(s[0],r),e.drawPoint(s[1],r),e.drawPoint(s[2],r),e.drawPoint(s[3],r),e.drawCurve(o,r),e.setColor("rgb(255,160,160)"),e.drawLine(s[0],s[1],r),e.drawLine(s[1],s[2],r),e.drawLine(s[2],s[3],r),e.setFill("red"),e.text(s[0].x-t/2+","+(s[0].y-n/2),{x:s[0].x+7,y:s[0].y+3},r),e.text(s[1].x-t/2+","+(s[1].y-n/2),{x:s[1].x+7,y:s[1].y+3},r),e.text(s[2].x-t/2+","+(s[2].y-n/2),{x:s[2].x+7,y:s[2].y+7},r),e.text(s[3].x-t/2+","+(s[3].y-n/2),{x:s[3].x,y:s[3].y+13},r),s.forEach(function(e){e.x=-(e.x-t)}),e.setColor("blue"),e.drawCurve(o,r),e.drawLine(s[2],s[3],r),e.drawPoint(s[2],r),e.setFill("blue"),e.text("reflected",{x:s[2].x-30,y:s[2].y+13},r),e.setColor("rgb(200,200,255)"),e.drawLine(s[1],s[0],r),e.drawPoint(s[1],r),s.forEach(function(e){e.y=-(e.y-n)}),e.setColor("green"),e.drawCurve(o,r),s.forEach(function(e){e.x=-(e.x-t)}),e.setColor("purple"),e.drawCurve(o,r),e.drawLine(s[1],s[0],r),e.drawPoint(s[1],r),e.setFill("purple"),e.text("reflected",{x:s[1].x+10,y:s[1].y+3},r),e.setColor("rgb(200,200,255)"),e.drawLine(s[2],s[3],r),e.drawPoint(s[2],r),e.setColor("black"),e.setFill("black"),e.drawLine({x:t/2,y:n/2},{x:t/2+a-2,y:n/2},r),e.drawLine({x:t/2,y:n/2},{x:t/2,y:n/2+a-2},r),e.text("r = "+a,{x:t/2+a/3,y:n/2+10},r)}}},function(e,t,n){"use strict";var a=n(59),i=n(0);e.exports=i("circles_cubic",a)},function(e){"use strict";e.exports={componentDidMount:function(){return"undefined"==typeof document?this.silence():void(this.heading=document.getElementById(this.props.page),document.addEventListener("scroll",this.scrollHandler,{passive:!0}))},scrollHandler:function(){var e=this.heading.getBoundingClientRect(),t=e.top,n=window.innerHeight;t=20&&i.x<=n-20){this.drawLerpBox(e,n,20,i);var r=(i.x-20)/a;this.drawLerpPoint(e,(1-r)*(1-r),20,a,i),this.drawLerpPoint(e,2*(1-r)*r,20,a,i),this.drawLerpPoint(e,r*r,20,a,i)}this.drawFunction(e,"first term",{x:40,y:a},function(e){return{x:20+e*a,y:20+a*(1-e)*(1-e)}}),this.drawFunction(e,"second term",{x:n/2-30,y:n/2+20},function(e){return{x:20+e*a,y:20+2*a*(1-e)*e}}),this.drawFunction(e,"third term",{x:a-50,y:a},function(e){return{x:20+e*a,y:20+a*e*e}})},drawCubicLerp:function(e){e.reset();var n=e.getPanelWidth(),a=n-40;e.drawAxes(20,"t",0,1,"S","0%","100%");var i=e.hover;if(i&&i.x>=20&&i.x<=n-20){this.drawLerpBox(e,n,20,i);var r=(i.x-20)/a;this.drawLerpPoint(e,(1-r)*(1-r)*(1-r),20,a,i),this.drawLerpPoint(e,3*(1-r)*(1-r)*r,20,a,i),this.drawLerpPoint(e,3*(1-r)*r*r,20,a,i),this.drawLerpPoint(e,r*r*r,20,a,i)}this.drawFunction(e,"first term",{x:40,y:a},function(e){return{x:20+e*a,y:20+a*(1-e)*(1-e)*(1-e)}}),this.drawFunction(e,"second term",{x:n/2-80,y:n/2},function(e){return{x:20+e*a,y:20+3*a*(1-e)*(1-e)*e}}),this.drawFunction(e,"third term",{x:n/2+40,y:n/2},function(e){return{x:20+e*a,y:20+3*a*(1-e)*e*e}}),this.drawFunction(e,"fourth term",{x:a-50,y:a},function(e){return{x:20+e*a,y:20+a*e*e*e}})},draw15thLerp:function(e){e.reset();var i=e.getPanelWidth(),r=i-40;e.drawAxes(20,"t",0,1,"S","0%","100%");var o=[1,15,105,455,1365,3003,5005,6435,6435,5005,3003,1365,455,105,15,1],s=e.hover,l;if(s&&s.x>=20&&s.x<=i-20)for(this.drawLerpBox(e,i,20,s),l=0;15>=l;l++){var d=(s.x-20)/r,t=o[l]*a(1-d,15-l)*a(d,l);this.drawLerpPoint(e,t,20,r,s)}for(l=0;15>=l;l++){var c=!1,h=!1;0===l&&(c="first term",h={x:25,y:r}),15===l&&(c="last term",h={x:i-70,y:r}),this.drawFunction(e,c,h,function(e){return{x:20+e*r,y:20+r*o[l]*a(1-e,15-l)*a(e,l)}})}}}},function(e,t,n){"use strict";var a=n(65),i=n(0);e.exports=i("control",a)},function(e,t,n){"use strict";var a=n(14);e.exports={setup:function(e){this.api=e,this.reset()},reset:function(){this.points=[],this.curveset=!1;var e=this.api;e&&(e.setCurve(!1),e.reset(),e.redraw())},draw:function(e,t){if(e.setPanelCount(1),e.reset(),e.setColor("lightgrey"),e.drawGrid(10,10),e.setColor("black"),!this.curveset&&2t.c1.length()&&.6>t.c2.length())return a.finals.push(t);var n=t.c1.split(.5);e.setColor("black"),e.drawCurve(t.c1,r),e.setColor("red"),e.drawbbox(n.left.bbox(),r),e.drawbbox(n.right.bbox(),r);var i=t.c2.split(.5);e.setColor("black"),e.drawCurve(t.c2,r),e.setColor("blue"),e.drawbbox(i.left.bbox(),r),e.drawbbox(i.right.bbox(),r),n.left.overlaps(i.left)&&a.pairs.push({c1:n.left,c2:i.left}),n.left.overlaps(i.right)&&a.pairs.push({c1:n.left,c2:i.right}),n.right.overlaps(i.left)&&a.pairs.push({c1:n.right,c2:i.left}),n.right.overlaps(i.right)&&a.pairs.push({c1:n.right,c2:i.right})}),this.prevstep=this.step}else this.pairs.forEach(function(t){e.setColor("black"),e.drawCurve(t.c1,r),e.drawCurve(t.c2,r),e.setColor("red"),e.drawbbox(t.c1.bbox(),r),e.setColor("blue"),e.drawbbox(t.c2.bbox(),r)});0===this.pairs.length&&(this.pairReset(),this.draw(e,n)),r.x+=o,e.setColor("black"),e.drawLine({x:0,y:0},{x:0,y:s},r);var d=n[0].intersects(n[1]).map(function(e){var t=e.split("/").map(function(e){return parseFloat(e)});return{t1:t[0],t2:t[1]}}),c=d[0],h=function(e,n){return .01>t(e.t1-n.t1)&&.01>t(e.t2-n.t2)},u,m;for(m=1;m=s;s++)e.drawCircle(o[s],3);var l=n.get(r);e.drawCircle(l,5),e.setFill("black"),e.drawCircle(l,3);var d=0|100*r;r=d/100,e.text("Sequential interpolation for "+d+"% (t="+r+")",{x:10,y:15})}}}},function(e,t,n){"use strict";var a=n(71),i=n(0);e.exports=i("decasteljau",a)},function(e,t,n){"use strict";var a=n(0);e.exports=a("derivatives")},function(e){"use strict";e.exports={statics:{keyHandlingOptions:{propName:"step",values:{38:.1,40:-.1},controller:function(e){.1>e.step&&(e.step=.1)}}},setup:function(e){e.step=5},draw:function(e){var n=e.getPanelWidth(),a=n,i=n,r=a/2,s=i/2,d=r/2,c=s/2;e.reset(),e.setColor("black"),e.drawLine({x:0,y:s},{x:a,y:s}),e.drawLine({x:r,y:0},{x:r,y:i});for(var h={x:r,y:s},m=0,g;m<=e.step;m+=.1){g={x:d*u(m),y:c*l(m)},e.drawPoint(g,h);var f=m%1;(.05>f||.95e.steps&&(e.steps=1)}}},setupQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t),e.steps=3},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t),e.steps=5},drawFlattened:function(e,n){e.reset(),e.setColor("#DDD"),e.drawSkeleton(n),e.setColor("#DDD"),e.drawCurve(n);for(var a=1/e.steps,i=n.points[0],r=a,o;r<1+a;r+=a)o=n.get(m(r,1)),e.setColor("red"),e.drawLine(i,o),i=o;e.setFill("black"),e.text("Curve approximation using "+e.steps+" segments",{x:10,y:15})},values:{38:1,40:-1},onKeyDown:function(t,e){var n=this.values[t.keyCode];n&&(t.preventDefault(),e.steps+=n,1>e.steps&&(e.steps=1))}}},function(e,t,n){"use strict";var a=n(80),i=n(0),r=n(2);e.exports=r(i("flattening",a))},function(e){"use strict";e.exports={statics:{keyHandlingOptions:{propName:"distance",values:{38:1,40:-1}}},setup:function(e,t){e.setCurve(t),e.distance=20},setupQuadratic:function(e){var t=e.getDefaultQuadratic();this.setup(e,t)},setupCubic:function(e){var t=e.getDefaultCubic();this.setup(e,t)},draw:function(e,t){e.reset(),e.drawSkeleton(t),e.drawCurve(t),e.setColor("blue");var n=t.outline(0,0,e.distance,e.distance);n.curves.forEach(function(t){return e.drawCurve(t)})}}},function(e,t,n){"use strict";var a=n(82),i=n(0),r=n(2);e.exports=r(i("graduatedoffset",a))},function(e){"use strict";e.exports={setupCubic:function(e){var t=new e.Bezier(135,25,25,135,215,75,215,240);e.setCurve(t)},draw:function(e,n){e.reset(),e.drawSkeleton(n),e.drawCurve(n),e.setColor("red"),n.inflections().forEach(function(a){e.drawCircle(n.get(a),5)})}}},function(e,t,n){"use strict";var a=n(84),i=n(0);e.exports=i("inflections",a)},function(e){"use strict";var t=m,n=w;e.exports={setupLines:function(e){var t=new e.Bezier([50,50,150,110]),n=new e.Bezier([50,250,170,170]);e.setCurve(t,n)},drawLineIntersection:function(e,a){e.reset();var i=e.utils.lli4,r=i(a[0].points[0],a[0].points[1],a[1].points[0],a[1].points[1]),o=0;a.forEach(function(a){if(e.drawSkeleton(a),e.setColor("black"),r){var i=a.points,s=t(i[0].x,i[1].x),l=t(i[0].y,i[1].y),d=n(i[0].x,i[1].x),c=n(i[0].y,i[1].y);s<=r.x&&l<=r.y&&d>=r.x&&c>=r.y&&(e.setColor("#00FF00"),o++)}e.drawCurve(a)}),r&&(e.setColor(2>o?"red":"#00FF00"),e.drawCircle(r,3))},setupQuadratic:function(e){var t=e.getDefaultQuadratic(),n=new e.Bezier([15,250,220,20]);e.setCurve(t,n)},setupCubic:function(e){var t=new e.Bezier([100,240,30,60,210,230,160,30]),n=new e.Bezier([25,260,230,20]);e.setCurve(t,n)},draw:function(e,n){e.reset(),n.forEach(function(t){e.drawSkeleton(t),e.drawCurve(t)});var t=e.utils,a={p1:n[1].points[0],p2:n[1].points[1]},i=t.align(n[0].points,a),r=new e.Bezier(i),o=t.roots(r.points);o.forEach(function(a){var t=n[0].get(a);e.drawCircle(t,3),e.text("t = "+a,{x:t.x+5,y:t.y+10})})}}},function(e,t,n){"use strict";var a=n(86),i=n(0);e.exports=i("intersections",a)},function(e){"use strict";e.exports={drawQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t)},drawCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},drawCurve:function(e,t){e.reset(),e.drawSkeleton(t),e.drawCurve(t)}}},function(e,t,n){"use strict";var a=n(88),i=n(0);e.exports=i("introduction",a)},function(e,t,n){"use strict";var a=n(0);e.exports=a("matrix")},function(e,t,n){"use strict";var a=n(0);e.exports=a("matrixsplit")},function(e){"use strict";var n=r;e.exports={setupQuadratic:function(e){e.setPanelCount(3);var t=e.getDefaultQuadratic();t.points[2].x-=30,e.setCurve(t)},setupCubic:function(e){e.setPanelCount(3);var t=new e.Bezier([100,230,30,160,200,50,210,160]);t.points[2].y-=20,e.setCurve(t),e.lut=t.getLUT(100)},saveCurve:function(e,t){t.t&&(t.setCurve(t.newcurve),t.t=!1,t.redraw())},findTValue:function(e,n){var a=n.curve.on({x:e.offsetX,y:e.offsetY},7);return!(.05>a||.95=r;r++)o=r/10,s=a.get(o),l=a.derivative(o),c=f(l.x*l.x+l.y*l.y),l={x:l.x/c,y:l.y/c},d=a.normal(o),e.setColor("blue"),e.drawLine(s,{x:s.x+20*l.x,y:s.y+20*l.y}),e.setColor("red"),e.drawLine(s,{x:s.x+20*d.x,y:s.y+20*d.y}),e.setColor("black"),e.drawCircle(s,3)}}},function(e,t,n){"use strict";var a=n(100),i=n(0);e.exports=i("pointvectors",a)},function(e){"use strict";var t=s,n=f,r=l,o=u;e.exports={setupQuadratic:function(e){var t=e.getPanelWidth(),n=e.getPanelHeight(),a=t/2,i=n/2;e.lpts=[{x:a,y:40},{x:t-40,y:40},{x:t-40,y:i},{x:t-40,y:n-40},{x:a,y:n-40},{x:40,y:n-40},{x:40,y:i},{x:40,y:40}]},setupCubic:function(e){var t=e.getPanelWidth(),n=e.getPanelHeight(),a=t/2,i=n/2,r=.55228*((t-80)/2);e.lpts=[{x:a,y:40},{x:a+r,y:40},{x:t-40,y:i-r},{x:t-40,y:i},{x:t-40,y:i+r},{x:a+r,y:n-40},{x:a,y:n-40},{x:a-r,y:n-40},{x:40,y:i+r},{x:40,y:i},{x:40,y:i-r},{x:a-r,y:40}]},movePointsQuadraticLD:function(e,t){for(var n=1,a,i,r;4>n;n++)a=t+(2*n-2)+e.lpts.length,a=e.lpts[a%e.lpts.length],i=t+(2*n-1),i=e.lpts[i%e.lpts.length],r=t+2*n,r=e.lpts[r%e.lpts.length],r.x=i.x+(i.x-a.x),r.y=i.y+(i.y-a.y);r=t+6,r=e.lpts[r%e.lpts.length],e.problem=r},movePointsCubicLD:function(e,t){var n,a;1==t%3?(a=t-1,a+=0>a?e.lpts.length:0,n=t-2,n+=0>n?e.lpts.length:0):(a=(t+1)%e.lpts.length,n=(t+2)%e.lpts.length),a=e.lpts[a],n=e.lpts[n],n.x=a.x+(a.x-e.mp.x),n.y=a.y+(a.y-e.mp.y)},linkDerivatives:function(e,t){if(t.mp){var n=8===t.lpts.length,a=t.mp_idx;n?0!=a%2&&this.movePointsQuadraticLD(t,a):0!=a%3&&this.movePointsCubicLD(t,a)}},movePointsQuadraticDirOnly:function(e,s){var i,l,c;[-1,1].forEach(function(h){i=e.mp,l=s+h+e.lpts.length,l=e.lpts[l%e.lpts.length],c=s+2*h+e.lpts.length,c=e.lpts[c%e.lpts.length];var u=t(l.y-i.y,l.x-i.x),a=c.x-l.x,m=c.y-l.y,p=n(a*a+m*m);c.x=l.x+p*o(u),c.y=l.y+p*r(u)}),c=s+4,c=e.lpts[c%e.lpts.length],e.problem=c},movePointsCubicDirOnly:function(e,s){var i,l;1==s%3?(l=s-1,l+=0>l?e.lpts.length:0,i=s-2,i+=0>i?e.lpts.length:0):(l=(s+1)%e.lpts.length,i=(s+2)%e.lpts.length),l=e.lpts[l],i=e.lpts[i];var c=t(l.y-e.mp.y,l.x-e.mp.x),a=i.x-l.x,h=i.y-l.y,u=n(a*a+h*h);i.x=l.x+u*o(c),i.y=l.y+u*r(c)},linkDirection:function(e,t){if(t.mp){var n=8===t.lpts.length,a=t.mp_idx;n?0!=a%2&&this.movePointsQuadraticDirOnly(t,a):0!=a%3&&this.movePointsCubicDirOnly(t,a)}},bufferPoints:function(e,t){t.bpts=JSON.parse(JSON.stringify(t.lpts))},moveQuadraticPoint:function(e,s){this.moveCubicPoint(e,s),[-1,1].forEach(function(i){var l=s-i+e.lpts.length;l=e.lpts[l%e.lpts.length];var c=s-2*i+e.lpts.length;c=e.lpts[c%e.lpts.length];var h=s-3*i+e.lpts.length;h=e.lpts[h%e.lpts.length];var u=t(c.y-l.y,c.x-l.x),a=h.x-c.x,m=h.y-c.y,p=n(a*a+m*m);h.x=c.x+p*o(u),h.y=c.y+p*r(u)});var a=s+4;a=e.lpts[a%e.lpts.length],e.problem=a},moveCubicPoint:function(e,t){var n=e.bpts[t],a=e.lpts[t],i=a.x-n.x,o=a.y-n.y,s=e.lpts.length,d=t-1+s,l=t+1,r=e.bpts[d%s],c=e.bpts[l%s],h=e.lpts[d%s],u=e.lpts[l%s];return h.x=r.x+i,h.y=r.y+o,u.x=c.x+i,u.y=c.y+o,{x:i,y:o}},modelCurve:function(e,t){if(t.mp){var n=8===t.lpts.length,a=t.mp_idx;n?0==a%2?this.moveQuadraticPoint(t,a):this.movePointsQuadraticDirOnly(t,a):0==a%3?this.moveCubicPoint(t,a):this.movePointsCubicDirOnly(t,a)}},draw:function(e){e.reset();var t=e.lpts,n=8===t.length,a=n?new e.Bezier(t[0],t[1],t[2]):new e.Bezier(t[0],t[1],t[2],t[3]);e.drawSkeleton(a,!1,!0),e.drawCurve(a);var i=n?new e.Bezier(t[2],t[3],t[4]):new e.Bezier(t[3],t[4],t[5],t[6]);e.drawSkeleton(i,!1,!0),e.drawCurve(i);var r=n?new e.Bezier(t[4],t[5],t[6]):new e.Bezier(t[6],t[7],t[8],t[9]);e.drawSkeleton(r,!1,!0),e.drawCurve(r);var o=n?new e.Bezier(t[6],t[7],t[0]):new e.Bezier(t[9],t[10],t[11],t[0]);e.drawSkeleton(o,!1,!0),e.drawCurve(o),e.problem&&(e.setColor("red"),e.drawCircle(e.problem,5))}}},function(e,t,n){"use strict";var a=n(102),i=n(0);e.exports=i("polybezier",a)},function(e,t,n){"use strict";var a=n(0);e.exports=a("preface")},function(e){"use strict";e.exports={setup:function(e){e.setSize(320,320);var t=new e.Bezier([{x:248,y:188},{x:218,y:294},{x:45,y:290},{x:12,y:236},{x:14,y:82},{x:186,y:177},{x:221,y:90},{x:18,y:156},{x:34,y:57},{x:198,y:18}]);e.setCurve(t),e._lut=t.getLUT()},findClosest:function(e,t,n){var a=e.length,r=n(e[0],t),o=0,s,l;for(s=1;sr;r++)t.push({x:n/2+20*Math.random()+u(2*v*r/10)*(n/2-40),y:a/2+20*Math.random()+l(2*v*r/10)*(a/2-40)});var o=new e.Bezier(t);e.setCurve(o)},draw:function(e,n){e.reset();var a=n.points;this.setState({order:a.length});for(var r=a[0],o=0,s;1>=o;o+=.01){for(s=JSON.parse(JSON.stringify(a));1e.steps&&(e.steps=1)}}},setup:function(e){var t=e.getDefaultCubic();e.setCurve(t),e.steps=8},generate:function(e,n,a,i,r){a.x+=i,a.y+=i;for(var o=n.length(),s=[{x:0,y:0,d:0}],l=1,c,h;100>=l;l++)c=l/100,h=n.split(c).left.length(),s.push({x:e.utils.map(c,0,1,0,r),y:e.utils.map(h,0,o,0,r),d:h,t:c});return s},draw:function(e,t,n){e.reset(),e.drawSkeleton(t),e.drawCurve(t);var a=t.length(),i=e.getPanelWidth(),r=e.getPanelHeight(),o=20;return n.x+=i,e.drawLine({x:0,y:0},{x:0,y:r},n),e.drawAxes(o,"t",0,1,"d",0,a,n),this.generate(e,t,n,o,i-2*o)},plotOnly:function(e,t){e.setPanelCount(2);for(var n={x:0,y:0},a=this.draw(e,t,n),r=0;rm){u--;break}0>u&&(u=0),u===d.length&&(u=d.length-1),s.push(d[u])}for(h=0;h and ending at the value listed on top of the \u03A3)."),a.createElement("div",{className:"howtocode"},a.createElement("h3",{id:"how-to-implement-the-basis-function"},"How to implement the basis function"),a.createElement("p",null,"We could naively implement the basis function as a mathematical construct, using the function as our guide, like this:"),a.createElement("pre",null,"function Bezier(n,t):\n sum = 0\n for(k=0; k= lut.length):\n s = lut.length\n nextRow = new array(size=s+1)\n nextRow[0] = 1\n for(i=1, prev=s-1; i<=s; i++):\n nextRow[i] = lut[prev][i-1] + lut[prev][i]\n nextRow[s] = 1\n lut.add(nextRow)\n return lut[n][k]\n"),a.createElement("p",null,"So what's going on here? First, we declare a lookup table with a size that's reasonably large enough to accommodate most lookups. Then, we declare a function to get us the values we need, and we make sure that if an n/k pair is requested that isn't in the LUT yet, we expand it first. Our basis function now looks like this:"),a.createElement("pre",null,"function Bezier(n,t):\n sum = 0\n for(k=0; k<=n; k++):\n sum += binomial(n,k) * (1-t)^(n-k) * t^(k)\n return sum\n"),a.createElement("p",null,"Perfect. Of course, we can optimize further. For most computer graphics purposes, we don't need arbitrary curves. We need quadratic and cubic curves (this primer actually does do arbitrary curves, so you'll find code similar to shown here), which means we can drastically simplify the code:"),a.createElement("pre",null,"function Bezier(2,t):\n t2 = t * t\n mt = 1-t\n mt2 = mt * mt\n return mt2 + 2*mt*t + t2\n\nfunction Bezier(3,t):\n t2 = t * t\n t3 = t2 * t\n mt = 1-t\n mt2 = mt * mt\n mt3 = mt2 * mt\n return mt3 + 3*mt2*t + 3*mt*t2 + t3\n"),a.createElement("p",null,"And now we know how to program the basis function. Exellent.")),a.createElement("p",null,"So, now we know what the base function(s) look(s) like, time to add in the magic that makes B\xE9zier curves so special: control points."))}},control:{locale:"en-GB",title:"Controlling B\xE9zier curvatures",getContent:function(e){return a.createElement("section",{className:"control"},a.createElement(r,{name:"control",title:"Controlling B\xE9zier curvatures",number:"4"}),a.createElement("p",null,"B\xE9zier curves are (like all \"splines\") interpolation functions, meaning they take a set of points, and generate values somewhere \"between\" those points. (One of the consequences of this is that you'll never be able to generate a point that lies outside the outline for the control points, commonly called the \"hull\" for the curve. Useful information!). In fact, we can visualize how each point contributes to the value generated by the function, so we can see which points are important, where, in the curve."),a.createElement("p",null,"The following graphs show the interpolation functions for quadratic and cubic curves, with \"S\" being the strength of a point's contribution to the total sum of the B\xE9zier function. Click or click-drag to see the interpolation percentages for each curve-defining point at a specific ",a.createElement("i",null,"t")," value."),a.createElement("div",{className:"figure"},a.createElement(i,{handler:e.props.handler,section:"control",inline:!0,title:"Quadratic interpolations",draw:e.drawQuadraticLerp,dname:"drawQuadraticLerp"}),a.createElement(i,{handler:e.props.handler,section:"control",inline:!0,title:"Cubic interpolations",draw:e.drawCubicLerp,dname:"drawCubicLerp"}),a.createElement(i,{handler:e.props.handler,section:"control",inline:!0,title:"15th order interpolations",draw:e.draw15thLerp,dname:"draw15thLerp"})),a.createElement("p",null,"Also shown is the interpolation function for a 15",a.createElement("sup",null,"th")," order B\xE9zier function. As you can see, the start and end point contribute considerably more to the curve's shape than any other point in the control point set."),a.createElement("p",null,"If we want to change the curve, we need to change the weights of each point, effectively changing the interpolations. The way to do this is about as straight forward as possible: just multiply each point with a value that changes its strength. These values are conventionally called \"Weights\", and we can add them to our original B\xE9zier function:"),a.createElement("img",{className:"LaTeX SVG",src:"images/latex/cc82da74955e71db3f5f0ab77dcc4664c0387bec.svg",width:"369.59999999999997",height:"57.4"}),a.createElement("p",null,"That looks complicated, but as it so happens, the \"weights\" are actually just the coordinate values we want our curve to have: for an ",a.createElement("i",null,"n",a.createElement("sup",null,"th"))," order curve, w",a.createElement("sub",null,"0")," is our start coordinate, w",a.createElement("sub",null,"n")," is our last coordinate, and everything in between is a controlling coordinate. Say we want a cubic curve that starts at (120,160), is controlled by (35,200) and (220,260) and ends at (220,40), we use this B\xE9zier curve:"),a.createElement("img",{className:"LaTeX SVG",src:"images/latex/853858526831a7ef3eb170efe49de397bb4913a1.svg",width:"496.99999999999994",height:"42"}),a.createElement("p",null,"Which gives us the curve we saw at the top of the article:"),a.createElement(i,{handler:e.props.handler,section:"control",title:"Our cubic B\xE9zier curve",setup:e.drawCubic,sname:"drawCubic",draw:e.drawCurve,dname:"drawCurve"}),a.createElement("p",null,"What else can we do with B\xE9zier curves? Quite a lot, actually. The rest of this article covers a multitude of possible operations and algorithms that we can apply, and the tasks they achieve."),a.createElement("div",{className:"howtocode"},a.createElement("h3",{id:"how-to-implement-the-weighted-basis-function"},"How to implement the weighted basis function"),a.createElement("p",null,"Given that we already know how to implement basis function, adding in the control points is remarkably easy:"),a.createElement("pre",null,"function Bezier(n,t,w[]):\n sum = 0\n for(k=0; k