From 60d6346a78fb5257eaf36f17a5fcb764a342c012 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 16 Apr 2012 15:07:16 -0700 Subject: Fixed materials editor popup not refreshing correctly. Signed-off-by: Nivesh Rajbhandari --- .../materials-popup.reel/materials-popup.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) 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, { enumerable: true, value: function(materialID) { - // Note that setting Array.length = 0 will empty arrays, - // which is fine if you use getMaterialData to get a new array, but not for the - // dummyData arrays. - this._materialsData.length = 0; + //TODO - Hack to force repetition to draw. Setting .length = 0 did not work. + this.materialsData = []; + this._materialName = materialID; if( (materialID === "UberMaterial") || @@ -231,16 +230,14 @@ exports.MaterialsPopup = Montage.create(Component, { if (material) { this._material = material; - var matData = this.getMaterialData( material ); - this.materialsData = matData; + this.materialsData = this.getMaterialData( material ); } } else { - this.materialsData = this._dummyData1.slice(0); + this.materialsData = this[materialID]; } - - this.needsDraw = true; + this.needsDraw = true; } }, @@ -445,7 +442,8 @@ exports.MaterialsPopup = Montage.create(Component, { } }, - _dummyData1: { + // _dummyData1 + CheckerBoard: { value: [ { "label": "Texture1", @@ -588,7 +586,8 @@ exports.MaterialsPopup = Montage.create(Component, { ] }, - _dummyData2: { + // _dummyData2 + ShinyMetal: { value: [ { "label": "Diffuse", -- cgit v1.2.3 From b183dbb1d5efef5db0ba3f8004b674b63b66b76a Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 25 Apr 2012 13:36:41 -0700 Subject: Changing canvas-2d gradient drawing to more closely match div's background-image gradient support. Signed-off-by: Nivesh Rajbhandari --- js/lib/geom/circle.js | 4 ++-- js/lib/geom/rectangle.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) 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() { if(this._fillColor.gradientMode) { if(this._fillColor.gradientMode === "radial") { gradient = ctx.createRadialGradient(xCtr, yCtr, 0, - xCtr, yCtr, Math.max(yScale, xScale)); + xCtr, yCtr, Math.max(this._width, this._height)/2); } else { - gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2); + gradient = ctx.createLinearGradient(lineWidth/2, this._height/2, this._width-lineWidth, this._height/2); } colors = this._fillColor.color; diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index 91b1d426..8278f1a3 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js @@ -452,13 +452,13 @@ var Rectangle = function GLRectangle() { // render the fill ctx.beginPath(); if (this._fillColor) { - inset = Math.ceil( lw ) + 0.5; + inset = Math.ceil( lw ); if(this._fillColor.gradientMode) { if(this._fillColor.gradientMode === "radial") { - gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(w/2, h/2)-inset); + gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(w, h)/2); } else { - gradient = ctx.createLinearGradient(inset, h/2, w-2*inset, h/2); + gradient = ctx.createLinearGradient(inset/2, h/2, w-inset, h/2); } colors = this._fillColor.color; @@ -486,11 +486,11 @@ var Rectangle = function GLRectangle() { // render the stroke ctx.beginPath(); if (this._strokeColor) { - inset = Math.ceil( 0.5*lw ) + 0.5; + inset = Math.ceil( 0.5*lw ); if(this._strokeColor.gradientMode) { if(this._strokeColor.gradientMode === "radial") { - gradient = ctx.createRadialGradient(w/2, h/2, Math.min(h/2, w/2)-inset, w/2, h/2, Math.max(h/2, w/2)); + gradient = ctx.createRadialGradient(w/2, h/2, Math.min(h, w)/2-inset, w/2, h/2, Math.max(h, w)/2); } else { gradient = ctx.createLinearGradient(0, h/2, w, h/2); } -- cgit v1.2.3 From 5e029d148e267b7ec8662f31ccdae2a0916de329 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 25 Apr 2012 13:37:02 -0700 Subject: IKNinja-406 - Strange behavior when changing the corner radius to the maximum value. IKNinja-1236 - Corner radius is not applied if stroke size is >= 2 times the corner radius. Signed-off-by: Nivesh Rajbhandari --- js/lib/geom/rectangle.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index 8278f1a3..fcd1c1bd 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js @@ -356,7 +356,9 @@ var Rectangle = function GLRectangle() { // various declarations var pt, rad, ctr, startPt, bPts; var width = Math.round(this.getWidth()), - height = Math.round(this.getHeight()); + height = Math.round(this.getHeight()), + hw = 0.5*width, + hh = 0.5*height; pt = [inset, inset]; // top left corner @@ -364,6 +366,12 @@ var Rectangle = function GLRectangle() { var trRad = this._trRadius; var blRad = this._blRadius; var brRad = this._brRadius; + // limit the radii to half the rectangle dimension + var minDimen = hw < hh ? hw : hh; + if (tlRad > minDimen) tlRad = minDimen; + if (blRad > minDimen) blRad = minDimen; + if (brRad > minDimen) brRad = minDimen; + if (trRad > minDimen) trRad = minDimen; if ((tlRad <= 0) && (blRad <= 0) && (brRad <= 0) && (trRad <= 0)) { ctx.rect(pt[0], pt[1], width - 2*inset, height - 2*inset); @@ -452,7 +460,7 @@ var Rectangle = function GLRectangle() { // render the fill ctx.beginPath(); if (this._fillColor) { - inset = Math.ceil( lw ); + inset = Math.ceil( lw ) - 0.5; if(this._fillColor.gradientMode) { if(this._fillColor.gradientMode === "radial") { @@ -486,7 +494,7 @@ var Rectangle = function GLRectangle() { // render the stroke ctx.beginPath(); if (this._strokeColor) { - inset = Math.ceil( 0.5*lw ); + inset = Math.ceil( 0.5*lw ) - 0.5; if(this._strokeColor.gradientMode) { if(this._strokeColor.gradientMode === "radial") { -- cgit v1.2.3 From 7a03f8393b2a8fe4ada75757d967a0af8b649553 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 25 Apr 2012 14:33:34 -0700 Subject: Updating the canvas runtime files for gradient and rectangle radius fixes. Signed-off-by: Nivesh Rajbhandari --- assets/canvas-runtime.js | 40 ++++++++++++++++++++++++---------------- js/io/system/ninjalibrary.json | 2 +- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index ee9f24a4..ce2a15de 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js @@ -685,14 +685,22 @@ NinjaCvsRt.RuntimeRectangle = function () // various declarations var pt, rad, ctr, startPt, bPts; var width = Math.round(this._width), - height = Math.round(this._height); - - pt = [inset, inset]; // top left corner - - var tlRad = this._tlRadius; //top-left radius - var trRad = this._trRadius; - var blRad = this._blRadius; - var brRad = this._brRadius; + height = Math.round(this._height), + hw = 0.5*width, + hh = 0.5*height; + + pt = [inset, inset]; // top left corner + + var tlRad = this._tlRadius; //top-left radius + var trRad = this._trRadius; + var blRad = this._blRadius; + var brRad = this._brRadius; + // limit the radii to half the rectangle dimension + var minDimen = hw < hh ? hw : hh; + if (tlRad > minDimen) tlRad = minDimen; + if (blRad > minDimen) blRad = minDimen; + if (brRad > minDimen) brRad = minDimen; + if (trRad > minDimen) trRad = minDimen; if ((tlRad <= 0) && (blRad <= 0) && (brRad <= 0) && (trRad <= 0)) { @@ -769,7 +777,7 @@ NinjaCvsRt.RuntimeRectangle = function () var lw = this._strokeWidth; var w = world.getViewportWidth(), h = world.getViewportHeight(); - + var c, inset, gradient, @@ -781,13 +789,13 @@ NinjaCvsRt.RuntimeRectangle = function () // render the fill ctx.beginPath(); if (this._fillColor) { - inset = Math.ceil( lw ) + 0.5; + inset = Math.ceil( lw ) - 0.5; if(this._fillColor.gradientMode) { if(this._fillColor.gradientMode === "radial") { - gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(w/2, h/2)-inset); + gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(w, h)/2); } else { - gradient = ctx.createLinearGradient(inset, h/2, w-2*inset, h/2); + gradient = ctx.createLinearGradient(inset/2, h/2, w-inset, h/2); } colors = this._fillColor.color; @@ -815,11 +823,11 @@ NinjaCvsRt.RuntimeRectangle = function () // render the stroke ctx.beginPath(); if (this._strokeColor) { - inset = Math.ceil( 0.5*lw ) + 0.5; + inset = Math.ceil( 0.5*lw ) - 0.5; if(this._strokeColor.gradientMode) { if(this._strokeColor.gradientMode === "radial") { - gradient = ctx.createRadialGradient(w/2, h/2, Math.min(h/2, w/2)-inset, w/2, h/2, Math.max(h/2, w/2)); + gradient = ctx.createRadialGradient(w/2, h/2, Math.min(h, w)/2-inset, w/2, h/2, Math.max(h, w)/2); } else { gradient = ctx.createLinearGradient(0, h/2, w, h/2); } @@ -1025,9 +1033,9 @@ NinjaCvsRt.RuntimeOval = function () if(this._fillColor.gradientMode) { if(this._fillColor.gradientMode === "radial") { gradient = ctx.createRadialGradient(xCtr, yCtr, 0, - xCtr, yCtr, Math.max(yScale, xScale)); + xCtr, yCtr, Math.max(this._width, this._height)/2); } else { - gradient = ctx.createLinearGradient(0, this._height/2, this._width, this._height/2); + gradient = ctx.createLinearGradient(lineWidth/2, this._height/2, this._width-lineWidth, this._height/2); } colors = this._fillColor.color; 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 @@ { "libraries": [ {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.7.0.0"}, - {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.4.0"} + {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.5.0"} ] } \ No newline at end of file -- cgit v1.2.3