From 4290e20e2b2f4536f4365d02e1cd7a1418bc8ea9 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 24 Apr 2012 15:40:12 -0700 Subject: allow the realtime drawing of brush strokes drawn off the standard XY plane by passing in the transformation matrix --- js/lib/geom/brush-stroke.js | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'js/lib') diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js index efd21c4a..89ef79fb 100755 --- a/js/lib/geom/brush-stroke.js +++ b/js/lib/geom/brush-stroke.js @@ -117,7 +117,7 @@ var BrushStroke = function GLBrushStroke() { }; this.getPoint = function (index) { - return this._Points[index]; + return this._Points[index].slice(0); }; this.addPoint = function (pt) { @@ -399,7 +399,7 @@ var BrushStroke = function GLBrushStroke() { // ***** unproject all the centered points and convert them to 2D (plane space)***** // (undo the projection step performed by the browser) - localPoint = this._unprojectPt(localPoint, 1400); //todo get the perspective distance from the canvas + //localPoint = this._unprojectPt(localPoint, 1400); //todo get the perspective distance from the canvas localPoint = MathUtils.transformPoint(localPoint, this._planeMatInv); //add to the list of local points @@ -572,13 +572,13 @@ var BrushStroke = function GLBrushStroke() { ctx.restore(); } //this.render() - this.drawToContext = function(ctx, origX, origY, drawStageWorldPts){ + this.drawToContext = function(ctx, deltaX, deltaY, drawStageWorldPts, stageWorldToScreenMat){ var points = this._LocalPoints; - if (drawStageWorldPts){ + if (drawStageWorldPts){ //this is usually true when we're drawing the brush stroke on the stage (no canvas yet) points = this._Points; } var numPoints = points.length; - + var tempP, p; if (this._strokeUseCalligraphic) { //build the stamp for the brush stroke var t=0; @@ -623,9 +623,9 @@ var BrushStroke = function GLBrushStroke() { //ctx.strokeStyle="rgba("+parseInt(255*currStrokeColor[0])+","+parseInt(255*currStrokeColor[1])+","+parseInt(255*currStrokeColor[2])+","+alphaVal+")"; ctx.translate(disp[0],disp[1]); ctx.beginPath(); - ctx.moveTo(points[0][0]-origX, points[0][1]-origY); + ctx.moveTo(points[0][0]-deltaX, points[0][1]-deltaY); for (var i=0;i --- js/lib/NJUtils.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'js/lib') diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 67bb59c4..dae128e4 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -94,10 +94,10 @@ exports.NJUtils = Object.create(Object.prototype, { ///// TODO: find a different place for this function makeElementModel: { value: function(el, selection, controller, isShape) { + //el.elementModel = Montage.create(ElementModel).initialize(el.nodeName, selection, controller, isShape); + var p3d = Montage.create(Properties3D); - if(selection === "Stage") { - p3d.init(el, true); - } + var shapeProps = null; var pi = controller + "Pi"; @@ -143,6 +143,7 @@ exports.NJUtils = Object.create(Object.prototype, { isShape: { value: isShape} }); + } }, @@ -167,15 +168,12 @@ exports.NJUtils = Object.create(Object.prototype, { break; case "canvas": isShape = el.getAttribute("data-RDGE-id"); - if(isShape) - { + if(isShape) { // TODO - Need more info about the shape selection = "canvas"; controller = "shape"; isShape = true; - } - else - { + } else { selection = "canvas"; controller = "canvas"; } -- cgit v1.2.3