0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-12-12 17:24:57 +01:00
doodle3d-client/www/printmanager/js/svg.min.js

2 lines
44 KiB
JavaScript
Raw Normal View History

!function(t,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.SVG=e()}(this,function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i}function e(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function i(t){return 4==t.length?["#",t.substring(1,2),t.substring(1,2),t.substring(2,3),t.substring(2,3),t.substring(3,4),t.substring(3,4)].join(""):t}function n(t){var e=t.toString(16);return 1==e.length?"0"+e:e}function r(t,e,i){return(null==e||null==i)&&(null==i?i=t.height/t.width*e:null==e&&(e=t.width/t.height*i)),{width:e,height:i}}function s(t,e){return"number"==typeof t.from?t.from+(t.to-t.from)*e:t instanceof l.Color||t instanceof l.Number?t.at(e):1>e?t.from:t.to}function h(t){for(var e=0,i=t.length,n="";i>e;e++)n+=t[e][0],null!=t[e][1]&&(n+=t[e][1],null!=t[e][2]&&(n+=" ",n+=t[e][2],null!=t[e][3]&&(n+=" ",n+=t[e][3],n+=" ",n+=t[e][4],null!=t[e][5]&&(n+=" ",n+=t[e][5],n+=" ",n+=t[e][6],null!=t[e][7]&&(n+=" ",n+=t[e][7])))));return n+" "}function o(t){t.x2=t.x+t.width,t.y2=t.y+t.height,t.cx=t.x+t.width/2,t.cy=t.y+t.height/2}function a(t){if(t.matrix){var e=t.matrix.replace(/\s/g,"").split(",");6==e.length&&(t.a=parseFloat(e[0]),t.b=parseFloat(e[1]),t.c=parseFloat(e[2]),t.d=parseFloat(e[3]),t.e=parseFloat(e[4]),t.f=parseFloat(e[5]))}return t}function u(t){var e=t.toString().match(l.regex.reference);return e?e[1]:void 0}var l=this.SVG=function(t){return l.supported?(t=new l.Doc(t),l.parser||l.prepare(t),t):void 0};if(l.ns="http://www.w3.org/2000/svg",l.xmlns="http://www.w3.org/2000/xmlns/",l.xlink="http://www.w3.org/1999/xlink",l.did=1e3,l.eid=function(t){return"Svgjs"+t.charAt(0).toUpperCase()+t.slice(1)+l.did++},l.create=function(t){var e=document.createElementNS(this.ns,t);return e.setAttribute("id",this.eid(t)),e},l.extend=function(){var t,e,i,n;for(t=[].slice.call(arguments),e=t.pop(),n=t.length-1;n>=0;n--)if(t[n])for(i in e)t[n].prototype[i]=e[i];l.Set&&l.Set.inherit&&l.Set.inherit()},l.prepare=function(t){var e=document.getElementsByTagName("body")[0],i=(e?new l.Doc(e):t.nested()).size(2,0),n=l.create("path");i.node.appendChild(n),l.parser={body:e||t.parent,draw:i.style("opacity:0;position:fixed;left:100%;top:100%;overflow:hidden"),poly:i.polyline().node,path:n}},l.supported=function(){return!!document.createElementNS&&!!document.createElementNS(l.ns,"svg").createSVGRect}(),!l.supported)return!1;l.get=function(t){var e=document.getElementById(u(t)||t);return e?e.instance:void 0},l.invent=function(t){var e="function"==typeof t.create?t.create:function(){this.constructor.call(this,l.create(t.create))};return t.inherit&&(e.prototype=new t.inherit),t.extend&&l.extend(e,t.extend),t.construct&&l.extend(t.parent||l.Container,t.construct),e},"function"!=typeof t&&(t.prototype=window.Event.prototype,window.CustomEvent=t),function(t){for(var e=0,i=["moz","webkit"],n=0;n<i.length&&!window.requestAnimationFrame;++n)t.requestAnimationFrame=t[i[n]+"RequestAnimationFrame"],t.cancelAnimationFrame=t[i[n]+"CancelAnimationFrame"]||t[i[n]+"CancelRequestAnimationFrame"];t.requestAnimationFrame=t.requestAnimationFrame||function(i){var n=(new Date).getTime(),r=Math.max(0,16-(n-e)),s=t.setTimeout(function(){i(n+r)},r);return e=n+r,s},t.cancelAnimationFrame=t.cancelAnimationFrame||t.clearTimeout}(window),l.regex={unit:/^(-?[\d\.]+)([a-z%]{0,2})$/,hex:/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,rgb:/rgb\((\d+),(\d+),(\d+)\)/,reference:/#([a-z0-9\-_]+)/i,isHex:/^#[a-f0-9]{3,6}$/i,isRgb:/^rgb\(/,isCss:/[^:]+:[^;]+;?/,isBlank:/^(\s+)?$/,isNumber:/^-?[\d\.]+$/,isPercent:/^-?[\d\.]+%$/,isImage:/\.(jpg|jpeg|png|gif)(\?[^=]+.*)?/i,isEvent:/^[\w]+:[\w]+$/},l.defaults={matrix:"1 0 0 1 0 0",attrs:{"fill-opacity":1,"stroke-opacity":1,"stroke-width":0,"stroke-linejoin":"miter","stroke-linecap":"butt",fill:"#000000",stroke:"#000000",opacity:1,x:0,y:0,cx:0,cy:0,width:0,height:0,r:0,rx:0,ry:0,offset:0,"stop-opacity":1,"stop-color":"#000000","font-size":16,"font-fa
}}}),l.Use=l.invent({create:"use",inherit:l.Shape,extend:{element:function(t){return this.target=t,this.attr("href","#"+t,l.xlink)}},construct:{use:function(t){return this.put(new l.Use).element(t)}}}),l.Rect=l.invent({create:"rect",inherit:l.Shape,construct:{rect:function(t,e){return this.put((new l.Rect).size(t,e))}}}),l.Ellipse=l.invent({create:"ellipse",inherit:l.Shape,extend:{x:function(t){return null==t?this.cx()-this.attr("rx"):this.cx(t+this.attr("rx"))},y:function(t){return null==t?this.cy()-this.attr("ry"):this.cy(t+this.attr("ry"))},cx:function(t){return null==t?this.attr("cx"):this.attr("cx",new l.Number(t).divide(this.trans.scaleX))},cy:function(t){return null==t?this.attr("cy"):this.attr("cy",new l.Number(t).divide(this.trans.scaleY))},width:function(t){return null==t?2*this.attr("rx"):this.attr("rx",new l.Number(t).divide(2))},height:function(t){return null==t?2*this.attr("ry"):this.attr("ry",new l.Number(t).divide(2))},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr({rx:new l.Number(i.width).divide(2),ry:new l.Number(i.height).divide(2)})}},construct:{circle:function(t){return this.ellipse(t,t)},ellipse:function(t,e){return this.put(new l.Ellipse).size(t,e).move(0,0)}}}),l.Line=l.invent({create:"line",inherit:l.Shape,extend:{x:function(t){var e=this.bbox();return null==t?e.x:this.attr({x1:this.attr("x1")-e.x+t,x2:this.attr("x2")-e.x+t})},y:function(t){var e=this.bbox();return null==t?e.y:this.attr({y1:this.attr("y1")-e.y+t,y2:this.attr("y2")-e.y+t})},cx:function(t){var e=this.bbox().width/2;return null==t?this.x()+e:this.x(t-e)},cy:function(t){var e=this.bbox().height/2;return null==t?this.y()+e:this.y(t-e)},width:function(t){var e=this.bbox();return null==t?e.width:this.attr(this.attr("x1")<this.attr("x2")?"x2":"x1",e.x+t)},height:function(t){var e=this.bbox();return null==t?e.height:this.attr(this.attr("y1")<this.attr("y2")?"y2":"y1",e.y+t)},size:function(t,e){var i=r(this.bbox(),t,e);return this.width(i.width).height(i.height)},plot:function(t,e,i,n){return this.attr({x1:t,y1:e,x2:i,y2:n})}},construct:{line:function(t,e,i,n){return this.put((new l.Line).plot(t,e,i,n))}}}),l.Polyline=l.invent({create:"polyline",inherit:l.Shape,construct:{polyline:function(t){return this.put(new l.Polyline).plot(t)}}}),l.Polygon=l.invent({create:"polygon",inherit:l.Shape,construct:{polygon:function(t){return this.put(new l.Polygon).plot(t)}}}),l.extend(l.Polyline,l.Polygon,{morphArray:l.PointArray,plot:function(t){return this.attr("points",this.array=new l.PointArray(t,[[0,0]]))},move:function(t,e){return this.attr("points",this.array.move(t,e))},x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},width:function(t){var e=this.bbox();return null==t?e.width:this.size(t,e.height)},height:function(t){var e=this.bbox();return null==t?e.height:this.size(e.width,t)},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr("points",this.array.size(i.width,i.height))}}),l.Path=l.invent({create:"path",inherit:l.Shape,extend:{plot:function(t){return this.attr("d",this.array=new l.PathArray(t,[["M",0,0]]))},move:function(t,e){return this.attr("d",this.array.move(t,e))},x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},size:function(t,e){var i=r(this.bbox(),t,e);return this.attr("d",this.array.size(i.width,i.height))},width:function(t){return null==t?this.bbox().width:this.size(t,this.bbox().height)},height:function(t){return null==t?this.bbox().height:this.size(this.bbox().width,t)}},construct:{path:function(t){return this.put(new l.Path).plot(t)}}}),l.Image=l.invent({create:"image",inherit:l.Shape,extend:{load:function(t){if(!t)return this;var e=this,i=document.createElement("img");return i.onload=function(){var n=e.doc(l.Pattern);0==e.width()&&0==e.height()&&e.size(i.width,i.height),n&&0==n.width()&&0==n.height()&&n.size(e.width(),e.height()),"function"==typeof e._loaded&&e._loaded.call(e,{width:i.width,height:i.height,ratio:i.width/i