diff --git a/www/js/canvasDrawing.js b/www/js/canvasDrawing.js index 649f004..c750947 100644 --- a/www/js/canvasDrawing.js +++ b/www/js/canvasDrawing.js @@ -302,17 +302,17 @@ function onCanvasMouseDown(e) { function saveToSvg() { var lastX = 0, lastY = 0, lastIsMove; - var data = ''; //TODO: change data to an array which is collapsed after the loop? var svg = ''; - var boundsWidth = doodleBounds[3] - doodleBounds[1]; - var boundsHeight = doodleBounds[2] - doodleBounds[0]; + var boundsWidth = doodleBounds[2] - doodleBounds[0]; + var boundsHeight = doodleBounds[3] - doodleBounds[1]; svg += '\n'; svg += '\n'; svg += '\n'; svg += '\tDoodle 3D sketch\n'; + var data = ''; for (var i = 0; i < _points.length; ++i) { var x = _points[i][0], y = _points[i][1], isMove = _points[i][2]; var dx = x - lastX, dy = y - lastY; @@ -329,20 +329,23 @@ function saveToSvg() { lastIsMove = isMove; } - svg += '\t\n'; + svg += '\t\n'; - var field = 'height', value = numLayers; - svg += '\t\n'; - field = 'outlineShape', value = VERTICALSHAPE; - svg += '\t\n'; - field = 'twist', value = rStep; - svg += '\t\n'; + var makeField = function(k,v) { return k + ': ' + v + '; '; } + svg += '\n'; svg += '\n'; return svg; } +function loadFromSvg(svgData) { + //clear out points + //read svg and fill points (and update bounds) + //NOTE: generate the fields comment with some magic value so we can easily detect this while parsing + //update any state necessary to have the canvas/client re-init itself to the new data +} + var prevPoint = {x:-1, y:-1}; function onCanvasMouseMove(e) { // console.log("f:onCanvasMouseMove()");