ipad changes

master
Mark MacKay 2012-07-25 04:18:34 -05:00
parent 60f34ac637
commit a9896f345e
4 changed files with 66 additions and 66 deletions

View File

@ -147,8 +147,8 @@ svgedit.path.addPointGrip = function(index, x, y) {
svgedit.utilities.assignAttributes(pointGrip, {
'id': "pathpointgrip_" + index,
'display': "none",
'width': svgeditor.browser.isTouch() ? 30 : 5,
'height': svgeditor.browser.isTouch() ? 30 : 5,
'width': svgedit.browser.isTouch() ? 30 : 5,
'height': svgedit.browser.isTouch() ? 30 : 5,
'fill': "#fff",
'stroke': "#4F80FF",
'shape-rendering': "crispEdges",
@ -167,8 +167,8 @@ svgedit.path.addPointGrip = function(index, x, y) {
if(x && y) {
// set up the point grip element and display it
svgedit.utilities.assignAttributes(pointGrip, {
'x': x-(svgeditor.browser.isTouch() ? 15 : 2.5),
'y': y-(svgeditor.browser.isTouch() ? 15 : 2.5),
'x': x-(svgedit.browser.isTouch() ? 15 : 2.5),
'y': y-(svgedit.browser.isTouch() ? 15 : 2.5),
'display': "inline"
});
}
@ -193,7 +193,7 @@ svgedit.path.addCtrlGrip = function(id) {
svgedit.utilities.assignAttributes(pointGrip, {
'id': "ctrlpointgrip_" + id,
'display': "none",
'r': svgeditor.browser.isTouch() ? 15 : 3,
'r': svgedit.browser.isTouch() ? 15 : 3,
'fill': "#4F80FF",
'cursor': 'move',
'style': 'pointer-events:all',
@ -224,8 +224,8 @@ svgedit.path.getPointGrip = function(seg, update) {
if(update) {
var pt = svgedit.path.getGripPt(seg);
svgedit.utilities.assignAttributes(pointGrip, {
'x': pt.x-(svgeditor.browser.isTouch() ? 15 : 2.5),
'y': pt.y-(svgeditor.browser.isTouch() ? 15 : 2.5),
'x': pt.x-(svgedit.browser.isTouch() ? 15 : 2.5),
'y': pt.y-(svgedit.browser.isTouch() ? 15 : 2.5),
'display': "inline"
});
}
@ -446,7 +446,7 @@ svgedit.path.Segment.prototype.addGrip = function() {
svgedit.path.Segment.prototype.update = function(full) {
if(this.ptgrip) {
var pt = svgedit.path.getGripPt(this);
var reposition = (svgeditor.browser.isTouch() ? 15 : 2.5)
var reposition = (svgedit.browser.isTouch() ? 15 : 2.5)
var properties = (this.ptgrip.nodeName == "rect") ? {'x': pt.x-reposition, 'y': pt.y-reposition} : {'cx': pt.x, 'cy': pt.y};
svgedit.utilities.assignAttributes(this.ptgrip, properties);
svgedit.path.getSegSelector(this, true);

View File

@ -167,31 +167,31 @@ m);break}}})();svgedit=svgedit||{};
(function(){if(!svgedit.path)svgedit.path={};var a={pathNodeTooltip:"Drag node to move it. Double-click node to change segment type",pathCtrlPtTooltip:"Drag control point to adjust curve properties"},p={2:["x","y"],4:["x","y"],6:["x","y","x1","y1","x2","y2"],8:["x","y","x1","y1"],10:["x","y","r1","r2","angle","largeArcFlag","sweepFlag"],12:["x"],14:["y"],16:["x","y","x2","y2"],18:["x","y"]},g=[],c=true,m={};svgedit.path.setLinkControlPoints=function(f){c=f};var s=svgedit.path.path=null;svgedit.path.init=
function(f){s=f;g=[0,"ClosePath"];$.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(d,k){g.push(k+"Abs");g.push(k+"Rel")})};svgedit.path.insertItemBefore=function(f,d,k){f=f.pathSegList;if(svgedit.browser.supportsPathInsertItemBefore())f.insertItemBefore(d,k);else{for(var q=f.numberOfItems,B=[],o=0;o<q;o++){var J=f.getItem(o);B.push(J)}f.clear();for(o=0;o<q;o++){o==k&&f.appendItem(d);f.appendItem(B[o])}}};
svgedit.path.ptObjToArr=function(f,d){for(var k=p[f],q=k.length,B=Array(q),o=0;o<q;o++)B[o]=d[k[o]];return B};svgedit.path.getGripPt=function(f,d){var k={x:d?d.x:f.item.x,y:d?d.y:f.item.y},q=f.path;if(q.matrix)k=svgedit.math.transformPoint(k.x,k.y,q.matrix);k.x*=s.getCurrentZoom();k.y*=s.getCurrentZoom();return k};svgedit.path.getPointFromGrip=function(f,d){var k={x:f.x,y:f.y};if(d.matrix){f=svgedit.math.transformPoint(k.x,k.y,d.imatrix);k.x=f.x;k.y=f.y}k.x/=s.getCurrentZoom();k.y/=s.getCurrentZoom();
return k};svgedit.path.addPointGrip=function(f,d,k){var q=svgedit.path.getGripContainer(),B=svgedit.utilities.getElem("pathpointgrip_"+f);if(!B){B=document.createElementNS("http://www.w3.org/2000/svg","rect");svgedit.utilities.assignAttributes(B,{id:"pathpointgrip_"+f,display:"none",width:svgeditor.browser.isTouch()?30:5,height:svgeditor.browser.isTouch()?30:5,fill:"#fff",stroke:"#4F80FF","shape-rendering":"crispEdges","stroke-width":1,cursor:"move",style:"pointer-events:all","xlink:title":a.pathNodeTooltip});
B=q.appendChild(B);$("#pathpointgrip_"+f).dblclick(function(){svgedit.path.path&&svgedit.path.path.setSegType()})}if(d&&k)svgedit.utilities.assignAttributes(B,{x:d-(svgeditor.browser.isTouch()?15:2.5),y:k-(svgeditor.browser.isTouch()?15:2.5),display:"inline"});return B};svgedit.path.getGripContainer=function(){var f=svgedit.utilities.getElem("pathpointgrip_container");if(!f){f=svgedit.utilities.getElem("selectorParentGroup").appendChild(document.createElementNS("http://www.w3.org/2000/svg","g"));
f.id="pathpointgrip_container"}return f};svgedit.path.addCtrlGrip=function(f){var d=svgedit.utilities.getElem("ctrlpointgrip_"+f);if(d)return d;d=document.createElementNS("http://www.w3.org/2000/svg","circle");svgedit.utilities.assignAttributes(d,{id:"ctrlpointgrip_"+f,display:"none",r:svgeditor.browser.isTouch()?15:3,fill:"#4F80FF",cursor:"move",style:"pointer-events:all","xlink:title":a.pathCtrlPtTooltip});svgedit.path.getGripContainer().appendChild(d);return d};svgedit.path.getCtrlLine=function(f){var d=
svgedit.utilities.getElem("ctrlLine_"+f);if(d)return d;d=document.createElementNS("http://www.w3.org/2000/svg","line");svgedit.utilities.assignAttributes(d,{id:"ctrlLine_"+f,stroke:"#4F80FF","stroke-width":1,style:"pointer-events:none"});svgedit.path.getGripContainer().appendChild(d);return d};svgedit.path.getPointGrip=function(f,d){var k=svgedit.path.addPointGrip(f.index);if(d){var q=svgedit.path.getGripPt(f);svgedit.utilities.assignAttributes(k,{x:q.x-(svgeditor.browser.isTouch()?15:2.5),y:q.y-
(svgeditor.browser.isTouch()?15:2.5),display:"inline"})}return k};svgedit.path.getControlPoints=function(f){var d=f.item,k=f.index;if(!("x1"in d)||!("x2"in d))return null;var q={};svgedit.path.getGripContainer();for(var B=[svgedit.path.path.segs[k-1].item,d],o=1;o<3;o++){var J=k+"c"+o,U=q["c"+o+"_line"]=svgedit.path.getCtrlLine(J),M=svgedit.path.getGripPt(f,{x:d["x"+o],y:d["y"+o]}),I=svgedit.path.getGripPt(f,{x:B[o-1].x,y:B[o-1].y});svgedit.utilities.assignAttributes(U,{x1:M.x,y1:M.y,x2:I.x,y2:I.y,
display:"inline"});q["c"+o+"_line"]=U;pointGrip=q["c"+o]=svgedit.path.addCtrlGrip(J);svgedit.utilities.assignAttributes(pointGrip,{cx:M.x,cy:M.y,display:"inline"});q["c"+o]=pointGrip}return q};svgedit.path.replacePathSeg=function(f,d,k,q){q=q||svgedit.path.path.elem;f=q["createSVGPathSeg"+g[f]].apply(q,k);if(svgedit.browser.supportsPathReplaceItem())q.pathSegList.replaceItem(f,d);else{k=q.pathSegList;q=k.numberOfItems;for(var B=[],o=0;o<q;o++){var J=k.getItem(o);B.push(J)}k.clear();for(o=0;o<q;o++)o==
d?k.appendItem(f):k.appendItem(B[o])}};svgedit.path.getSegSelector=function(f,d){var k=f.index,q=svgedit.utilities.getElem("segline_"+k);if(!q){var B=svgedit.path.getGripContainer();q=document.createElementNS("http://www.w3.org/2000/svg","path");svgedit.utilities.assignAttributes(q,{id:"segline_"+k,display:"none",fill:"none",stroke:"#0FF","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"});B.appendChild(q)}if(d){k=f.prev;if(!k){q.setAttribute("display","none");return q}k=svgedit.path.getGripPt(k);
svgedit.path.replacePathSeg(2,0,[k.x,k.y],q);B=svgedit.path.ptObjToArr(f.type,f.item,true);for(var o=0;o<B.length;o+=2){k=svgedit.path.getGripPt(f,{x:B[o],y:B[o+1]});B[o]=k.x;B[o+1]=k.y}svgedit.path.replacePathSeg(f.type,1,B,q)}return q};svgedit.path.smoothControlPoints=this.smoothControlPoints=function(f,d,k){var q=f.x-k.x,B=f.y-k.y,o=d.x-k.x,J=d.y-k.y;if((q!=0||B!=0)&&(o!=0||J!=0)){f=Math.atan2(B,q);d=Math.atan2(J,o);q=Math.sqrt(q*q+B*B);o=Math.sqrt(o*o+J*J);B=s.getSVGRoot().createSVGPoint();J=
s.getSVGRoot().createSVGPoint();if(f<0)f+=2*Math.PI;if(d<0)d+=2*Math.PI;var U=Math.abs(f-d),M=Math.abs(Math.PI-U)/2;if(f-d>0){f=U<Math.PI?f+M:f-M;d=U<Math.PI?d-M:d+M}else{f=U<Math.PI?f-M:f+M;d=U<Math.PI?d+M:d-M}B.x=q*Math.cos(f)+k.x;B.y=q*Math.sin(f)+k.y;J.x=o*Math.cos(d)+k.x;J.y=o*Math.sin(d)+k.y;return[B,J]}};svgedit.path.Segment=function(f,d){this.selected=false;this.index=f;this.item=d;this.type=d.pathSegType;this.ctrlpts=[];this.segsel=this.ptgrip=null};svgedit.path.Segment.prototype.showCtrlPts=
function(f){for(var d in this.ctrlpts)this.ctrlpts[d].setAttribute("display",f?"inline":"none")};svgedit.path.Segment.prototype.selectCtrls=function(){$("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill","#4F80FF")};svgedit.path.Segment.prototype.show=function(f){if(this.ptgrip){this.ptgrip.setAttribute("display",f?"inline":"none");this.segsel.setAttribute("display",f?"inline":"none");this.showCtrlPts(f)}};svgedit.path.Segment.prototype.select=function(f){if(this.ptgrip){this.ptgrip.setAttribute("stroke",
f?"#0FF":"#00F");this.segsel.setAttribute("display",f?"inline":"none");this.ctrlpts&&this.selectCtrls(f);this.selected=f}};svgedit.path.Segment.prototype.addGrip=function(){this.ptgrip=svgedit.path.getPointGrip(this,true);this.ctrlpts=svgedit.path.getControlPoints(this,true);this.segsel=svgedit.path.getSegSelector(this,true)};svgedit.path.Segment.prototype.update=function(f){if(this.ptgrip){var d=svgedit.path.getGripPt(this),k=svgeditor.browser.isTouch()?15:2.5;svgedit.utilities.assignAttributes(this.ptgrip,
this.ptgrip.nodeName=="rect"?{x:d.x-k,y:d.y-k}:{cx:d.x,cy:d.y});svgedit.path.getSegSelector(this,true);if(this.ctrlpts){if(f){this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.type=this.item.pathSegType}svgedit.path.getControlPoints(this)}}};svgedit.path.Segment.prototype.move=function(f,d){var k=this.item;k=this.ctrlpts?[k.x+=f,k.y+=d,k.x1,k.y1,k.x2+=f,k.y2+=d]:[k.x+=f,k.y+=d];svgedit.path.replacePathSeg(this.type,this.index,k);if(this.next&&this.next.ctrlpts){k=this.next.item;
k=[k.x,k.y,k.x1+=f,k.y1+=d,k.x2,k.y2];svgedit.path.replacePathSeg(this.next.type,this.next.index,k)}if(this.mate){k=this.mate.item;k=[k.x+=f,k.y+=d];svgedit.path.replacePathSeg(this.mate.type,this.mate.index,k)}this.update(true);this.next&&this.next.update(true)};svgedit.path.Segment.prototype.setLinked=function(f){var d,k,q;if(f==2){k=1;d=this.next;if(!d)return;q=this.item}else{k=2;d=this.prev;if(!d)return;q=d.item}var B=d.item;B["x"+k]=q.x+(q.x-this.item["x"+f]);B["y"+k]=q.y+(q.y-this.item["y"+
f]);svgedit.path.replacePathSeg(d.type,d.index,[B.x,B.y,B.x1,B.y1,B.x2,B.y2]);d.update(true)};svgedit.path.Segment.prototype.moveCtrl=function(f,d,k){var q=this.item;q["x"+f]+=d;q["y"+f]+=k;svgedit.path.replacePathSeg(this.type,this.index,[q.x,q.y,q.x1,q.y1,q.x2,q.y2]);this.update(true)};svgedit.path.Segment.prototype.setType=function(f,d){svgedit.path.replacePathSeg(f,this.index,d);this.type=f;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.showCtrlPts(f===6);this.ctrlpts=svgedit.path.getControlPoints(this);
this.update(true)};svgedit.path.Path=function(f){if(!f||f.tagName!=="path")throw"svgedit.path.Path constructed without a <path> element";this.elem=f;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var f=this.elem.pathSegList,d=f.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var k=0;k<d;k++){var q=f.getItem(k);q=new svgedit.path.Segment(k,q);
q.path=this;this.segs.push(q)}f=this.segs;q=null;for(k=0;k<d;k++){var B=f[k],o=k+1>=d?null:f[k+1],J=k-1<0?null:f[k-1];if(B.type===2){if(J&&J.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip()}q=k}else if(o&&o.type===1){B.next=f[q+1];B.next.prev=B;B.mate=f[q];B.addGrip();if(this.first_seg==null)this.first_seg=B}else if(o){if(B.type!==1){B.addGrip();if(o&&o.type!==2){B.next=o;B.next.prev=B}}}else if(B.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip();B.addGrip();if(!this.first_seg)this.first_seg=
f[q]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var d=this.segs.length,k=0;k<d;k++)if(f.call(this.segs[k],k)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var d=this.segs[f];if(d.prev){var k=d.prev,q;switch(d.item.pathSegType){case 4:var B=(d.item.x+k.item.x)/2,o=(d.item.y+k.item.y)/2;q=this.elem.createSVGPathSegLinetoAbs(B,o);break;case 6:q=(k.item.x+d.item.x1)/2;var J=(d.item.x1+d.item.x2)/2,U=(d.item.x2+d.item.x)/2,M=(q+J)/2;J=(J+U)/2;B=(M+J)/2;var I=(k.item.y+
d.item.y1)/2,S=(d.item.y1+d.item.y2)/2;k=(d.item.y2+d.item.y)/2;var Y=(I+S)/2;S=(S+k)/2;o=(Y+S)/2;q=this.elem.createSVGPathSegCurvetoCubicAbs(B,o,q,I,M,Y);svgedit.path.replacePathSeg(d.type,f,[d.item.x,d.item.y,J,S,U,k])}svgedit.path.insertItemBefore(this.elem,q,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var d=this.segs[f],k=this.elem.pathSegList;d.show(false);var q=d.next;if(d.mate){var B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,q.index,B);svgedit.path.replacePathSeg(4,d.index,
B);k.removeItem(d.mate.index)}else{if(!d.prev){B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,d.next.index,B)}k.removeItem(f)}};svgedit.path.Path.prototype.subpathIsClosed=function(f){var d=false;svgedit.path.path.eachSeg(function(k){if(k<=f)return true;if(this.type===2)return false;else if(this.type===1){d=true;return false}});return d};svgedit.path.Path.prototype.removePtFromSelection=function(f){var d=this.selected_pts.indexOf(f);if(d!=-1){this.segs[f].select(false);this.selected_pts.splice(d,
1)}};svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg(function(){this.select(false)});this.selected_pts=[]};svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")};svgedit.path.Path.prototype.show=function(f){this.eachSeg(function(){this.show(f)});f&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(f,d){for(var k=this.selected_pts.length;k--;)this.segs[this.selected_pts[k]].move(f,d)};svgedit.path.Path.prototype.moveCtrl=
function(f,d){var k=this.segs[this.selected_pts[0]];k.moveCtrl(this.dragctrl,f,d);c&&k.setLinked(this.dragctrl)};svgedit.path.Path.prototype.setSegType=function(f){this.storeD();for(var d=this.selected_pts.length,k;d--;){var q=this.segs[this.selected_pts[d]],B=q.prev;if(B){if(!f){k="Toggle Path Segment Type";f=q.type==6?4:6}f-=0;var o=q.item.x,J=q.item.y,U=B.item.x;B=B.item.y;var M;switch(f){case 6:if(q.olditem){U=q.olditem;M=[o,J,U.x1,U.y1,U.x2,U.y2]}else{M=o-U;var I=J-B;M=[o,J,U+M/3,B+I/3,o-M/3,
J-I/3]}break;case 4:M=[o,J];q.olditem=q.item}q.setType(f,M)}}svgedit.path.path.endChanges(k)};svgedit.path.Path.prototype.selectPt=function(f,d){this.clearSelection();f==null&&this.eachSeg(function(k){if(this.prev)f=k});this.addPtsToSelection(f);if(d){this.dragctrl=d;c&&this.segs[f].setLinked(d)}};svgedit.path.Path.prototype.update=function(){var f=this.elem;if(svgedit.utilities.getRotationAngle(f)){this.matrix=svgedit.math.getMatrix(f);this.imatrix=this.matrix.inverse()}else this.imatrix=this.matrix=
null;this.eachSeg(function(d){this.item=f.pathSegList.getItem(d);this.update()});return this};svgedit.path.getPath_=function(f){var d=m[f.id];d||(d=m[f.id]=new svgedit.path.Path(f));return d};svgedit.path.removePath_=function(f){f in m&&delete m[f]};var b=function(f,d){dx=f-oldcx;dy=d-oldcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)+angle;dx=r*Math.cos(theta)+oldcx;dy=r*Math.sin(theta)+oldcy;dx-=newcx;dy-=newcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)-angle;return{x:(r*Math.cos(theta)+
newcx)/1,y:(r*Math.sin(theta)+newcy)/1}};svgedit.path.recalcRotatedPath=function(){var f=svgedit.path.path.elem,d=svgedit.utilities.getRotationAngle(f,true);if(d){var k=svgedit.utilities.getBBox(f),q=svgedit.path.path.oldbbox,B=q.x+q.width/2,o=q.y+q.height/2;q=k.x+k.width/2;k=k.y+k.height/2;q=q-B;var J=k-o;k=Math.sqrt(q*q+J*J);J=Math.atan2(J,q)+d;q=k*Math.cos(J)+B;k=k*Math.sin(J)+o;B=f.pathSegList;for(o=B.numberOfItems;o;){o-=1;J=B.getItem(o);var U=J.pathSegType;if(U!=1){var M=b(J.x,J.y);M=[M.x,M.y];
if(J.x1!=null&&J.x2!=null){c_vals1=b(J.x1,J.y1);c_vals2=b(J.x2,J.y2);M.splice(M.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(U,o,M)}}svgedit.utilities.getBBox(f);B=svgroot.createSVGTransform();f=svgedit.transformlist.getTransformList(f);B.setRotate(d*180/Math.PI,q,k);f.replaceItem(B,0)}};svgedit.path.clearData=function(){m={}}})();if(!window.console){window.console={};window.console.log=function(){};window.console.dir=function(){}}if(window.opera){window.console.log=function(a){opera.postError(a)};window.console.dir=function(){}}
return k};svgedit.path.addPointGrip=function(f,d,k){var q=svgedit.path.getGripContainer(),B=svgedit.utilities.getElem("pathpointgrip_"+f);if(!B){B=document.createElementNS("http://www.w3.org/2000/svg","rect");svgedit.utilities.assignAttributes(B,{id:"pathpointgrip_"+f,display:"none",width:svgedit.browser.isTouch()?30:5,height:svgedit.browser.isTouch()?30:5,fill:"#fff",stroke:"#4F80FF","shape-rendering":"crispEdges","stroke-width":1,cursor:"move",style:"pointer-events:all","xlink:title":a.pathNodeTooltip});
B=q.appendChild(B);$("#pathpointgrip_"+f).dblclick(function(){svgedit.path.path&&svgedit.path.path.setSegType()})}if(d&&k)svgedit.utilities.assignAttributes(B,{x:d-(svgedit.browser.isTouch()?15:2.5),y:k-(svgedit.browser.isTouch()?15:2.5),display:"inline"});return B};svgedit.path.getGripContainer=function(){var f=svgedit.utilities.getElem("pathpointgrip_container");if(!f){f=svgedit.utilities.getElem("selectorParentGroup").appendChild(document.createElementNS("http://www.w3.org/2000/svg","g"));f.id=
"pathpointgrip_container"}return f};svgedit.path.addCtrlGrip=function(f){var d=svgedit.utilities.getElem("ctrlpointgrip_"+f);if(d)return d;d=document.createElementNS("http://www.w3.org/2000/svg","circle");svgedit.utilities.assignAttributes(d,{id:"ctrlpointgrip_"+f,display:"none",r:svgedit.browser.isTouch()?15:3,fill:"#4F80FF",cursor:"move",style:"pointer-events:all","xlink:title":a.pathCtrlPtTooltip});svgedit.path.getGripContainer().appendChild(d);return d};svgedit.path.getCtrlLine=function(f){var d=
svgedit.utilities.getElem("ctrlLine_"+f);if(d)return d;d=document.createElementNS("http://www.w3.org/2000/svg","line");svgedit.utilities.assignAttributes(d,{id:"ctrlLine_"+f,stroke:"#4F80FF","stroke-width":1,style:"pointer-events:none"});svgedit.path.getGripContainer().appendChild(d);return d};svgedit.path.getPointGrip=function(f,d){var k=svgedit.path.addPointGrip(f.index);if(d){var q=svgedit.path.getGripPt(f);svgedit.utilities.assignAttributes(k,{x:q.x-(svgedit.browser.isTouch()?15:2.5),y:q.y-(svgedit.browser.isTouch()?
15:2.5),display:"inline"})}return k};svgedit.path.getControlPoints=function(f){var d=f.item,k=f.index;if(!("x1"in d)||!("x2"in d))return null;var q={};svgedit.path.getGripContainer();for(var B=[svgedit.path.path.segs[k-1].item,d],o=1;o<3;o++){var J=k+"c"+o,U=q["c"+o+"_line"]=svgedit.path.getCtrlLine(J),M=svgedit.path.getGripPt(f,{x:d["x"+o],y:d["y"+o]}),I=svgedit.path.getGripPt(f,{x:B[o-1].x,y:B[o-1].y});svgedit.utilities.assignAttributes(U,{x1:M.x,y1:M.y,x2:I.x,y2:I.y,display:"inline"});q["c"+o+
"_line"]=U;pointGrip=q["c"+o]=svgedit.path.addCtrlGrip(J);svgedit.utilities.assignAttributes(pointGrip,{cx:M.x,cy:M.y,display:"inline"});q["c"+o]=pointGrip}return q};svgedit.path.replacePathSeg=function(f,d,k,q){q=q||svgedit.path.path.elem;f=q["createSVGPathSeg"+g[f]].apply(q,k);if(svgedit.browser.supportsPathReplaceItem())q.pathSegList.replaceItem(f,d);else{k=q.pathSegList;q=k.numberOfItems;for(var B=[],o=0;o<q;o++){var J=k.getItem(o);B.push(J)}k.clear();for(o=0;o<q;o++)o==d?k.appendItem(f):k.appendItem(B[o])}};
svgedit.path.getSegSelector=function(f,d){var k=f.index,q=svgedit.utilities.getElem("segline_"+k);if(!q){var B=svgedit.path.getGripContainer();q=document.createElementNS("http://www.w3.org/2000/svg","path");svgedit.utilities.assignAttributes(q,{id:"segline_"+k,display:"none",fill:"none",stroke:"#0FF","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"});B.appendChild(q)}if(d){k=f.prev;if(!k){q.setAttribute("display","none");return q}k=svgedit.path.getGripPt(k);svgedit.path.replacePathSeg(2,
0,[k.x,k.y],q);B=svgedit.path.ptObjToArr(f.type,f.item,true);for(var o=0;o<B.length;o+=2){k=svgedit.path.getGripPt(f,{x:B[o],y:B[o+1]});B[o]=k.x;B[o+1]=k.y}svgedit.path.replacePathSeg(f.type,1,B,q)}return q};svgedit.path.smoothControlPoints=this.smoothControlPoints=function(f,d,k){var q=f.x-k.x,B=f.y-k.y,o=d.x-k.x,J=d.y-k.y;if((q!=0||B!=0)&&(o!=0||J!=0)){f=Math.atan2(B,q);d=Math.atan2(J,o);q=Math.sqrt(q*q+B*B);o=Math.sqrt(o*o+J*J);B=s.getSVGRoot().createSVGPoint();J=s.getSVGRoot().createSVGPoint();
if(f<0)f+=2*Math.PI;if(d<0)d+=2*Math.PI;var U=Math.abs(f-d),M=Math.abs(Math.PI-U)/2;if(f-d>0){f=U<Math.PI?f+M:f-M;d=U<Math.PI?d-M:d+M}else{f=U<Math.PI?f-M:f+M;d=U<Math.PI?d+M:d-M}B.x=q*Math.cos(f)+k.x;B.y=q*Math.sin(f)+k.y;J.x=o*Math.cos(d)+k.x;J.y=o*Math.sin(d)+k.y;return[B,J]}};svgedit.path.Segment=function(f,d){this.selected=false;this.index=f;this.item=d;this.type=d.pathSegType;this.ctrlpts=[];this.segsel=this.ptgrip=null};svgedit.path.Segment.prototype.showCtrlPts=function(f){for(var d in this.ctrlpts)this.ctrlpts[d].setAttribute("display",
f?"inline":"none")};svgedit.path.Segment.prototype.selectCtrls=function(){$("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill","#4F80FF")};svgedit.path.Segment.prototype.show=function(f){if(this.ptgrip){this.ptgrip.setAttribute("display",f?"inline":"none");this.segsel.setAttribute("display",f?"inline":"none");this.showCtrlPts(f)}};svgedit.path.Segment.prototype.select=function(f){if(this.ptgrip){this.ptgrip.setAttribute("stroke",f?"#0FF":"#00F");this.segsel.setAttribute("display",
f?"inline":"none");this.ctrlpts&&this.selectCtrls(f);this.selected=f}};svgedit.path.Segment.prototype.addGrip=function(){this.ptgrip=svgedit.path.getPointGrip(this,true);this.ctrlpts=svgedit.path.getControlPoints(this,true);this.segsel=svgedit.path.getSegSelector(this,true)};svgedit.path.Segment.prototype.update=function(f){if(this.ptgrip){var d=svgedit.path.getGripPt(this),k=svgedit.browser.isTouch()?15:2.5;svgedit.utilities.assignAttributes(this.ptgrip,this.ptgrip.nodeName=="rect"?{x:d.x-k,y:d.y-
k}:{cx:d.x,cy:d.y});svgedit.path.getSegSelector(this,true);if(this.ctrlpts){if(f){this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.type=this.item.pathSegType}svgedit.path.getControlPoints(this)}}};svgedit.path.Segment.prototype.move=function(f,d){var k=this.item;k=this.ctrlpts?[k.x+=f,k.y+=d,k.x1,k.y1,k.x2+=f,k.y2+=d]:[k.x+=f,k.y+=d];svgedit.path.replacePathSeg(this.type,this.index,k);if(this.next&&this.next.ctrlpts){k=this.next.item;k=[k.x,k.y,k.x1+=f,k.y1+=d,k.x2,k.y2];svgedit.path.replacePathSeg(this.next.type,
this.next.index,k)}if(this.mate){k=this.mate.item;k=[k.x+=f,k.y+=d];svgedit.path.replacePathSeg(this.mate.type,this.mate.index,k)}this.update(true);this.next&&this.next.update(true)};svgedit.path.Segment.prototype.setLinked=function(f){var d,k,q;if(f==2){k=1;d=this.next;if(!d)return;q=this.item}else{k=2;d=this.prev;if(!d)return;q=d.item}var B=d.item;B["x"+k]=q.x+(q.x-this.item["x"+f]);B["y"+k]=q.y+(q.y-this.item["y"+f]);svgedit.path.replacePathSeg(d.type,d.index,[B.x,B.y,B.x1,B.y1,B.x2,B.y2]);d.update(true)};
svgedit.path.Segment.prototype.moveCtrl=function(f,d,k){var q=this.item;q["x"+f]+=d;q["y"+f]+=k;svgedit.path.replacePathSeg(this.type,this.index,[q.x,q.y,q.x1,q.y1,q.x2,q.y2]);this.update(true)};svgedit.path.Segment.prototype.setType=function(f,d){svgedit.path.replacePathSeg(f,this.index,d);this.type=f;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.showCtrlPts(f===6);this.ctrlpts=svgedit.path.getControlPoints(this);this.update(true)};svgedit.path.Path=function(f){if(!f||f.tagName!==
"path")throw"svgedit.path.Path constructed without a <path> element";this.elem=f;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var f=this.elem.pathSegList,d=f.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var k=0;k<d;k++){var q=f.getItem(k);q=new svgedit.path.Segment(k,q);q.path=this;this.segs.push(q)}f=this.segs;q=null;for(k=0;k<d;k++){var B=
f[k],o=k+1>=d?null:f[k+1],J=k-1<0?null:f[k-1];if(B.type===2){if(J&&J.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip()}q=k}else if(o&&o.type===1){B.next=f[q+1];B.next.prev=B;B.mate=f[q];B.addGrip();if(this.first_seg==null)this.first_seg=B}else if(o){if(B.type!==1){B.addGrip();if(o&&o.type!==2){B.next=o;B.next.prev=B}}}else if(B.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip();B.addGrip();if(!this.first_seg)this.first_seg=f[q]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var d=
this.segs.length,k=0;k<d;k++)if(f.call(this.segs[k],k)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var d=this.segs[f];if(d.prev){var k=d.prev,q;switch(d.item.pathSegType){case 4:var B=(d.item.x+k.item.x)/2,o=(d.item.y+k.item.y)/2;q=this.elem.createSVGPathSegLinetoAbs(B,o);break;case 6:q=(k.item.x+d.item.x1)/2;var J=(d.item.x1+d.item.x2)/2,U=(d.item.x2+d.item.x)/2,M=(q+J)/2;J=(J+U)/2;B=(M+J)/2;var I=(k.item.y+d.item.y1)/2,S=(d.item.y1+d.item.y2)/2;k=(d.item.y2+d.item.y)/2;var Y=(I+
S)/2;S=(S+k)/2;o=(Y+S)/2;q=this.elem.createSVGPathSegCurvetoCubicAbs(B,o,q,I,M,Y);svgedit.path.replacePathSeg(d.type,f,[d.item.x,d.item.y,J,S,U,k])}svgedit.path.insertItemBefore(this.elem,q,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var d=this.segs[f],k=this.elem.pathSegList;d.show(false);var q=d.next;if(d.mate){var B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,q.index,B);svgedit.path.replacePathSeg(4,d.index,B);k.removeItem(d.mate.index)}else{if(!d.prev){B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,
d.next.index,B)}k.removeItem(f)}};svgedit.path.Path.prototype.subpathIsClosed=function(f){var d=false;svgedit.path.path.eachSeg(function(k){if(k<=f)return true;if(this.type===2)return false;else if(this.type===1){d=true;return false}});return d};svgedit.path.Path.prototype.removePtFromSelection=function(f){var d=this.selected_pts.indexOf(f);if(d!=-1){this.segs[f].select(false);this.selected_pts.splice(d,1)}};svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg(function(){this.select(false)});
this.selected_pts=[]};svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")};svgedit.path.Path.prototype.show=function(f){this.eachSeg(function(){this.show(f)});f&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(f,d){for(var k=this.selected_pts.length;k--;)this.segs[this.selected_pts[k]].move(f,d)};svgedit.path.Path.prototype.moveCtrl=function(f,d){var k=this.segs[this.selected_pts[0]];k.moveCtrl(this.dragctrl,f,d);c&&k.setLinked(this.dragctrl)};
svgedit.path.Path.prototype.setSegType=function(f){this.storeD();for(var d=this.selected_pts.length,k;d--;){var q=this.segs[this.selected_pts[d]],B=q.prev;if(B){if(!f){k="Toggle Path Segment Type";f=q.type==6?4:6}f-=0;var o=q.item.x,J=q.item.y,U=B.item.x;B=B.item.y;var M;switch(f){case 6:if(q.olditem){U=q.olditem;M=[o,J,U.x1,U.y1,U.x2,U.y2]}else{M=o-U;var I=J-B;M=[o,J,U+M/3,B+I/3,o-M/3,J-I/3]}break;case 4:M=[o,J];q.olditem=q.item}q.setType(f,M)}}svgedit.path.path.endChanges(k)};svgedit.path.Path.prototype.selectPt=
function(f,d){this.clearSelection();f==null&&this.eachSeg(function(k){if(this.prev)f=k});this.addPtsToSelection(f);if(d){this.dragctrl=d;c&&this.segs[f].setLinked(d)}};svgedit.path.Path.prototype.update=function(){var f=this.elem;if(svgedit.utilities.getRotationAngle(f)){this.matrix=svgedit.math.getMatrix(f);this.imatrix=this.matrix.inverse()}else this.imatrix=this.matrix=null;this.eachSeg(function(d){this.item=f.pathSegList.getItem(d);this.update()});return this};svgedit.path.getPath_=function(f){var d=
m[f.id];d||(d=m[f.id]=new svgedit.path.Path(f));return d};svgedit.path.removePath_=function(f){f in m&&delete m[f]};var b=function(f,d){dx=f-oldcx;dy=d-oldcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)+angle;dx=r*Math.cos(theta)+oldcx;dy=r*Math.sin(theta)+oldcy;dx-=newcx;dy-=newcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)-angle;return{x:(r*Math.cos(theta)+newcx)/1,y:(r*Math.sin(theta)+newcy)/1}};svgedit.path.recalcRotatedPath=function(){var f=svgedit.path.path.elem,d=svgedit.utilities.getRotationAngle(f,
true);if(d){var k=svgedit.utilities.getBBox(f),q=svgedit.path.path.oldbbox,B=q.x+q.width/2,o=q.y+q.height/2;q=k.x+k.width/2;k=k.y+k.height/2;q=q-B;var J=k-o;k=Math.sqrt(q*q+J*J);J=Math.atan2(J,q)+d;q=k*Math.cos(J)+B;k=k*Math.sin(J)+o;B=f.pathSegList;for(o=B.numberOfItems;o;){o-=1;J=B.getItem(o);var U=J.pathSegType;if(U!=1){var M=b(J.x,J.y);M=[M.x,M.y];if(J.x1!=null&&J.x2!=null){c_vals1=b(J.x1,J.y1);c_vals2=b(J.x2,J.y2);M.splice(M.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(U,
o,M)}}svgedit.utilities.getBBox(f);B=svgroot.createSVGTransform();f=svgedit.transformlist.getTransformList(f);B.setRotate(d*180/Math.PI,q,k);f.replaceItem(B,0)}};svgedit.path.clearData=function(){m={}}})();if(!window.console){window.console={};window.console.log=function(){};window.console.dir=function(){}}if(window.opera){window.console.log=function(a){opera.postError(a)};window.console.dir=function(){}}
(function(){var a=jQuery.fn.attr;jQuery.fn.attr=function(p,g){var c=this.length;if(!c)return a.apply(this,arguments);for(var m=0;m<c;m++){var s=this[m];if(s.namespaceURI==="http://www.w3.org/2000/svg")if(g!==undefined)s.setAttribute(p,g);else if($.isArray(p)){c=p.length;for(m={};c--;){var b=p[c],f=s.getAttribute(b);if(f||f==="0")f=isNaN(f)?f:f-0;m[b]=f}return m}else if(typeof p==="object")for(b in p)s.setAttribute(b,p[b]);else{if((f=s.getAttribute(p))||f==="0")f=isNaN(f)?f:f-0;return f}else return a.apply(this,
arguments)}return this}})();
$.SvgCanvas=function(a,p){function g(e,h){for(var l=svgedit.utilities.getBBox(e),z=0;z<2;z++){var v=z===0?"fill":"stroke",G=e.getAttribute(v);if(G&&G.indexOf("url(")===0){G=T(G);if(G.tagName==="linearGradient"){var A=G.getAttribute("x1")||0,u=G.getAttribute("y1")||0,F=G.getAttribute("x2")||1,H=G.getAttribute("y2")||0;A=l.width*A+l.x;u=l.height*u+l.y;F=l.width*F+l.x;H=l.height*H+l.y;A=P(A,u,h);H=P(F,H,h);F={};F.x1=(A.x-l.x)/l.width;F.y1=(A.y-l.y)/l.height;F.x2=(H.x-l.x)/l.width;F.y2=(H.y-l.y)/l.height;

View File

@ -147,8 +147,8 @@ svgedit.path.addPointGrip = function(index, x, y) {
svgedit.utilities.assignAttributes(pointGrip, {
'id': "pathpointgrip_" + index,
'display': "none",
'width': svgeditor.browser.isTouch() ? 30 : 5,
'height': svgeditor.browser.isTouch() ? 30 : 5,
'width': svgedit.browser.isTouch() ? 30 : 5,
'height': svgedit.browser.isTouch() ? 30 : 5,
'fill': "#fff",
'stroke': "#4F80FF",
'shape-rendering': "crispEdges",
@ -167,8 +167,8 @@ svgedit.path.addPointGrip = function(index, x, y) {
if(x && y) {
// set up the point grip element and display it
svgedit.utilities.assignAttributes(pointGrip, {
'x': x-(svgeditor.browser.isTouch() ? 15 : 2.5),
'y': y-(svgeditor.browser.isTouch() ? 15 : 2.5),
'x': x-(svgedit.browser.isTouch() ? 15 : 2.5),
'y': y-(svgedit.browser.isTouch() ? 15 : 2.5),
'display': "inline"
});
}
@ -193,7 +193,7 @@ svgedit.path.addCtrlGrip = function(id) {
svgedit.utilities.assignAttributes(pointGrip, {
'id': "ctrlpointgrip_" + id,
'display': "none",
'r': svgeditor.browser.isTouch() ? 15 : 3,
'r': svgedit.browser.isTouch() ? 15 : 3,
'fill': "#4F80FF",
'cursor': 'move',
'style': 'pointer-events:all',
@ -224,8 +224,8 @@ svgedit.path.getPointGrip = function(seg, update) {
if(update) {
var pt = svgedit.path.getGripPt(seg);
svgedit.utilities.assignAttributes(pointGrip, {
'x': pt.x-(svgeditor.browser.isTouch() ? 15 : 2.5),
'y': pt.y-(svgeditor.browser.isTouch() ? 15 : 2.5),
'x': pt.x-(svgedit.browser.isTouch() ? 15 : 2.5),
'y': pt.y-(svgedit.browser.isTouch() ? 15 : 2.5),
'display': "inline"
});
}
@ -446,7 +446,7 @@ svgedit.path.Segment.prototype.addGrip = function() {
svgedit.path.Segment.prototype.update = function(full) {
if(this.ptgrip) {
var pt = svgedit.path.getGripPt(this);
var reposition = (svgeditor.browser.isTouch() ? 15 : 2.5)
var reposition = (svgedit.browser.isTouch() ? 15 : 2.5)
var properties = (this.ptgrip.nodeName == "rect") ? {'x': pt.x-reposition, 'y': pt.y-reposition} : {'cx': pt.x, 'cy': pt.y};
svgedit.utilities.assignAttributes(this.ptgrip, properties);
svgedit.path.getSegSelector(this, true);

View File

@ -167,31 +167,31 @@ m);break}}})();svgedit=svgedit||{};
(function(){if(!svgedit.path)svgedit.path={};var a={pathNodeTooltip:"Drag node to move it. Double-click node to change segment type",pathCtrlPtTooltip:"Drag control point to adjust curve properties"},p={2:["x","y"],4:["x","y"],6:["x","y","x1","y1","x2","y2"],8:["x","y","x1","y1"],10:["x","y","r1","r2","angle","largeArcFlag","sweepFlag"],12:["x"],14:["y"],16:["x","y","x2","y2"],18:["x","y"]},g=[],c=true,m={};svgedit.path.setLinkControlPoints=function(f){c=f};var s=svgedit.path.path=null;svgedit.path.init=
function(f){s=f;g=[0,"ClosePath"];$.each(["Moveto","Lineto","CurvetoCubic","CurvetoQuadratic","Arc","LinetoHorizontal","LinetoVertical","CurvetoCubicSmooth","CurvetoQuadraticSmooth"],function(d,k){g.push(k+"Abs");g.push(k+"Rel")})};svgedit.path.insertItemBefore=function(f,d,k){f=f.pathSegList;if(svgedit.browser.supportsPathInsertItemBefore())f.insertItemBefore(d,k);else{for(var q=f.numberOfItems,B=[],o=0;o<q;o++){var J=f.getItem(o);B.push(J)}f.clear();for(o=0;o<q;o++){o==k&&f.appendItem(d);f.appendItem(B[o])}}};
svgedit.path.ptObjToArr=function(f,d){for(var k=p[f],q=k.length,B=Array(q),o=0;o<q;o++)B[o]=d[k[o]];return B};svgedit.path.getGripPt=function(f,d){var k={x:d?d.x:f.item.x,y:d?d.y:f.item.y},q=f.path;if(q.matrix)k=svgedit.math.transformPoint(k.x,k.y,q.matrix);k.x*=s.getCurrentZoom();k.y*=s.getCurrentZoom();return k};svgedit.path.getPointFromGrip=function(f,d){var k={x:f.x,y:f.y};if(d.matrix){f=svgedit.math.transformPoint(k.x,k.y,d.imatrix);k.x=f.x;k.y=f.y}k.x/=s.getCurrentZoom();k.y/=s.getCurrentZoom();
return k};svgedit.path.addPointGrip=function(f,d,k){var q=svgedit.path.getGripContainer(),B=svgedit.utilities.getElem("pathpointgrip_"+f);if(!B){B=document.createElementNS("http://www.w3.org/2000/svg","rect");svgedit.utilities.assignAttributes(B,{id:"pathpointgrip_"+f,display:"none",width:svgeditor.browser.isTouch()?30:5,height:svgeditor.browser.isTouch()?30:5,fill:"#fff",stroke:"#4F80FF","shape-rendering":"crispEdges","stroke-width":1,cursor:"move",style:"pointer-events:all","xlink:title":a.pathNodeTooltip});
B=q.appendChild(B);$("#pathpointgrip_"+f).dblclick(function(){svgedit.path.path&&svgedit.path.path.setSegType()})}if(d&&k)svgedit.utilities.assignAttributes(B,{x:d-(svgeditor.browser.isTouch()?15:2.5),y:k-(svgeditor.browser.isTouch()?15:2.5),display:"inline"});return B};svgedit.path.getGripContainer=function(){var f=svgedit.utilities.getElem("pathpointgrip_container");if(!f){f=svgedit.utilities.getElem("selectorParentGroup").appendChild(document.createElementNS("http://www.w3.org/2000/svg","g"));
f.id="pathpointgrip_container"}return f};svgedit.path.addCtrlGrip=function(f){var d=svgedit.utilities.getElem("ctrlpointgrip_"+f);if(d)return d;d=document.createElementNS("http://www.w3.org/2000/svg","circle");svgedit.utilities.assignAttributes(d,{id:"ctrlpointgrip_"+f,display:"none",r:svgeditor.browser.isTouch()?15:3,fill:"#4F80FF",cursor:"move",style:"pointer-events:all","xlink:title":a.pathCtrlPtTooltip});svgedit.path.getGripContainer().appendChild(d);return d};svgedit.path.getCtrlLine=function(f){var d=
svgedit.utilities.getElem("ctrlLine_"+f);if(d)return d;d=document.createElementNS("http://www.w3.org/2000/svg","line");svgedit.utilities.assignAttributes(d,{id:"ctrlLine_"+f,stroke:"#4F80FF","stroke-width":1,style:"pointer-events:none"});svgedit.path.getGripContainer().appendChild(d);return d};svgedit.path.getPointGrip=function(f,d){var k=svgedit.path.addPointGrip(f.index);if(d){var q=svgedit.path.getGripPt(f);svgedit.utilities.assignAttributes(k,{x:q.x-(svgeditor.browser.isTouch()?15:2.5),y:q.y-
(svgeditor.browser.isTouch()?15:2.5),display:"inline"})}return k};svgedit.path.getControlPoints=function(f){var d=f.item,k=f.index;if(!("x1"in d)||!("x2"in d))return null;var q={};svgedit.path.getGripContainer();for(var B=[svgedit.path.path.segs[k-1].item,d],o=1;o<3;o++){var J=k+"c"+o,U=q["c"+o+"_line"]=svgedit.path.getCtrlLine(J),M=svgedit.path.getGripPt(f,{x:d["x"+o],y:d["y"+o]}),I=svgedit.path.getGripPt(f,{x:B[o-1].x,y:B[o-1].y});svgedit.utilities.assignAttributes(U,{x1:M.x,y1:M.y,x2:I.x,y2:I.y,
display:"inline"});q["c"+o+"_line"]=U;pointGrip=q["c"+o]=svgedit.path.addCtrlGrip(J);svgedit.utilities.assignAttributes(pointGrip,{cx:M.x,cy:M.y,display:"inline"});q["c"+o]=pointGrip}return q};svgedit.path.replacePathSeg=function(f,d,k,q){q=q||svgedit.path.path.elem;f=q["createSVGPathSeg"+g[f]].apply(q,k);if(svgedit.browser.supportsPathReplaceItem())q.pathSegList.replaceItem(f,d);else{k=q.pathSegList;q=k.numberOfItems;for(var B=[],o=0;o<q;o++){var J=k.getItem(o);B.push(J)}k.clear();for(o=0;o<q;o++)o==
d?k.appendItem(f):k.appendItem(B[o])}};svgedit.path.getSegSelector=function(f,d){var k=f.index,q=svgedit.utilities.getElem("segline_"+k);if(!q){var B=svgedit.path.getGripContainer();q=document.createElementNS("http://www.w3.org/2000/svg","path");svgedit.utilities.assignAttributes(q,{id:"segline_"+k,display:"none",fill:"none",stroke:"#0FF","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"});B.appendChild(q)}if(d){k=f.prev;if(!k){q.setAttribute("display","none");return q}k=svgedit.path.getGripPt(k);
svgedit.path.replacePathSeg(2,0,[k.x,k.y],q);B=svgedit.path.ptObjToArr(f.type,f.item,true);for(var o=0;o<B.length;o+=2){k=svgedit.path.getGripPt(f,{x:B[o],y:B[o+1]});B[o]=k.x;B[o+1]=k.y}svgedit.path.replacePathSeg(f.type,1,B,q)}return q};svgedit.path.smoothControlPoints=this.smoothControlPoints=function(f,d,k){var q=f.x-k.x,B=f.y-k.y,o=d.x-k.x,J=d.y-k.y;if((q!=0||B!=0)&&(o!=0||J!=0)){f=Math.atan2(B,q);d=Math.atan2(J,o);q=Math.sqrt(q*q+B*B);o=Math.sqrt(o*o+J*J);B=s.getSVGRoot().createSVGPoint();J=
s.getSVGRoot().createSVGPoint();if(f<0)f+=2*Math.PI;if(d<0)d+=2*Math.PI;var U=Math.abs(f-d),M=Math.abs(Math.PI-U)/2;if(f-d>0){f=U<Math.PI?f+M:f-M;d=U<Math.PI?d-M:d+M}else{f=U<Math.PI?f-M:f+M;d=U<Math.PI?d+M:d-M}B.x=q*Math.cos(f)+k.x;B.y=q*Math.sin(f)+k.y;J.x=o*Math.cos(d)+k.x;J.y=o*Math.sin(d)+k.y;return[B,J]}};svgedit.path.Segment=function(f,d){this.selected=false;this.index=f;this.item=d;this.type=d.pathSegType;this.ctrlpts=[];this.segsel=this.ptgrip=null};svgedit.path.Segment.prototype.showCtrlPts=
function(f){for(var d in this.ctrlpts)this.ctrlpts[d].setAttribute("display",f?"inline":"none")};svgedit.path.Segment.prototype.selectCtrls=function(){$("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill","#4F80FF")};svgedit.path.Segment.prototype.show=function(f){if(this.ptgrip){this.ptgrip.setAttribute("display",f?"inline":"none");this.segsel.setAttribute("display",f?"inline":"none");this.showCtrlPts(f)}};svgedit.path.Segment.prototype.select=function(f){if(this.ptgrip){this.ptgrip.setAttribute("stroke",
f?"#0FF":"#00F");this.segsel.setAttribute("display",f?"inline":"none");this.ctrlpts&&this.selectCtrls(f);this.selected=f}};svgedit.path.Segment.prototype.addGrip=function(){this.ptgrip=svgedit.path.getPointGrip(this,true);this.ctrlpts=svgedit.path.getControlPoints(this,true);this.segsel=svgedit.path.getSegSelector(this,true)};svgedit.path.Segment.prototype.update=function(f){if(this.ptgrip){var d=svgedit.path.getGripPt(this),k=svgeditor.browser.isTouch()?15:2.5;svgedit.utilities.assignAttributes(this.ptgrip,
this.ptgrip.nodeName=="rect"?{x:d.x-k,y:d.y-k}:{cx:d.x,cy:d.y});svgedit.path.getSegSelector(this,true);if(this.ctrlpts){if(f){this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.type=this.item.pathSegType}svgedit.path.getControlPoints(this)}}};svgedit.path.Segment.prototype.move=function(f,d){var k=this.item;k=this.ctrlpts?[k.x+=f,k.y+=d,k.x1,k.y1,k.x2+=f,k.y2+=d]:[k.x+=f,k.y+=d];svgedit.path.replacePathSeg(this.type,this.index,k);if(this.next&&this.next.ctrlpts){k=this.next.item;
k=[k.x,k.y,k.x1+=f,k.y1+=d,k.x2,k.y2];svgedit.path.replacePathSeg(this.next.type,this.next.index,k)}if(this.mate){k=this.mate.item;k=[k.x+=f,k.y+=d];svgedit.path.replacePathSeg(this.mate.type,this.mate.index,k)}this.update(true);this.next&&this.next.update(true)};svgedit.path.Segment.prototype.setLinked=function(f){var d,k,q;if(f==2){k=1;d=this.next;if(!d)return;q=this.item}else{k=2;d=this.prev;if(!d)return;q=d.item}var B=d.item;B["x"+k]=q.x+(q.x-this.item["x"+f]);B["y"+k]=q.y+(q.y-this.item["y"+
f]);svgedit.path.replacePathSeg(d.type,d.index,[B.x,B.y,B.x1,B.y1,B.x2,B.y2]);d.update(true)};svgedit.path.Segment.prototype.moveCtrl=function(f,d,k){var q=this.item;q["x"+f]+=d;q["y"+f]+=k;svgedit.path.replacePathSeg(this.type,this.index,[q.x,q.y,q.x1,q.y1,q.x2,q.y2]);this.update(true)};svgedit.path.Segment.prototype.setType=function(f,d){svgedit.path.replacePathSeg(f,this.index,d);this.type=f;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.showCtrlPts(f===6);this.ctrlpts=svgedit.path.getControlPoints(this);
this.update(true)};svgedit.path.Path=function(f){if(!f||f.tagName!=="path")throw"svgedit.path.Path constructed without a <path> element";this.elem=f;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var f=this.elem.pathSegList,d=f.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var k=0;k<d;k++){var q=f.getItem(k);q=new svgedit.path.Segment(k,q);
q.path=this;this.segs.push(q)}f=this.segs;q=null;for(k=0;k<d;k++){var B=f[k],o=k+1>=d?null:f[k+1],J=k-1<0?null:f[k-1];if(B.type===2){if(J&&J.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip()}q=k}else if(o&&o.type===1){B.next=f[q+1];B.next.prev=B;B.mate=f[q];B.addGrip();if(this.first_seg==null)this.first_seg=B}else if(o){if(B.type!==1){B.addGrip();if(o&&o.type!==2){B.next=o;B.next.prev=B}}}else if(B.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip();B.addGrip();if(!this.first_seg)this.first_seg=
f[q]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var d=this.segs.length,k=0;k<d;k++)if(f.call(this.segs[k],k)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var d=this.segs[f];if(d.prev){var k=d.prev,q;switch(d.item.pathSegType){case 4:var B=(d.item.x+k.item.x)/2,o=(d.item.y+k.item.y)/2;q=this.elem.createSVGPathSegLinetoAbs(B,o);break;case 6:q=(k.item.x+d.item.x1)/2;var J=(d.item.x1+d.item.x2)/2,U=(d.item.x2+d.item.x)/2,M=(q+J)/2;J=(J+U)/2;B=(M+J)/2;var I=(k.item.y+
d.item.y1)/2,S=(d.item.y1+d.item.y2)/2;k=(d.item.y2+d.item.y)/2;var Y=(I+S)/2;S=(S+k)/2;o=(Y+S)/2;q=this.elem.createSVGPathSegCurvetoCubicAbs(B,o,q,I,M,Y);svgedit.path.replacePathSeg(d.type,f,[d.item.x,d.item.y,J,S,U,k])}svgedit.path.insertItemBefore(this.elem,q,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var d=this.segs[f],k=this.elem.pathSegList;d.show(false);var q=d.next;if(d.mate){var B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,q.index,B);svgedit.path.replacePathSeg(4,d.index,
B);k.removeItem(d.mate.index)}else{if(!d.prev){B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,d.next.index,B)}k.removeItem(f)}};svgedit.path.Path.prototype.subpathIsClosed=function(f){var d=false;svgedit.path.path.eachSeg(function(k){if(k<=f)return true;if(this.type===2)return false;else if(this.type===1){d=true;return false}});return d};svgedit.path.Path.prototype.removePtFromSelection=function(f){var d=this.selected_pts.indexOf(f);if(d!=-1){this.segs[f].select(false);this.selected_pts.splice(d,
1)}};svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg(function(){this.select(false)});this.selected_pts=[]};svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")};svgedit.path.Path.prototype.show=function(f){this.eachSeg(function(){this.show(f)});f&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(f,d){for(var k=this.selected_pts.length;k--;)this.segs[this.selected_pts[k]].move(f,d)};svgedit.path.Path.prototype.moveCtrl=
function(f,d){var k=this.segs[this.selected_pts[0]];k.moveCtrl(this.dragctrl,f,d);c&&k.setLinked(this.dragctrl)};svgedit.path.Path.prototype.setSegType=function(f){this.storeD();for(var d=this.selected_pts.length,k;d--;){var q=this.segs[this.selected_pts[d]],B=q.prev;if(B){if(!f){k="Toggle Path Segment Type";f=q.type==6?4:6}f-=0;var o=q.item.x,J=q.item.y,U=B.item.x;B=B.item.y;var M;switch(f){case 6:if(q.olditem){U=q.olditem;M=[o,J,U.x1,U.y1,U.x2,U.y2]}else{M=o-U;var I=J-B;M=[o,J,U+M/3,B+I/3,o-M/3,
J-I/3]}break;case 4:M=[o,J];q.olditem=q.item}q.setType(f,M)}}svgedit.path.path.endChanges(k)};svgedit.path.Path.prototype.selectPt=function(f,d){this.clearSelection();f==null&&this.eachSeg(function(k){if(this.prev)f=k});this.addPtsToSelection(f);if(d){this.dragctrl=d;c&&this.segs[f].setLinked(d)}};svgedit.path.Path.prototype.update=function(){var f=this.elem;if(svgedit.utilities.getRotationAngle(f)){this.matrix=svgedit.math.getMatrix(f);this.imatrix=this.matrix.inverse()}else this.imatrix=this.matrix=
null;this.eachSeg(function(d){this.item=f.pathSegList.getItem(d);this.update()});return this};svgedit.path.getPath_=function(f){var d=m[f.id];d||(d=m[f.id]=new svgedit.path.Path(f));return d};svgedit.path.removePath_=function(f){f in m&&delete m[f]};var b=function(f,d){dx=f-oldcx;dy=d-oldcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)+angle;dx=r*Math.cos(theta)+oldcx;dy=r*Math.sin(theta)+oldcy;dx-=newcx;dy-=newcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)-angle;return{x:(r*Math.cos(theta)+
newcx)/1,y:(r*Math.sin(theta)+newcy)/1}};svgedit.path.recalcRotatedPath=function(){var f=svgedit.path.path.elem,d=svgedit.utilities.getRotationAngle(f,true);if(d){var k=svgedit.utilities.getBBox(f),q=svgedit.path.path.oldbbox,B=q.x+q.width/2,o=q.y+q.height/2;q=k.x+k.width/2;k=k.y+k.height/2;q=q-B;var J=k-o;k=Math.sqrt(q*q+J*J);J=Math.atan2(J,q)+d;q=k*Math.cos(J)+B;k=k*Math.sin(J)+o;B=f.pathSegList;for(o=B.numberOfItems;o;){o-=1;J=B.getItem(o);var U=J.pathSegType;if(U!=1){var M=b(J.x,J.y);M=[M.x,M.y];
if(J.x1!=null&&J.x2!=null){c_vals1=b(J.x1,J.y1);c_vals2=b(J.x2,J.y2);M.splice(M.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(U,o,M)}}svgedit.utilities.getBBox(f);B=svgroot.createSVGTransform();f=svgedit.transformlist.getTransformList(f);B.setRotate(d*180/Math.PI,q,k);f.replaceItem(B,0)}};svgedit.path.clearData=function(){m={}}})();if(!window.console){window.console={};window.console.log=function(){};window.console.dir=function(){}}if(window.opera){window.console.log=function(a){opera.postError(a)};window.console.dir=function(){}}
return k};svgedit.path.addPointGrip=function(f,d,k){var q=svgedit.path.getGripContainer(),B=svgedit.utilities.getElem("pathpointgrip_"+f);if(!B){B=document.createElementNS("http://www.w3.org/2000/svg","rect");svgedit.utilities.assignAttributes(B,{id:"pathpointgrip_"+f,display:"none",width:svgedit.browser.isTouch()?30:5,height:svgedit.browser.isTouch()?30:5,fill:"#fff",stroke:"#4F80FF","shape-rendering":"crispEdges","stroke-width":1,cursor:"move",style:"pointer-events:all","xlink:title":a.pathNodeTooltip});
B=q.appendChild(B);$("#pathpointgrip_"+f).dblclick(function(){svgedit.path.path&&svgedit.path.path.setSegType()})}if(d&&k)svgedit.utilities.assignAttributes(B,{x:d-(svgedit.browser.isTouch()?15:2.5),y:k-(svgedit.browser.isTouch()?15:2.5),display:"inline"});return B};svgedit.path.getGripContainer=function(){var f=svgedit.utilities.getElem("pathpointgrip_container");if(!f){f=svgedit.utilities.getElem("selectorParentGroup").appendChild(document.createElementNS("http://www.w3.org/2000/svg","g"));f.id=
"pathpointgrip_container"}return f};svgedit.path.addCtrlGrip=function(f){var d=svgedit.utilities.getElem("ctrlpointgrip_"+f);if(d)return d;d=document.createElementNS("http://www.w3.org/2000/svg","circle");svgedit.utilities.assignAttributes(d,{id:"ctrlpointgrip_"+f,display:"none",r:svgedit.browser.isTouch()?15:3,fill:"#4F80FF",cursor:"move",style:"pointer-events:all","xlink:title":a.pathCtrlPtTooltip});svgedit.path.getGripContainer().appendChild(d);return d};svgedit.path.getCtrlLine=function(f){var d=
svgedit.utilities.getElem("ctrlLine_"+f);if(d)return d;d=document.createElementNS("http://www.w3.org/2000/svg","line");svgedit.utilities.assignAttributes(d,{id:"ctrlLine_"+f,stroke:"#4F80FF","stroke-width":1,style:"pointer-events:none"});svgedit.path.getGripContainer().appendChild(d);return d};svgedit.path.getPointGrip=function(f,d){var k=svgedit.path.addPointGrip(f.index);if(d){var q=svgedit.path.getGripPt(f);svgedit.utilities.assignAttributes(k,{x:q.x-(svgedit.browser.isTouch()?15:2.5),y:q.y-(svgedit.browser.isTouch()?
15:2.5),display:"inline"})}return k};svgedit.path.getControlPoints=function(f){var d=f.item,k=f.index;if(!("x1"in d)||!("x2"in d))return null;var q={};svgedit.path.getGripContainer();for(var B=[svgedit.path.path.segs[k-1].item,d],o=1;o<3;o++){var J=k+"c"+o,U=q["c"+o+"_line"]=svgedit.path.getCtrlLine(J),M=svgedit.path.getGripPt(f,{x:d["x"+o],y:d["y"+o]}),I=svgedit.path.getGripPt(f,{x:B[o-1].x,y:B[o-1].y});svgedit.utilities.assignAttributes(U,{x1:M.x,y1:M.y,x2:I.x,y2:I.y,display:"inline"});q["c"+o+
"_line"]=U;pointGrip=q["c"+o]=svgedit.path.addCtrlGrip(J);svgedit.utilities.assignAttributes(pointGrip,{cx:M.x,cy:M.y,display:"inline"});q["c"+o]=pointGrip}return q};svgedit.path.replacePathSeg=function(f,d,k,q){q=q||svgedit.path.path.elem;f=q["createSVGPathSeg"+g[f]].apply(q,k);if(svgedit.browser.supportsPathReplaceItem())q.pathSegList.replaceItem(f,d);else{k=q.pathSegList;q=k.numberOfItems;for(var B=[],o=0;o<q;o++){var J=k.getItem(o);B.push(J)}k.clear();for(o=0;o<q;o++)o==d?k.appendItem(f):k.appendItem(B[o])}};
svgedit.path.getSegSelector=function(f,d){var k=f.index,q=svgedit.utilities.getElem("segline_"+k);if(!q){var B=svgedit.path.getGripContainer();q=document.createElementNS("http://www.w3.org/2000/svg","path");svgedit.utilities.assignAttributes(q,{id:"segline_"+k,display:"none",fill:"none",stroke:"#0FF","stroke-width":2,style:"pointer-events:none",d:"M0,0 0,0"});B.appendChild(q)}if(d){k=f.prev;if(!k){q.setAttribute("display","none");return q}k=svgedit.path.getGripPt(k);svgedit.path.replacePathSeg(2,
0,[k.x,k.y],q);B=svgedit.path.ptObjToArr(f.type,f.item,true);for(var o=0;o<B.length;o+=2){k=svgedit.path.getGripPt(f,{x:B[o],y:B[o+1]});B[o]=k.x;B[o+1]=k.y}svgedit.path.replacePathSeg(f.type,1,B,q)}return q};svgedit.path.smoothControlPoints=this.smoothControlPoints=function(f,d,k){var q=f.x-k.x,B=f.y-k.y,o=d.x-k.x,J=d.y-k.y;if((q!=0||B!=0)&&(o!=0||J!=0)){f=Math.atan2(B,q);d=Math.atan2(J,o);q=Math.sqrt(q*q+B*B);o=Math.sqrt(o*o+J*J);B=s.getSVGRoot().createSVGPoint();J=s.getSVGRoot().createSVGPoint();
if(f<0)f+=2*Math.PI;if(d<0)d+=2*Math.PI;var U=Math.abs(f-d),M=Math.abs(Math.PI-U)/2;if(f-d>0){f=U<Math.PI?f+M:f-M;d=U<Math.PI?d-M:d+M}else{f=U<Math.PI?f-M:f+M;d=U<Math.PI?d+M:d-M}B.x=q*Math.cos(f)+k.x;B.y=q*Math.sin(f)+k.y;J.x=o*Math.cos(d)+k.x;J.y=o*Math.sin(d)+k.y;return[B,J]}};svgedit.path.Segment=function(f,d){this.selected=false;this.index=f;this.item=d;this.type=d.pathSegType;this.ctrlpts=[];this.segsel=this.ptgrip=null};svgedit.path.Segment.prototype.showCtrlPts=function(f){for(var d in this.ctrlpts)this.ctrlpts[d].setAttribute("display",
f?"inline":"none")};svgedit.path.Segment.prototype.selectCtrls=function(){$("#ctrlpointgrip_"+this.index+"c1, #ctrlpointgrip_"+this.index+"c2").attr("fill","#4F80FF")};svgedit.path.Segment.prototype.show=function(f){if(this.ptgrip){this.ptgrip.setAttribute("display",f?"inline":"none");this.segsel.setAttribute("display",f?"inline":"none");this.showCtrlPts(f)}};svgedit.path.Segment.prototype.select=function(f){if(this.ptgrip){this.ptgrip.setAttribute("stroke",f?"#0FF":"#00F");this.segsel.setAttribute("display",
f?"inline":"none");this.ctrlpts&&this.selectCtrls(f);this.selected=f}};svgedit.path.Segment.prototype.addGrip=function(){this.ptgrip=svgedit.path.getPointGrip(this,true);this.ctrlpts=svgedit.path.getControlPoints(this,true);this.segsel=svgedit.path.getSegSelector(this,true)};svgedit.path.Segment.prototype.update=function(f){if(this.ptgrip){var d=svgedit.path.getGripPt(this),k=svgedit.browser.isTouch()?15:2.5;svgedit.utilities.assignAttributes(this.ptgrip,this.ptgrip.nodeName=="rect"?{x:d.x-k,y:d.y-
k}:{cx:d.x,cy:d.y});svgedit.path.getSegSelector(this,true);if(this.ctrlpts){if(f){this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.type=this.item.pathSegType}svgedit.path.getControlPoints(this)}}};svgedit.path.Segment.prototype.move=function(f,d){var k=this.item;k=this.ctrlpts?[k.x+=f,k.y+=d,k.x1,k.y1,k.x2+=f,k.y2+=d]:[k.x+=f,k.y+=d];svgedit.path.replacePathSeg(this.type,this.index,k);if(this.next&&this.next.ctrlpts){k=this.next.item;k=[k.x,k.y,k.x1+=f,k.y1+=d,k.x2,k.y2];svgedit.path.replacePathSeg(this.next.type,
this.next.index,k)}if(this.mate){k=this.mate.item;k=[k.x+=f,k.y+=d];svgedit.path.replacePathSeg(this.mate.type,this.mate.index,k)}this.update(true);this.next&&this.next.update(true)};svgedit.path.Segment.prototype.setLinked=function(f){var d,k,q;if(f==2){k=1;d=this.next;if(!d)return;q=this.item}else{k=2;d=this.prev;if(!d)return;q=d.item}var B=d.item;B["x"+k]=q.x+(q.x-this.item["x"+f]);B["y"+k]=q.y+(q.y-this.item["y"+f]);svgedit.path.replacePathSeg(d.type,d.index,[B.x,B.y,B.x1,B.y1,B.x2,B.y2]);d.update(true)};
svgedit.path.Segment.prototype.moveCtrl=function(f,d,k){var q=this.item;q["x"+f]+=d;q["y"+f]+=k;svgedit.path.replacePathSeg(this.type,this.index,[q.x,q.y,q.x1,q.y1,q.x2,q.y2]);this.update(true)};svgedit.path.Segment.prototype.setType=function(f,d){svgedit.path.replacePathSeg(f,this.index,d);this.type=f;this.item=svgedit.path.path.elem.pathSegList.getItem(this.index);this.showCtrlPts(f===6);this.ctrlpts=svgedit.path.getControlPoints(this);this.update(true)};svgedit.path.Path=function(f){if(!f||f.tagName!==
"path")throw"svgedit.path.Path constructed without a <path> element";this.elem=f;this.segs=[];this.selected_pts=[];svgedit.path.path=this;this.init()};svgedit.path.Path.prototype.init=function(){$(svgedit.path.getGripContainer()).find("*").attr("display","none");var f=this.elem.pathSegList,d=f.numberOfItems;this.segs=[];this.selected_pts=[];this.first_seg=null;for(var k=0;k<d;k++){var q=f.getItem(k);q=new svgedit.path.Segment(k,q);q.path=this;this.segs.push(q)}f=this.segs;q=null;for(k=0;k<d;k++){var B=
f[k],o=k+1>=d?null:f[k+1],J=k-1<0?null:f[k-1];if(B.type===2){if(J&&J.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip()}q=k}else if(o&&o.type===1){B.next=f[q+1];B.next.prev=B;B.mate=f[q];B.addGrip();if(this.first_seg==null)this.first_seg=B}else if(o){if(B.type!==1){B.addGrip();if(o&&o.type!==2){B.next=o;B.next.prev=B}}}else if(B.type!==1){o=f[q];o.next=f[q+1];o.next.prev=o;o.addGrip();B.addGrip();if(!this.first_seg)this.first_seg=f[q]}}return this};svgedit.path.Path.prototype.eachSeg=function(f){for(var d=
this.segs.length,k=0;k<d;k++)if(f.call(this.segs[k],k)===false)break};svgedit.path.Path.prototype.addSeg=function(f){var d=this.segs[f];if(d.prev){var k=d.prev,q;switch(d.item.pathSegType){case 4:var B=(d.item.x+k.item.x)/2,o=(d.item.y+k.item.y)/2;q=this.elem.createSVGPathSegLinetoAbs(B,o);break;case 6:q=(k.item.x+d.item.x1)/2;var J=(d.item.x1+d.item.x2)/2,U=(d.item.x2+d.item.x)/2,M=(q+J)/2;J=(J+U)/2;B=(M+J)/2;var I=(k.item.y+d.item.y1)/2,S=(d.item.y1+d.item.y2)/2;k=(d.item.y2+d.item.y)/2;var Y=(I+
S)/2;S=(S+k)/2;o=(Y+S)/2;q=this.elem.createSVGPathSegCurvetoCubicAbs(B,o,q,I,M,Y);svgedit.path.replacePathSeg(d.type,f,[d.item.x,d.item.y,J,S,U,k])}svgedit.path.insertItemBefore(this.elem,q,f)}};svgedit.path.Path.prototype.deleteSeg=function(f){var d=this.segs[f],k=this.elem.pathSegList;d.show(false);var q=d.next;if(d.mate){var B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,q.index,B);svgedit.path.replacePathSeg(4,d.index,B);k.removeItem(d.mate.index)}else{if(!d.prev){B=[q.item.x,q.item.y];svgedit.path.replacePathSeg(2,
d.next.index,B)}k.removeItem(f)}};svgedit.path.Path.prototype.subpathIsClosed=function(f){var d=false;svgedit.path.path.eachSeg(function(k){if(k<=f)return true;if(this.type===2)return false;else if(this.type===1){d=true;return false}});return d};svgedit.path.Path.prototype.removePtFromSelection=function(f){var d=this.selected_pts.indexOf(f);if(d!=-1){this.segs[f].select(false);this.selected_pts.splice(d,1)}};svgedit.path.Path.prototype.clearSelection=function(){this.eachSeg(function(){this.select(false)});
this.selected_pts=[]};svgedit.path.Path.prototype.storeD=function(){this.last_d=this.elem.getAttribute("d")};svgedit.path.Path.prototype.show=function(f){this.eachSeg(function(){this.show(f)});f&&this.selectPt(this.first_seg.index);return this};svgedit.path.Path.prototype.movePts=function(f,d){for(var k=this.selected_pts.length;k--;)this.segs[this.selected_pts[k]].move(f,d)};svgedit.path.Path.prototype.moveCtrl=function(f,d){var k=this.segs[this.selected_pts[0]];k.moveCtrl(this.dragctrl,f,d);c&&k.setLinked(this.dragctrl)};
svgedit.path.Path.prototype.setSegType=function(f){this.storeD();for(var d=this.selected_pts.length,k;d--;){var q=this.segs[this.selected_pts[d]],B=q.prev;if(B){if(!f){k="Toggle Path Segment Type";f=q.type==6?4:6}f-=0;var o=q.item.x,J=q.item.y,U=B.item.x;B=B.item.y;var M;switch(f){case 6:if(q.olditem){U=q.olditem;M=[o,J,U.x1,U.y1,U.x2,U.y2]}else{M=o-U;var I=J-B;M=[o,J,U+M/3,B+I/3,o-M/3,J-I/3]}break;case 4:M=[o,J];q.olditem=q.item}q.setType(f,M)}}svgedit.path.path.endChanges(k)};svgedit.path.Path.prototype.selectPt=
function(f,d){this.clearSelection();f==null&&this.eachSeg(function(k){if(this.prev)f=k});this.addPtsToSelection(f);if(d){this.dragctrl=d;c&&this.segs[f].setLinked(d)}};svgedit.path.Path.prototype.update=function(){var f=this.elem;if(svgedit.utilities.getRotationAngle(f)){this.matrix=svgedit.math.getMatrix(f);this.imatrix=this.matrix.inverse()}else this.imatrix=this.matrix=null;this.eachSeg(function(d){this.item=f.pathSegList.getItem(d);this.update()});return this};svgedit.path.getPath_=function(f){var d=
m[f.id];d||(d=m[f.id]=new svgedit.path.Path(f));return d};svgedit.path.removePath_=function(f){f in m&&delete m[f]};var b=function(f,d){dx=f-oldcx;dy=d-oldcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)+angle;dx=r*Math.cos(theta)+oldcx;dy=r*Math.sin(theta)+oldcy;dx-=newcx;dy-=newcy;r=Math.sqrt(dx*dx+dy*dy);theta=Math.atan2(dy,dx)-angle;return{x:(r*Math.cos(theta)+newcx)/1,y:(r*Math.sin(theta)+newcy)/1}};svgedit.path.recalcRotatedPath=function(){var f=svgedit.path.path.elem,d=svgedit.utilities.getRotationAngle(f,
true);if(d){var k=svgedit.utilities.getBBox(f),q=svgedit.path.path.oldbbox,B=q.x+q.width/2,o=q.y+q.height/2;q=k.x+k.width/2;k=k.y+k.height/2;q=q-B;var J=k-o;k=Math.sqrt(q*q+J*J);J=Math.atan2(J,q)+d;q=k*Math.cos(J)+B;k=k*Math.sin(J)+o;B=f.pathSegList;for(o=B.numberOfItems;o;){o-=1;J=B.getItem(o);var U=J.pathSegType;if(U!=1){var M=b(J.x,J.y);M=[M.x,M.y];if(J.x1!=null&&J.x2!=null){c_vals1=b(J.x1,J.y1);c_vals2=b(J.x2,J.y2);M.splice(M.length,0,c_vals1.x,c_vals1.y,c_vals2.x,c_vals2.y)}svgedit.path.replacePathSeg(U,
o,M)}}svgedit.utilities.getBBox(f);B=svgroot.createSVGTransform();f=svgedit.transformlist.getTransformList(f);B.setRotate(d*180/Math.PI,q,k);f.replaceItem(B,0)}};svgedit.path.clearData=function(){m={}}})();if(!window.console){window.console={};window.console.log=function(){};window.console.dir=function(){}}if(window.opera){window.console.log=function(a){opera.postError(a)};window.console.dir=function(){}}
(function(){var a=jQuery.fn.attr;jQuery.fn.attr=function(p,g){var c=this.length;if(!c)return a.apply(this,arguments);for(var m=0;m<c;m++){var s=this[m];if(s.namespaceURI==="http://www.w3.org/2000/svg")if(g!==undefined)s.setAttribute(p,g);else if($.isArray(p)){c=p.length;for(m={};c--;){var b=p[c],f=s.getAttribute(b);if(f||f==="0")f=isNaN(f)?f:f-0;m[b]=f}return m}else if(typeof p==="object")for(b in p)s.setAttribute(b,p[b]);else{if((f=s.getAttribute(p))||f==="0")f=isNaN(f)?f:f-0;return f}else return a.apply(this,
arguments)}return this}})();
$.SvgCanvas=function(a,p){function g(e,h){for(var l=svgedit.utilities.getBBox(e),z=0;z<2;z++){var v=z===0?"fill":"stroke",G=e.getAttribute(v);if(G&&G.indexOf("url(")===0){G=T(G);if(G.tagName==="linearGradient"){var A=G.getAttribute("x1")||0,u=G.getAttribute("y1")||0,F=G.getAttribute("x2")||1,H=G.getAttribute("y2")||0;A=l.width*A+l.x;u=l.height*u+l.y;F=l.width*F+l.x;H=l.height*H+l.y;A=P(A,u,h);H=P(F,H,h);F={};F.x1=(A.x-l.x)/l.width;F.y1=(A.y-l.y)/l.height;F.x2=(H.x-l.x)/l.width;F.y2=(H.y-l.y)/l.height;