From 4ad072c7a25e3c259e5c1533481434a10ed1a5d1 Mon Sep 17 00:00:00 2001 From: Pomax Date: Sun, 9 Dec 2018 16:31:16 -0800 Subject: [PATCH] Add a curvature section (#159) * curvature and radius of curvature --- article.js | 2 +- changelog.js | 4 + .../sections/curvature/content.en-GB.md | 71 ++++++++ components/sections/curvature/handler.js | 70 ++++++++ components/sections/index.js | 1 + en-GB/article.js | 2 +- ...0f65b17aa4cafabdd89042ac8093106da82a42.svg | 1 + ...2aa77dcf141036503403477f22d8094efbdb1f.svg | 1 + ...b701ba4ab6ffbefb22d0c7afd376e149ea4f93.svg | 1 + ...1bbdd484aff99f57a789cbe91a08a4727b0b21.svg | 1 + ...a3b68ea4bd64cec99c8b9135281bea8f78cb02.svg | 1 + ...90b2c54f821a5ae611a2b8f3d313d16cea3692.svg | 1 + ...580f7ceeef59a351181fedefa782c8284d1bb1.svg | 1 + ...76ea1d5c703043138c33d7bedcfa117866418f.svg | 1 + ...248116e7660d1d5b94932a19fc9530607d04d9.svg | 1 + ...c934a93607cc0d45c9acff9cec2b3008477c6a.svg | 1 + ...42c1b2f9233ed88db5e70b8503f307be11fb09.svg | 1 + ...60c0ffe4aefc0f5f4cc08477cc95f79437a8eb.svg | 1 + index.html | 1 - ja-JP/article.js | 2 +- lib/site/handlers.js | 73 +++++++++ package-lock.json | 155 +++++++++++++++++- package.json | 5 +- tools/copy-default-locale.js | 1 - zh-CN/article.js | 2 +- 25 files changed, 390 insertions(+), 11 deletions(-) create mode 100644 components/sections/curvature/content.en-GB.md create mode 100644 components/sections/curvature/handler.js create mode 100644 images/latex/030f65b17aa4cafabdd89042ac8093106da82a42.svg create mode 100644 images/latex/2b2aa77dcf141036503403477f22d8094efbdb1f.svg create mode 100644 images/latex/3db701ba4ab6ffbefb22d0c7afd376e149ea4f93.svg create mode 100644 images/latex/5a1bbdd484aff99f57a789cbe91a08a4727b0b21.svg create mode 100644 images/latex/73a3b68ea4bd64cec99c8b9135281bea8f78cb02.svg create mode 100644 images/latex/7890b2c54f821a5ae611a2b8f3d313d16cea3692.svg create mode 100644 images/latex/93580f7ceeef59a351181fedefa782c8284d1bb1.svg create mode 100644 images/latex/9576ea1d5c703043138c33d7bedcfa117866418f.svg create mode 100644 images/latex/a7248116e7660d1d5b94932a19fc9530607d04d9.svg create mode 100644 images/latex/d1c934a93607cc0d45c9acff9cec2b3008477c6a.svg create mode 100644 images/latex/dc42c1b2f9233ed88db5e70b8503f307be11fb09.svg create mode 100644 images/latex/f760c0ffe4aefc0f5f4cc08477cc95f79437a8eb.svg diff --git a/article.js b/article.js index 265cdf07..a9aed023 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()})(window,function(){var e=Math.log,n=Math.floor,t=Math.tan,o=Math.round,w=Math.max,d=Math.min,l=Math.PI,r=Math.pow,u=Math.sqrt,h=Math.atan2,m=Math.acos,s=Math.sin,g=Math.cos,_=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.d=function(e,n,a){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:a})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(t.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var i in e)t.d(a,i,function(t){return e[t]}.bind(null,i));return 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=136)}([function(e,t,n){"use strict";var a=n(1),i=n(11),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";n.r(t),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=H.test(r))break;if(n)for(r in a=e.attributes={},t)t.hasOwnProperty(r)&&(a[H.test(r)?r.replace(/([A-Z0-9])/,"-$1").toLowerCase():r]=t[r])}}function s(e,t,n){var a=t&&t._preactCompatRendered&&t._preactCompatRendered.base;a&&a.parentNode!==t&&(a=null),!a&&t&&(a=t.firstElementChild);for(var r=t.childNodes.length;r--;)t.childNodes[r]!==a&&t.removeChild(t.childNodes[r]);var o=Object(V.e)(e,t,a);return t&&(t._preactCompatRendered=o&&(o._component||{base:o})),"function"==typeof n&&n(),o&&o._component||o}function l(e,t,n,a){var i=Object(V.c)(J,{context:e.context},t),r=s(i,n),o=r._component||r.base;return a&&a.call(o,r),o}function d(e){var t=e._preactCompatRendered&&e._preactCompatRendered.base;return!!(t&&t.parentNode===e)&&(Object(V.e)(Object(V.c)(a),e,t),!0)}function c(e){return g.bind(null,e)}function h(e,t){for(var n=t||0,a;ne.map(e=>e[n]))}},function(e){e.exports=function(t){if(t.length===t[0].length){var n=0,a=0,r=0,o=t.length,s=0,l=[],d=[];for(n=0;ne?-a(-e,1/3):a(e,1/3)},c=l,y=2*c,p=c/2,v=Number.MAX_SAFE_INTEGER||9007199254740991,b=Number.MIN_SAFE_INTEGER||-9007199254740991,x={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),f(a)},between:function(e,t,n){return t<=e&&e<=n||x.approximately(e,t)||x.approximately(e,n)},approximately:function(e,t,n){return o(e-t)<=(n||1e-6)},length:function(e){var n=.5,a=0,r=x.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=-d(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=x.align(e,n),l=function(e){return 0<=e&&1>=e};if(2==o){var h=s[0].y,u=s[1].y,g=s[2].y,v=h-2*u+g;if(0!==v){var _=-f(u*u-h*g),E=-h+u,k=-(_+E)/v,C=-(-_+E)/v;return[k,C].filter(l)}return u!==g&&0===v?[(2*u-g)/(2*u-2*g)].filter(l):[]}var S=s[0].y,T=s[1].y,z=s[2].y,B=s[3].y,v=-S+3*T-3*z+B,h=3*S-6*T+3*z,u=-3*S+3*T,g=S;if(x.approximately(v,0)){if(x.approximately(h,0))return x.approximately(u,0)?[]:[-g/u].filter(l);var L=f(u*u-4*h*g),N=2*h;return[(L-u)/N,(-u-L)/N].filter(l)}h/=v,u/=v,g/=v;var s=(3*u-h*h)/3,P=s/3,L=(2*h*h*h-9*h*u+27*g)/27,I=L/2,A=I*I+P*P*P,j,k,O,D,M;if(0>A){var V=-s/3,F=f(V*V*V),r=-L/(2*F),t=-1>r?-1:1I?w(-I):-w(I),O=2*j-h/3,D=-j-h/3,[O,D].filter(l);var X=f(A);return j=w(-I+X),k=w(I+X),[j-k-h/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=-f(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=x.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(x.approximately(s,0)){if(!x.approximately(l,0)){var h=-c/l;if(0<=h&&1>=h)return[h]}return[]}var t=u(l*l-4*s*c),o=2*s;return x.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.sizez||z>m)&&(r+=y),r>m&&(B=m,m=r,r=B)):mthis.order){var r=n*n,s=e*e,l=0,h,u,m;2===this.order?(t=[t[0],t[1],t[2],o],h=r,u=2*(n*e),m=s):3===this.order&&(h=r*n,u=3*(r*e),m=3*(n*s),l=e*s);var g={x:h*t[0].x+u*t[1].x+m*t[2].x+l*t[3].x,y:h*t[0].y+u*t[1].y+m*t[2].y+l*t[3].y};return this._3d&&(g.z=h*t[0].z+u*t[1].z+m*t[2].z+l*t[3].z),g}for(var f=JSON.parse(JSON.stringify(this.points));1=e}),n=n.concat(t[e].sort(f.numberSort))}.bind(this)),n=n.sort(f.numberSort).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]=f.getminmax(this,n,e[n])}.bind(this)),t},overlaps:function(e){var t=this.bbox(),n=e.bbox();return f.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 y(o)]}var s=this.reduce();return s.map(function(t){return t.scale(e)})},simple:function(){if(3===this.order){var e=f.angle(this.points[0],this.points[3],this.points[1]),n=f.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=f.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,s=a?a(1):e,l=[this.offset(0,10),this.offset(1,10)],c=f.lli4(l[0],l[0].c,l[1],l[1].c);if(!c)throw new Error("cannot scale this curve. Try reducing it first.");var o=this.points,u=[];return([0,1].forEach(function(e){var t=u[e*n]=f.copy(o[e*n]);t.x+=(e?s:r)*l[e].n.x,t.y+=(e?s:r)*l[e].n.y}.bind(this)),!a)?([0,1].forEach(function(e){if(2!==this.order||!e){var t=u[e*n],a=this.derivative(e),i={x:t.x+a.x,y:t.y+a.y};u[e+1]=f.lli4(t,i,c,o[e+1])}}.bind(this)),new y(u)):([0,1].forEach(function(r){if(2!==this.order||!r){var t=o[r+1],s={x:t.x-c.x,y:t.y-c.y},l=a?a((r+1)/n):e;a&&!i&&(l=-l);var d=h(s.x*s.x+s.y*s.y);s.x/=d,s.y/=d,u[r+1]={x:t.x+l*s.x,y:t.y+l*s.y}}}.bind(this)),new y(u))},outline:function(e,t,n,a){function i(t,n,e,a,i){return function(r){var o=n-t;return f.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,h=this.length(),u;r.forEach(function(r){_=r.length(),"undefined"!=typeof n&&"undefined"!=typeof a?(s.push(r.scale(i(e,n,h,d,_))),l.push(r.scale(i(-t,-a,h,d,_)))):(s.push(r.scale(e)),l.push(r.scale(-t))),d+=_}),l=l.map(function(e){return u=e.points,e.points=u[3]?[u[3],u[2],u[1],u[0]]:[u[2],u[1],u[0]],e}).reverse();var m=s[0].points[0],g=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=f.makeline(w,m),b=f.makeline(g,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;oi++);if(100<=i)break;y=y?y:w,t.push(y),n=h}while(1>a);return t}},e.exports=y})()},function(e,t,n){var a=n(123),i=function(){this.data={},this.data=a};i.prototype={getSectionLocale:function(e){return this.data[e].locale},getContent:function(e,t){return this.data[e].getContent(t)},getTitle:function(e){return this.data[e].title}},e.exports=i},function(e,t,n){"use strict";var a=n(1),i=a.createClass({displayName:"Footer",render:function(){return a.createElement("div",null,a.createElement("footer",{className:"copyright"},"This article is ","\xA9 2011-2018"," to me, Mike \"Pomax\" Kamermans, but the text, code, and images are ",a.createElement("a",{href:"https://github.com/Pomax/bezierinfo/blob/gh-pages/LICENSE.md"},"almost no rights reserved"),". Go do something cool with it!"),a.createElement("footer",{className:"print copyright"},"Content printed from https://pomax.github.io/bezierinfo, ","\xA9 2011-2018"," Mike \"Pomax\" Kamermans."))}});e.exports=i},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;tn;n++)this.points.push({x:this.width/2+t*g(n/6*e),y:this.height/2+t*s(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*l,t=0;te.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),T=t(h.y-S.y,h.x-S.x),m=t(u.y-S.y,u.x-S.x),z;return rT||T>m)&&(r+=a),r>m&&(z=m,m=r,r=z)):me.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(e,i){var o=e.offsetX-i.w/2,s=e.offsetY-i.h/2;if(!(o>i.w/2)){var d=h(s,o);0>d&&(d=2*l+d);var c=i.curve.points,u=i.r,r=4*t(d/4)/3;c[1]={x:i.w/2+u,y:i.w/2+u*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(25),i=n(0);e.exports=i("circles_cubic",a)},function(e){"use strict";var t=s,n=g;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,s=h(o,i),l=a.curve.points,d=a.r,r=(n(s)-1)/t(s);l[1]={x:a.w/2+d*(n(s)-r*t(s)),y:a.w/2+d*(t(s)+r*n(s))},l[2]={x:a.w/2+a.r*n(s),y:a.w/2+a.r*t(s)},a.setCurve(new a.Bezier(l)),a.angle=s}}},function(e,t,n){"use strict";var a=n(27),i=n(0);e.exports=i("circles",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(29),i=n(0),r=n(3);e.exports=r(i("graduatedoffset",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);var n=t.reduce();n.forEach(function(t){e.setRandomColor(),e.drawCurve(t),e.drawCircle(t.points[0],1)});var a=n.slice(-1)[0];e.drawPoint(a.points[3]||a.points[2]),e.setColor("red");var i=t.offset(e.distance);i.forEach(function(t){e.drawPoint(t.points[0]),e.drawCurve(t)}),a=i.slice(-1)[0],e.drawPoint(a.points[3]||a.points[2]),e.setColor("blue"),i=t.offset(-e.distance),i.forEach(function(t){e.drawPoint(t.points[0]),e.drawCurve(t)}),a=i.slice(-1)[0],e.drawPoint(a.points[3]||a.points[2])}}},function(e,t,n){"use strict";var a=n(31),i=n(0),r=n(3);e.exports=r(i("offsetting",a))},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;sn;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(37),i=n(0);e.exports=i("polybezier",a)},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=u(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},m={x:r.x+(s.x-o.x)+e.distance*l,y:r.y+(s.y-o.y)+e.distance*d},p=e.utils.lli4(r,s,o,{x:(h.x+m.x)/2,y:(h.y+m.y)/2});e.setColor("blue"),e.drawCircle(p,3,i),e.drawLine(t[1],p,i),e.setColor("#666"),e.drawLine(p,h,i),e.drawLine(p,m,i),e.setFill("blue"),e.text("p0",h,{x:-20+i.x,y:i.y+2}),e.text("p4",m,{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(m,3,i),e.drawLine(o,m,i),e.drawLine(s,{x:s.x+(m.x-o.x)/5,y:s.y+(m.y-o.y)/5},i);var g=new e.Bezier(this.convert(h,r,o,s)),f=new e.Bezier(this.convert(r,o,s,m));e.setColor("lightgrey"),e.drawCurve(g,i),e.drawCurve(f,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(g,i),e.drawCurve(f,i),e.drawPoints(g.points,i),e.drawPoints(f.points,i),e.setColor("lightgrey"),e.drawLine(g.points[0],g.points[1],i),e.drawLine(g.points[2],f.points[1],i),e.drawLine(f.points[2],f.points[3],i)}}},function(e,t,n){"use strict";var a=n(39),i=n(0),r=n(3);e.exports=r(i("catmullmoulding",a))},function(e,t,n){"use strict";var a=n(0);e.exports=a("catmullconv")},function(e,t,n){function a(e,t){if(0===e)return 1;for(var n=y;e>=n.length;){for(var a=n.length,r=[1],o=1,s=a-1;ot.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;nr(e,t))}function p(e,t){t=t||e.length;for(var a=[],r=0;r{s[t]=e/l}),s},v.equidistant=function(e,t){return"0".repeat(t).split("").map((e,n)=>n/(t-1))},f.modes=["polygonal","equidistant"],e.exports=window.makeFit=f},function(e,t,n){"use strict";var a=n(42);e.exports={setup:function(e){this.api=e,this.reset()},reset:function(){if(this.points=[],this.curveset=!1,this.mode=0,this.api){var e=this.api;e.setCurve(!1),e.reset(),e.redraw()}},toggle:function(){this.api&&(this.customTimeValues=!1,this.mode=(this.mode+1)%a.modes.length,this.fitCurve(this.api),this.api.redraw())},draw:function(e,t){e.setPanelCount(1),e.reset(),e.setColor("lightgrey"),e.drawGrid(10,10),e.setColor("black"),!this.curveset&&2a||.95t.t||.95t.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=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(53),i=n(0);e.exports=i("intersections",a)},function(e){"use strict";e.exports={statics:{keyHandlingOptions:{propName:"steps",values:{38:1,40:-1},controller:function(e){1>e.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;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(d(s,1)),e.setColor("red"),e.drawLine(o,l),o=l;for(var c=n.length(),h=0,m=0,p,g,f;m=n?1:0;e.reset(),e.setColor("transparent"),e.setFill("rgba(150,150,255, 0.4)");for(var d=t/n,c=d/2,h,u,m;c=e});var l=s[0],t=n.get(l);e.drawLine({x:t.x,y:t.y},{x:t.x,y:i}),e.drawLine({x:t.x,y:t.y},{x:0,y:t.y}),e.text("y="+(0|t.y),{x:t.x/2,y:t.y-5}),e.text("x="+(0|t.x),{x:o+5,y:i-(i-t.y)/2}),e.text("t="+(0|100*l)/100,{x:o+15,y:t.y})}}}};e.exports=t},function(e,t,n){"use strict";var a=n(61),i=n(0);e.exports=i("yforx",a)},function(e){"use strict";e.exports={setup:function(e){var t=e.getDefaultCubic();e.setCurve(t),e.reset(),e._map_loaded=!1},draw:function(e,t){var n=this.unit,a={x:200,y:200};e.setSize(400,400),e.setPanelCount(2),e.reset(),e.drawSkeleton(t),e.drawCurve(t),e.offset.x+=400,e._map_loaded?e.image(e._map_image):setTimeout(function(){this.drawBase(e,t),this.draw(e,t)}.bind(this),100),e.drawLine({x:0,y:0},{x:0,y:400});var i=[{x:0,y:0},{x:0,y:n},{x:n,y:n},this.forwardTransform(t.points,n)],r=new e.Bezier(i);e.setColor("blue"),e.drawCurve(r,a),e.drawCircle(i[3],3,a)},forwardTransform:function(e,t){t=t||1;var n=e[0],a=e[1],i=e[2],r=e[3],o=-n.x+r.x-(-n.x+a.x)*(-n.y+r.y)/(-n.y+a.y),l=-n.x+i.x-(-n.x+a.x)*(-n.y+i.y)/(-n.y+a.y),d=t*o/l,c=t*(-n.y+r.y)/(-n.y+a.y),h=t-t*(-n.y+i.y)/(-n.y+a.y);return{x:d,y:c+h*o/l}},drawBase:function(e){e.reset();var t=this.unit=80,n={x:200,y:200};e.setSize(400,400),e.setColor("lightgrey");for(var a=0;a<400;a+=t/2)e.drawLine({x:a,y:0},{x:a,y:400});for(var i=0;i<400;i+=t/2)e.drawLine({x:0,y:i},{x:400,y:i});e.setColor("black"),e.drawLine({x:200,y:0},{x:200,y:400}),e.drawLine({x:0,y:200},{x:400,y:200}),e.setColor("green"),e.drawLine({x:-200,y:t},{x:200,y:t},n),e.setColor("black"),e.setFill("black"),e.drawCircle({x:0,y:0},4,n),e.text("(0,0)",{x:5+n.x,y:15+n.y}),e.drawCircle({x:0,y:t},4,n),e.text("(0,1)",{x:5+n.x,y:t+15+n.y}),e.drawCircle({x:t,y:t},4,n),e.text("(1,1)",{x:t+5+n.x,y:t+15+n.y}),e.setWeight(1.5),e.setColor("#FF0000"),e.setFill(e.getColor());var r=[],o=1,s=1;for(a=-10;1>=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(63),i=n(0);e.exports=i("canonical",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(65),i=n(0);e.exports=i("inflections",a)},function(e){"use strict";e.exports={setupQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},align:function(e,t){var n=t.p1.x,i=t.p1.y,r=-h(t.p2.y-i,t.p2.x-n),a=g,o=s;return e.map(function(e){return{x:(e.x-n)*a(r)-(e.y-i)*o(r),y:(e.x-n)*o(r)+(e.y-i)*a(r),a:r}})},transpose:function(e,t,n){var a=n.x,i=n.y,r=g,o=s,l=[e.x.min,e.y.min,e.x.max,e.y.max];return[{x:l[0],y:l[1]},{x:l[2],y:l[1]},{x:l[2],y:l[3]},{x:l[0],y:l[3]}].map(function(e){var n=e.x,s=e.y;return{x:n*r(t)-s*o(t)+a,y:n*o(t)+s*r(t)+i}})},draw:function(e,t){e.reset();var n=t.points,a={p1:n[0],p2:n[n.length-1]},i=this.align(n,a),r=-i[0].a,o=new e.Bezier(i),s=o.bbox(),l=this.transpose(s,r,n[0]);e.setColor("#00FF00"),e.drawLine(l[0],l[1]),e.drawLine(l[1],l[2]),e.drawLine(l[2],l[3]),e.drawLine(l[3],l[0]),e.setColor("black"),e.drawSkeleton(t),e.drawCurve(t)}}},function(e,t,n){"use strict";var a=n(67),i=n(0);e.exports=i("tightbounds",a)},function(e){"use strict";e.exports={setupQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},align:function(e,t){var n=t.p1.x,i=t.p1.y,r=-h(t.p2.y-i,t.p2.x-n),a=g,o=s;return e.map(function(e){return{x:(e.x-n)*a(r)-(e.y-i)*o(r),y:(e.x-n)*o(r)+(e.y-i)*a(r)}})},draw:function(e,t){e.setPanelCount(2),e.reset(),e.drawSkeleton(t),e.drawCurve(t);var n=t.points,a={p1:n[0],p2:n[n.length-1]},i=this.align(n,a),r=new e.Bezier(i),o=e.getPanelWidth(),s=e.getPanelHeight(),l={x:o,y:0};e.setColor("black"),e.drawLine({x:0,y:0},{x:0,y:s},l),l.x+=o/4,l.y+=s/2,e.setColor("grey"),e.drawLine({x:0,y:-s/2},{x:0,y:s/2},l),e.drawLine({x:-o/4,y:0},{x:o,y:0},l),e.setFill("grey"),e.setColor("black"),e.drawSkeleton(r,l),e.drawCurve(r,l)}}},function(e,t,n){"use strict";var a=n(69),i=n(0);e.exports=i("aligning",a)},function(e){"use strict";e.exports={setupQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},draw:function(e,n){e.reset(),e.setColor("#00FF00"),e.drawbbox(n.bbox()),e.setColor("black"),e.drawSkeleton(n),e.drawCurve(n),e.setColor("red"),n.extrema().values.forEach(function(a){e.drawCircle(n.get(a),3)})}}},function(e,t,n){"use strict";var a=n(71),i=n(0);e.exports=i("boundingbox",a)},function(e){"use strict";e.exports={setupQuadratic:function(e){var t=e.getDefaultQuadratic();t.points[2].x=210,e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},draw:function(e,t){e.setPanelCount(3),e.reset(),e.drawSkeleton(t),e.drawCurve(t);var n=t.order+1,a=t.points,i=e.getPanelWidth(),r=e.getPanelHeight(),o={x:i,y:0},s=JSON.parse(JSON.stringify(a)).map(function(e,a){return{x:i*a/n,y:e.x}});e.setColor("black"),e.drawLine({x:0,y:0},{x:0,y:r},o),e.drawAxes(20,"t",0,1,"x",0,i,o),o.x+=20;var l=new e.Bezier(s);e.drawCurve(l,o),e.setColor("red"),l.extrema().y.forEach(function(n){var t=l.get(n);e.drawCircle(t,3,o)}),o.x+=i-20;var d=JSON.parse(JSON.stringify(a)).map(function(e,a){return{x:i*a/n,y:e.y}});e.setColor("black"),e.drawLine({x:0,y:0},{x:0,y:r},o),e.drawAxes(20,"t",0,1,"y",0,i,o),o.x+=20;var c=new e.Bezier(d);e.drawCurve(c,o),e.setColor("red"),c.extrema().y.forEach(function(n){var t=c.get(n);e.drawCircle(t,3,o)})}}},function(e,t,n){"use strict";var a=n(73),i=n(0);e.exports=i("extremities",a)},function(e){"use strict";e.exports={setupQuadratic:function(e){var t=e.getDefaultQuadratic();t.points[2].x=210,e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},draw:function(e,t){e.setPanelCount(3),e.reset(),e.drawSkeleton(t),e.drawCurve(t);var n=t.order,a=t.points,i=e.getPanelWidth(),r=i-40,o=e.getPanelHeight(),s={x:i,y:0},l=JSON.parse(JSON.stringify(a)).map(function(e,a){return{x:r*a/n,y:e.x}});e.drawLine({x:0,y:0},{x:0,y:o},s),e.drawAxes(20,"t",0,1,"x",0,i,s),s.x+=20,e.drawCurve(new e.Bezier(l),s),s.x+=i-20;var d=JSON.parse(JSON.stringify(a)).map(function(e,a){return{x:r*a/n,y:e.y}});e.drawLine({x:0,y:0},{x:0,y:o},s),e.drawAxes(20,"t",0,1,"y",0,i,s),s.x+=20,e.drawCurve(new e.Bezier(d),s)}}},function(e,t,n){"use strict";var a=n(75),i=n(0);e.exports=i("components",a)},function(e){"use strict";function a(e){var t=u(e.x*e.x+e.y*e.y+e.z*e.z);return{x:e.x/t,y:e.y/t,z:e.z/t}}function t(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function n(e,t){return{x:t*e.x,y:t*e.y,z:t*e.z}}function i(e,t){return{x:e.x+t.x,y:e.y+t.y,z:e.z+t.z}}function r(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function s(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}function o(e,t,n){return{x:(1-e)*t.x+e*n.x,y:(1-e)*t.y+e*n.y,z:(1-e)*t.z+e*n.z}}var l=!0,d;e.exports={setup:function(e){d={x:2*e.getPanelWidth()/5,y:4*e.getPanelHeight()/5},e.setSize(1.25*e.getPanelWidth(),e.getPanelHeight())},drawCube:function(e){var t=function(t){return e.project(t,d)},n=[{x:0,y:0,z:0},{x:200,y:0,z:0},{x:200,y:200,z:0},{x:0,y:200,z:0},{x:0,y:0,z:200},{x:200,y:0,z:200},{x:200,y:200,z:200},{x:0,y:200,z:200}].map(function(e){return t(e)});e.setColor("grey"),e.drawLine(n[1],n[2]),e.drawLine(n[2],n[3]),e.drawLine(n[1],n[5]),e.drawLine(n[2],n[6]),e.drawLine(n[3],n[7]),e.drawLine(n[4],n[5]),e.drawLine(n[5],n[6]),e.drawLine(n[6],n[7]),e.drawLine(n[7],n[4]),e.setColor("blue"),e.drawLine(n[0],n[1]),e.setColor("red"),e.drawLine(n[3],n[0]),e.setColor("green"),e.drawLine(n[0],n[4])},drawCurve:function(e,t,n){var a=function(t){return e.project(t,d)},i=t.map(function(e){return a(e)});n&&(e.setColor("rgba(0,0,0,"+.2+")"),e.drawCurve({points:t.map(function(t){return e.projectXY(t,d)})}),e.drawCurve({points:t.map(function(t){return e.projectYZ(t,d)})}),e.drawCurve({points:t.map(function(t){return e.projectXZ(t,d)})})),e.setColor("#333"),e.drawLine(i[0],i[1]),e.drawCircle(i[1],3),e.drawCircle(i[2],3),e.drawLine(i[2],i[3]),e.setColor("black"),e.drawCircle(i[0],3),e.drawCircle(i[3],3);new e.Bezier(i);e.drawCurve({points:i})},getFrenetVectors:function(e,t,l){var d=t.get(e),o=l.get(e),c=l.derivative(e),h=a(i(o,c)),u=a(s(h,o)),r=a(s(u,o));return{o:d,dt:o,r:u,n:r}},lerpVectors:function(e,t,n){var a={};return["o","dt","r","n"].forEach(function(i){a[i]=o(e,t[i],n[i])}),a},generateRMF:function(e,a){var i=[],o=.05;i.push(this.getFrenetVectors(0,e,a));for(var l=0;1>=l;l+=o){var d=i.slice(-1)[0],c=l+o,h={o:e.get(c),dt:a.get(c)},u=r(h.o,d.o),m=t(u,u),p=r(d.r,n(u,2/m*t(u,d.r))),g=r(d.dt,n(u,2/m*t(u,d.dt))),f=r(h.dt,g),w=t(f,f);h.r=r(p,n(f,2/w*t(f,p))),h.n=s(h.r,h.dt),i.push(h)}return i},getRMF:function(e,n,a){this.rmf_LUT||(this.rmf_LUT=this.generateRMF(n,a));var r=this.rmf_LUT.length,o=e*r;if(o!=(0|o)){if(o|=0,o===r-1)return this.rmf_LUT[o-1];var s=o+1,l=o/r;return e=(e-l)/(s/r-l),this.lerpVectors(e,this.rmf_LUT[o],this.rmf_LUT[s])}return this.rmf_LUT[o]},drawVector:function(e,t,n,i,o,r,s){var l=function(t){return e.project(t,d)};n=a(n),n={x:t.x+i*n.x,y:t.y+i*n.y,z:t.z+i*n.z},e.setColor("rgba("+o+","+r+","+s+",1)"),e.drawLine(l(t),l(n))},drawFrenetVectors:function(e){e.reset();var n=function(t){return e.project(t,d)};this.drawCube(e);var a=[{x:120,y:0,z:0},{x:120,y:220,z:0},{x:30,y:0,z:30},{x:0,y:0,z:200}];this.drawCurve(e,a,l);var i=new e.Bezier(a),r=new e.Bezier(i.dpoints[0]),o=w(e.hover.x?e.hover.x/e.getPanelWidth():0,0),t=i.get(o);e.drawCircle(n(t),3);var s=this.getFrenetVectors(o,i,r);this.drawVector(e,t,s.dt,40,0,200,0),this.drawVector(e,t,s.r,40,0,0,200),this.drawVector(e,t,s.n,40,200,0,0)},drawRMFNormals:function(e){e.reset();var n=function(t){return e.project(t,d)};this.drawCube(e);var a=[{x:120,y:0,z:0},{x:120,y:220,z:0},{x:30,y:0,z:30},{x:0,y:0,z:200}];this.drawCurve(e,a,l);var i=new e.Bezier(a),r=new e.Bezier(i.dpoints[0]),o=w(e.hover.x?e.hover.x/e.getPanelWidth():0,0),t=i.get(o);e.drawCircle(n(t),3);var s=this.getRMF(o,i,r);this.drawVector(e,t,s.dt,40,0,200,0),this.drawVector(e,t,s.r,40,0,0,200),this.drawVector(e,t,s.n,40,200,0,0)}}},function(e,t,n){"use strict";var a=n(77),i=n(0);e.exports=i("pointvectors3d",a)},function(e){"use strict";e.exports={setupQuadratic:function(e){var t=e.getDefaultQuadratic();e.setCurve(t)},setupCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},draw:function(e,a){e.reset(),e.drawSkeleton(a);var r,o,s,l,d,c;for(r=0;10>=r;r++)o=r/10,s=a.get(o),l=a.derivative(o),c=u(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(79),i=n(0);e.exports=i("pointvectors",a)},function(e,t,n){"use strict";var a=n(0);e.exports=a("derivatives")},function(e,t,n){var a=n(5);e.exports=function(e,t){var n=[],i=a(t);return e.forEach((e,t)=>{n[t]=[],i.forEach((a,i)=>{n[t][i]=e.map((e,t)=>a[t]*e).reduce((e,t)=>e+t,0)})}),n}},function(e,t,n){"use strict";var a=n(6),r=n(82),o=n(5),i={statics:{keyHandlingOptions:{values:{38:function(e){e.setCurve(e.curve.raise()),e.redraw()},40:function(e){e.setCurve(i.lower(e)),e.redraw()}}}},lower:function(e){var t=e.curve,n=t.points,s=n.length,l=[],d;for(d=0;dr;r++)t.push({x:n/2+20*Math.random()+g(2*l*r/10)*(n/2-40),y:a/2+20*Math.random()+s(2*l*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)}}},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(d(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(88),i=n(0),r=n(3);e.exports=r(i("flattening",a))},function(e){"use strict";e.exports={setup:function(e){e.setCurve(new e.Bezier([{x:90,y:110},{x:25,y:40},{x:230,y:40},{x:150,y:240}]))},draw:function(e,n){if(e.reset(),e.drawSkeleton(n),e.drawCurve(n),e.hover){e.setColor("rgb(200,100,100)");for(var a=e.getPanelWidth(),r=e.hover.x/a,o=e.drawHull(n,r),s=4;8>=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(90),i=n(0);e.exports=i("decasteljau",a)},function(e,t,n){"use strict";var a=n(0);e.exports=a("matrix")},function(e){"use strict";e.exports={setupQuadratic:function(e){var t=new e.Bezier(70,155,20,110,100,75);e.setCurve(t)},setupCubic:function(e){var t=new e.Bezier(60,105,75,30,215,115,140,160);e.setCurve(t)},draw:function(e,n){e.reset(),e.drawSkeleton(n),e.drawCurve(n),e.setColor("lightgrey");var a=.05,i=n.get(-10-a),r,o;for(r=-10;r<=a;r+=a)o=n.get(r),e.drawLine(i,o),i=o;i=n.get(1);for(r=1+a;r<=10;r+=a)o=n.get(r),e.drawLine(i,o),i=o}}},function(e,t,n){"use strict";var a=n(93),i=n(0);e.exports=i("extended",a)},function(e){"use strict";e.exports={drawCubic:function(e){var t=e.getDefaultCubic();e.setCurve(t)},drawCurve:function(e,t){e.reset(),e.drawSkeleton(t),e.drawCurve(t)},drawFunction:function(e,t,n,a){e.setRandomColor(),e.drawFunction(a),e.setFill(e.getColor()),t&&e.text(t,n)},drawLerpBox:function(e,t,n,a){e.noColor(),e.setFill("rgba(0,0,100,0.2)");var i={x:a.x-5,y:n},r={x:a.x+5,y:t};e.drawRect(i,r),e.setColor("black")},drawLerpPoint:function(e,t,n,a,i){i.y=n+t*a,e.drawCircle(i,3),e.setFill("black"),e.text((0|1e4*t)/100+"%",{x:i.x+10,y:i.y+4}),e.noFill()},drawQuadraticLerp: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),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 a=e.getPanelWidth(),i=a-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<=a-20)for(this.drawLerpBox(e,a,20,s),l=0;15>=l;l++){var d=(s.x-20)/i,t=o[l]*r(1-d,15-l)*r(d,l);this.drawLerpPoint(e,t,20,i,s)}for(l=0;15>=l;l++){var c=!1,h=!1;0===l&&(c="first term",h={x:25,y:i}),15===l&&(c="last term",h={x:a-70,y:i}),this.drawFunction(e,c,h,function(e){return{x:20+e*i,y:20+i*o[l]*r(1-e,15-l)*r(e,l)}})}}}},function(e,t,n){"use strict";var a=n(95),i=n(0);e.exports=i("control",a)},function(e){e.exports=function(){}},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,l=i/2,d=r/2,c=l/2;e.reset(),e.setColor("black"),e.drawLine({x:0,y:l},{x:a,y:l}),e.drawLine({x:r,y:0},{x:r,y:i});for(var h={x:r,y:l},u=0,m;u<=e.step;u+=.1){m={x:d*g(u),y:c*s(u)},e.drawPoint(m,h);var f=u%1;(.05>f||.95=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&&sa)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;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=u(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;tn--||setTimeout(a,200))})(),a.disconnect()});a.observe(div,{childList:!0,subtree:!0}),comments=document.getElementById("comments"),comments.scrollIntoView()}else t()}}},function(e){e.exports=function(e){e=e.replace(/,/g," ").replace(/-/g," - ").replace(/-\s+/g,"-").replace(/([a-zA-Z])/g," $1 ");var t=e.replace(/([a-zA-Z])\s?/g,"|$1").split("|"),n=t.length,r=[],o=0,s=0,l=0,c=0,h=0,u=0,m=0,p=0,g="",f,w,v,b,_,E;for(f=1;fn&&(e=n),e},Xe=function(e){return 3<=e.length?Array.prototype.slice.call(e):e[0]},V=function(e){var t,n;for(e._clipped=!1,e._unclipped=e.slice(0),t=n=0;3>n;t=++n)3>t?((0>e[t]||255e[t]&&(e[t]=0),255e[t]&&(e[t]=0),1=e?12.92*e:1.055*Ee(e,1/2.4)-.055)},de=function(e){return e>E.t1?e*e*e:E.t2*(e-E.t0)},E={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},Ne=function(){var e,t,n,a,i,o,s,l;return a=Xe(arguments),n=a[0],t=a[1],e=a[2],i=qe(n,t,e),o=i[0],s=i[1],l=i[2],[116*s-16,500*(o-s),200*(s-l)]},Oe=function(e){return .04045>=(e/=255)?e/12.92:Ee((e+.055)/1.055,2.4)},Ue=function(e){return e>E.t3?Ee(e,1/3):e/E.t2+E.t0},qe=function(){var e,t,n,a,i,o,s;return a=Xe(arguments),n=a[0],t=a[1],e=a[2],n=Oe(n),t=Oe(t),e=Oe(e),i=Ue((.4124564*n+.3575761*t+.1804375*e)/E.Xn),o=Ue((.2126729*n+.7151522*t+.072175*e)/E.Yn),s=Ue((.0193339*n+.119192*t+.9503041*e)/E.Zn),[i,o,s]},M.lab=function(){return function(e,t,n){n.prototype=e.prototype;var a=new n,i=e.apply(a,t);return Object(i)===i?i:a}(v,f.call(arguments).concat(["lab"]),function(){})},L.lab=le,v.prototype.lab=function(){return Ne(this._rgb)},A=function(e){var t,n,a,i,r,s,l,d,o,h,u;return e=function(){var t,n,a;for(a=[],n=0,t=e.length;n=n;t=++n)a.push(r[t]+e*(s[t]-r[t]));return a}(),M.lab.apply(M,n)}):3===e.length?(h=function(){var t,n,a;for(a=[],n=0,t=e.length;n=n;t=++n)a.push((1-e)*(1-e)*r[t]+2*(1-e)*e*s[t]+e*e*l[t]);return a}(),M.lab.apply(M,n)}):4===e.length?(u=function(){var t,n,a;for(a=[],n=0,t=e.length;n=n;t=++n)a.push((1-e)*(1-e)*(1-e)*r[t]+3*(1-e)*(1-e)*e*s[t]+3*(1-e)*e*e*l[t]+e*e*e*d[t]);return a}(),M.lab.apply(M,n)}):5===e.length&&(n=A(e.slice(0,3)),a=A(e.slice(2,5)),t=function(e){return .5>e?n(2*e):a(2*(e-.5))}),t},M.bezier=function(e){var t;return t=A(e),t.scale=function(){return M.scale(t)},t},M.cubehelix=function(e,t,n,i,o){var s,d,a;return null==e&&(e=300),null==t&&(t=-1.5),null==n&&(n=1),null==i&&(i=1),null==o&&(o=[0,1]),s=0,"array"===Re(o)?d=o[1]-o[0]:(d=0,o=[o,o]),a=function(c){var u,m,p,f,w,y,v,x,_;return u=S*((e+120)/360+t*c),v=Ee(o[0]+d*c,i),y=0===s?n:n[0]+c*s,m=y*v*(1-v)/2,f=W(u),_=Fe(u),x=v+m*(-.14861*f+1.78277*_),w=v+m*(-.29227*f-.90649*_),p=v+m*(+1.97294*f),M(V([255*x,255*w,255*p]))},a.start=function(t){return null==t?e:(e=t,a)},a.rotations=function(e){return null==e?t:(t=e,a)},a.gamma=function(e){return null==e?i:(i=e,a)},a.hue=function(e){return null==e?n:(n=e,"array"===Re(n)?(s=n[1]-n[0],0===s&&(n=n[1])):s=0,a)},a.lightness=function(e){return null==e?o:("array"===Re(e)?(o=e,d=e[1]-e[0]):(o=[e,e],d=0),a)},a.scale=function(){return M.scale(a)},a.hue(n),a},M.random=function(){var e,t,n,a;for(t="0123456789abcdef",e="#",n=a=0;6>a;n=++a)e+=t.charAt(Q(16*Math.random()));return new v(e)},N=[],te=function(e,t,n,a){var i,r,s,l;for(null==n&&(n=.5),null==a&&(a="rgb"),"object"!==Re(e)&&(e=M(e)),"object"!==Re(t)&&(t=M(t)),(s=0,r=N.length);s=e[3]?"rgb":void 0}}),L.lrgb=L.rgb,ie=function(e,t,n,a){var i,r;return i=e._rgb,r=t._rgb,new v(Ge(Ee(i[0],2)*(1-n)+Ee(r[0],2)*n),Ge(Ee(i[1],2)*(1-n)+Ee(r[1],2)*n),Ge(Ee(i[2],2)*(1-n)+Ee(r[2],2)*n),a)},T=function(e){var t,n,a,i,r,s;for(n=1/e.length,s=[0,0,0,0],(i=0,a=e.length);in;)n+=360;for(;360<=n;)n-=360;w[m]=n}else w[m]/=s[m];return M(w,t).alpha(a/p)},Y=function(e){var t,n,i,o,s,l;if(e.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/))return(4===e.length||7===e.length)&&(e=e.substr(1)),3===e.length&&(e=e.split(""),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),l=parseInt(e,16),o=l>>16,i=255&l>>8,n=255&l,[o,i,n,1];if(e.match(/^#?([A-Fa-f0-9]{8})$/))return 9===e.length&&(e=e.substr(1)),l=parseInt(e,16),o=255&l>>24,i=255&l>>16,n=255&l>>8,t=Me(100*((255&l)/255))/100,[o,i,n,t];if(null!=L.css&&(s=L.css(e)))return s;throw"unknown color: "+e},Te=function(e,t){var n,i,s,l,d,c,h;return null==t&&(t="rgb"),d=e[0],s=e[1],i=e[2],n=e[3],d=o(d),s=o(s),i=o(i),h=d<<16|s<<8|i,c="000000"+h.toString(16),c=c.substr(c.length-6),l="0"+Me(255*n).toString(16),l=l.substr(l.length-2),"#"+function(){switch(t.toLowerCase()){case"rgba":return c+l;case"argb":return l+c;default:return c;}}()},L.hex=function(e){return Y(e)},M.hex=function(){return function(e,t,n){n.prototype=e.prototype;var a=new n,i=e.apply(a,t);return Object(i)===i?i:a}(v,f.call(arguments).concat(["hex"]),function(){})},v.prototype.hex=function(e){return null==e&&(e="rgb"),Te(this._rgb,e)},z.push({p:4,test:function(e){if(1===arguments.length&&"string"===Re(e))return"hex"}}),$=function(){var e,t,n,a,d,u,m,p,f,w,y,v,x,_;if(e=Xe(arguments),d=e[0],y=e[1],m=e[2],0===y)f=a=t=255*m;else{for(_=[0,0,0],n=[0,0,0],x=.5>m?m*(1+y):m+y-m*y,v=2*m-x,d/=360,_[0]=d+1/3,_[1]=d,_[2]=d-1/3,u=p=0;2>=p;u=++p)0>_[u]&&(_[u]+=1),1<_[u]&&(_[u]-=1),n[u]=1>6*_[u]?v+6*(x-v)*_[u]:1>2*_[u]?x:2>3*_[u]?v+6*((x-v)*(2/3-_[u])):v;w=[Me(255*n[0]),Me(255*n[1]),Me(255*n[2])],f=w[0],a=w[1],t=w[2]}return 3i?(ye-o)/(ye+o):(ye-o)/(2-ye-o),e===ye?a=(t-n)/(ye-o):t===ye?a=2+(n-e)/(ye-o):n===ye&&(a=4+(e-t)/(ye-o)),a*=60,0>a&&(a+=360),[a,u,i]},M.hsl=function(){return function(e,t,n){n.prototype=e.prototype;var a=new n,i=e.apply(a,t);return Object(i)===i?i:a}(v,f.call(arguments).concat(["hsl"]),function(){})},L.hsl=$,v.prototype.hsl=function(){return Be(this._rgb)},ee=function(){var e,n,a,o,l,d,c,u,m,w,y,x,_,E,k,C,S,T;return e=Xe(arguments),l=e[0],C=e[1],T=e[2],T*=255,(0===C?m=o=n=T:(360===l&&(l=0),360l&&(l+=360),l/=60,d=Q(l),a=l-d,c=T*(1-C),u=T*(1-C*a),S=T*(1-C*(1-a)),0===d?(w=[T,S,c],m=w[0],o=w[1],n=w[2]):1===d?(y=[u,T,c],m=y[0],o=y[1],n=y[2]):2===d?(x=[c,T,S],m=x[0],o=x[1],n=x[2]):3===d?(_=[c,u,T],m=_[0],o=_[1],n=_[2]):4===d?(E=[S,c,T],m=E[0],o=E[1],n=E[2]):5===d?(k=[T,c,u],m=k[0],o=k[1],n=k[2]):void 0),[m,o,n,3a&&(a+=360)),[a,c,u]},M.hsv=function(){return function(e,t,n){n.prototype=e.prototype;var a=new n,i=e.apply(a,t);return Object(i)===i?i:a}(v,f.call(arguments).concat(["hsv"]),function(){})},L.hsv=ee,v.prototype.hsv=function(){return Le(this._rgb)},xe=function(e){var t,n,a;return"number"===Re(e)&&0<=e&&16777215>=e?(a=e>>16,n=255&e>>8,t=255&e,[a,n,t,1]):(console.warn("unknown num color: "+e),[0,0,0,1])},Ae=function(){var e,t,n,a;return a=Xe(arguments),n=a[0],t=a[1],e=a[2],(n<<16)+(t<<8)+e},M.num=function(e){return new v(e,"num")},v.prototype.num=function(e){return null==e&&(e="rgb"),Ae(this._rgb,e)},L.num=xe,z.push({p:1,test:function(e){if(1===arguments.length&&"number"===Re(e)&&0<=e&&16777215>=e)return"num"}}),K=function(){var e,n,a,o,s,l,d,u,m,w,y,x,_,E,k,C,S,T,z,B;return a=Xe(arguments),u=a[0],s=a[1],n=a[2],s/=100,d=255*(d/100),e=255*s,(0===s?x=d=o=n:(360===u&&(u=0),360u&&(u+=360),u/=60,m=Q(u),l=u-m,w=n*(1-s),y=w+e*(1-l),z=w+e*l,B=w+e,0===m?(_=[B,z,w],x=_[0],d=_[1],o=_[2]):1===m?(E=[y,B,w],x=E[0],d=E[1],o=E[2]):2===m?(k=[w,B,z],x=k[0],d=k[1],o=k[2]):3===m?(C=[w,y,B],x=C[0],d=C[1],o=C[2]):4===m?(S=[z,w,B],x=S[0],d=S[1],o=S[2]):5===m?(T=[B,w,y],x=T[0],d=T[1],o=T[2]):void 0),[x,d,o,3o&&(o+=360)),[o,n,e]},M.hcg=function(){return function(e,t,n){n.prototype=e.prototype;var a=new n,i=e.apply(a,t);return Object(i)===i?i:a}(v,f.call(arguments).concat(["hcg"]),function(){})},L.hcg=K,v.prototype.hcg=function(){return Se(this._rgb)},R=function(e){var t,n,a,r,s,l,d,c;if(e=e.toLowerCase(),null!=M.colors&&M.colors[e])return Y(M.colors[e]);if(s=e.match(/rgb\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*\)/)){for(d=s.slice(1,4),r=l=0;2>=l;r=++l)d[r]=+d[r];d[3]=1}else if(s=e.match(/rgba\(\s*(\-?\d+),\s*(\-?\d+)\s*,\s*(\-?\d+)\s*,\s*([01]|[01]?\.\d+)\)/))for(d=s.slice(1,5),r=c=0;3>=c;r=++c)d[r]=+d[r];else if(s=e.match(/rgb\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/)){for(d=s.slice(1,4),r=t=0;2>=t;r=++t)d[r]=Me(2.55*d[r]);d[3]=1}else if(s=e.match(/rgba\(\s*(\-?\d+(?:\.\d+)?)%,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/)){for(d=s.slice(1,5),r=n=0;2>=n;r=++n)d[r]=Me(2.55*d[r]);d[3]=+d[3]}else(s=e.match(/hsl\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*\)/))?(a=s.slice(1,4),a[1]*=.01,a[2]*=.01,d=$(a),d[3]=1):(s=e.match(/hsla\(\s*(\-?\d+(?:\.\d+)?),\s*(\-?\d+(?:\.\d+)?)%\s*,\s*(\-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)/))&&(a=s.slice(1,4),a[1]*=.01,a[2]*=.01,d=$(a),d[3]=+s[4]);return d},Ce=function(e){var t;return(t=1>e[3]?"rgba":"rgb","rgb"===t)?t+"("+e.slice(0,3).map(Me).join(",")+")":"rgba"===t?t+"("+e.slice(0,3).map(Me).join(",")+","+e[3]+")":void 0},De=function(e){return Me(100*e)/100},J=function(e,t){var n;return n=1>t?"hsla":"hsl",e[0]=De(e[0]||0),e[1]=De(100*e[1])+"%",e[2]=De(100*e[2])+"%","hsla"===n&&(e[3]=t),n+"("+e.join(",")+")"},L.css=function(e){return R(e)},M.css=function(){return function(e,t,n){n.prototype=e.prototype;var a=new n,i=e.apply(a,t);return Object(i)===i?i:a}(v,f.call(arguments).concat(["css"]),function(){})},v.prototype.css=function(e){return(null==e&&(e="rgb"),"rgb"===e.slice(0,3))?Ce(this._rgb):"hsl"===e.slice(0,3)?J(this.hsl(),this.alpha()):void 0},L.named=function(e){return Y(He[e])},z.push({p:5,test:function(e){if(1===arguments.length&&null!=He[e])return"named"}}),v.prototype.name=function(e){var t,n;for(n in arguments.length&&(He[e]&&(this._rgb=Y(He[e])),this._rgb[3]=1,this),t=this.hex(),He)if(t===He[n])return n;return t},ce=function(){var e,t,n,a;return a=Xe(arguments),n=a[0],e=a[1],t=a[2],t*=b,[n,W(t)*e,Fe(t)*e]},he=function(){var e,t,n,i,o,s,d,u,m,p,f;return n=Xe(arguments),u=n[0],o=n[1],d=n[2],p=ce(u,o,d),e=p[0],t=p[1],i=p[2],f=le(e,t,i),m=f[0],s=f[1],i=f[2],[m,s,i,3o?1/(1-o):0,n=(1-l-o)*a,s=(1-i-o)*a,h=(1-t-o)*a,[n,s,h,o]},F=function(){var e,t,n,a,i,o,s,l,d;return(t=Xe(arguments),a=t[0],s=t[1],d=t[2],o=t[3],e=4=n;e=++n)a[e]*=255;return a},M.gl=function(){return function(e,t,n){n.prototype=e.prototype;var a=new n,i=e.apply(a,t);return Object(i)===i?i:a}(v,f.call(arguments).concat(["gl"]),function(){})},v.prototype.gl=function(){var e;return e=this._rgb,[e[0]/255,e[1]/255,e[2]/255,e[3]]},Ie=function(e,t,n){var a;return a=Xe(arguments),e=a[0],t=a[1],n=a[2],e=fe(e),t=fe(t),n=fe(n),.2126*e+.7152*t+.0722*n},fe=function(e){return e/=255,.03928>=e?e/12.92:Ee((e+.055)/1.055,2.4)},oe=function(e,t,n,a){var i,r;return i=e._rgb,r=t._rgb,new v(i[0]+n*(r[0]-i[0]),i[1]+n*(r[1]-i[1]),i[2]+n*(r[2]-i[2]),a)},N.push(["rgb",oe]),v.prototype.luminance=function(e,t){var n,a,i,r,o;return(null==t&&(t="rgb"),!arguments.length)?Ie(this._rgb):(r=this._rgb,0===e?r=[0,0,0,this._rgb[3]]:1===e?r=[255,255,255,this[3]]:(n=Ie(this._rgb),a=1e-7,i=20,o=function(n,r){var s,l;return l=n.interpolate(r,.5,t),s=l.luminance(),_(e-s)e?o(n,l):o(l,r)},r=n>e?o(M("black"),this).rgba():o(this,M("white")).rgba()),M(r).alpha(this.alpha()))},We=function(e){var t,n,a,i;return i=e/100,66>i?(a=255,n=-155.25485562709179-.44596950469579133*(n=i-2)+104.49216199393888*ge(n),t=20>i?0:-254.76935184120902+.8274096064007395*(t=i-10)+115.67994401066147*ge(t)):(a=351.97690566805693+.114206453784165*(a=i-55)-40.25366309332127*ge(a),n=325.4494125711974+.07943456536662342*(n=i-50)-28.0852963507957*ge(n),t=255),[a,n,t]},je=function(){var e,t,n,a,i,o,s,l,d;for(s=Xe(arguments),o=s[0],n=s[1],e=s[2],i=1e3,a=4e4,t=.4;a-i>t;)d=.5*(a+i),l=We(d),l[2]/l[0]>=e/o?a=d:i=d;return Me(d)},M.temperature=M.kelvin=function(){return function(e,t,n){n.prototype=e.prototype;var a=new n,i=e.apply(a,t);return Object(i)===i?i:a}(v,f.call(arguments).concat(["temperature"]),function(){})},L.temperature=L.kelvin=L.K=We,v.prototype.temperature=function(){return je(this._rgb)},v.prototype.kelvin=v.prototype.temperature,M.contrast=function(e,t){var n,i,r,o;return("string"===(r=Re(e))||"number"===r)&&(e=new v(e)),("string"===(o=Re(t))||"number"===o)&&(t=new v(t)),n=e.luminance(),i=t.luminance(),n>i?(n+.05)/(i+.05):(i+.05)/(n+.05)},M.distance=function(e,t,n){var r,o,s,l,c,h,m;for(o in null==n&&(n="lab"),("string"===(c=Re(e))||"number"===c)&&(e=new v(e)),("string"===(h=Re(t))||"number"===h)&&(t=new v(t)),s=e.get(n),l=t.get(n),m=0,s)r=(s[o]||0)-(l[o]||0),m+=r*r;return u(m)},M.deltaE=function(e,n,i,r){var o,s,l,d,c,h,u,m,p,g,w,y,_,E,k,S,T,z,B,N,A,j,q,O,D,M,V;for(null==i&&(i=1),null==r&&(r=1),("string"===(T=Re(e))||"number"===T)&&(e=new v(e)),("string"===(z=Re(n))||"number"===z)&&(n=new v(n)),B=e.lab(),o=B[0],l=B[1],c=B[2],N=n.lab(),s=N[0],d=N[1],h=N[2],u=Ge(l*l+c*c),m=Ge(d*d+h*h),q=16>o?.511:.040975*o/(1+.01765*o),A=.0638*u/(1+.0131*u)+.638,S=1e-6>u?0:180*I(c,l)/x;0>S;)S+=360;for(;360<=S;)S-=360;return O=164<=S&&345>=S?.56+P(.2*W(x*(S+168)/180)):.36+P(.4*W(x*(S+35)/180)),p=u*u*u*u,k=Ge(p/(p+1900)),j=A*(k*O+1-k),E=o-s,_=u-m,w=l-d,y=c-h,g=w*w+y*y-_*_,D=E/(i*q),M=_/(r*A),V=j,Ge(D*D+M*M+g/(V*V))},v.prototype.get=function(e){var t,n,a,r,o,s;return a=this,o=e.split("."),r=o[0],t=o[1],s=a[r](),t?(n=r.indexOf(t),-1t[1]&&(t[1]=0),M.lch(t).alpha(n.alpha())},v.prototype.desaturate=function(e){return null==e&&(e=1),this.saturate(-e)},v.prototype.premultiply=function(){var e,t;return t=this.rgb(),e=this.alpha(),M(t[0]*e,t[1]*e,t[2]*e,e)},j=function(e,t,n){if(!j[n])throw"unknown blend mode "+n;return j[n](e,t)},q=function(e){return function(t,n){var a,i;return a=M(n).rgb(),i=M(t).rgb(),M(e(a,i),"rgb")}},U=function(e){return function(t,n){var a,r,s;for(s=[],a=r=0;3>=r;a=++r)s[a]=e(t[a],n[a]);return s}},be=function(e){return e},ve=function(e,t){return e*t/255},X=function(e,t){return e>t?t:e},ue=function(e,t){return e>t?e:t},Ve=function(e,t){return 255*(1-(1-e/255)*(1-t/255))},_e=function(e,t){return 128>t?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255))},D=function(e,t){return 255*(1-(1-t/255)/(e/255))},H=function(e,t){return 255===e?255:(e=255*(t/255)/(1-e/255),255a.max&&(a.max=i),a.count+=1);return a.domain=[a.min,a.max],a.limits=function(e,t){return M.limits(a,e,t)},a},M.scale=function(e){var a,r,s,t,l,i,h,u,m,o,g,p,y,v,c,b,x,E,C,k,S,T,z;return o="rgb",g=M("#ccc"),c=0,i=!1,l=[0,1],v=[],y=[0,0],a=!1,s=[],p=!1,m=0,u=1,t=!1,r={},b=!0,h=1,T=function(e){var t,n,a,i,r,l;if(null==e&&(e=["#fff","#000"]),null!=e&&"string"===Re(e)&&null!=M.brewer&&(e=M.brewer[e]||M.brewer[e.toLowerCase()]||e),"array"===Re(e)){for(e=e.slice(0),t=a=0,i=e.length-1;0<=i?a<=i:a>=i;t=0<=i?++a:--a)n=e[t],"string"===Re(n)&&(e[t]=M(n));for(v.length=0,t=l=0,r=e.length-1;0<=r?l<=r:l>=r;t=0<=r?++l:--l)v.push(t/(e.length-1))}return S(),s=e},C=function(e){var t,r;if(null!=a){for(r=a.length-1,t=0;t=a[t];)t++;return t-1}return 0},z=function(e){return e},x=function(e){var t,r,o,s,l;return l=e,2=B;_=0<=B?++S:--S){if(T=v[_],L<=T){x=s[_];break}if(L>=T&&_===v.length-1){x=s[_];break}if(L>T&&L=h;t=0<=h?++p:--p)v.push(t/(a-1));return l=[m,u],E},E.mode=function(e){return arguments.length?(o=e,S(),E):o},E.range=function(e,t){return T(e,t),E},E.out=function(e){return p=e,E},E.spread=function(e){return arguments.length?(c=e,E):c},E.correctLightness=function(e){return null==e&&(e=!0),t=e,S(),z=t?function(e){var n,a,i,r,o,s,l,d,c;for(n=k(0,!0).lab()[0],a=k(1,!0).lab()[0],l=n>a,i=k(e,!0).lab()[0],o=n+(a-n)*e,r=i-o,d=0,c=1,s=20;.01<_(r)&&0r?(d=e,e+=.5*(c-e)):(c=e,e+=.5*(d-e)),i=k(e,!0).lab()[0],r=i-o})();return e}:function(e){return e},E},E.padding=function(e){return null==e?y:("number"===Re(e)&&(e=[e,e]),y=e,E)},E.colors=function(t,n){var r,o,d,c,h,u,m,p;if(2>arguments.length&&(n="hex"),h=[],0===arguments.length)h=s.slice(0);else if(1===t)h=[E(.5)];else if(1t;0<=t?e++:e--)u.push(e);return u}.apply(this).map(function(e){return E(o+e/(t-1)*r)});else{if(e=[],m=[],a&&2c;d=1<=c?++p:--p)m.push(.5*(a[d-1]+a[d]));else m=l;h=m.map(function(e){return E(e)})}return M[n]&&(h=h.map(function(e){return e[n]()})),h},E.cache=function(e){return null==e?b:(b=e,E)},E.gamma=function(e){return null==e?h:(h=e,E)},E},null==M.scales&&(M.scales={}),M.scales.cool=function(){return M.scale([M.hsl(180,1,.9),M.hsl(250,.7,.4)])},M.scales.hot=function(){return M.scale(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")},M.analyze=function(e,t,n){var a,i,s,l,d,c,h;if(d={min:p,max:-1*p,sum:0,values:[],count:0},null==n&&(n=function(){return!0}),a=function(e){null==e||isNaN(e)||(d.values.push(e),d.sum+=e,ed.max&&(d.max=e),d.count+=1)},h=function(e,i){if(n(e,i))return null!=t&&"function"===Re(t)?a(t(e)):null!=t&&"string"===Re(t)||"number"===Re(t)?a(e[t]):a(e)},"array"===Re(e))for(l=0,s=e.length;l=U;B=1<=U?++W:--W)I.push(q+B/a*(ye-q));I.push(ye)}else if("l"===t.substr(0,1)){if(0>=q)throw"Logarithmic scales are only possible for values > 0";for(O=r*ge(q),A=r*ge(ye),I.push(q),(B=ve=1,K=a-1);1<=K?ve<=K:ve>=K;B=1<=K?++ve:--ve)I.push(Ee(10,O+B/a*(A-O)));I.push(ye)}else if("q"===t.substr(0,1)){for(I.push(q),B=s=1,te=a-1;1<=te?s<=te:s>=te;B=1<=te?++s:--s)R=(we.length-1)*B/a,X=Q(R),X===R?I.push(we[X]):(H=R-X,I.push(we[X]*(1-H)+we[X+1]*H));I.push(ye)}else if("k"===t.substr(0,1)){for(V=we.length,E=Array(V),T=Array(a),ce=!0,F=0,C=null,C=[],C.push(q),(B=l=1,ne=a-1);1<=ne?l<=ne:l>=ne;B=1<=ne?++l:--l)C.push(q+B/a*(ye-q));for(C.push(ye);ce;){for(L=d=0,ie=a-1;0<=ie?d<=ie:d>=ie;L=0<=ie?++d:--d)T[L]=0;for(B=c=0,re=V-1;0<=re?c<=re:c>=re;B=0<=re?++c:--c){for(fe=we[B],D=p,(L=h=0,oe=a-1);0<=oe?h<=oe:h>=oe;L=0<=oe?++h:--h)z=P(C[L]-fe),z=se;L=0<=se?++u:--u)G[L]=null;for(B=m=0,le=V-1;0<=le?m<=le:m>=le;B=0<=le?++m:--m)S=E[B],null===G[S]?G[S]=we[B]:G[S]+=we[B];for(L=g=0,de=a-1;0<=de?g<=de:g>=de;L=0<=de?++g:--g)G[L]*=1/T[L];for(ce=!1,L=f=0,Y=a-1;0<=Y?f<=Y:f>=Y;L=0<=Y?++f:--f)if(G[L]!==C[B]){ce=!0;break}C=G,F++,200=Z;L=0<=Z?++y:--y)N[L]=[];for(B=b=0,J=V-1;0<=J?b<=J:b>=J;B=0<=J?++b:--b)S=E[B],N[S].push(we[B]);for(ue=[],L=x=0,$=a-1;0<=$?x<=$:x>=$;L=0<=$?++x:--x)ue.push(N[L][0]),ue.push(N[L][N[L].length-1]);for(ue=ue.sort(function(e,t){return e-t}),I.push(ue[0]),(B=_=1,ee=ue.length-1);_<=ee;B=_+=2)pe=ue[B],isNaN(pe)||-1!==I.indexOf(pe)||I.push(pe)}return I},Z=function(e,t,n){var a,o,l,d;return a=Xe(arguments),e=a[0],t=a[1],n=a[2],isNaN(e)&&(e=0),e/=360,e<1/3?(o=(1-t)/3,d=(1+t*W(S*e)/W(k-S*e))/3,l=1-(o+d)):e<2/3?(e-=1/3,d=(1-t)/3,l=(1+t*W(S*e)/W(k-S*e))/3,o=1-(d+l)):(e-=2/3,l=(1-t)/3,o=(1+t*W(S*e)/W(k-S*e))/3,d=1-(l+o)),d=pe(3*(n*d)),l=pe(3*(n*l)),o=pe(3*(n*o)),[255*d,255*l,255*o,3t&&(n=S-n),n/=S),[360*n,f,a]},M.hsi=function(){return function(e,t,n){n.prototype=e.prototype;var a=new n,i=e.apply(a,t);return Object(i)===i?i:a}(v,f.call(arguments).concat(["hsi"]),function(){})},L.hsi=Z,v.prototype.hsi=function(){return ze(this._rgb)},ne=function(e,t,n,a){var i,r,o,s,l,d,c,h,u,p,g,f,w;return"hsl"===a?(f=e.hsl(),w=t.hsl()):"hsv"===a?(f=e.hsv(),w=t.hsv()):"hcg"===a?(f=e.hcg(),w=t.hcg()):"hsi"===a?(f=e.hsi(),w=t.hsi()):("lch"==a||"hcl"==a)&&(a="hcl",f=e.hcl(),w=t.hcl()),"h"===a.substr(0,1)&&(o=f[0],p=f[1],d=f[2],s=w[0],g=w[1],c=w[2]),isNaN(o)||isNaN(s)?isNaN(o)?isNaN(s)?r=y:(r=s,(1===d||0===d)&&"hsv"!==a&&(u=g)):(r=o,(1===c||0===c)&&"hsv"!==a&&(u=p)):(i=s>o&&180_(t.mx-e.x)&&10>_(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>_(a-n.x)&&10>_(i-n.y)&&(t=t||!0)}),this.cvs.style.cursor=t?"pointer":"default",this.hover={x:e.offsetX,y:e.offsetY},!this.movingPoint)this.mx=e.offsetX,this.my=e.offsetY;else if(this.ox=e.offsetX-this.mx,this.oy=e.offsetY-this.my,this.mp.x=w(0,d(this.defaultWidth,this.cx+this.ox)),this.mp.y=w(0,d(this.defaultHeight,this.cy+this.oy)),this.curve.forEach){for(var n=0,a,r;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*l),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"]=o),e.exports=o},function(){},function(){},function(a,i,c){var p=function(v){var x=Math.ceil;v=v||c(120);var b=v.window,E=v.document,C=new function(){function e(e,a,i,r,l){function d(n,d){d=d||(d=o(a,n))&&(d.get?d:d.value),"string"==typeof d&&"#"===d[0]&&(d=e[d.substring(1)]||d);var h="function"==typeof d,u=d,m=l||h&&!d.base?d&&d.get?n in e:e[n]:null,p;l&&m||(h&&m&&(d.base=m),h&&!1!==r&&(p=n.match(/^([gs]et|is)(([A-Z])(.*))$/))&&(c[p[3].toLowerCase()+p[4]]=p[2]),(!u||h||!u.get||"function"!=typeof u.get||!t.isPlainObject(u))&&(u={value:u,writable:!0}),(o(e,n)||{configurable:!0}).configurable&&(u.configurable=!0,u.enumerable=null==i?!p:i),s(e,n,u))}var c={};if(a){for(var h in a)a.hasOwnProperty(h)&&!n.test(h)&&d(h);for(var h in c){var u=c[h],m=e["set"+u],p=e["get"+u]||m&&e["is"+u];p&&(!0===r||0===p.length)&&d(h,{get:p,set:m})}}return e}function t(){for(var e=0,t=arguments.length,n;e=a)return o&&(e.__index=s+1),d&&n&&n.clone?d.clone():d;if(d=C.create(r),o&&(d.__read=!0),d=d.initialize.apply(d,0e.length&&(n=e.length);for(var s=0;sthis.precision?o(e*this.multiplier)/this.multiplier:e},pair:function(e,t,n){return this.number(e)+(n||",")+this.number(t)},point:function(e,t){return this.number(e.x)+(t||",")+this.number(e.y)},size:function(e,t){return this.number(e.width)+(t||",")+this.number(e.height)},rectangle:function(e,t){return this.point(e,t)+(t||",")+this.size(e,t)}});z.instance=new z;var B=new function(){function l(e,t,n){return en?n:e}function t(e,t,n){function a(e){var t=134217729*e,n=e-t+t;return[n,e-n]}var r=t*t-e*n;if(3*i(r)e||1e8=-p&&e<=p},clamp:l,integrate:function(e,t,a,r){for(var n=s[r-2],o=d[r-2],l=.5*(a-t),c=l+t,h=0,u=1&r?o[h++]*e(c):0,m;h>1;)m=l*n[h],u+=o[h++]*(e(c+m)+e(c-m));return l*u},findRoot:function(e,t,r,o,s,d,n){for(var c=0;c=s?.5*(o+s):m)}return l(r,o,s)},solveQuadratic:function(e,r,o,s,d,u){var m=1/0,w;if(i(e)=-g){var f=0>y?0:h(y),x=r+(0>r?-f:f);0===x?(w=o/e,m=-w):(w=x/e,m=o/x)}}var _=0,E=null==d,k=d-p,C=u+p;return isFinite(w)&&(E||w>k&&wk&&mN?-1:1,s=-z/e,P=0r*f);i(e)*f*f>i(y/f)&&(T=-y/f,S=(T-u)/f)}}var A=B.solveQuadratic(e,S,T,v,_,E),j=null==_;return isFinite(f)&&(0===A||0_-p&&fn?-1:1e?-1:1)&&0<=this.y*(2c&&(l=u.x,c=-c),0>h&&(d=u.y,h=-h)}else{var m=I.read(arguments);c=m.width,h=m.height}this._set(l,d,c,h),r=arguments.__index;var p=arguments.__filtered;p&&(this.__filtered=p)}return this.__read&&(this.__read=r),this},set:"#initialize",_set:function(e,t,n,a){return this.x=e,this.y=t,this.width=n,this.height=a,this},clone:function(){return new O(this.x,this.y,this.width,this.height)},equals:function(e){var t=C.isPlainValue(e)?O.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=z.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:N;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?I:A;return new t(this.width,this.height,this,"setSize")},_fw:1,_fh:1,setSize:function(){var e=I.read(arguments),t=this._sx,n=this._sy,a=e.width,i=e.height;t&&(this.x+=(this.width-a)*t),n&&(this.y+=(this.height-i)*n),this.width=a,this.height=i,this._fw=this._fh=1},getLeft:function(){return this.x},setLeft:function(e){if(!this._fw){var t=e-this.x;this.width-=.5===this._sx?2*t:t}this.x=e,this._sx=this._fw=0},getTop:function(){return this.y},setTop:function(e){if(!this._fh){var t=e-this.y;this.height-=.5===this._sy?2*t:t}this.y=e,this._sy=this._fh=0},getRight:function(){return this.x+this.width},setRight:function(e){if(!this._fw){var t=e-this.x;this.width=.5===this._sx?2*t:t}this.x=e-this.width,this._sx=1,this._fw=0},getBottom:function(){return this.y+this.height},setBottom:function(e){if(!this._fh){var t=e-this.y;this.height=.5===this._sy?2*t:t}this.y=e-this.height,this._sy=1,this._fh=0},getCenterX:function(){return this.x+this.width/2},setCenterX:function(e){this._fw||.5===this._sx?this.x=e-this.width/2:(this._sx&&(this.x+=2*(e-this.x)*this._sx),this.width=2*(e-this.x)),this._sx=.5,this._fw=0},getCenterY:function(){return this.y+this.height/2},setCenterY:function(e){this._fh||.5===this._sy?this.y=e-this.height/2:(this._sy&&(this.y+=2*(e-this.y)*this._sy),this.height=2*(e-this.y)),this._sy=.5,this._fh=0},getCenter:function(e){var t=e?P:N;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(O.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=O.read(arguments),t=C.read(arguments)||0;return e.x+e.width>this.x-t&&e.y+e.height>this.y-t&&e.xarguments.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._c+this._tx,a*this._b+i*this._d+this._ty,n)},_transformCoordinates:function(e,t,n){for(var a=0;a<2*n;a+=2){var r=e[a],o=e[a+1];t[a]=r*this._a+o*this._c+this._tx,t[a+1]=r*this._b+o*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 O),t._set(r[0],r[1],o[0]-r[0],o[1]-r[1],n)},inverseTransform:function(){return this._inverseTransform(P.read(arguments))},_inverseTransform:function(e,t,n){var i=this._a,a=this._b,r=this._c,o=this._d,s=this._tx,l=this._ty,d=i*o-a*r,c=null;if(d&&!isNaN(d)&&isFinite(s)&&isFinite(l)){var h=e.x-this._tx,u=e.y-this._ty;t||(t=new P),c=t._set((h*o-u*r)/d,(u*i-h*a)/d,n)}return c},decompose:function(){var e=this._a,t=this._b,n=this._c,a=this._d,i=e*a-t*n,o=u,d=h,c=180/l,p,g,f;if(0!==e||0!==t){var w=o(e*e+t*t);p=m(e/w)*(0=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!s&&B.isZero(d)&&(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)/u(n*n+a*a)},getDistance:function(e,t,n,a,i,r,o){return _(D.getSignedDistance(e,t,n,a,i,r,o))}}}),M=T.extend({_class:"Project",_list:"projects",_reference:"project",_compactSerialize:!0,initialize:function(e){T.call(this,!0),this._children=[],this._namedChildren={},this._activeLayer=null,this._currentStyle=new le(null,null,this),this._view=he.create(this,e||xe.getCanvas(1,1)),this._selectionItems={},this._selectionCount=0,this._updateVersion=0},_serialize:function(e,t){return C.serialize(this._children,e,!0,t)},_changed:function(e,t){if(1&e){var n=this._view;n&&(n._needsUpdate=!0,!n._requested&&n._autoUpdate&&n.requestUpdate())}var a=this._changes;if(a&&t){var i=this._changesById,r=t._id,o=i[r];o?o.flags|=e:a.push(i[r]={item:t,flags:e})}},clear:function(){for(var e=this._children,t=e.length-1;0<=t;t--)e[t].remove()},isEmpty:function(){return!this._children.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.set(e)},getIndex:function(){return this._index},getOptions:function(){return this._scope.settings},getLayers:function(){return this._children},getActiveLayer:function(){return this._activeLayer||new G({project:this,insert:!0})},getSymbolDefinitions:function(){var e=[],t={};return this.getItems({class:X,match:function(n){var a=n._definition,i=a._id;return t[i]||(t[i]=!0,e.push(a)),!1}}),e},getSymbols:"getSymbolDefinitions",getSelectedItems:function(){var e=this._selectionItems,t=[];for(var n in e){var a=e[n],i=a._selection;1&i&&a.isInserted()?t.push(a):!i&&this._updateSelection(a)}return t},_updateSelection:function(e){var t=e._id,n=this._selectionItems;e._selection?n[t]!==e&&(this._selectionCount++,n[t]=e):n[t]===e&&(this._selectionCount--,delete n[t])},selectAll:function(){for(var e=this._children,t=0,n=e.length;t=e.subtract(a).divide(d).length)return new U(t,u,{name:n?C.hyphenate(n):t,point:a})}if(this._locked||!this._visible||this._guide&&!t.guides||this.isEmpty())return null;var o=this._matrix,s=n?n.appended(o):this.getGlobalMatrix().prepend(this.getView()._matrix),l=w(t.tolerance,1e-12),d=t._tolerancePadding=new I($._getStrokePadding(l,o._shiftless().invert()));if(e=o._inverseTransform(e),!e||!this._children&&!this.getBounds({internal:!0,stroke:!0,handle:!0}).expand(d.multiply(2))._containsPoint(e))return null;var c=!(t.guides&&!this._guide||t.selected&&!this.isSelected()||t.type&&t.type!==C.hyphenate(this._class)||t.class&&!(this instanceof t.class)),h=t.match,u=this,m=t.position,p=t.center,g=t.bounds,f,y;if(c&&this._parent&&(m||p||g)){if((p||g)&&(f=this.getInternalBounds()),y=m&&r("position")||p&&r("center","Center"),!y&&g)for(var v=["TopLeft","TopRight","BottomLeft","BottomRight","LeftCenter","TopCenter","RightCenter","BottomCenter"],b=0;8>b&&!y;b++)y=r("bounds",v[b]);y=a(y)}return y||(y=this._hitTestChildren(e,t,s)||c&&a(this._hitTestSelf(e,t,s,this.getStrokeScaling()?null:s._shiftless().invert()))||null),y&&y.point&&(y.point=o.transform(y.point)),y},_hitTestSelf:function(e,t){if(t.fill&&this.hasFill()&&this._contains(e))return new U("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(C.isPlainObject(i)&&C.isPlainObject(r)){if(!n(i,r))return!1;}else if(!C.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;return!0}if("function"==a)return e(this);if("match"===e)return t(this);var r=/^(empty|editable)$/.test(e)?this["is"+C.capitalize(e)]():"type"===e?C.hyphenate(this._class):this[e];if("class"===e){if("function"==typeof t)return this instanceof t;r=this._class}if("function"==typeof t)return!!t(r);if(t){if(t.test)return t.test(r);if(C.isPlainObject(t))return n(t,r)}return C.equals(r,t)},getItems:function(e){return V._getItems(this,e,this._matrix)},getItem:function(e){return V._getItems(this,e,this._matrix,null,!0)[0]||null},statics:{_getItems:function e(t,n,a,r,o){if(!r){var s="object"==typeof n&&n,d=s&&s.overlapping,c=s&&s.inside,h=d||c,u=h&&O.read([h]);r={items:[],recursive:s&&!1!==s.recursive,inside:!!c,overlapping:!!d,rect:u,path:d&&new $.Rectangle({rectangle:u,insert:!1})},s&&(n=C.filter({},n,{recursive:!0,inside:!0,overlapping:!0}))}var m=t._children,p=r.items,u=r.rect;a=u&&(a||new q);for(var g=0,f=m&&m.length;gi:ad)&&this._canComposite(),m=t.pixelRatio||1,p,g,f;if(!u){var w=this.getStrokeBounds(r);if(!w.width||!w.height)return;f=t.offset,g=t.offset=w.getTopLeft().floor(),p=e,e=xe.getContext(w.getSize().ceil().add(1).multiply(m)),1!==m&&e.scale(m,m)}e.save();var y=n?n.appended(o):this._canScaleStroke&&!this.getStrokeScaling(!0)&&r,v=!u&&t.clipItem,b=!y||v;if(u?(e.globalAlpha=d,h&&(e.globalCompositeOperation=l)):b&&e.translate(-g.x,-g.y),b&&(u?o:r).applyToContext(e),v&&t.clipItem.draw(e,t.extend({clip:!0})),y){e.setTransform(m,0,0,m,0,0);var x=t.offset;x&&e.translate(-x.x,-x.y)}this._draw(e,t,r,y),e.restore(),i.pop(),t.clip&&!t.dontFinish&&e.clip(),u||(_e.process(l,e,p,d,g.subtract(f).multiply(m)),xe.release(e),t.offset=f)}}},_isUpdated:function(e){var t=this._parent;if(t instanceof ee)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){var o=this._selection,s=1&o,d=2&o||s&&this._selectBounds,c=4&o;if(this._drawSelected||(s=!1),(s||d||c)&&this._isUpdated(r)){var h=this.getSelectedColor(!0)||(p=this.getLayer())&&p.getSelectedColor(!0),u=t.appended(this.getGlobalMatrix(!0)),m=n/2,p;if(e.strokeStyle=e.fillStyle=h?h.toCanvasStyle(e):"#009dec",s&&this._drawSelected(e,u,a),c){var g=this.getPosition(!0),f=g.x,w=g.y;e.beginPath(),e.arc(f,w,m,0,2*l,!0),e.stroke();for(var y=[[0,-1],[1,0],[0,1],[-1,0]],v=m,b=n+1,x=0;4>x;x++){var _=y[x],E=_[0],k=_[1];e.moveTo(f+E*v,w+k*v),e.lineTo(f+E*b,w+k*b),e.stroke()}}if(d){var C=u._transformCorners(this.getInternalBounds());e.beginPath();for(var x=0;8>x;x++)e[x?"lineTo":"moveTo"](C[x],C[++x]);e.closePath(),e.stroke();for(var x=0;8>x;x++)e.fillRect(C[x]-m,C[++x]-m,n,n)}}},_canComposite:function(){return!1}},C.each(["down","drag","up","move"],function(e){this["removeOn"+C.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}})),F=V.extend({_class:"Group",_selectBounds:!1,_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=this._children,n=0,a=t.length;n=r;r++){var o=new P(1r?-1:1,2=i.subtract(i.normalize()).multiply(t).divide(n).length}return{_contains:function t(n){if("rectangle"===this._type){var a=e(this,n);return a?1>=n.subtract(a.point).divide(this._radius).getLength():t.base.call(this,n)}return .5>=n.divide(this.size).getLength()},_hitTestSelf:function n(a,i,r,o){var s=!1,l=this._style,d=i.stroke&&l.hasStroke(),c=i.fill&&l.hasFill();if(d||c){var h=this._type,u=this._radius,m=d?l.getStrokeWidth()/2:0,p=i._tolerancePadding.add($._getStrokePadding(m,!l.getStrokeScaling()&&o));if("rectangle"===h){var g=p.multiply(2),f=e(this,a,g);if(f)s=t(a.subtract(f.point),u,p,f.quadrant);else{var w=new O(this._size).setCenter(0,0),y=w.expand(g),v=w.expand(g.negate());s=y._containsPoint(a)&&!v._containsPoint(a)}}else s=t(a,u,p)}return s?new U(d?"stroke":"fill",this):n.base.apply(this,arguments)}}},{statics:new function(){function e(e,t,n,a,i){var r=new W(C.getNamed(i),t);return r._type=e,r._size=n,r._radius=a,r}return{Circle:function(){var t=P.readNamed(arguments,"center"),n=C.readNamed(arguments,"radius");return e("circle",t,new I(2*n),n,arguments)},Rectangle:function(){var t=O.readNamed(arguments,"rectangle"),n=I.min(I.readNamed(arguments,"radius"),t.getSize(!0).divide(2));return e("rectangle",t.getCenter(!0),t.getSize(!0),n,arguments)},Ellipse:function(){var t=W._readEllipse(arguments),n=t.radius;return e("ellipse",t.center,n.multiply(2),n,arguments)},_readEllipse:function(e){var t,n;if(C.hasNamed(e,"radius"))t=P.readNamed(e,"center"),n=I.readNamed(e,"radius");else{var a=O.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,_boundsOptions:{stroke:!1,handle:!1},_serializeFields:{crossOrigin:null,source:null},_prioritize:["crossOrigin"],initialize:function(e,t){if(!this._initialize(e,void 0!==t&&P.read(arguments,1))){var n="string"==typeof e?E.getElementById(e):e;n?this.setImage(n):this.setSource(e)}this._size||(this._size=new I,this._loaded=!1)},_equals:function(e){return this.getSource()===e.getSource()},copyContent:function(e){var t=e._image,n=e._canvas;if(t)this._setImage(t);else if(n){var a=xe.getCanvas(e._size);a.getContext("2d").drawImage(n,0,0),this._setImage(a)}this._crossOrigin=e._crossOrigin},getSize:function(){var e=this._size;return new A(e?e.width:0,e?e.height:0,this,"setSize")},setSize:function(){var e=I.read(arguments);if(!e.equals(this._size))if(0g;g++)m[g]/=p;return p?re.read(m):null},getPixel:function(){var e=P.read(arguments),t=this.getContext().getImageData(e.x,e.y,1,1).data;return new re("rgb",[t[0]/255,t[1]/255,t[2]/255],t[3]/255)},setPixel:function(){var e=P.read(arguments),t=re.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=I.read(arguments);return this.getContext().createImageData(e.width,e.height)},getImageData:function(){var e=O.read(arguments);return e.isEmpty()&&(e=new O(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){var t=new O(this._size).setCenter(0,0);return e?e._transformBounds(t):t},_hitTestSelf:function(e){if(this._contains(e)){var t=this;return new U("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}}),X=V.extend({_class:"SymbolItem",_applyMatrix:!1,_canApplyMatrix:!1,_boundsOptions:{stroke:!0},_serializeFields:{symbol:null},initialize:function(e,t){this._initialize(e,void 0!==t&&P.read(arguments,1))||this.setDefinition(e instanceof H?e:new H(e))},_equals:function(e){return this._definition===e._definition},copyContent:function(e){this.setDefinition(e._definition)},getDefinition:function(){return this._definition},setDefinition:function(e){this._definition=e,this._changed(9)},getSymbol:"#getDefinition",setSymbol:"#setDefinition",isEmpty:function(){return this._definition._item.isEmpty()},_getBounds:function(e,t){var n=this._definition._item;return n._getCachedBounds(n._matrix.prepended(e),t)},_hitTestSelf:function(e,t,n){var a=this._definition._item._hitTest(e,t,n);return a&&(a.item=this),a},_draw:function(e,t){this._definition._item.draw(e,t)}}),H=C.extend({_class:"SymbolDefinition",initialize:function(e,t){this._id=L.get(),this.project=p.project,e&&this.setItem(e,t)},_serialize:function(e,t){return t.add(this,function(){return C.serialize([this._class,this._item],e,!1,t)})},_changed:function(e){8&e&&V._clearBoundsCache(this),1&e&&this.project._changed(e)},getItem:function(){return this._item},setItem:function(e,t){e._symbol&&(e=e.clone()),this._item&&(this._item._symbol=null),this._item=e,e.remove(),e.setSelected(!1),t||e.setPosition(new P),e._symbol=this,this._changed(9)},getDefinition:"#getItem",setDefinition:"#setItem",place:function(e){return new X(this,e)},clone:function(){return new H(this._item.clone(!1))},equals:function(e){return e===this||e&&this._item.equals(e._item)||!1}}),U=C.extend({_class:"HitResult",initialize:function(e,t,n){this.type=e,this.item=t,n&&this.inject(n)},statics:{getOptions:function(e){var t=e&&C.read(e);return C.set({type:null,tolerance:p.settings.hitTolerance,fill:!t,stroke:!t,segments:!t,handles:!1,ends:!1,position:!1,center:!1,bounds:!1,guides:!1,selected:!1},t)}}}),Q=C.extend({_class:"Segment",beans:!0,_selection:0,initialize:function(e,t,n,a,i,r){var o=arguments.length,s,l,d,c;0n;n+=2)t.push(new P(e[n],e[n+1]));return t}},{getLength:function(){return null==this._length&&(this._length=Y.getLength(this.getValues(),0,1)),this._length},getArea:function(){return Y.getArea(this.getValues())},getLine:function(){return new D(this._segment1._point,this._segment2._point)},getPart:function(e,t){return new Y(Y.getPart(this.getValues(),e,t))},getPartLength:function(e,t){return Y.getLength(this.getValues(),e,t)},divideAt:function(e){return this.divideAtTime(e&&e.curve===this?e.time:this.getTimeAt(e))},divideAtTime:function(e,t){var n=1e-8,a=null;if(e>=n&&e<=1-n){var i=Y.subdivide(this.getValues(),e),r=i[0],o=i[1],s=t||this.hasHandles(),l=this._segment1,d=this._segment2,c=this._path;s&&(l._handleOut._set(r[2]-r[0],r[3]-r[1]),d._handleIn._set(o[4]-o[6],o[5]-o[7]));var h=r[6],u=r[7],m=new Q(new P(h,u),s&&new P(r[4]-h,r[5]-u),s&&new P(o[2]-h,o[3]-u));c?(c.insert(l._index+1,m),a=this.getNext()):(this._segment2=m,this._changed(),a=new Y(m,d))}return a},splitAt:function(e){var t=this._path;return t?t.splitAt(e):null},splitAtTime:function(e){return this.splitAt(this.getLocationAtTime(e))},divide:function(e,t){return this.divideAtTime(void 0===e?.5:t?e:this.getTimeAt(e))},split:function(e,t){return this.splitAtTime(void 0===e?.5:t?e:this.getTimeAt(e))},reversed:function(){return new Y(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,a){var i=e._point,r=e._handleOut,o=t._handleIn,s=t._point,l=i.x,d=i.y,c=s.x,h=s.y,u=a?[l,d,l,d,c,h,c,h]:[l,d,l+r._x,d+r._y,c+o._x,h+o._y,c,h];return n&&n._transformCoordinates(u,u,4),u},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]]},getMonoCurves:function(e,a){var i=[],r=a?0:1,o=e[r+0],s=e[r+2],l=e[r+4],d=e[r+6];if(o>=s==s>=l&&s>=l==l>=d||Y.isStraight(e))i.push(e);else{var c=1e-8,h=[],u=B.solveQuadratic(3*(s-l)-o+d,2*(o+l)-4*s,s-o,h,c,1-c);if(!u)i.push(e);else{h.sort();var n=h[0],m=Y.subdivide(e,n);i.push(m[0]),1n&&d>n&&s>n&&l>n)){var u=3*(s-o),c=3*(l-s)-u;h=B.solveCubic(d-o-u-c,c,u,o-n,a,i,r)}return h},getTimeOf:function(e,n){var a=new P(e[0],e[1]),r=new P(e[6],e[7]),o=1e-12,s=1e-7,l=n.isClose(a,o)?0:n.isClose(r,o)?1:null;if(null===l)for(var t=[n.x,n.y],d=[],h=0,m;2>h;h++){m=Y.solveCubic(e,h,t[h],d,0,1);for(var p=0,g;p=a){var t=n.getDistance(Y.getPoint(e,a),!0);if(th?0:.999999999999n;if(a){var i=t;t=n,n=i}return 0n&&(e=Y.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},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)<=16*t*t},getArea:function(e){var t=e[0],n=e[1],a=e[2],i=e[3],r=e[4],o=e[5],s=e[6],l=e[7];return 3*((l-n)*(a+r)-(s-t)*(i+o)+i*(t-r)-a*(n-o)+l*(r+t/3)-s*(o+n/3))/20},getBounds:function(e){for(var t=e.slice(0,2),n=t.slice(),a=[0,0],r=0;2>r;r++)Y._addBounds(e[r],e[r+2],e[r+4],e[r+6],r,0,t,n,a);return new O(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)}s/=2;var m=l[o]-s,p=d[o]+s;if(ep||n>p||a>p||r>p)if(n=l&&0>=d&&-1<=d}}return!1},isLinear:function(e,t,n,a){var i=a.subtract(e).divide(3);return t.equals(i)&&n.negate().equals(i)}},function(e,t){this[t]=function(t){var n=this._segment1,a=this._segment2;return e(n._point,n._handleOut,a._handleIn,a._point,t)},this.statics[t]=function(t,n){var a=t[0],i=t[1],r=t[6],o=t[7];return e(new P(a,i),new P(t[2]-a,t[3]-i),new P(t[4]-r,t[5]-o),new P(r,o),n)}},{statics:{},hasHandles:function(){return!this._segment1._handleOut.isZero()||!this._segment2._handleIn.isZero()},hasLength:function(e){return(!this.getPoint1().equals(this.getPoint2())||this.hasHandles())&&this.getLength()>(e||0)},isCollinear:function(e){return e&&this.isStraight()&&e.isStraight()&&this.getLine().isCollinear(e.getLine())},isHorizontal:function(){return this.isStraight()&&1e-8>_(this.getTangentAtTime(.5).y)},isVertical:function(){return this.isStraight()&&1e-8>_(this.getTangentAtTime(.5).x)}}),{beans:!1,getLocationAt:function(e,t){return this.getLocationAtTime(t?e:this.getTimeAt(e))},getLocationAtTime:function(e){return null!=e&&0<=e&&1>=e?new Z(this,e):null},getTimeAt:function(e,t){return Y.getTimeAt(this.getValues(),e,t)},getParameterAt:"#getTimeAt",getOffsetAtTime:function(e){return this.getPartLength(0,e)},getLocationOf:function(){return this.getLocationAtTime(this.getTimeOf(P.read(arguments)))},getOffsetOf:function(){var e=this.getLocationOf.apply(this,arguments);return e?e.getOffset():null},getTimeOf:function(){return Y.getTimeOf(this.getValues(),P.read(arguments))},getParameterOf:"#getTimeOf",getNearestLocation:function(){var e=P.read(arguments),n=this.getValues(),a=Y.getNearestTime(n,e),t=Y.getPoint(n,a);return new Z(this,a,t,null,e.getDistance(t))},getNearestPoint:function(){var e=this.getNearestLocation.apply(this,arguments);return e?e.getPoint():e}},new function(){var e=["getPoint","getTangent","getNormal","getWeightedTangent","getWeightedNormal","getCurvature"];return C.each(e,function(e){this[e+"At"]=function(t,n){var a=this.getValues();return Y[e](a,n?t:Y.getTimeAt(a,t))},this[e+"AtTime"]=function(t){return Y[e](this.getValues(),t)}},{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 u(t*t+c*c)}}function n(e,t){return w(2,d(16,x(32*_(t-e))))}function a(e,n,t,a){if(null==n||0>n||1T?(k=3*(m-c),C=3*(p-h)):(k=(3*v*n+2*w)*n+f,C=(3*E*n+2*_)*n+b),a){0===k&&0===C&&(nT)&&(k=c-s,C=h-l);var z=u(k*k+C*C);z&&(k/=z,C/=z)}if(3===t){var c=6*v*n+2*w,h=6*E*n+2*_,L=r(k*k+C*C,3/2);k=0===L?0:(k*h-C*c)/L,C=0}}return 2===t?new P(C,-k):new P(k,C)}return{statics:{classify:function(e){function t(e,t,n){var a=void 0!==t,i=a&&0t,r=a&&0n;return!a||(i||r)&&("loop"!==e||i&&r)||(e="arch",i=r=!1),{type:e,roots:i||r?i&&r?tr&&(s=Y.subdivide(s,r)[0],i/=r),0i?1:0),0===i)return r;var s=_,l=1e-12,d=0l)return null;var p=0;return B.findRoot(o,h,r+i/u,c,a,32,1e-12)},getPoint:function(e,n){return a(e,n,0,!1)},getTangent:function(e,n){return a(e,n,1,!0)},getWeightedTangent:function(e,n){return a(e,n,1,!1)},getNormal:function(e,n){return a(e,n,2,!0)},getWeightedNormal:function(e,n){return a(e,n,2,!1)},getCurvature:function(e,n){return a(e,n,3,!1).x},getPeaks:function(e){var t=e[0],n=e[1],a=e[2],i=e[3],r=e[4],o=e[5],s=e[6],l=e[7],d=-t+3*a-3*r+s,c=3*t-6*a+3*r,h=-3*t+3*a,u=-n+3*i-3*o+l,m=3*n-6*i+3*o,p=-3*n+3*i,g=1e-8,f=[];return B.solveCubic(9*(d*d+u*u),9*(d*c+m*u),2*(c*c+m*m)+3*(h*d+p*u),h*c+m*p,f,g,1-g),f.sort()}}}},new function(){function e(e,t,n,a,i,r,o){var s=!o&&n.getPrevious()===i,l=!o&&n!==i&&n.getNext()===i,d=1e-8,c=1-d;if(null!==a&&a>=(s?d:0)&&a<=(l?c:1)&&null!==r&&r>=(l?d:0)&&r<=(s?c:1)){var h=new Z(n,a,null,o),u=new Z(i,r,null,o);h._intersection=u,u._intersection=h,(!t||t(h))&&Z.insert(e,h,!0)}}function n(r,o,s,l,c,h,m,p,g,f,y,v,b){if(4096<=++g||40<=++p)return g;var x=1e-9,_=o[0],E=o[1],k=o[6],C=o[7],S=D.getSignedDistance,T=S(_,E,k,C,o[2],o[3]),z=S(_,E,k,C,o[4],o[5]),B=0=x?n(o,r,l,s,c,h,!m,p,g,v,b,G,W):n(r,o,s,l,c,h,m,p,g,G,W,v,b);else if(W-G>b-v){var H=Y.subdivide(r,.5),R=(G+W)/2;g=n(o,H[0],l,s,c,h,!m,p,g,v,b,G,R),g=n(o,H[1],l,s,c,h,!m,p,g,v,b,R,W)}else{var H=Y.subdivide(o,.5),X=(v+b)/2;g=n(H[0],r,l,s,c,h,!m,p,g,v,X,G,W),g=n(H[1],r,l,s,c,h,!m,p,g,X,b,G,W)}return g}function a(e,t,n,a){var i=[0,e],r=[1/3,t],o=[2/3,n],s=[1,a],l=t-(2*e+a)/3,d=n-(e+2*a)/3,c;if(0>l*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 r(e,n,a,r,o){var l=B.isZero;if(l(r)&&l(o)){var d=Y.getTimeOf(e,new P(n,a));return null===d?[]:[d]}for(var t=h(-o,r),c=s(t),u=g(t),m=[],p=[],f=0;8>f;f+=2){var w=e[f]-n,v=e[f+1]-a;m.push(w*u-v*c,w*c+v*u)}return Y.solveCubic(m,1,0,p,0,1),p}function o(t,n,a,o,s,d,c){for(var h=n[0],u=n[1],m=n[6],p=n[7],g=r(t,h,u,m-h,p-u),f=0,w=g.length;fm(a[0],a[2],a[4],a[6])&&m(t[0],t[2],t[4],t[6])-um(a[1],a[3],a[5],a[7])&&m(t[1],t[3],t[5],t[7])-uy;y++)v=f[y],e(c,h,r,v[0],s,v[1],!0);else{var b=Y.isStraight(t),x=Y.isStraight(a),_=b&&x,E=b&&!x,k=c.length;if((_?l:b||x?o:n)(E?a:t,E?t:a,E?s:r,E?r:s,c,h,E,0,0,0,1,0,1),!_||c.length===k)for(var y=0;4>y;y++){var C=y>>1,S=1&y,T=6*C,z=6*S,B=new P(t[T],t[T+1]),L=new P(a[z],a[z+1]);B.isClose(L,u)&&e(c,h,r,C,s,S)}}}return c}function u(t,n,a,i){var r=Y.classify(t);if("loop"===r.type){var o=r.roots;e(a,i,n,o[0],n,o[1])}return a}function m(e,t,n,a,r,o){var s=!t;s&&(t=e);for(var d=e.length,h=t.length,m=[],p=[],g=0,f,w;gb&&2>v.length;b++){var x=1&b,E=1^x,k=b>>1,C=Y.getTimeOf(y[x],new P(y[E][k?6:0],y[E][k?7:1]));if(null!=C){var S=x?[k,C]:[C,k];(!v.length||a(S[0]-v[0][0])>o&&a(S[1]-v[0][1])>o)&&v.push(S)}if(2s||a(z[3]-T[3])>s||a(z[4]-T[4])>s||a(z[5]-T[5])>s)&&(v=null)}return v}return{getIntersections:function(e){var t=this.getValues(),n=e&&e!==this&&e.getValues();return n?c(t,n,this,e,[]):u(t,this,[])},statics:{getOverlaps:p,getIntersections:m,getCurveLineIntersections:r}}}),Z=C.extend({_class:"CurveLocation",initialize:function(e,t,n,a,i){if(.99999999<=t){var r=e.getNext();r&&(t=0,e=r)}this._setCurve(e),this._time=t,this._point=n||e.getPointAtTime(t),this._overlap=a,this._distance=i,this._intersection=this._next=this._previous=null},_setCurve:function(e){var t=e._path;this._path=t,this._version=t?t._version:0,this._curve=e,this._segment=null,this._segment1=e._segment1,this._segment2=e._segment2},_setSegment:function(e){this._setCurve(e.getCurve()),this._segment=e,this._time=e===this._segment1?0:1,this._point=e._point.clone()},getSegment:function(){var e=this._segment;if(!e){var t=this.getCurve(),n=this.getTime();0===n?e=t._segment1:1===n?e=t._segment2:null!=n&&(e=t.getPartLength(0,n)t&&et||e=r&&a<=o,l=i>=r&&i<=o;if(s&&l)return!this.isTouching();var c=this.getCurve(),h=ao&&(c=c.getNext()),i>o&&(u=u.getNext()),!h||!c||!m||!u)return!1;var p=[];s||(e(h,!0),e(c,!1)),l||(e(m,!0),e(u,!1));var g=this.getPoint(),f=d.apply(Math,p),w=s?c.getTangentAtTime(a):c.getPointAt(f).subtract(g),y=s?w.negate():h.getPointAt(-f).subtract(g),v=l?u.getTangentAtTime(i):u.getPointAt(f).subtract(g),b=l?v.negate():m.getPointAt(-f).subtract(g),x=y.getAngle(),_=w.getAngle(),E=b.getAngle(),k=v.getAngle();return s?!!(t(x,E,k)^t(_,E,k)&&t(x,k,E)^t(_,k,E)):!!(t(E,x,_)^t(k,x,_)&&t(E,_,x)^t(k,_,x))},hasOverlap:function(){return!!this._overlap}},C.each(Y._evaluateMethods,function(e){this[e]=function(){var t=this.getCurve(),n=this.getTime();return null!=n&&t&&t[e+"At"](n,!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(),1e-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.getTime()-(c.getIndex()+c.getTime()):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=t.length-1;0<=a;a--)e(n,t[a]._intersection,!1);return n}}}}),J=V.extend({_class:"PathItem",_selectBounds:!1,_canScaleStroke:!0,beans:!0,initialize:function(){},statics:{create:function(e){var t,n,a;if(C.isPlainObject(e)?(n=e.segments,t=e.pathData):Array.isArray(e)?n=e:"string"==typeof e&&(t=e),n){var i=n[0];a=i&&Array.isArray(i[0])}else t&&(a=1<(t.match(/m/gi)||[]).length||/z\s*\S+/i.test(t));var r=a?ee:$;return new r(e)}},_asPathItem:function(){return this},isClockwise:function(){return 0<=this.getArea()},setClockwise:function(e){this.isClockwise()!=(e=!!e)&&this.reverse()},setPathData:function(e){function t(e,t){var n=+d[e];return r&&(n+=o[t]),n}function n(e){return new P(t(e,"x"),t(e+1,"y"))}var a=e&&e.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/ig),r=!1,o=new P,s=new P,d,c,h;this.clear();for(var u=0,m=a&&a.length;uc&&this[a?"removeSegments":"removeChildren"](c,d);for(var u=0;u1-i&&(n++,a=0);var r=this.getCurves();if(0<=n&&n=i&&r[n++].divideAtTime(a);var o=this.removeSegments(n,this._segments.length,!0),s;return this._closed?(this.setClosed(!1),s=this):(s=new $(V.NO_INSERT),s.insertAbove(this),s.copyAttributes(this)),s._add(o,0),this.addSegment(o[0]),s}return null},split:function(e,t){var n=void 0===t?e:(a=this.getCurves()[e])&&a.getLocationAtTime(t),a;return null==n?null:this.splitAt(n)},join:function(e,t){var n=t||0;if(e&&e!==this){var a=e._segments,i=this.getLastSegment(),r=e.getLastSegment();if(!r)return this;i&&i._point.isClose(r._point,n)&&e.reverse();var o=e.getFirstSegment();if(i&&i._point.isClose(o._point,n))i.setHandleOut(o._handleOut),this._add(a.slice(1));else{var s=this.getFirstSegment();s&&s._point.isClose(o._point,n)&&e.reverse(),r=e.getLastSegment(),s&&s._point.isClose(r._point,n)?(s.setHandleIn(r._handleIn),this._add(a.slice(0,a.length-1),0)):this._add(a.slice())}e._closed&&this._add([a[0]]),e.remove()}var l=this.getFirstSegment(),d=this.getLastSegment();return l!==d&&l._point.isClose(d._point,n)&&(l.setHandleIn(d._handleIn),d.remove(),this.setClosed(!0)),this},reduce:function(e){for(var t=this.getCurves(),n=e&&e.simplify,a=n?1e-7:0,r=t.length-1,o;0<=r;r--)o=t[r],!o.hasHandles()&&(!o.hasLength(a)||n&&o.isCollinear(o.getNext()))&&o.remove();return this},reverse:function(){this._segments.reverse();for(var e=0,t=this._segments.length;en&&h?n%c:0>n?n+c:n,c-1)}var r=this,o=e||{},s=o.type||"asymmetric",l=this._segments,c=l.length,h=this._closed,p=h&&void 0===o.from&&void 0===o.to,g=t(o.from,0),w=t(o.to,c-1);if(g>w)if(h)g-=c;else{var _=g;g=w,w=_}if(/^(?:asymmetric|continuous)$/.test(s)){var E="asymmetric"===s,k=d,C=w-g+1,S=C-1,T=p?k(C,4):1,z=T,B=T,L=[];if(h||(z=k(1,g),B=k(1,c-w-1)),S+=z+B,1>=S)return;for(var N=0,P=g-z;N<=S;N++,P++)L[N]=l[(0>P?P+c:P)%c]._point;for(var I=L[0]._x+2*L[1]._x,A=L[0]._y+2*L[1]._y,q=2,O=S-1,D=[I],M=[A],V=[q],F=[],G=[],N=1;NP?P+c:P],H=X._point,U=F[N]-H._x,Q=G[N]-H._y;(p||Nz)&&X.setHandleIn(-U,-Q)}}else for(var N=g;N<=w;N++)l[0>N?N+c:N].smooth(o,!p&&N===g,!p&&N===w)},toShape:function(e){function t(e,t){var n=r[e],a=n.getNext(),i=r[t],o=i.getNext();return n._handleOut.isZero()&&a._handleIn.isZero()&&i._handleOut.isZero()&&o._handleIn.isZero()&&a._point.subtract(n._point).isCollinear(o._point.subtract(i._point))}function n(e){var t=r[e],n=t.getNext(),a=t._handleOut,i=n._handleIn,o=.5522847498307936;if(a.isOrthogonal(i)){var s=t._point,l=n._point,d=new D(s,a,!0).intersect(new D(l,i,!0),!0);return d&&B.isZero(a.getLength()/d.subtract(s).getLength()-o)&&B.isZero(i.getLength()/d.subtract(l).getLength()-o)}return!1}function a(e,t){return r[e]._point.getDistance(r[t]._point)}if(!this._closed)return null;var r=this._segments,i,o,s,l;if(!this.hasHandles()&&4===r.length&&t(0,2)&&t(1,3)&&function(e){var t=r[e],n=t.getPrevious(),a=t.getNext();return n._handleOut.isZero()&&t._handleIn.isZero()&&t._handleOut.isZero()&&a._handleIn.isZero()&&t._point.subtract(n._point).isOrthogonal(a._point.subtract(t._point))}(1)?(i=W.Rectangle,o=new I(a(0,3),a(0,1)),l=r[1]._point.add(r[2]._point).divide(2)):8===r.length&&n(0)&&n(2)&&n(4)&&n(6)&&t(1,5)&&t(3,7)?(i=W.Rectangle,o=new I(a(1,6),a(0,3)),s=o.subtract(new I(a(0,7),a(1,2))).divide(2),l=r[3]._point.add(r[4]._point).divide(2)):4===r.length&&n(0)&&n(1)&&n(2)&&n(3)&&(B.isZero(a(0,2)-a(1,3))?(i=W.Circle,s=a(0,2)/2):(i=W.Ellipse,s=new I(a(2,0)/2,a(3,1)/2)),l=r[1]._point),i){var d=this.getPosition(!0),c=new i({center:d,size:o,radius:s,insert:!1});return c.copyAttributes(this,!0),c._matrix.prepend(this._matrix),c.rotate(l.subtract(d).getAngle()+90),(void 0===e||e)&&c.insertAbove(this),c}return null},toPath:"#clone",compare:function e(t){if(!t||t instanceof ee)return e.base.call(this,t);var n=this.getCurves(),a=t.getCurves(),r=n.length,o=a.length;if(!r||!o)return r==o;for(var s=n[0].getValues(),l=[],d=0,c=0,h=0,u,m,p;h=o&&(u=0),p=l[u]||a[u].getValues(),m=0),!s)return y[0]===u&&y[1]===m;continue}}}break}return!1},_hitTestSelf:function(e,t,n,a){function r(t,n){return 1>=e.subtract(t).divide(n).length}function o(e,n,a){if(!t.selected||n.isSelected()){var i=e._point;if(n!==i&&(n=n.add(i)),r(n,f))return new U(a,c,{segment:e,point:n})}}function s(e,n){return(n||t.segments)&&o(e,e._point,"segment")||!n&&t.handles&&(o(e,e._handleIn,"handle-in")||o(e,e._handleOut,"handle-out"))}function l(e){k.add(e)}function d(t){var n=p||0e)return s.getLocationAt(e-o)}if(0=C.remain(arguments))h=o,o=P.read(arguments);else{var b=I.read(arguments),E=B.isZero;if(E(b.width)||E(b.height))return this.lineTo(o);var k=C.read(arguments),c=!!C.read(arguments),S=!!C.read(arguments),v=r.add(o).divide(2),T=r.subtract(v).rotate(-k),L=T.x,N=T.y,y=t(b.width),A=t(b.height),j=y*y,O=A*A,M=L*L,V=N*N,F=n(M/j+V/O);if(1t(F)&&(F=0),0>F)throw new Error("Cannot create an arc with the given arguments");m=new P(y*N/A,-A*L/y).multiply((S===c?-1:1)*n(F)).rotate(k).add(v),w=new q().translate(m).rotate(k).scale(y,A),f=w._inverseTransform(r),p=f.getDirectedAngle(w._inverseTransform(o)),!c&&0p&&(p+=360)}if(h){var G=new D(r.add(h).divide(2),h.subtract(r).rotate(90),!0),W=new D(h.add(o).divide(2),o.subtract(h).rotate(90),!0),R=new D(r,o),X=R.getSide(h);if(m=G.intersect(W,!0),!m){if(!X)return this.lineTo(o);throw new Error("Cannot create an arc with the given arguments")}f=r.subtract(m),p=f.getDirectedAngle(o.subtract(m));var H=R.getSide(m);0===H?p=X*t(p):X===H&&(p+=0>p?360:-360)}for(var U=t(p),K=360<=U?4:x((U-1e-7)/90),Y=p/K,Z=Y*l/360,J=4/3*s(Z)/(1+g(Z)),z=[],$=0;$<=K;$++){var T=o,ee=null;if($t;t++)Y._addBounds(h[t],h[t+4],c[t+2],c[t],t,o?o[t]:0,u,m,p);var n=h;h=c,c=n}var d=e[0];if(!d)return new O;for(var c=[,,,,,,],h=d._transformCoordinates(a,[,,,,,,]),u=h.slice(0,2),m=u.slice(),p=[,,],g=1,f=e.length;gh.getDirectedAngle(u)&&(h=h.negate(),u=u.negate()),s&&o(c),o(c.add(h)),"miter"===t){var m=new D(c.add(h),new P(-h.y,h.x),!0).intersect(new D(c.add(u),new P(-u.y,u.x),!0),!0);m&&c.getDistance(m)<=a*n&&o(m)}o(c.add(u))},_addSquareCap:function(e,t,n,a,i,r,o){var s=e._point.transform(a),l=e.getLocation(),d=l.getNormal().multiply(0===l.getTime()?n:-n).transform(i);"square"===t&&(o&&(r(s.subtract(d)),r(s.add(d))),s=s.add(d.rotate(-90))),r(s.add(d)),r(s.subtract(d))},getHandleBounds:function(e,t,n,a,r){var o=n.getStyle(),s=r.stroke&&o.hasStroke(),d,c;if(s){var h=n._getStrokeMatrix(a,r),u=o.getStrokeWidth()/2,m=u;"miter"===o.getStrokeJoin()&&(m=u*o.getMiterLimit()),"square"===o.getStrokeCap()&&(m=w(m,u*Math.SQRT2)),d=$._getStrokePadding(u,h),c=$._getStrokePadding(m,h)}for(var p=[,,,,,,],g=1/0,f=-g,v=g,b=f,_=0,E=e.length,l;_k;k+=2){var C=k?d:c,S=C?C[0]:0,T=C?C[1]:0,z=p[k],x=p[k+1],y=z-S,B=z+S,L=x-T,N=x+T;yf&&(f=B),Lb&&(b=N)}}return new O(g,v,f-g,b-v)}}});$.inject({statics:new function(){function e(e,t,n){var a=C.getNamed(n),i=new $(a&&!1==a.insert&&V.NO_INSERT);return i._add(e),i._closed=t,i.set(a,{insert:!0})}function t(t,n,r){for(var o=[,,,,],s=0,l;4>s;s++)l=a[s],o[s]=new Q(l._point.multiply(n).add(t),l._handleIn.multiply(n),l._handleOut.multiply(n));return e(o,!0,r)}var n=.5522847498307936,a=[new Q([-1,0],[0,n],[0,-n]),new Q([0,-1],[-n,0],[n,0]),new Q([1,0],[0,-n],[0,n]),new Q([0,1],[n,0],[-n,0])];return{Line:function(){return e([new Q(P.readNamed(arguments,"from")),new Q(P.readNamed(arguments,"to"))],!1,arguments)},Circle:function(){var e=P.readNamed(arguments,"center"),n=C.readNamed(arguments,"radius");return t(e,new I(n),arguments)},Rectangle:function(){var t=O.readNamed(arguments,"rectangle"),a=I.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 Q(i),new Q(r),new Q(o),new Q(s)];else{a=I.min(a,t.getSize(!0).divide(2));var d=a.width,c=a.height,h=d*n,u=c*n;l=[new Q(i.add(d,0),null,[-h,0]),new Q(i.subtract(0,c),[0,u]),new Q(r.add(0,c),null,[0,-u]),new Q(r.add(d,0),[-h,0],null),new Q(o.subtract(d,0),null,[h,0]),new Q(o.add(0,c),[0,-u],null),new Q(s.subtract(0,c),null,[0,u]),new Q(s.subtract(d,0),[h,0])]}return e(l,!0,arguments)},RoundRectangle:"#Rectangle",Ellipse:function(){var e=W._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=C.getNamed(arguments),i=new $(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=C.readNamed(arguments,"sides"),a=C.readNamed(arguments,"radius"),r=0==n%3,o=new P(0,r?-a:a),s=r?-1:.5,l=Array(n),d=0;d=s&&(v/=f):(c=!w.hasHandles()||u&&u[a(w)],p=[],f=null,g=w)),x){p&&p.push(y);continue}else t&&o.unshift(y);if(f=b,vd)_=w._segment2;else{var E=w.divideAtTime(v,!0);c&&h.push(w,E),_=E._segment1;for(var k=p.length-1,C;0<=k;k--)C=p[k],C._time=(C._time-v)/(1-v)}y._setSegment(_);var S=_._intersection,T=y._intersection;if(S){i(S,T);for(var z=S;z;)i(z._intersection,S),z=z._next}else _._intersection=T}return n||r(h),o||e}function l(e,n,r,o,s){function t(i){var h=i[c+0],m=i[c+6];if(!(fp(h,m))){var w=i[d+0],v=i[d+2],_=i[d+4],E=i[d+6];if(h===m)return void((wb||Eb)&&(S=!0));var T=f===h?0:f===m?1:b>p(w,v,_,E)||xm?1:-1,L=P[c]>P[c+6]?1:-1,N=P[d+6];return f===h?(a==L?w!=N&&(Nx?(C+=a,S=!0):N>b&&tx&&(C+=a),z=0):(tx?C+=a:S=!0,t>g-y&&tb&&t=u(n,a,o,s))for(var h=e[d+0],m=e[d+2],g=e[d+4],w=e[d+6],y=b>p(h,m,g,w)||xh.quality;w++){p=c*g[w];for(var y=0,v=s.length;yh.quality&&(h=T);break}p-=x}}for(var y=s.length-1;0<=y;y--)s[y].segment._winding=h}function h(e,t){function n(e){var n;return!(!e||e._visited||t&&(!t[(n=e._winding||{}).winding]||t.unite&&2===n.winding&&n.windingL&&n.windingR))}function a(e){if(e)for(var t=0,n=d.length;t=u(c,h,g,f)&&a<=p(c,h,g,f))for(var w=Y.getMonoCurves(l),y=0,v=w.length;y=b&&a<=_||a>=_&&a<=b)){var E=a===b?m[0]:a===_?m[6]:1===Y.solveCubic(m,1,a,o,0,1)?Y.getPoint(m,o[0]).x:(m[0]+m[6])/2;r.push(E)}}}1m&&!(a&&Y.isStraight(e))&&!Y.isFlatEnough(e,t||.25)){var o=Y.subdivide(e,.5),l=(i+r)/2;s(o[0],n,i,l),s(o[1],n,l,r)}else{var d=e[6]-e[0],p=e[7]-e[1],g=u(d*d+p*p);0=e){this.index=r;var s=t[r-1],l=s&&s.index===o.index?s.time:0,d=s?s.offset:0;return{index:o.index,time:l+(o.time-l)*(e-d)/(o.offset-d)}}}return{index:t[n-1].index,time:1}},drawPart:function(e,t,n){for(var a=this._get(t),r=this._get(n),o=a.index,s=r.index,l;o<=s;o++)l=Y.getPart(this.curves[o],o===a.index?a.time:0,o===r.index?r.time:1),o===a.index&&e.moveTo(l[0],l[1]),e.bezierCurveTo.apply(e,l.slice(2))}},C.each(Y._evaluateMethods,function(e){this[e+"At"]=function(t){var n=this._get(t);return Y[e](this.curves[n.index],n.time)}},{})),ne=C.extend({initialize:function(e){for(var t=this.points=[],n=e._segments,a=e._closed,r=0,o=n.length,s,l;r=p;p++){var f=this.generateBezier(n,a,h,r,o),y=this.findMaxError(n,a,f,h);if(y.error=u)break;m=this.reparameterize(n,a,h,f),u=y.error}var v=s[g-1].subtract(s[g+1]);this.fitCubic(e,t,n,g,r,v),this.fitCubic(e,t,g,a,v.negate(),o)},addCurve:function(e,t){var n=e[e.length-1];n.setHandleOut(t[1].subtract(t[0])),e.push(new Q(t[3],t[2].subtract(t[3])))},generateBezier:function(e,n,a,r,o){for(var s=1e-12,l=_,d=this.points,c=d[e],h=d[n],m=[[0,0],[0,0]],p=[0,0],g=0;gs){var S=m[0][0]*p[1]-m[1][0]*p[0],T=p[0]*m[1][1]-p[1]*m[0][1];k=T/E,C=S/E}else{var z=m[0][0]+m[0][1],B=m[1][0]+m[1][1];k=C=l(z)>s?p[0]/z:l(B)>s?p[1]/B:0}var L=h.getDistance(c),N=s*L,P,I;if(kL*L&&(k=C=L/3,P=I=null)}return[c,c.add(P||r.normalize(k)),h.add(I||o.normalize(C)),h]},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=o;o++)a[o]=e[o+1].subtract(e[o]).multiply(3);for(var o=0;1>=o;o++)r[o]=a[o+1].subtract(a[o]).multiply(2);var s=this.evaluate(3,e,n),l=this.evaluate(2,a,n),d=this.evaluate(1,r,n),c=s.subtract(t),h=l.dot(l)+c.dot(d);return B.isZero(h)?n:n-c.dot(l)/h},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}}}),ae=V.extend({_class:"TextItem",_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsOptions:{stroke:!1,handle:!1},initialize:function(e){this._content="",this._lines=[];var t=e&&C.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},copyContent:function(e){this.setContent(e._content)},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"}),ie=ae.extend({_class:"PointText",initialize:function(){ae.apply(this,arguments)},getPoint:function(){var e=this._matrix.getTranslation();return new N(e.x,e.y,this,"setPoint")},setPoint:function(){var e=P.read(arguments);this.translate(e.subtract(this._matrix.getTranslation()))},_draw:function(e,t,n){if(this._content){this._setStyles(e,t,n);var a=this._lines,r=this._style,o=r.hasFill(),s=r.hasStroke(),d=r.getLeading(),c=e.shadowColor;e.font=r.getFontStyle(),e.textAlign=r.getJustification();for(var h=0,u=a.length;ha;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 if(b){var s=i[e];if(!s){l||(l=xe.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()}else n=[0,0,0];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=d(e,t,n),r=a-i,o=0==r?0:60*(a==e?(t-n)/r+(th?r/(a+i):r/(2-a-i);return[c,l,h]},"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 C.each(t,function(e,n){a[n]=[],C.each(e,function(e,i){var r=C.capitalize(e),o=/^(hue|saturation)$/.test(e),s=a[n][i]="gradient"===e?function(e){var t=this._components[0];return e=oe.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=arguments,s=this.__read,d=0,c,h,u,m;Array.isArray(r)&&(o=r,r=o[0]);var p=null!=r&&typeof r;if("string"===p&&r in t&&(c=r,r=o[1],Array.isArray(r)?(h=r,u=o[2]):(s&&(d=1),o=C.slice(o,1),p=typeof r)),!h){if(m="number"===p?o:"object"===p&&null!=r.length?r:null,m){c||(c=3<=m.length?"rgb":"gray");var g=t[c].length;u=m[g],s&&(d+=m===arguments?g+(null==u?0:1):1),m.length>g&&(m=C.slice(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,t){if(this._canvasStyle)return this._canvasStyle;if("gradient"!==this._type)return this._canvasStyle=this.toCSS();var n=this._components,a=n[0],r=a._stops,o=n[1],s=n[2],d=n[3],c=t&&t.inverted(),h;if(c&&(o=c._transformPoint(o),s=c._transformPoint(s),d&&(d=c._transformPoint(d))),a._radial){var u=s.getDistance(o);if(d){var m=d.subtract(o);m.getLength()>u&&(d=o.add(m.normalize(u-.1)))}var p=d||o;h=e.createRadialGradient(p.x,p.y,0,o.x,o.y,u)}else h=e.createLinearGradient(o.x,o.y,s.x,s.y);for(var g=0,f=r.length;ge.length)throw new Error("Gradient stop list needs to contain at least two stops.");var t=this._stops;if(t)for(var n=0,a=t.length;ns;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 O(o,s,r.width,r.height)},getViewportBounds:function(e){var t=e.ownerDocument,n=t.defaultView,a=t.documentElement;return new O(0,0,n.innerWidth||a.clientWidth,n.innerHeight||a.clientHeight)},getOffset:function(e,t){return de.getBounds(e,t).getPoint()},getSize:function(e){return de.getBounds(e,!0).getSize()},isInvisible:function(e){return de.getSize(e).equals(new I(0,0))},isInView:function(e){return!de.isInvisible(e)&&de.getViewportBounds(e).intersects(de.getBounds(e,!0))},isInserted:function(e){return E.body.contains(e)},getPrefixed:function(t,n){return t&&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)}}},ce={add:function(e,t){if(e)for(var n in t)for(var a=t[n],r=n.split(/[\s,]+/g),o=0,s=r.length;or?-1:1):r,n(t,e,t.viewToProject(i))}},scroll:t};m[c]=function(t){var n=he._focused=e(t);r||(r=!0,n._handleMouseEvent("mousedown",t))},g[h]=function(a){var i=he._focused;if(!o){var r=e(a);r?i!==r&&(i&&n(i,a),!l&&(l=i),i=he._focused=d=r):d&&d===i&&(l&&!l.isInserted()&&(l=null),i=he._focused=l,l=null,t())}i&&n(i,a)},g[c]=function(){o=!0},g[u]=function(e){var t=he._focused;t&&r&&t._handleMouseEvent("mouseup",e),o=r=!1},ce.add(E,g),ce.add(b,{load:t});var f=!1,w=!1,y={doubleclick:"click",mousedrag:"mousemove"},v=!1,x={mousedown:{mousedown:1,mousedrag:1,click:1,doubleclick:1},mouseup:{mouseup:1,mousedrag:1,click:1,doubleclick:1},mousemove:{mousedrag:1,mousemove:1,mouseenter:1,mouseleave:1}},k,C,S,T,z,B,L,N,P;return{_viewEvents:m,_handleMouseEvent:function(e,t,n){function o(e){return s.virtual[e]||h.responds(e)||c&&c.responds(e)}var s=this._itemEvents,l=s.native[e],d="mousemove"===e,c=this._scope.tool,h=this;d&&r&&o("mousedrag")&&(e="mousedrag"),n||(n=this.getEventPoint(t));var u=this.getBounds().contains(n),m=l&&u&&h._project.hitTest(n,{tolerance:0,fill:!0,stroke:!0}),p=m&&m.item||null,g=!1,y={};if(y[e.substr(5)]=!0,l&&p!==z&&(z&&a(z,null,"mouseleave",t,n),p&&a(p,null,"mouseenter",t,n),z=p),v^u&&(a(this,null,u?"mouseenter":"mouseleave",t,n),k=u?this:null,g=!0),(u||y.drag)&&!n.equals(S)&&(i(this,p,d?e:"mousemove",t,n,S),g=!0),v=u,y.down&&u||y.up&&C){if(i(this,p,e,t,n,C),y.down){if(P=p===L&&300>Date.now()-N,T=L=p,!w&&p){for(var b=p;b&&!b.responds("mousedrag");)b=b._parent;b&&(B=p)}C=n}else y.up&&(w||p!==T||(N=Date.now(),i(this,p,P?"doubleclick":"click",t,n,C),P=!1),T=B=null);v=!1,g=!0}S=n,g&&c&&(f=c._handleMouseEvent(e,t,n,y)||f),(f&&!y.move||y.down&&o("mouseup"))&&t.preventDefault()},_handleKeyEvent:function(e,t,n,a){function i(i){i.responds(e)&&(p=r,i.emit(e,s=s||new ge(e,t,n,a)))}var r=this._scope,o=r.tool,s;this.isVisible()&&(i(this),o&&o.responds(e)&&i(o))},_countItemEvent:function(e,t){var n=this._itemEvents,a=n.native,i=n.virtual;for(var r in x)a[r]=(a[r]||0)+(x[r][e]||0)*t;i[e]=(i[e]||0)+t},statics:{updateFocus:t}}}}),ue=he.extend({_class:"CanvasView",initialize:function(e,t){if(!(t instanceof b.HTMLCanvasElement)){var n=I.read(arguments,1);if(n.isZero())throw new Error("Cannot create CanvasView with the provided argument: "+C.slice(arguments,1));t=xe.getCanvas(n)}var a=this._context=t.getContext("2d");if(a.save(),this._pixelRatio=1,!/^off|false$/.test(S.getAttribute(t,"hidpi"))){var i=b.devicePixelRatio||1,r=de.getPrefixed(a,"backingStorePixelRatio")||1;this._pixelRatio=i/r}he.call(this,e,t),this._needsUpdate=!0},remove:function e(){return this._context.restore(),e.base.call(this)},_setElementSize:function e(t,n){var a=this._pixelRatio;if(e.base.call(this,t*a,n*a),1!==a){var i=this._element,r=this._context;if(!S.hasAttribute(i,"resize")){var o=i.style;o.width=t+"px",o.height=n+"px"}r.restore(),r.save(),r.scale(a,a)}},getPixelSize:function e(t){var n=p.agent,a;if(n&&n.firefox)a=e.base.call(this,t);else{var i=this._context,r=i.font;i.font=t+" serif",a=parseFloat(i.font),i.font=r}return a},getTextWidth:function(e,t){var n=this._context,a=n.font,r=0;n.font=e;for(var o=0,s=t.length;othis._maxDistance&&(this._maxDistance=e)},getMaxDistance:function(){return this._maxDistance},setMaxDistance:function(e){this._maxDistance=e,null!=this._minDistance&&null!=e&&ed){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=d,o=w,r=_,s={multiply:function(){x=g*h/255,E=f*u/255,k=y*m/255},screen:function(){x=g+h-g*h/255,E=f+u-f*u/255,k=y+m-y*m/255},overlay:function(){x=128>g?2*g*h/255:255-2*(255-g)*(255-h)/255,E=128>f?2*f*u/255:255-2*(255-f)*(255-u)/255,k=128>y?2*y*m/255:255-2*(255-y)*(255-m)/255},"soft-light":function(){var e=h*g/255;x=e+g*(255-(255-g)*(255-h)/255-e)/255,e=u*f/255,E=e+f*(255-(255-f)*(255-u)/255-e)/255,e=m*y/255,k=e+y*(255-(255-y)*(255-m)/255-e)/255},"hard-light":function(){x=128>h?2*h*g/255:255-2*(255-h)*(255-g)/255,E=128>u?2*u*f/255:255-2*(255-u)*(255-f)/255,k=128>m?2*m*y/255:255-2*(255-m)*(255-y)/255},"color-dodge":function(){x=0===g?0:255===h?255:i(255,255*g/(255-h)),E=0===f?0:255===u?255:i(255,255*f/(255-u)),k=0===y?0:255===m?255:i(255,255*y/(255-m))},"color-burn":function(){x=255===g?255:0===h?0:o(0,255-255*(255-g)/h),E=255===f?255:0===u?0:o(0,255-255*(255-f)/u),k=255===y?255:0===m?0:o(0,255-255*(255-y)/m)},darken:function(){x=gh?g:h,E=f>u?f:u,k=y>m?y:m},difference:function(){x=g-h,0>x&&(x=-x),E=f-u,0>E&&(E=-E),k=y-m,0>k&&(k=-k)},exclusion:function(){x=g+h*(255-g-g)/255,E=f+u*(255-f-f)/255,k=y+m*(255-y-y)/255},hue:function(){a(h,u,m,n(g,f,y)),t(x,E,k,e(g,f,y))},saturation:function(){a(g,f,y,n(h,u,m)),t(x,E,k,e(g,f,y))},luminosity:function(){t(g,f,y,e(h,u,m))},color:function(){t(h,u,m,e(g,f,y))},add:function(){x=i(g+h,255),E=i(f+u,255),k=i(y+m,255)},subtract:function(){x=o(g-h,0),E=o(f-u,0),k=o(y-m,0)},average:function(){x=(g+h)/2,E=(f+u)/2,k=(y+m)/2},negation:function(){x=255-r(255-h-g),E=255-r(255-u-f),k=255-r(255-m-y)}},c=this.nativeModes=C.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=xe.getContext(1,1),h,u,m,p,g,f,y,v,x,E,k;l&&(C.each(s,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}),xe.release(l)),this.process=function(e,t,n,a,r){var o=t.canvas,d="normal"===e;if(d||c[e])n.save(),n.setTransform(1,0,0,1,0,0),n.globalAlpha=a,d||(n.globalCompositeOperation=e),n.drawImage(o,r.x,r.y),n.restore();else{var w=s[e];if(!w)return;for(var b=n.getImageData(r.x,r.y,o.width,o.height),_=b.data,C=t.getImageData(0,0,o.width,o.height).data,S=0,T=_.length;Sw&&(s["stop-opacity"]=w),t.appendChild(Ee.create("stop",s,f))}h(e,t,"color")}return"url(#"+t.id+")"}function l(t){var n=Ee.create("text",e(t._matrix,!0),f);return n.textContent=t._content,n}function d(e,t,n){var a={},i=!n&&e.getParent(),r=[];return null!=e._name&&(a.id=e._name),C.each(ke,function(t){var n=t.get,o=t.type,l=e[n]();if(t.exportFilter?t.exportFilter(e,l):!i||!C.equals(i[n](),l)){if("color"===o&&null!=l){var d=l.getAlpha();1>d&&(a[t.attribute+"-opacity"]=d)}"style"===o?r.push(t.attribute+": "+l):a[t.attribute]=null==l?"none":"color"===o?l.gradient?s(l,e):l.toCSS(!0):"array"===o?l.join(","):"lookup"===o?t.toSVG[l]:l}}),r.length&&(a.style=r.join(";")),1===a.opacity&&delete a.opacity,e._visible||(a.visibility="hidden"),Ee.set(t,a,f)}function c(e,t){return w||(w={ids:{},svgs:{}}),e&&w.svgs[t+"-"+(e._id||e.__id||(e.__id=L.get("svg")))]}function h(e,t,n){w||c();var a=w.ids[n]=(w.ids[n]||0)+1;t.id=n+"-"+a,w.svgs[n+"-"+(e._id||e.__id)]=t}function u(e,t){var n=e,a=null;if(w){for(var r in n="svg"===e.nodeName.toLowerCase()&&e,w.svgs)a||(!n&&(n=Ee.create("svg"),n.appendChild(e)),a=n.insertBefore(Ee.create("defs"),n.firstChild)),a.appendChild(w.svgs[r]);w=null}return t.asString?new v.XMLSerializer().serializeToString(n):n}function m(e,t,n){var a=g[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&&d(e,i,n)}function p(e){return e||(e={}),f=new z(e.precision),e}var g={Group:t,Layer:t,Raster:n,Path:a,Shape:i,CompoundPath:r,SymbolItem:o,PointText:l},f,w;V.inject({exportSVG:function(e){return e=p(e),u(m(this,e,!0),e)}}),M.inject({exportSVG:function(t){t=p(t);var n=this._children,a=this.getView(),r=C.pick(t.bounds,"view"),o=t.matrix||"view"===r&&a._matrix,s=o&&q.read([o]),d="view"===r?new O([0,0],a.getViewSize()):"content"===r?V._getBounds(n,s,{stroke:!0}).rect:O.read([r],0,{readNull:!0}),c={version:"1.1",xmlns:Ee.svg,"xmlns:xlink":Ee.xlink};d&&(c.width=d.width,c.height=d.height,(d.x||d.y)&&(c.viewBox=f.rectangle(d)));var h=Ee.create("svg",c,f),g=h;s&&!s.isIdentity()&&(g=h.appendChild(Ee.create("g",e(s),f)));for(var w=0,y=n.length;w 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