aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-07-25 14:34:59 -0700
committerNivesh Rajbhandari2012-07-25 14:34:59 -0700
commit923e760bf4a16baa82e81da6d38e671620664e8f (patch)
tree72f3f71b6c55d2c7a6c445428e07c96df101f2f2 /js/lib
parent2c701ceeee7e7311cac5f4495b61005d9b8b63a7 (diff)
downloadninja-923e760bf4a16baa82e81da6d38e671620664e8f.tar.gz
Support line shape drawing inside existing canvases.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/lib')
-rwxr-xr-xjs/lib/geom/line.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js
index eec4f6d9..df65ee86 100755
--- a/js/lib/geom/line.js
+++ b/js/lib/geom/line.js
@@ -537,6 +537,15 @@ exports.Line = Object.create(GeomObj, {
537 ctx.strokeStyle = c; 537 ctx.strokeStyle = c;
538 } 538 }
539 539
540 var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils;
541 viewUtils.pushViewportObj( world.getCanvas() );
542 var cop = viewUtils.getCenterOfProjection();
543 viewUtils.popViewportObj();
544 var xCtr = cop[0] + this._xOffset, yCtr = cop[1] - this._yOffset;
545 var xLeft = xCtr - 0.5*this.getWidth(), yTop = yCtr - 0.5*this.getHeight();
546 var xDist = cop[0] - xLeft, yDist = cop[1] - yTop;
547 var xOff = 0.5*world.getViewportWidth() - xDist, yOff = 0.5*world.getViewportHeight() - yDist;
548
540 // get the points 549 // get the points
541 var p0, p1; 550 var p0, p1;
542 if(this._slope === "vertical") { 551 if(this._slope === "vertical") {
@@ -554,8 +563,8 @@ exports.Line = Object.create(GeomObj, {
554 } 563 }
555 564
556 // draw the line 565 // draw the line
557 ctx.moveTo( p0[0], p0[1] ); 566 ctx.moveTo( p0[0]+xOff, p0[1]+yOff );
558 ctx.lineTo( p1[0], p1[1] ); 567 ctx.lineTo( p1[0]+xOff, p1[1]+yOff );
559 ctx.stroke(); 568 ctx.stroke();
560 } 569 }
561 } 570 }