\n \n '),e.appendChild(i),r._.appendChild(e);var s=document.createElementNS("http://www.w3.org/2000/svg","rect");s.setAttribute("width","".concat(this.size[0])),s.setAttribute("height","".concat(this.size[1])),s.classList.add("background"),r._.appendChild(s);var a=document.createElementNS("http://www.w3.org/2000/svg","g");a.setAttribute("transform","translate(".concat(E,", ").concat(E,")"));var c=document.createElementNS("http://www.w3.org/2000/svg","rect");c.setAttribute("width","".concat(this.size[0]-160)),c.setAttribute("height","".concat(this.size[1]-160)),c.setAttribute("fill","url(#backGradient)"),a.appendChild(c),r._.appendChild(a),r.createGroup("ps","none","none");var h=function(t,e,n,i){for(var r,s=[],o=0;o1)for(var c=0;ce[1][0]&&pe[0][0]&&p>e[1][0]&&p0&&x.push(l(p,this.size,fxrand)),N>1&&x.push(l(p+Math.PI*(.5+.5*fxrand()),this.size,fxrand)),h.forEach(function(e){(e=e.reverse()).forEach(function(e){var n;fxrand()fxrand()?(n=u(e,fxrand,t.schrinkTile(),1)).poly.length>0&&t.drawBox(n):(n=$(e,fxrand,t.schrinkTile(),G,S,1)).clip&&n.poly.length>0&&t.boxes.push(n)),t.drawSolid(e.pts,"tile")})}),this.boxes.forEach(function(e){return t.drawBox(e)}),this.boxes=[],x.forEach(function(e){t.drawSolid(e.clip,"col-0"),e.tile.forEach(function(n,i){n.forEach(function(n){if(ifxrand()){if(.5>fxrand()){var c=u(a,fxrand,t.schrinkTile(),1);c.poly.length>1&&t.drawBox(c)}else{var l=_(a,S,G,1);l.poly.length>1&&t.drawBox(l)}}else t.drawSolid(n.pts,"tile")}else t.drawSolid(n.pts,"tile")})})}),this.boxes.forEach(function(e){return t.drawBox(e)}),this.blockByFrame=this.shapes.length/450,this.anim()},anim:function(){if(U.shapeDrawn0&&t.poly.map(function(t){t.length>0&&e.drawSolid(t,"col-".concat(n))}),void 0!==t.shadowArea&&t.shadowArea.length>0&&t.shadowArea.forEach(function(t,i){t.length>0&&e.drawSolid(t,"col-".concat(n,"-shdw-").concat(i))}),void 0!==t.glintArea&&t.glintArea.length>0&&t.glintArea.forEach(function(t){t.length>0&&e.drawSolid(t,"col-".concat(n,"-glnt"))}),t.front.length>1){this.drawSolid(t.front,"col-".concat(n));var i,r=fxrand(),s={pts:[t.front[3],t.front[0],t.front[1],t.front[2]]},o=(t.color+1)%q.length;if(r<.14){var a=u(s,fxrand,this.schrinkTile(),o);a.poly.length>0&&this.drawBox(a)}else if(r<.28)(i=$(s,fxrand,this.schrinkTile(),G,S,o)).front.length>1&&this.drawSolid(i.front,"col-".concat(n)),i.poly.length>0&&this.drawBox(i);else if(r<.42){var l=_(s,S,G,t.color);l.poly.length>0&&this.drawBox(l)}else if(r<.57){var h=function(t,e,n,i,r,s){var o={poly:[],shadowArea:[],glintArea:[],clip:[],front:[],color:s},a=p(t.pts,i);if(a){var l=g(a),h=c([l[0],l[1]],.5),f=c([l[2],h],.5),d=[c([l[0],l[1]],.25),c([l[0],l[1]],.75)];o.poly=[l],o.shadowArea=[[l[0],d[0],f,l[2]],x([f],d,!0)]}return o}(s,0,fxrand,this.schrinkTile(),0,o);h.poly.length>0&&this.drawBox(h)}else if(r<.71){var f=function(t,e,n,i,r,s){var o={poly:[],shadowArea:[],glintArea:[],clip:[],front:[],color:s},a=p(t.pts,i);if(a){var c=Math.atan2(t.pts[3].y-t.pts[0].y,t.pts[3].x-t.pts[0].x),l=1+Math.ceil(n()*e)*i,h=Math.PI*(r?.75:1.25),f=g(a),d=f.map(function(t){return{x:t.x+Math.cos(c+h)*l,y:t.y+Math.sin(c+h)*l}});o.poly=[d,[f[0],d[0],d[2],f[2]]],o.shadowArea=[[f[0],f[1],d[1],d[0]]]}return o}(s,S,fxrand,this.schrinkTile(),G,o);f.poly.length>0&&this.drawBox(f)}else(i=$(s,fxrand,this.schrinkTile(),G,S,o)).front.length>1&&this.drawSolid(i.front,"col-".concat(n)),i.poly.length>0&&this.drawBox(i)}},downloadSVG:function(t){r.download(t)}};U.draw(),r._.addEventListener("click",function(t){U.shapeDrawn=0,r.clearGroup("ps"),U.blockByFrame=U.shapes.length/900,U.fr=window.requestAnimationFrame(U.anim)}),document.addEventListener("keypress",function(t){["D","d"].includes(t.key)&&U.downloadSVG("Kallax - ".concat(V," - Nicolas Lebrun"))})})()})();