-
Notifications
You must be signed in to change notification settings - Fork 1
/
app-bundle.js
1 lines (1 loc) · 17.8 KB
/
app-bundle.js
1
(()=>{"use strict";Math.lerp=function(t,e,n){return t+(e-t)*n},Math.TWO_PI=2*Math.PI;var t,e=function(){function t(t,e){this.x=t,this.y=e}return t.prototype.clone=function(){return new t(this.x,this.y)},t.newZero=function(){return new t(0,0)},t.newOne=function(){return new t(1,1)},t.lerp=function(t,e,n,r){return t.x=Math.lerp(e.x,n.x,r),t.y=Math.lerp(e.y,n.y,r),t},t.add=function(t,e,n){return t.x=e.x+n.x,t.y=e.y+n.y,t},t.rotate=function(t,e,n){var r=Math.sin(n),i=Math.cos(n);return t.x=e.x*i-e.y*r,t.y=e.x*r+e.y*i,t},t.transform=function(t,e,n){return t.x=e.x*n.m00+e.y*n.m10+n.m20,t.y=e.x*n.m01+e.y*n.m11+n.m21,t},t.min=function(t,e,n){return t.x=Math.min(e.x,n.x),t.y=Math.min(e.y,n.y),t},t.max=function(t,e,n){return t.x=Math.max(e.x,n.x),t.y=Math.max(e.y,n.y),t},t.zero=t.newZero(),t.one=t.newOne(),t}(),n=function(){function t(t,e,n,r,i,o){this.m00=t,this.m01=e,this.m10=n,this.m11=r,this.m20=i,this.m21=o}return t.newIdentity=function(){return new t(1,0,0,1,0,0)},t.multiply=function(t,e,n){return t.m00=e.m00*n.m00+e.m10*n.m01,t.m01=e.m01*n.m00+e.m11*n.m01,t.m10=e.m00*n.m10+e.m10*n.m11,t.m11=e.m01*n.m10+e.m11*n.m11,t.m20=e.m00*n.m20+e.m10*n.m21+e.m20,t.m21=e.m01*n.m20+e.m11*n.m21+e.m21,t},t.fromSRT=function(t,e,n,r){var i=Math.sin(n),o=Math.cos(n);return t.m00=o*e.x,t.m01=i*e.x,t.m10=-i*e.y,t.m11=o*e.y,t.m20=r.x*o*e.x+r.y*i*e.x,t.m21=r.y*-i*e.y+r.y*o*e.y,t},t}(),r={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return t*(2-t)},easeInOutQuad:function(t){return t<.5?2*t*t:(4-2*t)*t-1},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return--t*t*t+1},easeInOutCubic:function(t){return t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return 1- --t*t*t*t},easeInOutQuart:function(t){return t<.5?8*t*t*t*t:1-8*--t*t*t*t},easeInQuint:function(t){return t*t*t*t*t},easeOutQuint:function(t){return 1+--t*t*t*t*t},easeInOutQuint:function(t){return t<.5?16*t*t*t*t*t:1+16*--t*t*t*t*t}};!function(t){t[t.image=0]="image",t[t.fill=1]="fill",t[t.stroke=2]="stroke",t[t.text=3]="text",t[t.none=4]="none"}(t||(t={}));var i,o=function(){function r(r,i){var o=this;void 0===i&&(i={}),this.points=r,this.children=[],this._worldPoints=[],this.parent=null,this.type=t.stroke,this.translation=e.newZero(),this.rotation=0,this.scale=e.newOne(),this._pointsDirty=!0,this._worldBoundingRect=null,this._localTransform=n.newIdentity(),this._absTransform=n.newIdentity(),Object.keys(i).forEach((function(t){return o[t]=i[t]}))}return Object.defineProperty(r.prototype,"absTransform",{get:function(){return n.fromSRT(this._localTransform,this.scale,this.rotation,this.translation),null===this.parent?this._localTransform:(n.multiply(this._absTransform,this.parent.absTransform,this._localTransform),this._absTransform)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"worldPoints",{get:function(){if(this._pointsDirty){for(var t=0;t<this.points.length;t++)this._worldPoints[t]||(this._worldPoints[t]=e.newZero()),e.transform(this._worldPoints[t],this.points[t],this.absTransform);this._pointsDirty=!1}return this._worldPoints},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"worldBoundingRect",{get:function(){if(null===this._worldBoundingRect){for(var t=new e(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),n=new e(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),r=0,i=this.worldPoints;r<i.length;r++){var o=i[r];e.min(t,t,o),e.max(n,n,o)}this._worldBoundingRect={x:t.x,y:t.y,width:n.x-t.x,height:n.y-t.y}}return this._worldBoundingRect},enumerable:!1,configurable:!0}),r.prototype.worldContains=function(t,e){for(var n=!1,r=this.worldPoints,i=0,o=r.length-1;i<r.length;o=i++)r[i].y>e!=r[o].y>e&&t<(r[o].x-r[i].x)*(e-r[i].y)/(r[o].y-r[i].y)+r[i].x&&(n=!n);return n},r.prototype.push=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];for(var r=0,i=e;r<i.length;r++){var o=i[r];o.parent=this}return(t=this.children).push.apply(t,e),this},r.prototype.setDirty=function(){this._worldBoundingRect=null,this._pointsDirty=!0;for(var t=0,e=this.children;t<e.length;t++)e[t].setDirty()},r.empty=function(t){return new r([],t)},r.hex=function(t,n,i,o){var s=.25*i,a=s*Math.sqrt(3);return new r([new e(t+0,n-2*s),new e(t+a,n-s),new e(t+a,n+s),new e(t+0,n+2*s),new e(t-a,n+s),new e(t-a,n-s)],o)},r.rect=function(t,n,i,o,s){return new r([new e(t,n),new e(t+i,n),new e(t+i,n+o),new e(t,n+o)],s)},r}(),s=function(){function e(t,e,n,r){void 0===n&&(n=.5),void 0===r&&(r=.5),this.canvas=t,this.shapes=e,this.translationFactorX=n,this.translationFactorY=r,this.ctx=t.getContext("2d")}return e.prototype.step=function(t){var e=this.canvas,n=this.ctx;this.ensureCanvasValid(e,n),n.clearRect(-e.translationX,-e.translationY,e.width,e.height),this.renderShapes(n,this.shapes)},e.prototype.renderShapes=function(e,n){for(var r=0,i=n;r<i.length;r++){var o=i[r],s=o.worldPoints;if(0!==s.length){e.beginPath();var a=s[s.length-1];e.moveTo(a.x,a.y);for(var h=0,l=s;h<l.length;h++)a=l[h],e.lineTo(a.x,a.y);switch(o.type){case t.image:var u=o.image,p=o.worldBoundingRect,c=p.x,f=p.y,d=p.width,y=p.height;e.drawImage(u,0,0,u.width,u.height,c,f,d,y);break;case t.fill:e.fillStyle=this.styleOrDefault(o.fillStyle),e.fill();break;case t.stroke:e.strokeStyle=this.styleOrDefault(o.strokeStyle),e.lineWidth=this.lineWidthOrDefault(o),e.stroke();break;case t.text:e.font=this.fontOrDefault(o),e.textAlign=this.textAlignOrDefault(o),e.fillStyle=this.styleOrDefault(o.fillStyle);var m=o.worldBoundingRect;c=m.x,f=m.y,y=m.height,e.fillText(o.text,c,f+.5*y)}o.children.length>0&&(e.save(),e.clip(),this.renderShapes(e,o.children),e.restore())}}},e.prototype.styleOrDefault=function(t){return null!=t?t:"#EA2E49"},e.prototype.fontOrDefault=function(t){var e;return t.worldBoundingRect.height+"px "+(null!==(e=t.font)&&void 0!==e?e:"Arial")},e.prototype.textAlignOrDefault=function(t){var e;return null!==(e=t.textAlign)&&void 0!==e?e:"start"},e.prototype.lineWidthOrDefault=function(t){var e;return null!==(e=t.lineWidth)&&void 0!==e?e:8},e.prototype.ensureCanvasValid=function(t,e){t.clientWidth===t.width&&t.clientHeight===t.height||(t.width=t.clientWidth,t.height=t.clientHeight,t.translationX=t.width*this.translationFactorX,t.translationY=t.height*this.translationFactorY,e.translate(t.translationX,t.translationY),e.lineCap="round",e.lineJoin="round")},e}();!function(t){t[t.pending=0]="pending",t[t.fulfilled=1]="fulfilled",t[t.rejected=2]="rejected"}(i||(i={}));var a,h=function(){function t(t){var e,n,o;void 0===t&&(t={}),this._children=[],this.elapsed=0,this.status=i.pending,this.manager=null,this.duration=null!==(e=t.duration)&&void 0!==e?e:1e3,this.endless=null!==(n=t.endless)&&void 0!==n&&n,this.easingFn=null!==(o=t.easingFn)&&void 0!==o?o:r.linear}return Object.defineProperty(t.prototype,"progress",{get:function(){return this.easingFn(Math.min(this.elapsed/this.duration,1))},enumerable:!1,configurable:!0}),t.prototype.init=function(){},t.prototype.push=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return(t=this._children).push.apply(t,e),this},t.prototype.resolve=function(){this.status=i.fulfilled},t.prototype.reject=function(){this.status=i.rejected},t.prototype.step=function(t){this.elapsed+=t,1===this.progress&&this.resolve()},t}(),l=function(){function t(t,e){this.canvas=t,this.shapes=e,this.processes=[],this.timeScale=1}return Object.defineProperty(t.prototype,"resolvableProcesses",{get:function(){return this.processes.filter((function(t){return!t.endless}))},enumerable:!1,configurable:!0}),t.prototype.push=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0,r=t;n<r.length;n++){var i=r[n];i.manager=this,i.init(),this.processes.push(i)}return this},t.prototype.step=function(t){for(var e=this.processes.length-1;e>=0;e--){var n=this.processes[e];n.step(t*this.timeScale),n.status===i.fulfilled&&(this.processes.splice(e,1),this.push.apply(this,n._children))}},t.prototype.resolveAll=function(){for(;this.resolvableProcesses.length>0;)this.step(1e5)},t}(),u=(a=function(t,e){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}a(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return u(e,t),e.prototype.step=function(e){t.prototype.step.call(this,e)},e}(h),c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return u(e,t),e.prototype.step=function(t){(null===this.manager||this.manager.resolvableProcesses.length<=1)&&this.resolve()},e}(h),f=function(t){function n(e){var n=t.call(this,e)||this;return n.shape=e.shape,n.target=e.target,n}return u(n,t),n.prototype.step=function(n){t.prototype.step.call(this,n),e.lerp(this.shape.translation,e.zero,this.target,this.progress),this.shape.setDirty()},n}(h),d=function(t){function e(e){var n=t.call(this,e)||this;return n.shape=e.shape,n.target=e.target,n}return u(e,t),e.prototype.step=function(e){t.prototype.step.call(this,e),this.shape.rotation=this.progress*this.target,this.shape.setDirty()},e}(h),y=function(t){function e(e){var n=t.call(this,e)||this;return n.command=e.command,n}return u(e,t),e.prototype.step=function(t){this.command(),this.resolve()},e}(h),m=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),v=function(t){function n(e){var n,r,i=t.call(this,e)||this;return i.x=null!==(n=e.x)&&void 0!==n?n:0,i.y=null!==(r=e.y)&&void 0!==r?r:0,i.width=e.width,i.height=e.height,i.shape=e.shape,i.target=o.rect(i.x,i.y,i.width,i.height),x(i.shape,4,i.x,i.y),i.shape.points[2]=i.target.points[3].clone(),i.shape.points[3]=i.target.points[3].clone(),i}return m(n,t),n.prototype.step=function(n){t.prototype.step.call(this,n);var r=this.progress,i=this.shape.points,o=this.target.points;e.lerp(i[1],o[0],o[1],r),e.lerp(i[2],o[3],o[2],r),this.shape.setDirty()},n}(h),g=function(t){function n(e){var n,r,i=t.call(this,e)||this;return i.phase=0,i.x=null!==(n=e.x)&&void 0!==n?n:0,i.y=null!==(r=e.y)&&void 0!==r?r:0,i.width=e.width,i.height=e.height,i.shape=e.shape,i.target=o.rect(i.x,i.y,i.width,i.height),i.duration=i.duration/2,x(i.shape,5,i.x,i.y),i}return m(n,t),n.prototype.step=function(t){this.elapsed+=t;var n=this.progress,r=this.shape.points,i=this.target.points;0===this.phase?(e.lerp(r[0],i[0],i[1],n),e.lerp(r[1],i[0],i[1],n),e.lerp(r[3],i[0],i[3],n),e.lerp(r[4],i[0],i[3],n),1===n&&_(this)):1===this.phase&&(e.lerp(r[0],i[1],i[2],n),e.lerp(r[4],i[3],i[2],n),1===n&&(r.length=4,this.resolve())),this.shape.setDirty()},n}(h),w=function(t){function n(e){var n,r,i=t.call(this,e)||this;return i.phase=0,i.x=null!==(n=e.x)&&void 0!==n?n:0,i.y=null!==(r=e.y)&&void 0!==r?r:0,i.diameter=e.diameter,i.shape=e.shape,i.target=o.hex(i.x,i.y,i.diameter),i.duration=i.duration/3,x(i.shape,6,i.x,i.y),i}return m(n,t),n.prototype.step=function(t){this.elapsed+=t;var n=this.progress,r=this.shape.points,i=this.target.points;0===this.phase?(e.lerp(r[0],e.zero,i[2],n),e.lerp(r[1],e.zero,i[2],n),e.lerp(r[2],e.zero,i[2],n),e.lerp(r[3],e.zero,i[5],n),e.lerp(r[4],e.zero,i[5],n),e.lerp(r[5],e.zero,i[5],n),1===n&&_(this)):1===this.phase?(e.lerp(r[1],i[2],i[3],n),e.lerp(r[2],i[2],i[3],n),e.lerp(r[4],i[5],i[0],n),e.lerp(r[5],i[5],i[0],n),1===n&&_(this)):2===this.phase&&(e.lerp(r[2],i[3],i[4],n),e.lerp(r[5],i[0],i[1],n),1===n&&this.resolve()),this.shape.setDirty()},n}(h);function x(t,n,r,i){var o,s=Array.apply(null,Array(n)).map((function(t){return new e(r,i)}));(o=t.points).push.apply(o,s),t.setDirty()}function _(t){t.phase++,t.elapsed=0}for(var b=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),O=function(t){function n(n){var r,i=t.call(this,n)||this;i.phase=0,i.hoverShapes=[],i.pa=e.newZero(),i.pb=e.newZero(),i.shape=n.shape,i.numShapes=null!==(r=n.numShapes)&&void 0!==r?r:10,i.minLineWidth=n.minLineWidth,i.maxLineWidth=n.maxLineWidth;for(var s=0;s<i.numShapes;s++){var a=i.shape.points[0],h=a.clone(),l=a.clone();i.hoverShapes.push(new o([h,e.add(l,l,e.one)],{translation:i.shape.translation,strokeStyle:i.shape.strokeStyle,lineWidth:i.minLineWidth+(i.maxLineWidth-i.minLineWidth)*s/i.numShapes}))}return i.duration=i.duration/i.shape.points.length,i.endless=!0,i}return b(n,t),n.prototype.init=function(){var t;null!==this.manager&&(t=this.manager.shapes).push.apply(t,this.hoverShapes)},n.prototype.step=function(t){this.elapsed+=t;for(var n=this.hoverShapes,r=this.progress,i=this.shape.points,o=0;o<n.length-1;o++){var s=n[o],a=n[o+1];s.points[0].x=a.points[0].x,s.points[0].y=a.points[0].y,s.points[1].x=a.points[1].x,s.points[1].y=a.points[1].y}var h,l,u=n[n.length-1],p=i[this.phase],c=i[(this.phase+1)%i.length];e.lerp(u.points[0],p,c,r),e.lerp(u.points[1],e.add(this.pa,p,e.one),e.add(this.pb,c,e.one),r),1===r&&(h=this,l=i.length,h.phase=(h.phase+1)%l,h.elapsed=0);for(var f=0,d=this.hoverShapes;f<d.length;f++)d[f].setDirty()},n.prototype.resolve=function(){if(t.prototype.resolve.call(this),null!==this.manager)for(var e=this.manager.shapes,n=0,r=this.hoverShapes;n<r.length;n++){var i=r[n];e.splice(e.indexOf(i),1)}},n}(h),I=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),S=function(t){function e(e){void 0===e&&(e={});var n=t.call(this,e)||this;return n.onKeyDown=function(t){27===t.keyCode&&null!==n.manager&&n.manager.resolveAll()},window.addEventListener("keydown",n.onKeyDown),n.endless=!0,n}return I(e,t),e.prototype.step=function(t){},e.prototype.resolve=function(){t.prototype.resolve.call(this),window.removeEventListener("keydown",this.onKeyDown)},e}(h),P=function(t){function e(e){var n=t.call(this,e)||this;return n.hoverEffect=null,n.onMouseMove=function(t){if(null!==n.manager){for(var e=n.manager.canvas,r=t.pageX-e.offsetLeft-e.translationX,i=t.pageY-e.offsetTop-e.translationY,o=null,s=0,a=n.shapes;s<a.length;s++){var h=a[s];if(h.worldContains(r,i)){o=h;break}}null!==o?(document.body.style.cursor="pointer",null===n.hoverEffect&&(n.hoverEffect=new O({shape:o,color:n.primaryColor,maxLineWidth:14,minLineWidth:6,duration:1250,numShapes:14}),n.manager.push(n.hoverEffect))):null!==n.hoverEffect&&n.resolveHoverEffect()}},n.onClick=function(t){null!==n.hoverEffect&&(window.open(n.hoverEffect.shape.url),n.resolveHoverEffect())},n.shapes=e.shapes,window.addEventListener("mousemove",n.onMouseMove),window.addEventListener("click",n.onClick),n.endless=!0,n}return I(e,t),e.prototype.step=function(t){},e.prototype.resolve=function(){t.prototype.resolve.call(this),window.removeEventListener("click",this.onClick),window.removeEventListener("mousemove",this.onMouseMove)},e.prototype.resolveHoverEffect=function(){document.body.style.cursor="auto",this.hoverEffect.resolve(),this.hoverEffect=null},e}(h),E=[{color:"#fff",path:"me.png",width:96,height:96},{color:"#1da1f2",path:"twitter.png",width:48,height:48,url:"https://twitter.com/discosultan"},{color:"#171516",path:"github.png",width:48,height:48,url:"https://github.com/discosultan"},{color:"#0274b3",path:"linkedin.png",width:48,height:48,url:"https://www.linkedin.com/in/jvarus/"}],T=0,M=0,k=E;M<k.length;M++){var D=k[M];D.img=new Image,D.img.src="./assets/"+D.path,D.img.onload=function(){++T>=E.length&&j()}}function j(){var n,i,a=null!==(n=document.getElementById("canvas"))&&void 0!==n?n:function(){throw Error("Canvas not available.")}(),h=null!==(i=a.getContext("2d"))&&void 0!==i?i:function(){throw Error("2d context not available.")}(),u=[],m=new l(a,u),x=new s(a,u,.36),_="#fff",b=r.easeInOutCubic,O=100,I=new e(-1,1),T="Montserrat";m.timeScale=.5,h.font="2px "+T,h.fillText("x",0,0);var M=new e(O,0),k=e.rotate(e.newZero(),M,Math.PI/3),D=e.rotate(e.newZero(),M,Math.PI),j=e.rotate(e.newZero(),M,5*Math.PI/3),A=o.empty({strokeStyle:_}),W=Q({url:E[1].url}),C=Q({url:E[2].url}),F=Q({url:E[3].url});u.push(A);var L=o.empty({type:t.none,scale:I}),N=Q({scale:I}),R=Q({scale:I,translation:k}),Y=Q({scale:I,translation:D}),B=Q({scale:I,translation:j});function Q(t){return void 0===t&&(t={}),t.strokeStyle=_,o.hex(0,0,O,t)}function Z(e,n){var r=o.rect(-50,-50,O,O,{type:t.fill,fillStyle:n.color});e.push(r);var i=o.rect(.5*-n.width,.5*-n.height,n.width,n.height,{type:t.image,image:n.img});e.push(i)}L.push(N,R,Y,B),Z(N,E[0]),Z(R,E[1]),Z(Y,E[2]),Z(B,E[3]);var z=o.empty({type:t.none,translation:new e(60,-25)});function V(e,n,r){return o.rect(0,0,300,25,{type:t.text,font:T,text:e,fillStyle:_,translation:n,scale:r})}function X(t,e){return new y({command:function(){return u.push(t)}}).push(new f({shape:t,easingFn:b,duration:300,target:e}))}u.push(z),z.push(V("JAANUS VARUS",new e(0,10),new e(1,1))),z.push(V("Amsterdam, The Netherlands",new e(0,60),new e(1,.6))),m.push(new p({duration:0}).push(new w({shape:A,easingFn:b,diameter:O,duration:600}).push(new d({shape:A,easingFn:b,target:-Math.TWO_PI,duration:300}).push(X(C,D),X(F,j),X(W,k))),(new c).push(new y({command:function(){return u.push(L)}}).push(new g({shape:L,x:-100,y:-150,width:250,height:300,duration:400})),new v({shape:z,width:300,height:50,duration:400}),new P({shapes:[W,C,F]})))),m.push(new S);var H=0;window.requestAnimationFrame((function t(e){var n=e-H;H=e,m.step(n),x.step(n),window.requestAnimationFrame(t)})),window.renderer=x,window.processManager=m}})();