aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom')
-rwxr-xr-xjs/lib/geom/geom-obj.js358
1 files changed, 179 insertions, 179 deletions
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 @@
1/* <copyright> 1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/> 2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> 3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */ 5 </copyright> */
6 6
7var MaterialsModel = require("js/models/materials-model").MaterialsModel; 7var MaterialsModel = require("js/models/materials-model").MaterialsModel;
8 8
@@ -14,19 +14,19 @@ var GeomObj = function GLGeomObj() {
14 /////////////////////////////////////////////////////////////////////// 14 ///////////////////////////////////////////////////////////////////////
15 // Constants 15 // Constants
16 /////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////
17 this.GEOM_TYPE_RECTANGLE = 1; 17 this.GEOM_TYPE_RECTANGLE = 1;
18 this.GEOM_TYPE_CIRCLE = 2; 18 this.GEOM_TYPE_CIRCLE = 2;
19 this.GEOM_TYPE_LINE = 3; 19 this.GEOM_TYPE_LINE = 3;
20 this.GEOM_TYPE_PATH = 4; 20 this.GEOM_TYPE_PATH = 4;
21 this.GEOM_TYPE_CUBIC_BEZIER = 5; 21 this.GEOM_TYPE_CUBIC_BEZIER = 5;
22 this.GEOM_TYPE_BRUSH_STROKE = 6; 22 this.GEOM_TYPE_BRUSH_STROKE = 6;
23 this.GEOM_TYPE_UNDEFINED = -1; 23 this.GEOM_TYPE_UNDEFINED = -1;
24 24
25 // Needed for calculating dashed/dotted strokes 25 // Needed for calculating dashed/dotted strokes
26 this.DASH_LENGTH = 0.15; 26 this.DASH_LENGTH = 0.15;
27 this.DOT_LENGTH = 0.05; 27 this.DOT_LENGTH = 0.05;
28 this.GAP_LENGTH = 0.05; 28 this.GAP_LENGTH = 0.05;
29 29
30 /////////////////////////////////////////////////////////////////////// 30 ///////////////////////////////////////////////////////////////////////
31 // Instance variables 31 // Instance variables
32 /////////////////////////////////////////////////////////////////////// 32 ///////////////////////////////////////////////////////////////////////
@@ -40,74 +40,74 @@ var GeomObj = function GLGeomObj() {
40 this.m_world = null; 40 this.m_world = null;
41 41
42 // stroke and fill colors 42 // stroke and fill colors
43 this._strokeColor = [0,0,0,0]; 43 this._strokeColor = [0, 0, 0, 0];
44 this._fillColor = [0,0,0,0]; 44 this._fillColor = [0, 0, 0, 0];
45 45
46 // stroke and fill materials 46 // stroke and fill materials
47 this._fillMaterial = null; 47 this._fillMaterial = null;
48 this._strokeMaterial = null; 48 this._strokeMaterial = null;
49 49
50 // array of primitives - used in RDGE 50 // array of primitives - used in RDGE
51 this._primArray = []; 51 this._primArray = [];
52 this._materialNodeArray = []; 52 this._materialNodeArray = [];
53 this._materialArray = []; 53 this._materialArray = [];
54 this._materialTypeArray = []; 54 this._materialTypeArray = [];
55 55
56 // the transform node used by RDGE 56 // the transform node used by RDGE
57 this._trNode = null; 57 this._trNode = null;
58 58
59 /////////////////////////////////////////////////////////////////////// 59 ///////////////////////////////////////////////////////////////////////
60 // Property accessors 60 // Property accessors
61 /////////////////////////////////////////////////////////////////////// 61 ///////////////////////////////////////////////////////////////////////
62 this.setWorld = function( world ) { 62 this.setWorld = function (world) {
63 this.m_world = world; 63 this.m_world = world;
64 }; 64 };
65 65
66 this.getWorld = function() { 66 this.getWorld = function () {
67 return this.m_world; 67 return this.m_world;
68 }; 68 };
69 69
70 this.getMatrix = function() { 70 this.getMatrix = function () {
71 return this._matrix.slice(0); 71 return this._matrix.slice(0);
72 }; 72 };
73 73
74 this.setMatrix = function(m) { 74 this.setMatrix = function (m) {
75 this._matrix = m.slice(0); 75 this._matrix = m.slice(0);
76 }; 76 };
77 77
78 this.setNext = function( next ) { 78 this.setNext = function (next) {
79 this._next = next; 79 this._next = next;
80 }; 80 };
81 81
82 this.getNext = function() { 82 this.getNext = function () {
83 return this._next; 83 return this._next;
84 }; 84 };
85 85
86 this.setPrev = function( prev ) { 86 this.setPrev = function (prev) {
87 this._prev = prev; 87 this._prev = prev;
88 }; 88 };
89 89
90 this.getPrev = function() { 90 this.getPrev = function () {
91 return this._prev; 91 return this._prev;
92 }; 92 };
93 93
94 this.setChild = function( child ) { 94 this.setChild = function (child) {
95 this._child = child; 95 this._child = child;
96 }; 96 };
97 97
98 this.getChild = function() { 98 this.getChild = function () {
99 return this._child; 99 return this._child;
100 }; 100 };
101 101
102 this.setParent = function( parent ) { 102 this.setParent = function (parent) {
103 this._parent = parent; 103 this._parent = parent;
104 }; 104 };
105 105
106 this.getParent = function() { 106 this.getParent = function () {
107 return this._parent; 107 return this._parent;
108 }; 108 };
109 109
110 this.geomType = function() { 110 this.geomType = function () {
111 return this.GEOM_TYPE_UNDEFINED; 111 return this.GEOM_TYPE_UNDEFINED;
112 }; 112 };
113 113
@@ -115,7 +115,7 @@ var GeomObj = function GLGeomObj() {
115 return this._primArray; 115 return this._primArray;
116 }; 116 };
117 117
118 this.getMaterialNodeArray = function() { 118 this.getMaterialNodeArray = function () {
119 return this._materialNodeArray; 119 return this._materialNodeArray;
120 }; 120 };
121 121
@@ -123,29 +123,29 @@ var GeomObj = function GLGeomObj() {
123 return this._materialArray; 123 return this._materialArray;
124 }; 124 };
125 125
126 this.getTransformNode = function() { 126 this.getTransformNode = function () {
127 return this._trNode; 127 return this._trNode;
128 }; 128 };
129 129
130 this.setTransformNode = function(t) { 130 this.setTransformNode = function (t) {
131 this._trNode = t; 131 this._trNode = t;
132 }; 132 };
133 133
134 this.setFillColor = function(c) { 134 this.setFillColor = function (c) {
135 this.setMaterialColor(c, "fill"); 135 this.setMaterialColor(c, "fill");
136 }; 136 };
137 137
138 this.setStrokeColor = function(c) { 138 this.setStrokeColor = function (c) {
139 this.setMaterialColor(c, "stroke"); 139 this.setMaterialColor(c, "stroke");
140 }; 140 };
141 /////////////////////////////////////////////////////////////////////// 141 ///////////////////////////////////////////////////////////////////////
142 // Methods 142 // Methods
143 /////////////////////////////////////////////////////////////////////// 143 ///////////////////////////////////////////////////////////////////////
144 this.setMaterialColor = function(c, type) { 144 this.setMaterialColor = function (c, type) {
145 var i = 0, 145 var i = 0,
146 nMats = 0; 146 nMats = 0;
147 if(c) { 147 if (c) {
148 if(c.gradientMode) { 148 if (c.gradientMode) {
149 // Gradient support 149 // Gradient support
150 if (this._materialArray && this._materialTypeArray) { 150 if (this._materialArray && this._materialTypeArray) {
151 nMats = this._materialArray.length; 151 nMats = this._materialArray.length;
@@ -156,21 +156,21 @@ var GeomObj = function GLGeomObj() {
156 156
157 var len = colors.length; 157 var len = colors.length;
158 // TODO - Current shaders only support 4 color stops 158 // TODO - Current shaders only support 4 color stops
159 if(len > 4) { 159 if (len > 4) {
160 len = 4; 160 len = 4;
161 } 161 }
162 162
163 for(var n=0; n<len; n++) { 163 for (var n = 0; n < len; n++) {
164 var position = colors[n].position/100; 164 var position = colors[n].position / 100;
165 var cs = colors[n].value; 165 var cs = colors[n].value;
166 var stop = [cs.r/255, cs.g/255, cs.b/255, cs.a]; 166 var stop = [cs.r / 255, cs.g / 255, cs.b / 255, cs.a];
167 stops.push(stop); 167 stops.push(stop);
168 168
169 if (nMats === this._materialTypeArray.length) { 169 if (nMats === this._materialTypeArray.length) {
170 for (i=0; i<nMats; i++) { 170 for (i = 0; i < nMats; i++) {
171 if (this._materialTypeArray[i] == type) { 171 if (this._materialTypeArray[i] == type) {
172 this._materialArray[i].setProperty( "color"+(n+1), stop.slice(0) ); 172 this._materialArray[i].setProperty("color" + (n + 1), stop.slice(0));
173 this._materialArray[i].setProperty( "colorStop"+(n+1), position ); 173 this._materialArray[i].setProperty("colorStop" + (n <