From 18609d375e7aab9cb48c9b3f5b291f85cbd28683 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Tue, 3 Apr 2012 13:39:32 -0700 Subject: removed old unused import and export functions. --- js/lib/drawing/world.js | 400 +++++--------------- js/lib/geom/brush-stroke.js | 12 - js/lib/geom/circle.js | 94 ----- js/lib/geom/geom-obj.js | 442 +++++++++------------- js/lib/geom/line.js | 70 ---- js/lib/geom/rectangle.js | 110 ------ js/lib/rdge/materials/bump-metal-material.js | 54 --- js/lib/rdge/materials/cloud-material.js | 41 -- js/lib/rdge/materials/flat-material.js | 28 -- js/lib/rdge/materials/linear-gradient-material.js | 63 --- js/lib/rdge/materials/material.js | 15 - js/lib/rdge/materials/pulse-material.js | 42 -- js/lib/rdge/materials/radial-blur-material.js | 38 -- js/lib/rdge/materials/radial-gradient-material.js | 59 --- js/lib/rdge/materials/taper-material.js | 38 -- js/lib/rdge/materials/twist-vert-material.js | 38 -- js/lib/rdge/materials/uber-material.js | 187 --------- 17 files changed, 282 insertions(+), 1449 deletions(-) (limited to 'js/lib') diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js index 801c199a..ae8c2cce 100755 --- a/js/lib/drawing/world.js +++ b/js/lib/drawing/world.js @@ -435,38 +435,38 @@ World.prototype.updateObject = function (obj) { } }; -World.prototype.addObject = function( obj ) { - if (!obj) return; +World.prototype.addObject = function (obj) { + if (!obj) return; try { // undefine all the links of the object - obj.setChild( undefined ); - obj.setNext( undefined ); - obj.setPrev( undefined ); - obj.setParent( undefined ); + obj.setChild(undefined); + obj.setNext(undefined); + obj.setPrev(undefined); + obj.setParent(undefined); - obj.setWorld( this ); + obj.setWorld(this); if (this._geomRoot == null) { this._geomRoot = obj; } else { var go = this._geomRoot; - while (go.getNext()) go = go.getNext(); - go.setNext( obj ); - obj.setPrev( go ); + while (go.getNext()) go = go.getNext(); + go.setNext(obj); + obj.setPrev(go); } - // build the WebGL buffers - if (this._useWebGL) { - obj.buildBuffers(); - this.restartRenderLoop(); - } + // build the WebGL buffers + if (this._useWebGL) { + obj.buildBuffers(); + this.restartRenderLoop(); + } } - catch(e) { - alert( "Exception in GLWorld.addObject " + e ); + catch (e) { + alert("Exception in GLWorld.addObject " + e); } -} +}; World.prototype.restartRenderLoop = function() { //console.log( "restartRenderLoop" ); @@ -734,146 +734,76 @@ World.prototype.getShapeFromPoint = function( offsetX, offsetY ) { -World.prototype.exportJSON = function() -{ - // world properties - var worldObj = +World.prototype.exportJSON = function () { + // world properties + var worldObj = { - 'version' : 1.1, - 'id' : this.getCanvas().getAttribute( "data-RDGE-id" ), - 'fov' : this._fov, - 'zNear' : this._zNear, - 'zFar' : this._zFar, - 'viewDist' : this._viewDist, - 'webGL' : this._useWebGL + 'version': 1.1, + 'id': this.getCanvas().getAttribute("data-RDGE-id"), + 'fov': this._fov, + 'zNear': this._zNear, + 'zFar': this._zFar, + 'viewDist': this._viewDist, + 'webGL': this._useWebGL }; - // RDGE scenegraph - if (this._useWebGL) - worldObj.scenedata = this.myScene.exportJSON(); + // RDGE scenegraph + if (this._useWebGL) + worldObj.scenedata = this.myScene.exportJSON(); - // object data - var strArray = []; - this.exportObjectsJSON( this._geomRoot, worldObj ); + // object data + var strArray = []; + this.exportObjectsJSON(this._geomRoot, worldObj); - // You would think that the RDGE export function - // would not be destructive of the data. You would be wrong... - // We need to rebuild everything - if (this._useWebGL) - { - if (worldObj.children && (worldObj.children.length === 1)) - { + // You would think that the RDGE export function + // would not be destructive of the data. You would be wrong... + // We need to rebuild everything + if (this._useWebGL) { + if (worldObj.children && (worldObj.children.length === 1)) { this.rebuildTree(this._geomRoot); this.restartRenderLoop(); - } - } - - // convert the object to a string - var jStr = JSON.stringify( worldObj ); - - // prepend some version information to the string. - // this string is also used to differentiate between JSON - // and pre-JSON versions of fileIO. - // the ending ';' in the version string is necessary - jStr = "v1.0;" + jStr; - - return jStr; -} - -World.prototype.rebuildTree = function( obj ) -{ - if (!obj) return; - - obj.buildBuffers(); - - if (obj.getChild()) { - this.rebuildTree( obj.getChild () ); + } } - if (obj.getNext()) - this.rebuildTree( obj.getNext() ); -} - -World.prototype.exportObjectsJSON = function( obj, parentObj ) -{ - if (!obj) return; - - var jObj = obj.exportJSON(); - if (!parentObj.children) parentObj.children = []; - parentObj.children.push( jObj ); + // convert the object to a string + var jStr = JSON.stringify(worldObj); - if (obj.getChild()) { - this.exportObjectsJSON( obj.getChild (), jObj ); - } + // prepend some version information to the string. + // this string is also used to differentiate between JSON + // and pre-JSON versions of fileIO. + // the ending ';' in the version string is necessary + jStr = "v1.0;" + jStr; - if (obj.getNext()) - this.exportObjectsJSON( obj.getNext(), parentObj ); -} + return jStr; +}; -/* -World.prototype.export = function() -{ - var exportStr = "GLWorld 1.0\n"; - var id = this.getCanvas().getAttribute( "data-RDGE-id" ); - exportStr += "id: " + id + "\n"; - //exportStr += "id: " + this._canvas.rdgeid + "\n"; - exportStr += "fov: " + this._fov + "\n"; - exportStr += "zNear: " + this._zNear + "\n"; - exportStr += "zFar: " + this._zFar + "\n"; - exportStr += "viewDist: " + this._viewDist + "\n"; - if (this._useWebGL) - exportStr += "webGL: true\n"; - - // we need 2 export modes: One for save/restore, one for publish. - // hardcoding for now - //var exportForPublish = false; - //if (!exportForPublish) exportForPublish = false; - var exportForPublish = true; - exportStr += "publish: " + exportForPublish + "\n"; - - if (exportForPublish && this._useWebGL) - { - exportStr += "scenedata: " + this.myScene.exportJSON() + "endscene\n"; +World.prototype.rebuildTree = function (obj) { + if (!obj) return; - // write out all of the objects - exportStr += "tree\n"; - exportStr += this.exportObjects( this._geomRoot ); - exportStr += "endtree\n"; - } - else - { - // output the material library - //exportStr += MaterialsLibrary.export(); // THIS NEEDS TO BE DONE AT THE DOC LEVEL + obj.buildBuffers(); - // write out all of the objects - exportStr += "tree\n"; - exportStr += this.exportObjects( this._geomRoot ); - exportStr += "endtree\n"; - } + if (obj.getChild()) { + this.rebuildTree(obj.getChild()); + } - return exportStr; + if (obj.getNext()) + this.rebuildTree(obj.getNext()); }; -World.prototype.exportObjects = function( obj ) { - if (!obj) return; +World.prototype.exportObjectsJSON = function (obj, parentObj) { + if (!obj) return; - var rtnStr = "OBJECT\n"; - rtnStr += obj.export(); + var jObj = obj.exportJSON(); + if (!parentObj.children) parentObj.children = []; + parentObj.children.push(jObj); - if (obj.getChild()) { - rtnStr += this.exportObjects( obj.getChild () ); + if (obj.getChild()) { + this.exportObjectsJSON(obj.getChild(), jObj); } - // the end object goes outside the children - rtnStr += "ENDOBJECT\n"; - - if (obj.getNext()) { - rtnStr += this.exportObjects( obj.getNext() ); - } - - return rtnStr; + if (obj.getNext()) + this.exportObjectsJSON(obj.getNext(), parentObj); }; -*/ World.prototype.findTransformNodeByMaterial = function( materialNode, trNode ) { //if (trNode == null) trNode = this._ctrNode; @@ -893,51 +823,45 @@ World.prototype.findTransformNodeByMaterial = function( materialNode, trNode ) return rtnNode; }; -World.prototype.importJSON = function( jObj ) -{ - if (jObj.webGL) - { - // start RDGE - rdgeStarted = true; - var id = this._canvas.getAttribute( "data-RDGE-id" ); - this._canvas.rdgeid = id; - RDGE.globals.engine.registerCanvas(this._canvas, this); - RDGE.RDGEStart( this._canvas ); - this._canvas.task.stop() - } +World.prototype.importJSON = function (jObj) { + if (jObj.webGL) { + // start RDGE + rdgeStarted = true; + var id = this._canvas.getAttribute("data-RDGE-id"); + this._canvas.rdgeid = id; + RDGE.globals.engine.registerCanvas(this._canvas, this); + RDGE.RDGEStart(this._canvas); + this._canvas.task.stop() + } - // import the objects - // there should be exactly one child of the parent object - if (jObj.children && (jObj.children.length === 1)) - this.importObjectsJSON( jObj.children[0] ); - else - throw new Error ("unrecoverable canvas import error - inconsistent root object: " + jObj.children ); + // import the objects + // there should be exactly one child of the parent object + if (jObj.children && (jObj.children.length === 1)) + this.importObjectsJSON(jObj.children[0]); + else + throw new Error("unrecoverable canvas import error - inconsistent root object: " + jObj.children); - if (!this._useWebGL) - { - // render using canvas 2D - this.render(); - } - else - this.restartRenderLoop(); -} + if (!this._useWebGL) { + // render using canvas 2D + this.render(); + } + else + this.restartRenderLoop(); +}; -World.prototype.importObjectsJSON = function( jObj, parentGeomObj ) -{ - // read the next object - var gObj = this.importObjectJSON( jObj, parentGeomObj ); +World.prototype.importObjectsJSON = function (jObj, parentGeomObj) { + // read the next object + var gObj = this.importObjectJSON(jObj, parentGeomObj); - // determine if we have children - if (jObj.children) - { - var nKids = ojObjbj.chilodren.length; - for (var i=0; i= 0) - if (this._useWebGL) - { - // start RDGE - rdgeStarted = true; - var id = this._canvas.getAttribute( "data-RDGE-id" ); - this._canvas.rdgeid = id; - RDGE.globals.engine.registerCanvas(this._canvas, this); - RDGE.RDGEStart( this._canvas ); - this._canvas.task.stop() - } - - this.importObjects( importStr, this._rootNode ); - - if (!this._useWebGL) - { - // render using canvas 2D - this.render(); - } -}; - -World.prototype.importObjects = function( importStr, parentNode ) { - var index = importStr.indexOf( "OBJECT\n", 0 ); - while (index >= 0) { - // update the string to the current object - importStr = importStr.substr( index+7 ); - - // read the next object - this.importObject( importStr, parentNode ); - - // determine if we have children - var endIndex = importStr.indexOf( "ENDOBJECT\n" ), - childIndex = importStr.indexOf( "OBJECT\n" ); - if (endIndex < 0) throw new Error( "ill-formed object data" ); - if ((childIndex >= 0) && (childIndex < endIndex)) { - importStr = importStr.substr( childIndex + 7 ); - importStr = this.importObjects( importStr, node ); - endIndex = importStr.indexOf( "ENDOBJECT\n" ) - } - - // remove the string for the object(s) just created - importStr = importStr.substr( endIndex ); - - // get the location of the next object - index = importStr.indexOf( "OBJECT\n", endIndex ); - } - - return importStr; -}; - -World.prototype.importObject = function( objStr, parentNode ) { - var go = new GeomObj(); - var type = Number( go.getPropertyFromString( "type: ", objStr ) ); - - var obj; - switch (type) - { - case 1: - obj = new Rectangle(); - obj.import( objStr ); - break; - - case 2: // circle - obj = new Circle(); - obj.import( objStr ); - break; - - case 3: // line - obj = new Line(); - obj.import( objStr ); - break; - - default: - throw new Error( "Unrecognized object type: " + type ); - break; - } - - if (obj) { - this.addObject( obj ); - } -}; - -World.prototype.importSubObject = function( objStr, parentNode ) { - // get the mesh text - var i0 = objStr.indexOf( "mesh: " ), - i1 = objStr.indexOf( "endMesh\n" ); - if ((i0 < 0) || (i1 < 0)) throw new Error( "ill-formed sub object" ); - i0 += 6; - var meshText = objStr.substr( i0, i1 - i0 ); - var meshObj = JSON.parse(meshText); - - // get the material text - var i0 = objStr.indexOf( "material: " ), - i1 = objStr.indexOf( "endMat\n" ); - if ((i0 < 0) || (i1 < 0)) throw new Error( "ill-formed sub object" ); - i0 += 10; - var matText = objStr.substr( i0, i1 - i0 ); - var shaderDef = JSON.parse( matText ); - var shader = new RDGE.jshader(); - shader.def = shaderDef; - shader.init(); - - // set the shader for this material - var matNode = RDGE.createMaterialNode("objMat") - matNode.setShader(shader); - - // create the transformation node - var trNode = RDGE.createTransformNode("subObjNode_"); - trNode.attachMeshNode(this.renderer.id + "_prim_", meshObj); - trNode.attachMaterial(matNode); - parentNode.insertAsChild(trNode); - - return trNode; -}; - if (typeof exports === "object") { exports.World = World; } \ No newline at end of file diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js index 22209815..26ac42e9 100755 --- a/js/lib/geom/brush-stroke.js +++ b/js/lib/geom/brush-stroke.js @@ -711,18 +711,6 @@ var BrushStroke = function GLBrushStroke() { this.update(); //after this, the stroke is ready to be rendered }; - - this.export = function() { - var jsonObject = this.exportJSON(); - var stringified = JSON.stringify(jsonObject); - return "type: " + this.geomType() + "\n" + stringified; - }; - - this.import = function( importStr ) { - var jsonObject = JSON.parse(importStr); - this.importJSON(jsonObject); - } - this.collidesWithPoint = function (x, y, z) { if (x < this._BBoxMin[0]) return false; if (x > this._BBoxMax[0]) return false; diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index e8c94b64..4bf37474 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js @@ -636,100 +636,6 @@ var Circle = function GLCircle() { 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 += "strokeWidth: " + this._strokeWidth + "\n"; - rtnStr += "innerRadius: " + this._innerRadius + "\n"; - rtnStr += "strokeStyle: " + this._strokeStyle + "\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"; - } - - if(this._fillColor.gradientMode) { - rtnStr += "fillGradientMode: " + this._fillColor.gradientMode + "\n"; - rtnStr += "fillColor: " + this.gradientToString(this._fillColor.color) + "\n"; - } else { - rtnStr += "fillColor: " + String(this._fillColor) + "\n"; - } - - rtnStr += "strokeMat: "; - if (this._strokeMaterial) { - rtnStr += this._strokeMaterial.getName(); - } else { - rtnStr += MaterialsModel.getDefaultMaterialName(); - } - - rtnStr += "\n"; - - rtnStr += "fillMat: "; - if (this._fillMaterial) { - rtnStr += this._fillMaterial.getName(); - } else { - rtnStr += MaterialsModel.getDefaultMaterialName(); - } - rtnStr += "\n"; - - rtnStr += this.exportMaterials(); - - 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._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) ); - this._innerRadius = Number( this.getPropertyFromString( "innerRadius: ", importStr ) ); - this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr ); - var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr ); - var fillMaterialName = this.getPropertyFromString( "fillMat: ", importStr ); - if(importStr.indexOf("fillGradientMode: ") < 0) { - this._fillColor = eval( "[" + this.getPropertyFromString( "fillColor: ", importStr ) + "]" ); - } else { - this._fillColor = {}; - this._fillColor.gradientMode = this.getPropertyFromString( "fillGradientMode: ", importStr ); - this._fillColor.color = this.stringToGradient(this.getPropertyFromString( "fillColor: ", 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; - - var fillMat = MaterialsModel.getMaterial( fillMaterialName ); - if (!fillMat) { - console.log( "object material not found in library: " + fillMaterialName ); - fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); - } - this._fillMaterial = fillMat; - - this.importMaterials( importStr ); - }; - this.collidesWithPoint = function( x, y ) { // if(x < this._xOffset) return false; // if(x > (this._xOffset + this._width)) return false; diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index f1aa9f8a..bb5b4a9a 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js @@ -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,109 +40,111 @@ 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; }; - this.getPrimitiveArray = function() { return this._primArray; + this.getPrimitiveArray = function () { + return this._primArray; }; - this.getMaterialNodeArray = function() { + this.getMaterialNodeArray = function () { return this._materialNodeArray; }; - this.getMaterialArray = function() { return this._materialArray; + this.getMaterialArray = function () { + 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.gradientMode) { + if (c.gradientMode) { // Gradient support if (this._materialArray && this._materialTypeArray) { nMats = this._materialArray.length; @@ -153,21 +155,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 = []; + 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