aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom
diff options
context:
space:
mode:
authorValerio Virgillito2012-07-09 14:16:17 -0700
committerValerio Virgillito2012-07-09 14:18:36 -0700
commit1bbba17e8605434356de0a477710d6a0136986fc (patch)
tree7cdc80226b776c6fb2250e250acdbcd53fdb1ddd /js/lib/geom
parentdc5b7a479a185dda8e9a09f4bbe26bd290641624 (diff)
parentab80aa9c7da912db384ec48c656f84fd673b5253 (diff)
downloadninja-1bbba17e8605434356de0a477710d6a0136986fc.tar.gz
Merge branch 'Taper' of https://github.com/ericmueller/ninja-internal
Conflicts: js/lib/geom/circle.js js/lib/rdge/materials/linear-gradient-material.js Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/lib/geom')
-rwxr-xr-xjs/lib/geom/circle.js1532
-rwxr-xr-xjs/lib/geom/line.js46
-rwxr-xr-xjs/lib/geom/rectangle.js286
-rw-r--r--js/lib/geom/shape-primitive.js181
4 files changed, 1192 insertions, 853 deletions
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index 12781ab8..2cd5a21f 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -42,49 +42,49 @@ var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils;
42/////////////////////////////////////////////////////////////////////// 42///////////////////////////////////////////////////////////////////////
43exports.Circle = Object.create(GeomObj, { 43exports.Circle = Object.create(GeomObj, {
44 44
45 /////////////////////////////////////////////////////////////////////// 45 ///////////////////////////////////////////////////////////////////////
46 // Instance variables 46 // Instance variables
47 /////////////////////////////////////////////////////////////////////// 47 ///////////////////////////////////////////////////////////////////////
48 _width: { value : 2.0, writable: true }, 48 _width: { value : 2.0, writable: true },
49 _height: { value : 2.0, writable: true }, 49 _height: { value : 2.0, writable: true },
50 _xOffset: { value : 0, writable: true }, 50 _xOffset: { value : 0, writable: true },
51 _yOffset: { value : 0, writable: true }, 51 _yOffset: { value : 0, writable: true },
52 52
53 _radius: { value : 2.0, writable: true }, 53 _radius: { value : 2.0, writable: true },
54 _strokeWidth: { value : 0.25, writable: true }, 54 _strokeWidth: { value : 0.25, writable: true },
55 _innerRadius: { value : 0, writable: true }, 55 _innerRadius: { value : 0, writable: true },
56 _ovalHeight: { value : 4.0, writable: true }, 56 _ovalHeight: { value : 4.0, writable: true },
57 _strokeStyle: { value : "Solid", writable: true }, 57 _strokeStyle: { value : "Solid", writable: true },
58 _aspectRatio: { value : 1.0, writable: true }, 58 _aspectRatio: { value : 1.0, writable: true },
59 59
60 init: { 60 init: {
61 value: function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) { 61 value: function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor, innerRadius, strokeMaterial, fillMaterial, strokeStyle) {
62 if(arguments.length > 0) { 62 if(arguments.length > 0) {
63 this._width = width; 63 this._width = width;
64 this._height = height; 64 this._height = height;
65 this._xOffset = xOffset; 65 this._xOffset = xOffset;
66 this._yOffset = yOffset; 66 this._yOffset = yOffset;
67 this._ovalHeight = 2.0 * this._radius; 67 this._ovalHeight = 2.0 * this._radius;
68 68
69 this._strokeWidth = strokeSize; 69 this._strokeWidth = strokeSize;
70 this._innerRadius = innerRadius; 70 this._innerRadius = innerRadius;
71 this._strokeColor = strokeColor; 71 this._strokeColor = strokeColor;
72 this._fillColor = fillColor; 72 this._fillColor = fillColor;
73 73
74 this._strokeStyle = strokeStyle; 74 this._strokeStyle = strokeStyle;
75 75
76 this._matrix = Matrix.I(4); 76 this._matrix = Matrix.I(4);
77 //this._matrix[12] = xOffset; 77 //this._matrix[12] = xOffset;
78 //this._matrix[13] = yOffset; 78 //this._matrix[13] = yOffset;
79 } 79 }
80 80
81 this.m_world = world; 81 this.m_world = world;
82 82
83 if(strokeMaterial) { 83 if(strokeMaterial) {
84 this._strokeMaterial = strokeMaterial.dup(); 84 this._strokeMaterial = strokeMaterial.dup();
85 } else { 85 } else {
86 this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); 86 this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup();
87 } 87 }
88 88
89 if(strokeColor) { 89 if(strokeColor) {
90 if(this._strokeMaterial.hasProperty("color")) { 90 if(this._strokeMaterial.hasProperty("color")) {
@@ -94,135 +94,135 @@ exports.Circle = Object.create(GeomObj, {
94 } 94 }
95 } 95 }
96 96
97 if(fillMaterial) { 97 if(fillMaterial) {
98 this._fillMaterial = fillMaterial.dup(); 98 this._fillMaterial = fillMaterial.dup();
99 } else { 99 } else {
100 this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); 100 this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup();
101 } 101 }
102 102
103 if(fillColor) { 103 if(fillColor) {
104 if(this._fillMaterial.hasProperty("color")) { 104 if(this._fillMaterial.hasProperty("color")) {
105 this._fillMaterial.setProperty( "color", this._fillColor ); 105 this._fillMaterial.setProperty( "color", this._fillColor );
106 } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) { 106 } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) {
107 this._fillMaterial.setGradientData(this._fillColor.color); 107 this._fillMaterial.setGradientData(this._fillColor.color);
108 } 108 }
109 } 109 }
110 } 110 }
111 }, 111 },
112 112
113 /////////////////////////////////////////////////////////////////////// 113 ///////////////////////////////////////////////////////////////////////
114 // Property Accessors 114 // Property Accessors
115 /////////////////////////////////////////////////////////////////////// 115 ///////////////////////////////////////////////////////////////////////
116 // TODO - Use getters/setters in the future 116 // TODO - Use getters/setters in the future
117 getStrokeWidth: { 117 getStrokeWidth: {
118 value: function() { 118 value: function() {
119 return this._strokeWidth; 119 return this._strokeWidth;
120 } 120 }
121 }, 121 },
122 122
123 setStrokeWidth: { 123 setStrokeWidth: {
124 value: function(w) { 124 value: function(w) {
125 this._strokeWidth = w; 125 this._strokeWidth = w;
126 } 126 }
127 }, 127 },
128 128
129 getStrokeMaterial: { 129 getStrokeMaterial: {
130 value: function() { 130 value: function() {
131 return this._strokeMaterial; 131 return this._strokeMaterial;
132 } 132 }
133 }, 133 },
134 134
135 setStrokeMaterial: { 135 setStrokeMaterial: {
136 value: function(m) { 136 value: function(m) {
137 this._strokeMaterial = m; 137 this._strokeMaterial = m;
138 } 138 }
139 }, 139 },
140 140
141 getFillMaterial: { 141 getFillMaterial: {
142 value: function() { 142 value: function() {
143 return this._fillMaterial; 143 return this._fillMaterial;
144 } 144 }
145 }, 145 },
146 146
147 setFillMaterial: { 147 setFillMaterial: {
148 value: function(m) { 148 value: function(m) {
149 this._fillMaterial = m; 149 this._fillMaterial = m;
150 } 150 }
151 }, 151 },
152 152
153 getRadius: { 153 getRadius: {
154 value: function() { 154 value: function() {
155 return this._radius; 155 return this._radius;
156 } 156 }
157 }, 157 },
158 158
159 setRadius: { 159 setRadius: {
160 value: function(r) { 160 value: function(r) {
161 this._radius = r; 161 this._radius = r;
162 } 162 }
163 }, 163 },
164 164
165 getInnerRadius: { 165 getInnerRadius: {
166 value: function() { 166 value: function() {
167 return this._innerRadius; 167 return this._innerRadius;
168 } 168 }
169 }, 169 },
170 170
171 setInnerRadius: { 171 setInnerRadius: {
172 value: function(r) { 172 value: function(r) {
173 this._innerRadius = r; 173 this._innerRadius = r;
174 } 174 }
175 }, 175 },
176 176
177 getStrokeStyle: { 177 getStrokeStyle: {
178 value: function() { 178 value: function() {
179 return this._strokeStyle; 179 return this._strokeStyle;
180 } 180 }
181 }, 181 },
182 182
183 setStrokeStyle: { 183 setStrokeStyle: {
184 value: function(s) { 184 value: function(s) {
185 this._strokeStyle = s; 185 this._strokeStyle = s;
186 } 186 }
187 }, 187 },
188 188
189 getWidth: { 189 getWidth: {
190 value: function() { 190 value: function() {
191 return this._width; 191 return this._width;
192 } <