aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/canvas-runtime.js4
-rwxr-xr-xjs/helper-classes/3D/draw-utils.js18
-rw-r--r--js/io/templates/descriptor.json7
-rwxr-xr-xjs/lib/geom/brush-stroke.js70
-rwxr-xr-xjs/lib/geom/sub-path.js35
-rwxr-xr-xjs/mediators/element-mediator.js1
-rwxr-xr-xjs/stage/stage.reel/stage.js42
-rwxr-xr-xjs/tools/PenTool.js10
8 files changed, 118 insertions, 69 deletions
diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js
index feb35187..6268f0bb 100644
--- a/assets/canvas-runtime.js
+++ b/assets/canvas-runtime.js
@@ -1969,7 +1969,8 @@ NinjaCvsRt.RuntimeSubPath = Object.create(NinjaCvsRt.RuntimeGeomObj, {
1969 if (ipColor.gradientMode){ 1969 if (ipColor.gradientMode){
1970 var position, gradient, cs, inset; //vars used in gradient calculations 1970 var position, gradient, cs, inset; //vars used in gradient calculations
1971 inset = Math.ceil( lw ) - 0.5; 1971 inset = Math.ceil( lw ) - 0.5;
1972 1972 inset=0;
1973
1973 if(ipColor.gradientMode === "radial") { 1974 if(ipColor.gradientMode === "radial") {
1974 var ww = w - 2*lw, hh = h - 2*lw; 1975 var ww = w - 2*lw, hh = h - 2*lw;
1975 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(ww, hh)/2); 1976 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(ww, hh)/2);
@@ -2181,6 +2182,7 @@ NinjaCvsRt.RuntimeBrushStroke = Object.create(NinjaCvsRt.RuntimeGeomObj, {
2181 if (ipColor.gradientMode){ 2182 if (ipColor.gradientMode){
2182 var position, gradient, cs, inset; //vars used in gradient calculations 2183 var position, gradient, cs, inset; //vars used in gradient calculations
2183 inset = Math.ceil( lw ) - 0.5; 2184 inset = Math.ceil( lw ) - 0.5;
2185 inset=0;
2184 2186
2185 if(ipColor.gradientMode === "radial") { 2187 if(ipColor.gradientMode === "radial") {
2186 var ww = w - 2*lw, hh = h - 2*lw; 2188 var ww = w - 2*lw, hh = h - 2*lw;
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js
index bef1e435..6a84c86b 100755
--- a/js/helper-classes/3D/draw-utils.js
+++ b/js/helper-classes/3D/draw-utils.js
@@ -117,7 +117,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
117 }, 117 },
118 118
119 initializeFromDocument:{ 119 initializeFromDocument:{
120 value:function(){ 120 value:function(adjustScrollOffsets){
121 var i, 121 var i,
122 documentRootChildren = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true), 122 documentRootChildren = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true),
123 stage = this.application.ninja.stage, 123 stage = this.application.ninja.stage,
@@ -144,13 +144,15 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, {
144 for(i=0; i<len; i++) { 144 for(i=0; i<len; i++) {
145 elt = documentRootChildren[i]; 145 elt = documentRootChildren[i];
146 plane = this.addElement(elt); 146 plane = this.addElement(elt);
147 l = plane._rect.m_left - docLeft; 147 if(adjustScrollOffsets) {
148 t = plane._rect.m_top - docTop; 148 l = plane._rect.m_left - docLeft;
149 if(l < minLeft) { 149 t = plane._rect.m_top - docTop;
150 minLeft = l; 150 if(l < minLeft) {
151 } 151 minLeft = l;
152 if(t < minTop) { 152 }
153 minTop = t; 153 if(t < minTop) {
154 minTop = t;
155 }
154 } 156 }
155 } 157 }
156 if(minLeft !== initL) { 158 if(minLeft !== initL) {
diff --git a/js/io/templates/descriptor.json b/js/io/templates/descriptor.json
index 9c9c4ac8..8edbedd2 100644
--- a/js/io/templates/descriptor.json
+++ b/js/io/templates/descriptor.json
@@ -90,7 +90,7 @@
90 "uri":"js/io/templates/files/banner.txt", 90 "uri":"js/io/templates/files/banner.txt",
91 "type":"file", 91 "type":"file",
92 "fileExtension":".html", 92 "fileExtension":".html",
93 "children":["120x600", "160x600", "200x200", "250x250", "300x250", "336x280"] 93 "children":["120x600", "160x600", "200x200", "250x250", "300x250", "336x280", "728x90"]
94 }, 94 },
95 95
96 "120x600":{ 96 "120x600":{
@@ -123,6 +123,11 @@
123 "uri": "336x280", 123 "uri": "336x280",
124 "type":"file" 124 "type":"file"
125 }, 125 },
126 "728x90":{
127 "name": "Leaderboard",
128 "uri": "728x90",
129 "type":"file"
130 },
126 131
127 "js/io/templates/files/animation.txt":{ 132 "js/io/templates/files/animation.txt":{
128 "name":"Animation", 133 "name":"Animation",
diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js
index 0e0406dd..c9224fde 100755
--- a/js/lib/geom/brush-stroke.js
+++ b/js/lib/geom/brush-stroke.js
@@ -31,6 +31,8 @@ var BrushStroke = function GLBrushStroke() {
31 31
32 //the HTML5 canvas that holds this brush stroke 32 //the HTML5 canvas that holds this brush stroke
33 this._canvas = null; 33 this._canvas = null;
34 //flag indicating whether or not to freeze the size and position of canvas
35 this._freezeCanvas = false;
34 36
35 //stroke information 37 //stroke information
36 this._strokeWidth = 1.0; 38 this._strokeWidth = 1.0;
@@ -174,11 +176,15 @@ BrushStroke.prototype.getStrokeWidth = function () {
174}; 176};
175 177
176BrushStroke.prototype.setStrokeWidth = function (w) { 178BrushStroke.prototype.setStrokeWidth = function (w) {
177 this._strokeWidth = w; 179 if (this._strokeWidth!==w) {
178 if (this._strokeWidth<1) { 180 this._strokeWidth = w;
179 this._strokeWidth = 1; 181
182 if (this._strokeWidth<1) {
183 this._strokeWidth = 1;
184 }
185 this._isDirty=true;
186 this._freezeCanvas=false;
180 } 187 }
181 this._isDirty=true;
182}; 188};
183/* 189/*
184BrushStroke.prototype.getStrokeMaterial = function () { 190BrushStroke.prototype.getStrokeMaterial = function () {
@@ -236,6 +242,7 @@ BrushStroke.prototype.setSmoothingAmount = function(a){
236 if (this._strokeAmountSmoothing!==a) { 242 if (this._strokeAmountSmoothing!==a) {
237 this._strokeAmountSmoothing = a; 243 this._strokeAmountSmoothing = a;
238 this._isDirty = true; 244 this._isDirty = true;
245 this._freezeCanvas=false;
239 } 246 }
240}; 247};
241 248
@@ -274,27 +281,32 @@ BrushStroke.prototype.setStrokeStyle = function (s) {
274}; 281};
275 282
276BrushStroke.prototype.setWidth = function (newW) { 283BrushStroke.prototype.setWidth = function (newW) {
277 if (newW<1) { 284 //get the old width from the canvas controller if the canvas is frozen, or from bbox if not frozen.
278 newW=1; //clamp minimum width to 1 285 var oldCanvasWidth = parseInt(CanvasController.getProperty(this._canvas, "width"));
286 if (!this._freezeCanvas){
287 oldCanvasWidth = Math.round(this._BBoxMax[0]-this._BBoxMin[0]);
288 }
289 var minWidth = 1+this._strokeWidth;
290 if (newW<minWidth) {
291 newW=minWidth;
279 } 292 }
280 293
281 //scale the contents of this subpath to lie within this width 294 if (oldCanvasWidth<minWidth) {
282 //determine the scale factor by comparing with the old width 295 oldCanvasWidth=minWidth;
283 var oldWidth = this._BBoxMax[0]-this._BBoxMin[0];
284 if (oldWidth<1) {
285 oldWidth=1;
286 } 296 }
287 297
288 var scaleX = newW/oldWidth; 298 //scale the contents of this subpath to lie within this width
299 //determine the scale factor by comparing with the old width
300 var scaleX = (newW-this._strokeWidth)/(oldCanvasWidth-this._strokeWidth);
289 if (scaleX===1) { 301 if (scaleX===1) {
302 console.log("Ignoring setWidth because scale is "+scaleX);
290 return; //no need to do anything 303 return; //no need to do anything
291 } 304 }
292
293 //scale the local point positions such that the width of the bbox is the newW 305 //scale the local point positions such that the width of the bbox is the newW
294 var origX = this._BBoxMin[0]; 306 var origX = 0.5*this._strokeWidth;//this._BBoxMin[0]; //this represents the left edge
295 var numPoints = this._LocalPoints.length; 307 var numPoints = this._LocalPoints.length;
296 for (var i=0;i<numPoints;i++){ 308 for (var i=0;i<numPoints;i++){
297 //compute the distance from the bboxMin 309 //compute the distance from the left edge
298 var oldW = this._LocalPoints[i][0] - origX; 310 var oldW = this._LocalPoints[i][0] - origX;
299 this._LocalPoints[i] = [(origX + oldW*scaleX),this._LocalPoints[i][1],this._LocalPoints[i][2]]; 311 this._LocalPoints[i] = [(origX + oldW*scaleX),this._LocalPoints[i][1],this._LocalPoints[i][2]];
300 312
@@ -305,24 +317,29 @@ BrushStroke.prototype.setWidth = function (newW) {
305}; 317};
306 318
307BrushStroke.prototype.setHeight = function (newH) { 319BrushStroke.prototype.setHeight = function (newH) {
308 if (newH<1) { 320 var oldCanvasHeight = parseInt(CanvasController.getProperty(this._canvas, "height"));
309 newH=1; //clamp minimum width to 1 321 if (!this._freezeCanvas){
322 oldCanvasHeight = this._BBoxMax[1]-this._BBoxMin[1];
323 }
324 var minHeight = 1 + this._strokeWidth;
325 if (oldCanvasHeight<minHeight) {
326 oldCanvasHeight=minHeight;
327 }
328 if (newH<minHeight) {
329 newH=minHeight;
310 } 330 }
311 331
332
312 //scale the contents of this subpath to lie within this height 333 //scale the contents of this subpath to lie within this height
313 //determine the scale factor by comparing with the old height 334 //determine the scale factor by comparing with the old height
314 var oldHeight = this._BBoxMax[1]-this._BBoxMin[1]; 335 var scaleY = (newH-this._strokeWidth)/(oldCanvasHeight-this._strokeWidth);
315 if (oldHeight<1) {
316 oldHeight=1;
317 }
318
319 var scaleY = newH/oldHeight;
320 if (scaleY===1) { 336 if (scaleY===1) {
337 console.log("Ignoring setHeight because scale is 1");
321 return; //no need to do anything 338 return; //no need to do anything
322 } 339 }
323 340
324 //scale the local point positions such that the width of the bbox is the newW 341 //scale the local point positions such that the width of the bbox is the newW
325 var origY = this._BBoxMin[1]; 342 var origY = 0.5*this._strokeWidth;//this._BBoxMin[1]; //this represents the top edge
326 var numPoints = this._LocalPoints.length; 343 var numPoints = this._LocalPoints.length;
327 for (var i=0;i<numPoints;i++){ 344 for (var i=0;i<numPoints;i++){
328 //compute the distance from the bboxMin 345 //compute the distance from the bboxMin
@@ -611,7 +628,7 @@ BrushStroke.prototype.render = function () {
611