From 903b01b9d0501e6f974034273385a0517107b1e3 Mon Sep 17 00:00:00 2001 From: Pushkar Joshi Date: Tue, 27 Mar 2012 12:42:42 -0700 Subject: File IO for the brush stroke AND changing the data type of brush stroke from GEOM_TYPE_CUBIC_BEZIER to GEOM_TYPE_BRUSH_STROKE --- js/lib/geom/geom-obj.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/lib/geom/geom-obj.js') diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index a87bdbf5..be80f1e4 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js @@ -19,6 +19,7 @@ var GeomObj = function GLGeomObj() { this.GEOM_TYPE_LINE = 3; this.GEOM_TYPE_PATH = 4; this.GEOM_TYPE_CUBIC_BEZIER = 5; + this.GEOM_TYPE_BRUSH_STROKE = 6; this.GEOM_TYPE_UNDEFINED = -1; // Needed for calculating dashed/dotted strokes -- cgit v1.2.3 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/geom/geom-obj.js | 82 +++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 40 deletions(-) (limited to 'js/lib/geom/geom-obj.js') diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index 3c4e4bbf..df4a018d 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js @@ -141,54 +141,56 @@ var GeomObj = function GLGeomObj() { this.setMaterialColor = function(c, type) { var i = 0, nMats = 0; - if(c.gradientMode) { - // Gradient support - if (this._materialArray && this._materialTypeArray) { - nMats = this._materialArray.length; - } + if(c) { + if(c.gradientMode) { + // Gradient support + if (this._materialArray && this._materialTypeArray) { + nMats = this._materialArray.length; + } - var stops = [], - colors = c.color; + var stops = [], + colors = c.color; - var len = colors.length; - // TODO - Current shaders only support 4 color stops - if(len > 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/geom-obj.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'js/lib/geom/geom-obj.js') 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 4) { + if (len > 4) { len = 4; } - for(var n=0; n 0) - { - var arr = []; + this.exportMaterialsJSON = function () { + var jObj; + if (this._materialArray && this._materialNodeArray && this.getWorld().isWebGL()) { + var nMats = this._materialArray.length; + if (nMats > 0) { + var arr = []; - for (var i=0; i= 0) { - rtnStr = rtnStr.substr(0, index); + var rtnStr = str.substr(index + prop.length); + index = rtnStr.indexOf("\n"); + if (index >= 0) { + rtnStr = rtnStr.substr(0, index); } - return rtnStr; - }; + return rtnStr; + }; // Gradient stops for rgba(255,0,0,1) at 0%; rgba(0,255,0,1) at 33%; rgba(0,0,255,1) at 100% will return // 255,0,0,1@0;0,255,0,1@33;0,0,255,1@100 - this.gradientToString = function(colors) { + this.gradientToString = function (colors) { var rtnStr = ""; - if(colors && colors.length) { - var c = colors[0], + if (colors && colors.length) { + var c = colors[0], len = colors.length; rtnStr += String(c.value.r + "," + c.value.g + "," + c.value.b + "," + c.value.a + "@" + c.position); - for(var i=1; i