From 5b4f6b1618cf571a6bce5a631f976a008e04a64e Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 29 Mar 2012 15:52:08 -0700 Subject: Updated shapes to always check for its stroke and fill colors and materials instead of relying on the shapeModel cache because it can get out of sync. Signed-off-by: Nivesh Rajbhandari --- js/lib/drawing/world.js | 2 +- js/lib/geom/circle.js | 15 +++++++++ js/lib/geom/geom-obj.js | 82 +++++++++++++++++++++++++----------------------- js/lib/geom/line.js | 8 +++++ js/lib/geom/rectangle.js | 15 +++++++++ 5 files changed, 81 insertions(+), 41 deletions(-) (limited to 'js/lib') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index fec6a478..1bf8c2e5 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -930,7 +930,7 @@ World.prototype.importObjectsJSON = function( jObj, parentGeomObj ) // determine if we have children if (jObj.children) { - var nKids = ojObjbj.chilodren.length; + var nKids = jObj.children.length; for (var i=0; i 4) { - len = 4; - } + var len = colors.length; + // TODO - Current shaders only support 4 color stops + if(len > 4) { + len = 4; + } - for(var n=0; n --- js/lib/geom/circle.js | 4 ++-- js/lib/geom/line.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'js/lib') diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index ee3e2abd..f74d4e57 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js @@ -42,8 +42,8 @@ var Circle = function GLCircle() { this._strokeWidth = strokeSize; this._innerRadius = innerRadius; - if (strokeColor) this._strokeColor = strokeColor; - if (fillColor) this._fillColor = fillColor; + this._strokeColor = strokeColor; + this._fillColor = fillColor; this._strokeStyle = strokeStyle; } diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js index 2b2434f5..f3806fac 100755 --- a/js/lib/geom/line.js +++ b/js/lib/geom/line.js @@ -44,7 +44,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok this._slope = slope; this._strokeWidth = strokeSize; - if (strokeColor) this._strokeColor = strokeColor.slice(); + this._strokeColor = strokeColor; this._strokeStyle = strokeStyle; this._scaleX = (world.getViewportWidth())/(world.getViewportHeight()); -- cgit v1.2.3 From c4e83a61311db75c7a1c307553262e77ecaae662 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 2 Apr 2012 13:16:27 -0700 Subject: IKNinna-1409 - Should dirty document when changing shape properties. IKNinja-1391 - Shapes need to support no-color. Signed-off-by: Nivesh Rajbhandari --- js/lib/geom/geom-obj.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'js/lib') diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index ce06498d..44daa291 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js @@ -196,6 +196,24 @@ var GeomObj = function GLGeomObj() { } } } + } else { + if (type === "fill") { + this._fillColor = null; + } else { + this._strokeColor = null; + } + + if (this._materialArray && this._materialTypeArray) { + nMats = this._materialArray.length; + if (nMats === this._materialTypeArray.length) { + for (i=0; i --- js/lib/NJUtils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/lib') diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 904aa41e..18796da0 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -136,7 +136,8 @@ exports.NJUtils = Object.create(Object.prototype, { controller: { value: ControllerFactory.getController(controller)}, pi: { value: pi}, props3D: { value: p3d}, - shapeModel: { value: shapeProps} + shapeModel: { value: shapeProps}, + isShape: { value: isShape} }); } @@ -168,6 +169,7 @@ exports.NJUtils = Object.create(Object.prototype, { // TODO - Need more info about the shape selection = "canvas"; controller = "shape"; + isShape = true; } else { -- cgit v1.2.3 From dc9650af5760b1f93d6e93a383eabceacfdc0ad8 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 2 Apr 2012 15:40:25 -0700 Subject: Snapping fixes. --- js/lib/geom/line.js | 70 ----------------------------------------------------- 1 file changed, 70 deletions(-) (limited to 'js/lib') diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js index e839e229..1848218d 100755 --- a/js/lib/geom/line.js +++ b/js/lib/geom/line.js @@ -140,76 +140,6 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok this.importMaterialsJSON( jObj.materials ); }; - this.export = function() { - var rtnStr = "type: " + this.geomType() + "\n"; - - rtnStr += "xoff: " + this._xOffset + "\n"; - rtnStr += "yoff: " + this._yOffset + "\n"; - rtnStr += "width: " + this._width + "\n"; - rtnStr += "height: " + this._height + "\n"; - rtnStr += "xAdj: " + this._xAdj + "\n"; - rtnStr += "yAdj: " + this._yAdj + "\n"; - rtnStr += "strokeWidth: " + this._strokeWidth + "\n"; - - if(this._strokeColor.gradientMode) { - rtnStr += "strokeGradientMode: " + this._strokeColor.gradientMode + "\n"; - rtnStr += "strokeColor: " + this.gradientToString(this._strokeColor.color) + "\n"; - } else { - rtnStr += "strokeColor: " + String(this._strokeColor) + "\n"; - } - - rtnStr += "strokeStyle: " + this._strokeStyle + "\n"; - rtnStr += "slope: " + String(this._slope) + "\n"; - - rtnStr += "strokeMat: "; - if (this._strokeMaterial) { - rtnStr += this._strokeMaterial.getName(); - } else { - rtnStr += MaterialsModel.getDefaultMaterialName(); - } - - rtnStr += "\n"; - return rtnStr; - }; - - this.import = function( importStr ) { - this._xOffset = Number( this.getPropertyFromString( "xoff: ", importStr ) ); - this._yOffset = Number( this.getPropertyFromString( "yoff: ", importStr ) ); - this._width = Number( this.getPropertyFromString( "width: ", importStr ) ); - this._height = Number( this.getPropertyFromString( "height: ", importStr ) ); - this._xAdj = Number( this.getPropertyFromString( "xAdj: ", importStr ) ); - this._yAdj = Number( this.getPropertyFromString( "yAdj: ", importStr ) ); - this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) ); - var slope = this.getPropertyFromString( "slope: ", importStr ); - - if(isNaN(Number(slope))) { - this._slope = slope; - } else { - this._slope = Number(slope); - } - - var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr ); - this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr ); - - if(importStr.indexOf("strokeGradientMode: ") < 0) - { - this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" ); - } else { - this._strokeColor = {}; - this._strokeColor.gradientMode = this.getPropertyFromString( "strokeGradientMode: ", importStr ); - this._strokeColor.color = this.stringToGradient(this.getPropertyFromString( "strokeColor: ", importStr )); - } - - var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); - if (!strokeMat) { - console.log( "object material not found in library: " + strokeMaterialName ); - strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); - } - - this._strokeMaterial = strokeMat; - - }; - /////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////// -- cgit v1.2.3