aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/io/system/ninjalibrary.json2
-rwxr-xr-xjs/lib/geom/circle.js4
-rwxr-xr-xjs/lib/geom/rectangle.js20
-rwxr-xr-xjs/mediators/drag-drop-mediator.js14
-rwxr-xr-xjs/panels/Materials/materials-popup.reel/materials-popup.js21
5 files changed, 34 insertions, 27 deletions
diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json
index 285444b5..e236f2e0 100644
--- a/js/io/system/ninjalibrary.json
+++ b/js/io/system/ninjalibrary.json
@@ -1,6 +1,6 @@
1{ 1{
2 "libraries": [ 2 "libraries": [
3 {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.7.0.0"}, 3 {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.7.0.0"},
4 {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.4.0"} 4 {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.5.0"}
5 ] 5 ]
6} \ No newline at end of file 6} \ No newline at end of file
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index 1073c2db..218dcfa6 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -457,9 +457,9 @@ var Circle = function GLCircle() {
457 if(this._fillColor.gradientMode) { 457 if(this._fillColor.gradientMode) {
458 if(this._fillColor.gradientMode === "radial") { 458 if(this._fillColor.gradientMode === "radial") {
459 gradient = ctx.createRadialGradient(xCtr, yCtr, 0, 459 gradient = ctx.createRadialGradient(xCtr, yCtr, 0,
460 xCtr, yCtr, Math.max(yScale, xScale)); 460 xCtr, yCtr, Math.max(this._width, this._height)/2);
461 } else { 461 } else {
462 gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2); 462 gradient = ctx.createLinearGradient(lineWidth/2, this._height/2, this._width-lineWidth, this._height/2);
463 } 463 }
464 colors = this._fillColor.color; 464 colors = this._fillColor.color;
465 465
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js
index 91b1d426..fcd1c1bd 100755
--- a/js/lib/geom/rectangle.js
+++ b/js/lib/geom/rectangle.js
@@ -356,7 +356,9 @@ var Rectangle = function GLRectangle() {
356 // various declarations 356 // various declarations
357 var pt, rad, ctr, startPt, bPts; 357 var pt, rad, ctr, startPt, bPts;
358 var width = Math.round(this.getWidth()), 358 var width = Math.round(this.getWidth()),
359 height = Math.round(this.getHeight()); 359 height = Math.round(this.getHeight()),
360 hw = 0.5*width,
361 hh = 0.5*height;
360 362
361 pt = [inset, inset]; // top left corner 363 pt = [inset, inset]; // top left corner
362 364
@@ -364,6 +366,12 @@ var Rectangle = function GLRectangle() {
364 var trRad = this._trRadius; 366 var trRad = this._trRadius;
365 var blRad = this._blRadius; 367 var blRad = this._blRadius;
366 var brRad = this._brRadius; 368 var brRad = this._brRadius;
369 // limit the radii to half the rectangle dimension
370 var minDimen = hw < hh ? hw : hh;
371 if (tlRad > minDimen) tlRad = minDimen;
372 if (blRad > minDimen) blRad = minDimen;
373 if (brRad > minDimen) brRad = minDimen;
374 if (trRad > minDimen) trRad = minDimen;
367 375
368 if ((tlRad <= 0) && (blRad <= 0) && (brRad <= 0) && (trRad <= 0)) { 376 if ((tlRad <= 0) && (blRad <= 0) && (brRad <= 0) && (trRad <= 0)) {
369 ctx.rect(pt[0], pt[1], width - 2*inset, height - 2*inset); 377 ctx.rect(pt[0], pt[1], width - 2*inset, height - 2*inset);
@@ -452,13 +460,13 @@ var Rectangle = function GLRectangle() {
452 // render the fill 460 // render the fill
453 ctx.beginPath(); 461 ctx.beginPath();
454 if (this._fillColor) { 462 if (this._fillColor) {
455 inset = Math.ceil( lw ) + 0.5; 463 inset = Math.ceil( lw ) - 0.5;
456 464
457 if(this._fillColor.gradientMode) { 465 if(this._fillColor.gradientMode) {
458 if(this._fillColor.gradientMode === "radial") { 466 if(this._fillColor.gradientMode === "radial") {
459 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(w/2, h/2)-inset); 467 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(w, h)/2);
460 } else { 468 } else {
461 gradient = ctx.createLinearGradient(inset, h/2, w-2*inset, h/2); 469 gradient = ctx.createLinearGradient(inset/2, h/2, w-inset, h/2);
462 } 470 }
463 colors = this._fillColor.color; 471 colors = this._fillColor.color;
464 472
@@ -486,11 +494,11 @@ var Rectangle = function GLRectangle() {
486 // render the stroke 494 // render the stroke
487 ctx.beginPath(); 495 ctx.beginPath();
488 if (this._strokeColor) { 496 if (this._strokeColor) {
489 inset = Math.ceil( 0.5*lw ) + 0.5; 497 inset = Math.ceil( 0.5*lw ) - 0.5;
490 498
491 if(this._strokeColor.gradientMode) { 499 if(this._strokeColor.gradientMode) {
492 if(this._strokeColor.gradientMode === "radial") { 500 if(this._strokeColor.gradientMode === "radial") {
493 gradient = ctx.createRadialGradient(w/2, h/2, Math.min(h/2, w/2)-inset, w/2, h/2, Math.max(h/2, w/2)); 501 gradient = ctx.createRadialGradient(w/2, h/2, Math.min(h, w)/2-inset, w/2, h/2, Math.max(h, w)/2);
494 } else { 502 } else {
495 gradient = ctx.createLinearGradient(0, h/2, w, h/2); 503 gradient = ctx.createLinearGradient(0, h/2, w, h/2);
496 } 504 }
diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js
index eedab8fc..b0aba5b6 100755
--- a/js/mediators/drag-drop-mediator.js
+++ b/js/mediators/drag-drop-mediator.js
@@ -115,25 +115,25 @@ exports.DragDropMediator = Montage.create(Component, {
115 // 115 //
116 if (e.currentTarget.fileType.indexOf('svg') !== -1) { 116 if (e.currentTarget.fileType.indexOf('svg') !== -1) {
117 element = NJUtils.makeNJElement('embed', 'SVG', 'block');//TODO: Verify this is proper 117 element = NJUtils.makeNJElement('embed', 'SVG', 'block');//TODO: Verify this is proper
118 element.type = 'image/svg+xml';
118 element.src = url+'/'+fileName; 119 element.src = url+'/'+fileName;
119 element.type = 'image/svg+xml';
120 } else { 120 } else {
121 element = NJUtils.makeNJElement('image', 'image', 'image'); 121 element = NJUtils.makeNJElement('image', 'image', 'image');
122 element.src = url+'/'+fileName; 122 element.src = url+'/'+fileName;
123 } 123 }
124 //TODO: Remove temp fix for elements to redraw on drop 124 //Adding element once it is loaded
125
126 element.onload = function () { 125 element.onload = function () {
127 self.application.ninja.elementMediator.addElements(element, rules); 126 element.onload = null;
127 self.application.ninja.elementMediator.addElements(element, rules, true);
128 }; 128 };
129 // 129 //Setting rules of element
130 rules = { 130 rules = {
131 'position': 'absolute', 131 'position': 'absolute',
132 'top' : (parseInt(e.currentTarget.filePosition.y) - parseInt(this.application.ninja.stage.userContentTop)) + 'px', 132 'top' : (parseInt(e.currentTarget.filePosition.y) - parseInt(this.application.ninja.stage.userContentTop)) + 'px',
133 'left' : (parseInt(e.currentTarget.filePosition.x) - parseInt(this.application.ninja.stage.userContentLeft)) + 'px' 133 'left' : (parseInt(e.currentTarget.filePosition.x) - parseInt(this.application.ninja.stage.userContentLeft)) + 'px'
134 }; 134 };
135 // 135 //
136 self.application.ninja.elementMediator.addElements(element, rules); 136 self.application.ninja.elementMediator.addElements(element, rules, false);
137 } else { 137 } else {
138 //TODO: HANDLE ERROR ON SAVING FILE TO BE ADDED AS ELEMENT 138 //TODO: HANDLE ERROR ON SAVING FILE TO BE ADDED AS ELEMENT
139 } 139 }
diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js
index bbccf45d..bd10f7a5 100755
--- a/js/panels/Materials/materials-popup.reel/materials-popup.js
+++ b/js/panels/Materials/materials-popup.reel/materials-popup.js
@@ -214,10 +214,9 @@ exports.MaterialsPopup = Montage.create(Component, {
214 enumerable: true, 214 enumerable: true,
215 value: function(materialID) 215 value: function(materialID)
216 { 216 {
217 // Note that setting Array.length = 0 will empty arrays, 217 //TODO - Hack to force repetition to draw. Setting .length = 0 did not work.
218 // which is fine if you use getMaterialData to get a new array, but not for the 218 this.materialsData = [];
219 // dummyData arrays. 219
220 this._materialsData.length = 0;
221 this._materialName = materialID; 220 this._materialName = materialID;
222 if( 221 if(
223 (materialID === "UberMaterial") || 222 (materialID === "UberMaterial") ||
@@ -231,16 +230,14 @@ exports.MaterialsPopup = Montage.create(Component, {
231 if (material) 230 if (material)
232 { 231 {
233 this._material = material; 232 this._material = material;
234 var matData = this.getMaterialData( material ); 233 this.materialsData = this.getMaterialData( material );
235 this.materialsData = matData;
236 } 234 }
237 } 235 }
238 else 236 else
239 { 237 {
240 this.materialsData = this._dummyData1.slice(0); 238 this.materialsData = this[materialID];
241 } 239 }
242 240 this.needsDraw = true;
243 this.needsDraw = true;
244 } 241 }
245 }, 242 },
246 243
@@ -445,7 +442,8 @@ exports.MaterialsPopup = Montage.create(Component, {
445 } 442 }
446 }, 443 },
447 444
448 _dummyData1: { 445 // _dummyData1
446 CheckerBoard: {
449 value: [ 447 value: [
450 { 448 {
451 "label": "Texture1", 449 "label": "Texture1",
@@ -588,7 +586,8 @@ exports.MaterialsPopup = Montage.create(Component, {
588 ] 586 ]
589 }, 587 },
590 588
591 _dummyData2: { 589 // _dummyData2
590 ShinyMetal: {
592 value: [ 591 value: [
593 { 592 {
594 "label": "Diffuse", 593 "label": "Diffuse",