aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorhwc4872012-04-25 11:06:12 -0700
committerhwc4872012-04-25 11:06:12 -0700
commit1304d00cec00f86442981a276817416ca37086b3 (patch)
treec46ae661f06cad048e6fbee073ba63160f424728 /js
parentcec076988d3ff6547b7c9d74ebc80530ffcea67b (diff)
parentd3a6350163ada5644d34ed8d5c2a00cef4db2afc (diff)
downloadninja-1304d00cec00f86442981a276817416ca37086b3.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Canvas-interaction
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/vec-utils.js19
-rwxr-xr-xjs/helper-classes/3D/view-utils.js85
-rwxr-xr-xjs/lib/drawing/world.js7
-rwxr-xr-xjs/lib/geom/anchor-point.js4
-rwxr-xr-xjs/lib/geom/brush-stroke.js16
-rwxr-xr-xjs/lib/geom/sub-path.js853
-rw-r--r--js/tools/BrushTool.js1
-rwxr-xr-xjs/tools/PenTool.js1256
-rwxr-xr-xjs/tools/drawing-tool-base.js2
12 files changed, 1190 insertions, 1061 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 f33a1177..ff5192b3 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -330,6 +330,10 @@ exports.HTMLDocument = Montage.create(TextDocument, {
330 elementModel.pi = "BrushStrokePi"; 330 elementModel.pi = "BrushStrokePi";
331 break; 331 break;
332 332
333 case root.GEOM_TYPE_CUBIC_BEZIER:
334 elementModel.selection = "Subpath";
335 elementModel.pi = "SubpathPi";
336 break;
333 337
334 default: 338 default:
335 console.log( "geometry type not supported for file I/O, " + root.geomType()); 339 console.log( "geometry type not supported for file I/O, " + root.geomType());
diff --git a/js/helper-classes/3D/vec-utils.js b/js/helper-classes/3D/vec-utils.js
index 4eacd856..0916c840 100755
--- a/js/helper-classes/3D/vec-utils.js
+++ b/js/helper-classes/3D/vec-utils.js
@@ -113,6 +113,25 @@ var VecUtils = exports.VecUtils = Object.create(Object.prototype,
113 } 113 }
114 }, 114 },
115 115
116 vecDistSq : {
117 value: function( dimen, a, b ) {
118 var sum;
119
120 if ((a.length < dimen) || (b.length < dimen))
121 {
122 throw new Error( "dimension error in VecUtils.vecDistSq" );
123 }
124
125 var sum = 0.0;
126 for (var i=0; i<dimen; i++)
127 {
128 var d = a[i] - b[i];
129 sum += d*d;
130 }
131 return sum;
132 }
133 },
134
116 vecDot : { 135 vecDot : {
117 value: function( dimen, v0, v1 ) { 136 value: function( dimen, v0, v1 ) {
118 if ((v0.length < dimen) || (v1.length < dimen)) 137 if ((v0.length < dimen) || (v1.length < dimen))
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index ee822f1f..40a19b90 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -246,7 +246,6 @@ exports.ViewUtils = Montage.create(Component, {
246 var worldPt = MathUtils.transformPoint( viewPt, mat ); 246 var worldPt = MathUtils.transformPoint( viewPt, mat );
247 var stageWorldPt = this.postViewToStageWorld( worldPt, elt ); 247 var stageWorldPt = this.postViewToStageWorld( worldPt, elt );
248 this.popViewportObj(); 248 this.popViewportObj();
249
250 return stageWorldPt; 249 return stageWorldPt;
251 } 250 }
252 }, 251 },
@@ -841,43 +840,21 @@ exports.ViewUtils = Montage.create(Component, {
841 }, 840 },
842 841
843 getStageWorldToGlobalMatrix: 842 getStageWorldToGlobalMatrix:
844 { 843 {
845 value: function() 844 value: function()
846 { 845 {
847 var stage = this.application.ninja.currentDocument.documentRoot; 846 var stage = this.application.ninja.currentDocument.documentRoot;
848 //projMat;
849
850 // get the matrix to the parent
851 //var mat = Matrix.I(4);
852 847
853 this.pushViewportObj( stage ); 848 this.pushViewportObj( stage );
849 // put the point into screen space of the stage - requires
850 // a translation to the top/left only
854 var cop = this.getCenterOfProjection(); 851 var cop = this.getCenterOfProjection();
855 var v2s = Matrix.Translation([cop[0], cop[1], 0]); 852 var v2s = Matrix.Translation([cop[0], cop[1], 0]);
856 this.popViewportObj(); 853 this.popViewportObj();
857 854
858 /* 855 // append the localToGlobal matrix of the stage.
859 var p = this.getPerspectiveDistFromElement(stage);
860 if(p)
861 {
862 projMat = glmat4.scale( Matrix.I(4), [p,p,p], [] );
863 projMat[11] = -1;
864 }
865 else
866 {
867 mat = v2s;
868 }
869 // offset to the parent
870 var offset = this.getElementOffset( stage );
871 var offMat = Matrix.Translation([offset[0], offset[1], 0]);
872 //mat = offMat.multiply( mat );
873 glmat4.multiply( offMat, mat, mat );
874 this.popViewportObj();
875 */
876
877 // append the localToGlobal matrix of the stage.
878 var mat = this.getLocalToGlobalMatrix( stage ); 856 var mat = this.getLocalToGlobalMatrix( stage );
879 glmat4.multiply( mat, v2s ); 857 glmat4.multiply( mat, v2s );
880
881 return mat; 858 return mat;
882 } 859 }
883 }, 860 },
@@ -1056,6 +1033,56 @@ exports.ViewUtils = Montage.create(Component, {
1056 } 1033 }
1057 }, 1034 },
1058 1035
1036 getLocalToStageWorldMatrix: {
1037 value: function( elt, shouldProject, shouldLocalTransform ) {
1038 var mat = Matrix.I(4);
1039 while (elt)
1040 {
1041 this.pushViewportObj( elt );
1042 var cop = this.getCenterOfProjection();
1043 var s2v = Matrix.Translation([-cop[0], -cop[1], 0]);
1044 var objMat = this.getMatrixFromElement( elt );
1045 var projMat;
1046 if(shouldProject)
1047 {
1048 //projMat = Matrix.I(4).multiply( this.getPerspectiveDistFromElement(elt) );
1049 var pDist = this.getPerspectiveDistFromElement(elt);
1050 var projMat = glmat4.scale(Matrix.I(4), [pDist,pDist,pDist], []);
1051 projMat[11] = -1;
1052 projMat[15] = 1400;
1053 }
1054 var v2s = Matrix.Translation([cop[0], cop[1], 0]);
1055 this.popViewportObj();
1056
1057 // multiply all the matrices together
1058 //mat = s2v.multiply( mat );
1059 glmat4.multiply( s2v, mat, mat );
1060 if (elt === this._stageElement) break;
1061 //mat = objMat.multiply( mat );
1062 if (shouldLocalTransform) {
1063 glmat4.multiply( objMat, mat, mat );
1064 }
1065 if(shouldProject)
1066 {
1067 //mat = projMat.multiply( mat );
1068 glmat4.multiply( projMat, mat, mat );
1069 }
1070 //mat = v2s.multiply( mat );
1071 glmat4.multiply( v2s, mat, mat );
1072
1073 // offset to the parent
1074 var offset = this.getElementOffset( elt );
1075 var offMat = Matrix.Translation([offset[0], offset[1], 0]);
1076 //mat = offMat.multiply( mat );
1077 glmat4.multiply( offMat, mat, mat );
1078
1079 elt = elt.parentElement;
1080 }
1081
1082 return mat;
1083 }
1084 },
1085
1059 getUpVectorFromMatrix: { 1086 getUpVectorFromMatrix: {
1060 value: function( mat ) { 1087 value: function( mat ) {
1061 //var inv = mat.inverse(); 1088 //var inv = mat.inverse();
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 8ad4c6f5..7ee9ee00 100755
--- a/js/lib/drawing/world.js
+++ b/