/** * Package: svgedit.path * * Licensed under the Apache License, Version 2 * * Copyright(c) 2011 Alexis Deveria * Copyright(c) 2011 Jeff Schiller */ // Dependencies: // 1) jQuery // 2) browser.js // 3) math.js // 4) svgutils.js var svgedit = svgedit || {}; (function() { if (!svgedit.path) { svgedit.path = {}; } var svgns = "http://www.w3.org/2000/svg"; var uiStrings = { "pathNodeTooltip": "Drag node to move it. Double-click node to change segment type", "pathCtrlPtTooltip": "Drag control point to adjust curve properties" }; var segData = { 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'] }; var pathFuncs = []; svgedit.path.path = null; var editorContext_ = null; svgedit.path.init = function(editorContext) { editorContext_ = editorContext; pathFuncs = [0,'ClosePath']; var pathFuncsStrs = ['Moveto', 'Lineto', 'CurvetoCubic', 'CurvetoQuadratic', 'Arc', 'LinetoHorizontal', 'LinetoVertical','CurvetoCubicSmooth','CurvetoQuadraticSmooth']; $.each(pathFuncsStrs, function(i,s) { pathFuncs.push(s+'Abs'); pathFuncs.push(s+'Rel'); }); }; svgedit.path.insertItemBefore = function(elem, newseg, index) { // Support insertItemBefore on paths for FF2 var list = elem.pathSegList; if(svgedit.browser.supportsPathInsertItemBefore()) { list.insertItemBefore(newseg, index); return; } var len = list.numberOfItems; var arr = []; for(var i=0; i