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/vec-utils.js19
-rwxr-xr-xjs/helper-classes/3D/view-utils.js72
-rwxr-xr-xjs/lib/drawing/world.js7
-rwxr-xr-xjs/lib/geom/brush-stroke.js16
-rwxr-xr-xjs/lib/geom/sub-path.js830
-rw-r--r--js/tools/BrushTool.js1
-rwxr-xr-xjs/tools/PenTool.js1216
-rwxr-xr-xjs/tools/drawing-tool-base.js2
11 files changed, 1150 insertions, 1021 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 2531465d..da775405 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 1cd1c313..dabb1fcf 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -240,7 +240,6 @@ exports.ViewUtils = Montage.create(Component, {
240 var worldPt = MathUtils.transformPoint( viewPt, mat ); 240 var worldPt = MathUtils.transformPoint( viewPt, mat );
241 var stageWorldPt = this.postViewToStageWorld( worldPt, elt ); 241 var stageWorldPt = this.postViewToStageWorld( worldPt, elt );
242 this.popViewportObj(); 242 this.popViewportObj();
243
244 return stageWorldPt; 243 return stageWorldPt;
245 } 244 }
246 }, 245 },
@@ -834,6 +833,7 @@ exports.ViewUtils = Montage.create(Component, {
834 } 833 }
835 }, 834 },
836 835
836 /*
837 getStageWorldToGlobalMatrix: { 837 getStageWorldToGlobalMatrix: {
838 value: function() { 838 value: function() {
839 var stage = this.application.ninja.currentDocument.documentRoot, 839 var stage = this.application.ninja.currentDocument.documentRoot,
@@ -874,6 +874,26 @@ exports.ViewUtils = Montage.create(Component, {
874 return mat; 874 return mat;
875 } 875 }
876 }, 876 },
877 */
878 getStageWorldToGlobalMatrix:
879 {
880 value: function()
881 {
882 var stage = this.application.ninja.currentDocument.documentRoot;
883
884 this.pushViewportObj( stage );
885 // put the point into screen space of the stage - requires
886 // a translation to the top/left only
887 var cop = this.getCenterOfProjection();
888 var v2s = Matrix.Translation([cop[0], cop[1], 0]);
889 this.popViewportObj();
890
891 // append the localToGlobal matrix of the stage.
892 var mat = this.getLocalToGlobalMatrix( stage );
893 glmat4.multiply( mat, v2s );
894 return mat;
895 }
896 },
877 897
878 localScreenToLocalWorld: { 898 localScreenToLocalWorld: {
879 value: function( objPt, elt ) { 899 value: function( objPt, elt ) {
@@ -1049,6 +1069,56 @@ exports.ViewUtils = Montage.create(Component, {
1049 } 1069 }
1050 }, 1070 },
1051 1071
1072 getLocalToStageWorldMatrix: {
1073 value: function( elt, shouldProject, shouldLocalTransform ) {
1074 var mat = Matrix.I(4);
1075 while (elt)
1076 {
1077 this.pushViewportObj( elt );
1078 var cop = this.getCenterOfProjection();
1079 var s2v = Matrix.Translation([-cop[0], -cop[1], 0]);
1080 var objMat = this.getMatrixFromElement( elt );
1081 var projMat;
1082 if(shouldProject)
1083 {
1084 //projMat = Matrix.I(4).multiply( this.getPerspectiveDistFromElement(elt) );
1085 var pDist = this.getPerspectiveDistFromElement(elt);
1086 var projMat = glmat4.scale(Matrix.I(4), [pDist,pDist,pDist], []);
1087 projMat[11] = -1;
1088 projMat[15] = 1400;
1089 }
1090 var v2s = Matrix.Translation([cop[0], cop[1], 0]);
1091 this.popViewportObj();
1092
1093 // multiply all the matrices together
1094 //mat = s2v.multiply( mat );
1095 glmat4.multiply( s2v, mat, mat );
1096 if (elt === this._stageElement) break;
1097 //mat = objMat.multiply( mat );
1098 if (shouldLocalTransform) {
1099 glmat4.multiply( objMat, mat, mat );
1100 }
1101 if(shouldProject)
1102 {
1103 //mat = projMat.multiply( mat );
1104 glmat4.multiply( projMat, mat, mat );
1105 }
1106 //mat = v2s.multiply( mat );
1107 glmat4.multiply( v2s, mat, mat );
1108
1109 // offset to the parent
1110 var offset = this.getElementOffset( elt );
1111 var offMat = Matrix.Translation([offset[0], offset[1], 0]);
1112 //mat = offMat.multiply( mat );
1113 glmat4.multiply( offMat, mat, mat );
1114
1115 elt = elt.parentElement;
1116 }
1117
1118 return mat;
1119 }
1120 },
1121
1052 getUpVectorFromMatrix: { 1122 getUpVectorFromMatrix: {
1053 value: function( mat ) { 1123 value: function( mat ) {
1054 //var inv = mat.inverse(); 1124 //var inv = mat.inverse();
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 945c9883..1a391338 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -866,7 +866,7 @@ World.prototype.importObjectJSON = function( jObj, parentGeomObj )
866{ 866{
867 var type = jObj.type; 867 var type = jObj.type;
868 var BrushStroke = require("js/lib/geom/brush-stroke").BrushStroke; 868 var BrushStroke = require("js/lib/geom/brush-stroke").BrushStroke;
869 869 var SubPath = require("js/lib/geom/sub-path").SubPath;
870 var obj; 870 var obj;
871 switch (type) 871 switch (type)
872 { 872 {
@@ -885,6 +885,11 @@ World.prototype.importObjectJSON = function( jObj, parentGeomObj )
885 obj.importJSON( jObj ); 885 obj.importJSON( jObj );
886 break; 886 break;
887 887
888 case 5: //cubic bezier
889 obj = new SubPath();
890 obj.importJSON(jObj);
891 break;
892
888 case 6: //brush stroke 893 case 6: //brush stroke
889 obj = new BrushStroke();