aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
authorKruti Shah2012-06-12 13:09:11 -0700
committerKruti Shah2012-06-12 13:09:11 -0700
commitd648c842905c7c53e0f89b943982493d2b79f56e (patch)
treeeb5585f92061975215f6d19305a8d1b76262e2fc /js/lib
parentbedb38e14887b29eae3cdf1c8d435259c920257c (diff)
parentcf3b96822665751dae7a64644db3cb3960733c3d (diff)
downloadninja-d648c842905c7c53e0f89b943982493d2b79f56e.tar.gz
Merge branch 'refs/heads/TimelineUberjd' into TimelineUber
Conflicts: js/controllers/elements/element-controller.js js/document/_toDelete/html-document.js js/panels/Timeline/Layer.reel/Layer.js Signed-off-by: Kruti Shah <kruti.shah@motorola.com>
Diffstat (limited to 'js/lib')
-rwxr-xr-xjs/lib/NJUtils.js120
-rwxr-xr-xjs/lib/geom/brush-stroke.js1352
-rwxr-xr-xjs/lib/geom/sub-path.js331
3 files changed, 924 insertions, 879 deletions
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js
index 7dd4c9e8..0dec6345 100755
--- a/js/lib/NJUtils.js
+++ b/js/lib/NJUtils.js
@@ -90,30 +90,6 @@ exports.NJUtils = Montage.create(Component, {
90 } 90 }
91 }, 91 },
92 92
93 createModel: {
94 value: function(el) {
95 el.elementModel = Montage.create(ElementModel).initialize(el);
96 }
97 },
98
99 createModelWithShape: {
100 value: function(el, selection) {
101 el.elementModel = Montage.create(ElementModel).initialize(el, true, selection);
102 }
103 },
104
105 createModelWithSelection: {
106 value: function(el, selection) {
107 el.elementModel = Montage.create(ElementModel).initialize(el, false, selection);
108 }
109 },
110
111 createModelForComponent: {
112 value: function(el, selection) {
113 el.elementModel = Montage.create(ElementModel).initialize(el, false, selection, true);
114 }
115 },
116
117 // TODO: Find a better place for this method 93 // TODO: Find a better place for this method
118 stylesFromDraw: { 94 stylesFromDraw: {
119 value: function(element, width, height, drawData, pos) { 95 value: function(element, width, height, drawData, pos) {
@@ -166,102 +142,6 @@ exports.NJUtils = Montage.create(Component, {
166 } 142 }
167 }, 143 },
168 144
169 ///// Element Model creation for existing elements
170 ///// TODO: find a different place for this function
171 makeElementModel: {
172 value: function(el, selection, controller, isShape) {
173 var p3d = Montage.create(Properties3D);
174
175 var shapeProps = null;
176 var pi = controller + "Pi";
177
178 if(isShape) {
179 shapeProps = Montage.create(ShapeModel);
180 }
181
182 if(el.controller) {
183
184 var componentInfo = Montage.getInfoForObject(el.controller);
185 var componentName = componentInfo.objectName.toLowerCase();
186
187 controller = "component";
188 isShape = false;
189
190 switch(componentName) {
191 case "feedreader":
192 selection = "Feed Reader";
193 pi = "FeedReaderPi";
194 break;
195 case "map":
196 selection = "Map";
197 pi = "MapPi";
198 break;
199 case "youtubechannel":
200 selection = "Youtube Channel";
201 pi = "YoutubeChannelPi";
202 break;
203 case "picasacarousel":
204 selection = "Picasa Carousel";
205 pi = "PicasaCarouselPi";
206 break;
207 }
208 }
209
210 el.elementModel = Montage.create(ElementModel, {
211 type: { value: el.nodeName},
212 selection: { value: selection},
213 controller: { value: ControllerFactory.getController(controller)},
214 pi: { value: pi},
215 props3D: { value: p3d},
216 shapeModel: { value: shapeProps},
217 isShape: { value: isShape}
218 });
219
220
221 }
222 },
223
224 ///// Element Model creation for existing elements based on element type.
225 ///// TODO: Selection and model should be based on the element type
226 makeModelFromElement: {
227 value: function(el) {
228 var selection = "div",
229 controller = "block",
230 isShape = false;
231 switch(el.nodeName.toLowerCase())
232 {
233 case "div":
234 break;
235 case "img":
236 selection = "image";
237 controller = "image";
238 break;
239 case "video":
240 selection = "video";
241 controller = "video";
242 break;
243 case "canvas":
244 isShape = el.getAttribute("data-RDGE-id");
245 if(isShape) {
246 // TODO - Need more info about the shape
247 selection = "canvas";
248 controller = "shape";
249 isShape = true;
250 } else {
251 selection = "canvas";
252 controller = "canvas";
253 }
254 break;
255 case "shape":
256 break;
257 }
258 this.makeElementModel(el, selection, controller, isShape);
259 if(el.elementModel && el.elementModel.props3D) {
260 el.elementModel.props3D.init(el, (selection === "Stage"));
261 }
262 }
263 },
264
265 ///// Removes all child nodes and returns node 145 ///// Removes all child nodes and returns node
266 ///// Accepts a single node, or an array of dom nodes 146 ///// Accepts a single node, or an array of dom nodes
267 empty : { 147 empty : {
diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js
index 6facdd5d..d9c2ab53 100755
--- a/js/lib/geom/brush-stroke.js
+++ b/js/lib/geom/brush-stroke.js
@@ -45,7 +45,7 @@ var BrushStroke = function GLBrushStroke() {
45 this._strokeAmountSmoothing = 0; 45 this._strokeAmountSmoothing = 0;
46 46
47 // currently, brush does not support a fill region 47 // currently, brush does not support a fill region
48 this.canFill = false; 48 this.canFill = true;
49 49
50 //threshold that tells us whether two samples are too far apart 50 //threshold that tells us whether two samples are too far apart
51 this._MAX_SAMPLE_DISTANCE_THRESHOLD = 5; 51 this._MAX_SAMPLE_DISTANCE_THRESHOLD = 5;
@@ -65,710 +65,840 @@ var BrushStroke = function GLBrushStroke() {
65 this._planeMatInv = null; 65 this._planeMatInv = null;
66 this._planeCenter = null; 66 this._planeCenter = null;
67 this._dragPlane = null; 67 this._dragPlane = null;
68}; //BrushStroke class defition
68 69
69 ///////////////////////////////////////////////////////// 70BrushStroke.prototype = Object.create(GeomObj, {});
70 // Property Accessors/Setters
71 /////////////////////////////////////////////////////////
72 this.setCanvas = function(c) {
73 this._canvas = c;
74 }
75
76 this.setWorld = function (world) {
77 this._world = world;
78 };
79
80 this.getWorld = function () {
81 return this._world;
82 };
83
84 this.geomType = function () {
85 return this.GEOM_TYPE_BRUSH_STROKE;
86 };
87
88 this.setDrawingTool = function (tool) {
89 this._drawingTool = tool;
90 };
91
92 this.getDrawingTool = function () {
93 return this._drawingTool;
94 };
95
96 this.setPlaneMatrix = function(planeMat){
97 this._planeMat = planeMat;
98 };
99
100 this.setPlaneMatrixInverse = function(planeMatInv){
101 this._planeMatInv = planeMatInv;
102 };
103
104 this.setPlaneCenter = function(pc){
105 this._planeCenter = pc;
106 };
107
108 this.setDragPlane = function(p){
109 this._dragPlane = p;
110 };
111
112 this.getNumPoints = function () {
113 if (this._LocalPoints.length)
114 return this._LocalPoints.length;
115 else
116 return this._Points.length;
117 };
118
119 this.getPoint = function (index) {
120 return this._Points[index].slice(0);
121 };
122 71
123 this.addPoint = function (pt) { 72/////////////////////////////////////////////////////////
124 //add the point only if it is some epsilon away from the previous point 73// Property Accessors/Setters
125 var numPoints = this._Points.length; 74/////////////////////////////////////////////////////////
126 if (numPoints>0) { 75BrushStroke.prototype.setCanvas = function(c) {
127 var threshold = this._MIN_SAMPLE_DISTANCE_THRESHOLD; 76 this._canvas = c;
128 var prevPt = this._Points[numPoints-1]; 77};
129 var diffPt = [prevPt[0]-pt[0], prevPt[1]-pt[1]]; 78
130 var diffPtMag = Math.sqrt(diffPt[0]*diffPt[0] + diffPt[1]*diffPt[1]); 79BrushStroke.prototype.setWorld = function (world) {
131 if (diffPtMag>threshold){ 80 this._world = world;
132 this._Points.push(pt); 81};
133 this._isDirty=true; 82
134 this._isInit = false; 83BrushStroke.prototype.getWorld = function () {
135 } 84 return this._world;
136 } else { 85};
86
87BrushStroke.prototype.geomType = function () {
88 return this.GEOM_TYPE_BRUSH_STROKE;
89};