aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/components/tools-properties/brush-properties.reel/brush-properties.html2
-rwxr-xr-xjs/components/tools-properties/pen-properties.reel/pen-properties.html2
-rwxr-xr-xjs/document/html-document.js4
-rwxr-xr-xjs/helper-classes/3D/view-utils.js1
-rwxr-xr-xjs/lib/drawing/world.js7
-rwxr-xr-xjs/lib/geom/brush-stroke.js16
-rwxr-xr-xjs/lib/geom/sub-path.js504
-rwxr-xr-xjs/tools/PenTool.js362
8 files changed, 577 insertions, 321 deletions
diff --git a/js/components/tools-properties/brush-properties.reel/brush-properties.html b/js/components/tools-properties/brush-properties.reel/brush-properties.html
index 98442164..d9c35dc2 100755
--- a/js/components/tools-properties/brush-properties.reel/brush-properties.html
+++ b/js/components/tools-properties/brush-properties.reel/brush-properties.html
@@ -84,7 +84,7 @@
84 </head> 84 </head>
85 85
86 <body> 86 <body>
87 <div id="brushProperties" class="subToolHolderPanel"> 87 <div data-montage-id="brushProperties" class="subToolHolderPanel">
88 <div id="strokesContainer" class="leftLabel" style="margin-left:25px; padding-top: 3px;"> 88 <div id="strokesContainer" class="leftLabel" style="margin-left:25px; padding-top: 3px;">
89 <label class="label"> Width:</label> 89 <label class="label"> Width:</label>
90 <div id="strokeSize" class="label"></div> 90 <div id="strokeSize" class="label"></div>
diff --git a/js/components/tools-properties/pen-properties.reel/pen-properties.html b/js/components/tools-properties/pen-properties.reel/pen-properties.html
index 74a3a747..acbedcac 100755
--- a/js/components/tools-properties/pen-properties.reel/pen-properties.html
+++ b/js/components/tools-properties/pen-properties.reel/pen-properties.html
@@ -39,7 +39,7 @@
39 </head> 39 </head>
40 40
41 <body> 41 <body>
42 <div id="penProperties" class="subToolHolderPanel"> 42 <div data-montage-id="penProperties" class="subToolHolderPanel">
43 <div id="strokesContainer" class="leftLabel" style="margin-left:25px; padding-top: 3px;"> 43 <div id="strokesContainer" class="leftLabel" style="margin-left:25px; padding-top: 3px;">
44 <label class="label"> Stroke:</label> 44 <label class="label"> Stroke:</label>
45 <div id="strokeSize" class="label"></div> 45 <div id="strokeSize" class="label"></div>
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 42a7d537..5538229c 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -345,6 +345,10 @@ exports.HTMLDocument = Montage.create(TextDocument, {
345 elementModel.pi = "BrushStrokePi"; 345 elementModel.pi = "BrushStrokePi";
346 break; 346 break;
347 347
348 case root.GEOM_TYPE_CUBIC_BEZIER:
349 elementModel.selection = "Subpath";
350 elementModel.pi = "SubpathPi";
351 break;
348 352
349 default: 353 default:
350 console.log( "geometry type not supported for file I/O, " + root.geomType()); 354 console.log( "geometry type not supported for file I/O, " + root.geomType());
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index a72b7906..f60b953a 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -242,7 +242,6 @@ exports.ViewUtils = Montage.create(Component, {
242 var worldPt = MathUtils.transformPoint( viewPt, mat ); 242 var worldPt = MathUtils.transformPoint( viewPt, mat );
243 var stageWorldPt = this.postViewToStageWorld( worldPt, elt ); 243 var stageWorldPt = this.postViewToStageWorld( worldPt, elt );
244 this.popViewportObj(); 244 this.popViewportObj();
245
246 return stageWorldPt; 245 return stageWorldPt;
247 } 246 }
248 }, 247 },
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 5a054224..a1a5b5ae 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -943,7 +943,7 @@ World.prototype.importObjectJSON = function( jObj, parentGeomObj )
943{ 943{
944 var type = jObj.type; 944 var type = jObj.type;
945 var BrushStroke = require("js/lib/geom/brush-stroke").BrushStroke; 945 var BrushStroke = require("js/lib/geom/brush-stroke").BrushStroke;
946 946 var SubPath = require("js/lib/geom/sub-path").SubPath;
947 var obj; 947 var obj;
948 switch (type) 948 switch (type)
949 { 949 {
@@ -962,6 +962,11 @@ World.prototype.importObjectJSON = function( jObj, parentGeomObj )
962 obj.importJSON( jObj ); 962 obj.importJSON( jObj );
963 break; 963 break;
964 964
965 case 5: //cubic bezier
966 obj = new SubPath();
967 obj.importJSON(jObj);
968 break;
969
965 case 6: //brush stroke 970 case 6: //brush stroke
966 obj = new BrushStroke(); 971 obj = new BrushStroke();
967 obj.importJSON(jObj); 972 obj.importJSON(jObj);
diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js
index 22209815..2a751a89 100755
--- a/js/lib/geom/brush-stroke.js
+++ b/js/lib/geom/brush-stroke.js
@@ -413,7 +413,7 @@ var BrushStroke = function GLBrushStroke() {
413 this._LocalPoints[i][1]+= halfheight; 413 this._LocalPoints[i][1]+= halfheight;
414 414
415 //store the original points 415 //store the original points
416 this._OrigLocalPoints .push([this._LocalPoints[i][0],this._LocalPoints[i][1],this._LocalPoints[i][2]]); 416 this._OrigLocalPoints.push([this._LocalPoints[i][0],this._LocalPoints[i][1],this._LocalPoints[i][2]]);
417 } 417 }
418 //update the bbox with the same adjustment as was made for the local points above 418 //update the bbox with the same adjustment as was made for the local points above
419 this._BBoxMax[0]+= halfwidth;this._BBoxMin[0]+= halfwidth; 419 this._BBoxMax[0]+= halfwidth;this._BBoxMin[0]+= halfwidth;
@@ -541,6 +541,10 @@ var BrushStroke = function GLBrushStroke() {
541 var bboxWidth = bboxMax[0] - bboxMin[0]; 541 var bboxWidth = bboxMax[0] - bboxMin[0];
542 var bboxHeight = bboxMax[1] - bboxMin[1]; 542 var bboxHeight = bboxMax[1] - bboxMin[1];
543 543
544 if (!this._canvas){
545 //set the canvas by querying the world
546 this._canvas = this.getWorld().getCanvas();
547 }
544 if (this._canvas) { 548 if (this._canvas) {
545 var newLeft = Math.round(this._stageWorldCenter[0] - 0.5 * bboxWidth); 549 var newLeft = Math.round(this._stageWorldCenter[0] - 0.5 * bboxWidth);
546 var newTop = Math.round(this._stageWorldCenter[1] - 0.5 * bboxHeight); 550 var newTop = Math.round(this._stageWorldCenter[1] - 0.5 * bboxHeight);
@@ -550,7 +554,7 @@ var BrushStroke = function GLBrushStroke() {
550 554
551 CanvasController.setProperty(this._canvas, "width", bboxWidth+"px"); 555 CanvasController.setProperty(this._canvas, "width", bboxWidth+"px");
552 CanvasController.setProperty(this._canvas, "height", bboxHeight+"px"); 556 CanvasController.setProperty(this._canvas, "height", bboxHeight+"px");
553 this._canvas.elementModel.shapeModel.GLWorld.setViewportFromCanvas(this._canvas); 557 //this._canvas.elementModel.shapeModel.GLWorld.setViewportFromCanvas(this._canvas);
554 } 558 }
555 559
556 560
@@ -662,8 +666,8 @@ var BrushStroke = function GLBrushStroke() {
662 this._copyCoordinates3D(this._OrigLocalPoints, retObject.origLocalPoints); //todo <ditto> 666 this._copyCoordinates3D(this._OrigLocalPoints, retObject.origLocalPoints); //todo <ditto>
663 667
664 retObject.stageWorldCenter = [this._stageWorldCenter[0],this._stageWorldCenter[1],this._stageWorldCenter[2]]; 668 retObject.stageWorldCenter = [this._stageWorldCenter[0],this._stageWorldCenter[1],this._stageWorldCenter[2]];
665 retObject.planeMat = [this._planeMat[0],this._planeMat[1],this._planeMat[2],this._planeMat[3]]; 669 retObject.planeMat = this._planeMat;
666 retObject.planeMatInv = [this._planeMatInv[0],this._planeMatInv[1],this._planeMatInv[2],this._planeMatInv[3]]; 670 retObject.planeMatInv = this._planeMatInv;
667 retObject.dragPlane = [this._dragPlane[0],this._dragPlane[1],this._dragPlane[2],this._dragPlane[3]]; 671 retObject.dragPlane = [this._dragPlane[0],this._dragPlane[1],this._dragPlane[2],this._dragPlane[3]];
668 672
669 //stroke appearance properties 673 //stroke appearance properties
@@ -691,8 +695,8 @@ var BrushStroke = function GLBrushStroke() {
691 this._copyCoordinates3D(jo.origLocalPoints, this._OrigLocalPoints); //todo <ditto> 695 this._copyCoordinates3D(jo.origLocalPoints, this._OrigLocalPoints); //todo <ditto>
692 696
693 this._stageWorldCenter = [jo.stageWorldCenter[0],jo.stageWorldCenter[1],jo.stageWorldCenter[2]]; 697 this._stageWorldCenter = [jo.stageWorldCenter[0],jo.stageWorldCenter[1],jo.stageWorldCenter[2]];
694 this._planeMat = [jo.planeMat[0], jo.planeMat[1],jo.planeMat[2],jo.planeMat[3]]; 698 this._planeMat = jo.planeMat;
695 this._planeMatInv = [jo.planeMatInv[0],jo.planeMatInv[1],jo.planeMatInv[2],jo.planeMatInv[3]]; 699 this._planeMatInv = jo.planeMatInv;
696 this._dragPlane = [jo.dragPlane[0],jo.dragPlane[1],jo.dragPlane[2],jo.dragPlane[3]]; 700 this._dragPlane = [jo.dragPlane[0],jo.dragPlane[1],jo.dragPlane[2],jo.dragPlane[3]];
697 701
698 //stroke appearance properties 702 //stroke appearance properties
diff --git a/js/lib/geom/sub-path.js b/js/lib/geom/sub-path.js
index 7046673e..35070915 100755
--- a/js/lib/geom/sub-path.js
+++ b/js/lib/geom/sub-path.js
@@ -12,6 +12,7 @@ var AnchorPoint = require("js/lib/geom/anchor-point").AnchorPoint;
12var MaterialsModel = require("js/models/materials-model").MaterialsModel; 12var MaterialsModel = require("js/models/materials-model").MaterialsModel;
13 13
14// TODO Those function do not seems to be used. We should remove them 14// TODO Those function do not seems to be used. We should remove them
15/*
15function SubpathOffsetPoint(pos, mapPos) { 16function SubpathOffsetPoint(pos, mapPos) {
16 this.Pos = [pos[0],pos[1],pos[2]]; 17 this.Pos = [pos[0],pos[1],pos[2]];
17 this.CurveMapPos = [mapPos[0], mapPos[1], mapPos[2]]; 18 this.CurveMapPos = [mapPos[0], mapPos[1], mapPos[2]];
@@ -33,7 +34,7 @@ function sortNumberDescending(a,b){
33function SegmentIntersections(){ 34function SegmentIntersections(){
34 this.paramArray = []; 35 this.paramArray = [];
35} 36}
36 37*/
37/////////////////////////////////////////////////////////////////////// 38///////////////////////////////////////////////////////////////////////
38// Class GLSubpath 39// Class GLSubpath
39// representation a sequence of cubic bezier curves. 40// representation a sequence of cubic bezier curves.
@@ -49,27 +50,34 @@ var GLSubpath = function GLSubpath() {
49 this._BBoxMax = [0, 0, 0]; 50 this._BBoxMax = [0, 0, 0];
50 this._isClosed = false; 51 this._isClosed = false;
51 52
52 this._samples = []; //polyline representation of this curve 53 this._samples = []; //polyline representation of this curve in stage world space
53 this._sampleParam = []; //parametric distance of samples, within [0, N], where N is # of Bezier curves (=# of anchor points if closed, =#anchor pts -1 if open) 54 this._sampleParam = []; //parametric distance of samples, within [0, N], where N is # of Bezier curves (=# of anchor points if closed, =#anchor pts -1 if open)
54 this._anchorSampleIndex = []; //index within _samples corresponding to anchor points 55 this._anchorSampleIndex = []; //index within _samples corresponding to anchor points
55 56
57 this._LocalPoints = []; //polyline representation of this curve in canvas space
58 this._LocalBBoxMin = [0,0,0]; //bbox min point of _LocalPoints
59 this._LocalBBoxMax = [0,0,0]; //bbox max point of _LocalPoints
60
56 this._UnprojectedAnchors = []; 61 this._UnprojectedAnchors = [];
57 62
58 //initially set the _dirty bit so we will construct samples 63 //initially set the _dirty bit so we will construct samples
59 this._dirty = true; 64 this._dirty = true;
60 65
66 //initially set the local dirty bit so we will construct local coordinates
67 this._isLocalDirty = true;
68
61 //whether or not to use the canvas drawing to stroke/fill 69 //whether or not to use the canvas drawing to stroke/fill
62 this._useCanvasDrawing = true; 70 this._useCanvasDrawing = true;
63 71
64 //the canvas that will draw this subpath 72 //the canvas that will draw this subpath
65 this._canvas = null; 73 this._canvas = null;
66 74
67 //the X and Y location of this subpath's canvas in stage world space of Ninja 75 //the top left location of this subpath's canvas in screen space
68 this._canvasX = 0; 76 this._canvasLeft = 0;
69 this._canvasY = 0; 77 this._canvasTop = 0;
70 78
71 //stroke information 79