From 49eba848c3006045c6096d21fd8262c9d98a35d8 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 20 Mar 2012 13:47:03 -0700 Subject: IKNINJA-1370 - Toggle WebGL on/off is no longer working in the PI. This bug was injected by some changes in GLWorld.import. Signed-off-by: Nivesh Rajbhandari --- js/lib/drawing/world.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'js/lib') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 049145ce..c1ee0cd0 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -810,14 +810,17 @@ World.prototype.findTransformNodeByMaterial = function( materialNode, trNode ) return rtnNode; }; -World.prototype.import = function( importStr ) { +World.prototype.import = function( importStr, fromToggle ) { // import the worldattributes - not currently used // determine if the data was written for export (no Ninja objects) // or for save/restore //var index = importStr.indexOf( "scenedata: " ); - var index = importStr.indexOf( "webGL: " ); - this._useWebGL = (index >= 0) + // Skip if we are toggling between canvas2d and WebGL since importStr doesn't have the correct webGL value yet + if(!fromToggle) { + var index = importStr.indexOf( "webGL: " ); + this._useWebGL = (index >= 0) + } if (this._useWebGL) { // start RDGE -- cgit v1.2.3 From 52fac825174d16e3ff6875fc497d3f3cfaf4812c Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 21 Mar 2012 12:02:36 -0700 Subject: Get matrix and perspective distance from styles controller. Signed-off-by: Nivesh Rajbhandari --- js/lib/NJUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/lib') diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 4f1082f9..f611052b 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -94,7 +94,7 @@ exports.NJUtils = Object.create(Object.prototype, { ///// TODO: find a different place for this function makeElementModel: { value: function(el, selection, controller, isShape) { - var p3d = Montage.create(Properties3D).init(el); + var p3d = Montage.create(Properties3D).init(el, (selection === "Stage")); var shapeProps = null; if(isShape) { shapeProps = Montage.create(ShapeModel); -- cgit v1.2.3 From 3987b73569e58843f2a91c0c6c4e4132f51ac247 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 21 Mar 2012 17:13:56 -0700 Subject: Do not set webkit-transform styles on elements unless 3d is used on them. Signed-off-by: Nivesh Rajbhandari --- js/lib/NJUtils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js/lib') diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index f611052b..cb877591 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -94,7 +94,10 @@ exports.NJUtils = Object.create(Object.prototype, { ///// TODO: find a different place for this function makeElementModel: { value: function(el, selection, controller, isShape) { - var p3d = Montage.create(Properties3D).init(el, (selection === "Stage")); + var p3d = Montage.create(Properties3D); + if(selection === "Stage") { + p3d.init(el, true); + } var shapeProps = null; if(isShape) { shapeProps = Montage.create(ShapeModel); -- cgit v1.2.3 From 62438ba52de51bb8ae20de07ec2f4dad55b9a929 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 27 Mar 2012 10:32:26 -0700 Subject: Build elements' properties3d values on file open. Signed-off-by: Nivesh Rajbhandari --- js/lib/NJUtils.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js/lib') diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 0457120b..c01d865b 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -182,6 +182,9 @@ exports.NJUtils = Object.create(Object.prototype, { break; } this.makeElementModel(el, selection, controller, isShape); + if(el.elementModel && el.elementModel.props3D) { + el.elementModel.props3D.init(el, (selection === "Stage")); + } } }, -- 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/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 From 55f4835aa33546f5cd27e501ed461a0f7eb5038b Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 5 Apr 2012 10:31:45 -0700 Subject: Undoing mistakes from auto-merge. Signed-off-by: Nivesh Rajbhandari --- js/lib/geom/geom-obj.js | 358 ++++++++++++++++++++++++------------------------ 1 file changed, 179 insertions(+), 179 deletions(-) (limited to 'js/lib') diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index 56cf7c98..2cde8a75 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js @@ -1,8 +1,8 @@ /* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. + */ var MaterialsModel = require("js/models/materials-model").MaterialsModel; @@ -14,19 +14,19 @@ var GeomObj = function GLGeomObj() { /////////////////////////////////////////////////////////////////////// // Constants /////////////////////////////////////////////////////////////////////// - this.GEOM_TYPE_RECTANGLE = 1; - this.GEOM_TYPE_CIRCLE = 2; - 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; + this.GEOM_TYPE_RECTANGLE = 1; + this.GEOM_TYPE_CIRCLE = 2; + 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 this.DASH_LENGTH = 0.15; this.DOT_LENGTH = 0.05; this.GAP_LENGTH = 0.05; - + /////////////////////////////////////////////////////////////////////// // Instance variables /////////////////////////////////////////////////////////////////////// @@ -40,74 +40,74 @@ var GeomObj = function GLGeomObj() { this.m_world = null; // stroke and fill colors - this._strokeColor = [0,0,0,0]; - this._fillColor = [0,0,0,0]; + this._strokeColor = [0, 0, 0, 0]; + this._fillColor = [0, 0, 0, 0]; - // stroke and fill materials - this._fillMaterial = null; - this._strokeMaterial = null; + // stroke and fill materials + this._fillMaterial = null; + this._strokeMaterial = null; - // array of primitives - used in RDGE - this._primArray = []; - this._materialNodeArray = []; - this._materialArray = []; - this._materialTypeArray = []; + // array of primitives - used in RDGE + this._primArray = []; + this._materialNodeArray = []; + this._materialArray = []; + this._materialTypeArray = []; - // the transform node used by RDGE - this._trNode = null; + // the transform node used by RDGE + this._trNode = null; /////////////////////////////////////////////////////////////////////// // Property accessors /////////////////////////////////////////////////////////////////////// - this.setWorld = function( world ) { + this.setWorld = function (world) { this.m_world = world; }; - this.getWorld = function() { + this.getWorld = function () { return this.m_world; }; - this.getMatrix = function() { + this.getMatrix = function () { return this._matrix.slice(0); }; - this.setMatrix = function(m) { + this.setMatrix = function (m) { this._matrix = m.slice(0); }; - this.setNext = function( next ) { + this.setNext = function (next) { this._next = next; }; - this.getNext = function() { + this.getNext = function () { return this._next; }; - this.setPrev = function( prev ) { + this.setPrev = function (prev) { this._prev = prev; }; - this.getPrev = function() { + this.getPrev = function () { return this._prev; }; - this.setChild = function( child ) { + this.setChild = function (child) { this._child = child; }; - this.getChild = function() { + this.getChild = function () { return this._child; }; - this.setParent = function( parent ) { + this.setParent = function (parent) { this._parent = parent; }; - this.getParent = function() { + this.getParent = function () { return this._parent; }; - this.geomType = function() { + this.geomType = function () { return this.GEOM_TYPE_UNDEFINED; }; @@ -115,7 +115,7 @@ var GeomObj = function GLGeomObj() { return this._primArray; }; - this.getMaterialNodeArray = function() { + this.getMaterialNodeArray = function () { return this._materialNodeArray; }; @@ -123,29 +123,29 @@ var GeomObj = function GLGeomObj() { return this._materialArray; }; - this.getTransformNode = function() { + this.getTransformNode = function () { return this._trNode; }; - this.setTransformNode = function(t) { + this.setTransformNode = function (t) { this._trNode = t; }; - this.setFillColor = function(c) { + this.setFillColor = function (c) { this.setMaterialColor(c, "fill"); }; - this.setStrokeColor = function(c) { + this.setStrokeColor = function (c) { this.setMaterialColor(c, "stroke"); }; /////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////// - this.setMaterialColor = function(c, type) { + this.setMaterialColor = function (c, type) { var i = 0, nMats = 0; - if(c) { - if(c.gradientMode) { + if (c) { + if (c.gradientMode) { // Gradient support if (this._materialArray && this._materialTypeArray) { nMats = this._materialArray.length; @@ -156,21 +156,21 @@ var GeomObj = function GLGeomObj() { var len = colors.length; // TODO - Current shaders only support 4 color stops - if(len > 4) { + if (len > 4) { len = 4; } - for(var n=0; n 0) { - var arr = []; + var arr = []; for (var i = 0; i < nMats; i++) { - var matObj = - { - 'materialNodeName' : this._materialNodeArray[i].name, - 'material' : this._materialArray[i].exportJSON(), - 'type' : this._materialTypeArray[i] - } - arr.push( matObj ); - } - - jObj = - { - 'nMaterials' : nMats, - 'materials' : arr - }; - } - } - - return jObj; - } + var matObj = + { + 'materialNodeName':this._materialNodeArray[i].name, + 'material':this._materialArray[i].exportJSON(), + 'type':this._materialTypeArray[i] + } + arr.push(matObj); + } + + jObj = + { + 'nMaterials':nMats, + 'materials':arr + }; + } + } + + return jObj; + } this.importMaterialsJSON = function (jObj) { - this._materialArray = []; - this._materialTypeArray = []; + this._materialArray = []; + this._materialTypeArray = []; - if (!jObj) return; + if (!jObj) return; - var nMaterials = jObj.nMaterials; - var matArray = jObj.materials; + var nMaterials = jObj.nMaterials; + var matArray = jObj.materials; for (var i = 0; i < nMaterials; i++) { - var mat; - var matObj = matArray[i].material; - var shaderName = matObj.material; + var mat; + var matObj = matArray[i].material; + var shaderName = matObj.material; switch (shaderName) { - case "flat": - case "radialGradient": - case "linearGradient": - case "bumpMetal": - case "uber": - case "plasma": - case "deform": - case "water": - case "paris": - case "raiders": - case "tunnel": - case "reliefTunnel": - case "squareTunnel": - case "twist": - case "fly": - case "julia": - case "mandel": - case "star": - case "zinvert": - case "keleidoscope": - case "radialBlur": - case "pulse": - mat = MaterialsModel.getMaterialByShader( shaderName ); - if (mat) mat = mat.dup(); - break; - - default: - console.log( "material type: " + shaderName + " is not supported" ); - break; - } + case "flat": + case "radialGradient": + case "linearGradient": + case "bumpMetal": + case "uber": + case "plasma": + case "deform": + case "water": + case "paris": + case "raiders": + case "tunnel": + case "reliefTunnel": + case "squareTunnel": + case "twist": + case "fly": + case "julia": + case "mandel": + case "star": + case "zinvert": + case "keleidoscope": + case "radialBlur": + case "pulse": + mat = MaterialsModel.getMaterialByShader(shaderName); + if (mat) mat = mat.dup(); + break; + + default: + console.log("material type: " + shaderName + " is not supported"); + break; + } if (mat) { - mat.importJSON( matObj ); - this._materialArray.push( mat ); - this._materialTypeArray.push( matObj.type ); - var type = matArray[i].type; - if (type == "fill") this._fillMaterial = mat; - else this._strokeMaterial = mat; - } - } - }; - - this.translate = function(v) { - var mat = Matrix.Translation( v ); + mat.importJSON(matObj); + this._materialArray.push(mat); + this._materialTypeArray.push(matObj.type); + var type = matArray[i].type; + if (type == "fill") this._fillMaterial = mat; + else this._strokeMaterial = mat; + } + } + }; + + this.translate = function (v) { + var mat = Matrix.Translation(v); //var mat2 = mat.multiply( this._matrix ); //this._matrix = mat2; - glmat4.multiply(mat, this._matrix, this._matrix); + glmat4.multiply(mat, this._matrix, this._matrix); }; - this.transform = function( mat ) { + this.transform = function (mat) { if (mat) { //this._matrix = mat.multiply( this._matrix ); - glmat4.multiply(mat, this._matrix, this._matrix); - } + glmat4.multiply(mat, this._matrix, this._matrix); + } }; - this.setMatrix = function(mat) { + this.setMatrix = function (mat) { var gl = this.getWorld().getGLContext(); if (gl) { gl.uniformMatrix4fv(this.getWorld().getShaderProgram().mvMatrixUniform, false, new Float32Array(mat)); } }; - this.buildBuffers = function() { + this.buildBuffers = function () { // this function must be overridden by the base class - alert( "GLGeomObj.buildBuffers must be overridden by base class" ); + alert("GLGeomObj.buildBuffers must be overridden by base class"); }; - this.render = function() { - alert( "GLGeomObj.render method must be overridden by sub class" ); + this.render = function () { + alert("GLGeomObj.render method must be overridden by sub class"); }; - this.collidesWithPoint = function( x, y ) { - alert( "GLGeomObj.collidesWithPoint method must be overridden by sub class" ); + this.collidesWithPoint = function (x, y) { + alert("GLGeomObj.collidesWithPoint method must be overridden by sub class"); }; - this.getNearPoint = function( pt, dir ) { - // the alert is not displayed. Objects may choose not to implement this method. + this.getNearPoint = function (pt, dir) { + // the alert is not displayed. Objects may choose not to implement this method. //alert( "GLGeomObj.getNearPoint method must be overridden by sub class" ); }; - this.getNearVertex = function( pt, dir ) { - // this should be overridden by objects (such as rectangles) that have corners - }; + this.getNearVertex = function (pt, dir) { + // this should be overridden by objects (such as rectangles) that have corners + }; - this.containsPoint = function( pt, dir ) { - // the alert is not displayed. Objects may choose not to implement this method. + this.containsPoint = function (pt, dir) { + // the alert is not displayed. Objects may choose not to implement this method. //alert( "GLGeomObj.containsPoint method must be overridden by sub class" ); }; - this.getPropertyFromString = function( prop, str ) { - var index = str.indexOf( prop ); - if (index < 0) throw new Error( "property " + prop + " not found in string: " + str); + this.getPropertyFromString = function (prop, str) { + var index = str.indexOf(prop); + if (index < 0) throw new Error("property " + prop + " not found in string: " + str); - var rtnStr = str.substr( index+prop.length ); - index = rtnStr.indexOf( "\n" ); - if (index >= 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