diff options
author | Pushkar Joshi | 2012-05-31 14:34:21 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-05-31 14:34:21 -0700 |
commit | 0a7357bad4e646177b0420848844f503e0b64161 (patch) | |
tree | 7845956332034c8893fa8470176848d115f5300e | |
parent | 4bc52365b1f81a386c3c59fd7c6ad874bb387cb5 (diff) | |
download | ninja-0a7357bad4e646177b0420848844f503e0b64161.tar.gz |
somewhat working version of the canvas runtime for pen paths (the runtime renders properly if we go through debugger)...also removed calls to getStageElement from pen tool
-rw-r--r-- | assets/canvas-runtime.js | 10 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 4 |
2 files changed, 10 insertions, 4 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index c0c4ccfc..3ed7ed0f 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js | |||
@@ -1920,6 +1920,12 @@ NinjaCvsRt.RuntimeSubPath = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
1920 | _strokeColor: {value: null, writable: true}, | 1920 | _strokeColor: {value: null, writable: true}, |
1921 | _fillColor: {value: null, writable: true}, | 1921 | _fillColor: {value: null, writable: true}, |
1922 | 1922 | ||
1923 | geomType: { | ||
1924 | value: function () { | ||
1925 | return this.GEOM_TYPE_CUBIC_BEZIER; | ||
1926 | } | ||
1927 | }, | ||
1928 | |||
1923 | importJSON: { | 1929 | importJSON: { |
1924 | value: function(jo) { | 1930 | value: function(jo) { |
1925 | if (this.geomType()!== jo.geomType){ | 1931 | if (this.geomType()!== jo.geomType){ |
@@ -1929,7 +1935,7 @@ NinjaCvsRt.RuntimeSubPath = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
1929 | this._Anchors = []; | 1935 | this._Anchors = []; |
1930 | var i=0; | 1936 | var i=0; |
1931 | for (i=0;i<jo.anchors.length;i++){ | 1937 | for (i=0;i<jo.anchors.length;i++){ |
1932 | var newAnchor = new NinjaCvsRt.AnchorPoint(); | 1938 | var newAnchor = Object.create(NinjaCvsRt.AnchorPoint); |
1933 | var ipAnchor = jo.anchors[i]; | 1939 | var ipAnchor = jo.anchors[i]; |
1934 | newAnchor.setPos(ipAnchor._x, ipAnchor._y, ipAnchor._z); | 1940 | newAnchor.setPos(ipAnchor._x, ipAnchor._y, ipAnchor._z); |
1935 | newAnchor.setPrevPos(ipAnchor._prevX, ipAnchor._prevY, ipAnchor._prevZ); | 1941 | newAnchor.setPrevPos(ipAnchor._prevX, ipAnchor._prevY, ipAnchor._prevZ); |
@@ -1993,8 +1999,8 @@ NinjaCvsRt.RuntimeSubPath = Object.create(NinjaCvsRt.RuntimeGeomObj, { | |||
1993 | var currAnchor = this._Anchors[0]; | 1999 | var currAnchor = this._Anchors[0]; |
1994 | ctx.bezierCurveTo(prevAnchor.getNextX(),prevAnchor.getNextY(), currAnchor.getPrevX(), currAnchor.getPrevY(), currAnchor.getPosX(), currAnchor.getPosY()); | 2000 | ctx.bezierCurveTo(prevAnchor.getNextX(),prevAnchor.getNextY(), currAnchor.getPrevX(), currAnchor.getPrevY(), currAnchor.getPosX(), currAnchor.getPosY()); |
1995 | prevAnchor = currAnchor; | 2001 | prevAnchor = currAnchor; |
1996 | ctx.fill(); | ||
1997 | } | 2002 | } |
2003 | ctx.fill(); | ||
1998 | ctx.stroke(); | 2004 | ctx.stroke(); |
1999 | } | 2005 | } |
2000 | ctx.restore(); | 2006 | ctx.restore(); |
diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 0532bdb3..bb163202 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js | |||
@@ -337,7 +337,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
337 | var hitRec = this.getHitRecord(event.pageX, event.pageY, false); | 337 | var hitRec = this.getHitRecord(event.pageX, event.pageY, false); |
338 | var globalMousePos=null, localMousePos=null, stageWorldMousePos = null, drawingCanvas=null; | 338 | var globalMousePos=null, localMousePos=null, stageWorldMousePos = null, drawingCanvas=null; |
339 | if (!this._selectedSubpathCanvas){ | 339 | if (!this._selectedSubpathCanvas){ |
340 | drawingCanvas = ViewUtils.getStageElement(); | 340 | drawingCanvas = this.application.ninja.currentDocument.model.documentRoot;//ViewUtils.getStageElement(); |
341 | stageWorldMousePos = hitRec.calculateStageWorldPoint(); | 341 | stageWorldMousePos = hitRec.calculateStageWorldPoint(); |
342 | stageWorldMousePos[0]+= snapManager.getStageWidth()*0.5; | 342 | stageWorldMousePos[0]+= snapManager.getStageWidth()*0.5; |
343 | stageWorldMousePos[1]+= snapManager.getStageHeight()*0.5; | 343 | stageWorldMousePos[1]+= snapManager.getStageHeight()*0.5; |
@@ -550,7 +550,7 @@ exports.PenTool = Montage.create(ShapeTool, { | |||
550 | var globalMousePos=null, localMousePos=null, stageWorldMousePos = null; | 550 | var globalMousePos=null, localMousePos=null, stageWorldMousePos = null; |
551 | var drawingCanvas = this._selectedSubpath.getCanvas(); | 551 | var drawingCanvas = this._selectedSubpath.getCanvas(); |
552 | if (!drawingCanvas){ | 552 | if (!drawingCanvas){ |
553 | drawingCanvas = ViewUtils.getStageElement(); | 553 | drawingCanvas = this.application.ninja.currentDocument.model.documentRoot; //ViewUtils.getStageElement(); |
554 | stageWorldMousePos = hitRec.calculateStageWorldPoint(); | 554 | stageWorldMousePos = hitRec.calculateStageWorldPoint(); |
555 | stageWorldMousePos[0]+= snapManager.getStageWidth()*0.5; | 555 | stageWorldMousePos[0]+= snapManager.getStageWidth()*0.5; |
556 | stageWorldMousePos[1]+= snapManager.getStageHeight()*0.5; | 556 | stageWorldMousePos[1]+= snapManager.getStageHeight()*0.5; |