aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/rectangle.js
diff options
context:
space:
mode:
authorJonathan Duran2012-03-06 11:38:39 -0800
committerJonathan Duran2012-03-06 11:38:39 -0800
commit342fb451bd251358068a0dcb10e9dc218b79a176 (patch)
treeaa0195d581c3934fb6dc09981506b3c070002806 /js/lib/geom/rectangle.js
parent2815adfd7c19b3dff89dc3e1bda9af8d30dca8d6 (diff)
downloadninja-342fb451bd251358068a0dcb10e9dc218b79a176.tar.gz
Squashed commit of the following:
commit 1cd89d4d06e3a8f2c221628b19cf26a2c69f5d3f Author: Jose Antonio Marquez <kgq387@motorola.com> Date: Tue Mar 6 11:24:25 2012 -0800 Fixing WebGL not available bug commit 84332ab81c1b445195f1d9be8bbeae0725c8e758 Author: Valerio Virgillito <valerio@motorola.com> Date: Tue Mar 6 10:58:25 2012 -0800 Squashed commit of preload-fix into Master - Requiring all the previously pre-loaded files - RDGE, Codemirror and gl-matrix are not included via a script tag. Signed-off-by: Valerio Virgillito <valerio@motorola.com> commit 13f52cf0c74f53a919fa864f86669e8155f82961 Merge: dced508 abc04f3 Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 15:46:11 2012 -0800 Merge pull request #93 from imix23ways/Timeline Timeline: Critical bug fixes commit dced508bb19a7bcd467ff1b86b5df5bbec4be794 Merge: 0aeb400 cc772ef Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 15:45:35 2012 -0800 Merge pull request #92 from mqg734/WebGLFixes Selection Tool Fixes for elements flying off into space when they overlap commit 0aeb400070762cf01d83cf9f9ee25a5595098b7f Merge: ff0a956 aabb48a Author: Valerio Virgillito <valerio@motorola.com> Date: Fri Mar 2 14:05:21 2012 -0800 Merge pull request #94 from ericguzman/PresetsPanel Presets Panel - Fix single-click activation, and transition cut-off bug. commit cc772ef3333ed419d269a2bda7aea5b0150a7bd9 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 11:34:58 2012 -0800 Fixing flying off into space bug for translate tool too. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit abc04f3d50311ed1c21067344bc7e448686f8c5c Author: Jonathan Duran <jduran@motorola.com> Date: Fri Mar 2 11:26:25 2012 -0800 Timeline Fix timing function Signed-off-by: Jonathan Duran <jduran@motorola.com> commit aabb48a1c8d34bc968f4c6b0ffee4e31c1d5d286 Author: Eric Guzman <ericg@motorola.com> Date: Fri Mar 2 11:22:44 2012 -0800 Presets Panel - Fix single-click activation, and transition cut-off bug. Use double-click as the activation event for transition presets. Also fixed the bug when applying a style preset before the transition preset, which disabled transitions after the first one. commit f3207f39ea9d8c1c34246217a23d3a689671903d Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 11:21:29 2012 -0800 Don't draw transform handles if the stage is the target element. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 5425be91e7125c22955b4459a62412ff574e49a8 Author: Jonathan Duran <jduran@motorola.com> Date: Fri Mar 2 11:11:48 2012 -0800 Timeline: Fix for animation iteration count Add default webkit css properties to allow animations with integer iteration counts. Signed-off-by: Jonathan Duran <jduran@motorola.com> commit 1760bac1da9218315ad1bacdcf3a157495a049e8 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Mar 2 10:48:41 2012 -0800 Fix for jumping issue when moving items that have any 3d on them. We can't translate 3d moves into 2d space due to perspective, so we must update the matrix3d values instead of the top-left values if items have 3d. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 2c04935f0ccb1cb7c98371fc10b43155f2d956c4 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 22:20:06 2012 -0800 Fix for elements flying off into space when moving elements that overlap. This was happening because our hit record's element and the browser's element from point did not match. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 50058746779f714ed9b0287f49e56c9f0d35593e Merge: 500426d ff0a956 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 21:49:44 2012 -0800 Merge branch 'refs/heads/ninja-internal' into WebGLFixes commit 500426dea0ca95a6b45be8ea8d132cfdb4d2c940 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 10:11:39 2012 -0800 Fixed logic error when resizing with the top-left transform handles. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 7980d9bde2b43aa5a494ddf6f1db5c4959a57b91 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Mar 1 10:04:15 2012 -0800 Re-fixing IKNinja-940 - Can't select objects when in side/top view. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit f04cc0146d8f7573628678613a99c270116768e4 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Wed Feb 29 16:45:40 2012 -0800 Last-used material (instead of FlatMaterial) is applied to shape when turning on use WebGL checkbox in the PI. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'js/lib/geom/rectangle.js')
-rwxr-xr-xjs/lib/geom/rectangle.js1165
1 files changed, 1165 insertions, 0 deletions
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js
new file mode 100755
index 00000000..81b385b3
--- /dev/null
+++ b/js/lib/geom/rectangle.js
@@ -0,0 +1,1165 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<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.
5 </copyright> */
6
7var GeomObj = require("js/lib/geom/geom-obj").GeomObj;
8var ShapePrimitive = require("js/lib/geom/shape-primitive").ShapePrimitive;
9var MaterialsModel = require("js/models/materials-model").MaterialsModel;
10var FlatMaterial = require("js/lib/rdge/materials/flat-material").FlatMaterial;
11 ///////////////////////////////////////////////////////////////////////
12// Class GLRectangle
13// GL representation of a rectangle.
14// Derived from class GeomObj
15///////////////////////////////////////////////////////////////////////
16var Rectangle = function GLRectangle() {
17 // CONSTANTS
18 this.N_TRIANGLES = 15;
19
20 ///////////////////////////////////////////////////////////////////////
21 // Instance variables
22 ///////////////////////////////////////////////////////////////////////
23 this._width = 2.0;
24 this._height = 2.0;
25 this._xOffset = 0;
26 this._yOffset = 0;
27
28 this._tlRadius = 0;
29 this._trRadius = 0;
30 this._blRadius = 0;
31 this._brRadius = 0;
32
33 this._strokeWidth = 0.25;
34
35 this._strokeStyle = "Solid";
36 this.init = function(world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor,
37 tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle) {
38
39
40 this.m_world = world;
41
42 if (arguments.length > 0) {
43 this._width = width;
44 this._height = height;
45 this._xOffset = xOffset;
46 this._yOffset = yOffset;
47
48 this._strokeWidth = strokeSize;
49 this._strokeColor = strokeColor;
50 this._fillColor = fillColor;
51
52 this.setTLRadius(tlRadius);
53 this.setTRRadius(trRadius);
54 this.setBLRadius(blRadius);
55 this.setBRRadius(brRadius);
56
57 this._strokeStyle = strokeStyle;
58 }
59
60 // the overall radius includes the fill and the stroke. separate the two based onthe stroke width
61 // this._fillRad = this._radius - this._strokeWidth;
62 // var err = 0.05;
63 var err = 0;
64 this._fillWidth = this._width - this._strokeWidth + err;
65 this._fillHeight = this._height - this._strokeWidth + err;
66
67 this._materialAmbient = [0.2, 0.2, 0.2, 1.0];
68 this._materialDiffuse = [0.4, 0.4, 0.4, 1.0];
69 this._materialSpecular = [0.4, 0.4, 0.4, 1.0];
70
71 if(strokeMaterial) {
72 this._strokeMaterial = strokeMaterial;
73 } else {
74 this._strokeMaterial = MaterialsModel.exportFlatMaterial();
75 }
76
77 if(fillMaterial) {
78 this._fillMaterial = fillMaterial;
79 } else {
80 this._fillMaterial = MaterialsModel.exportFlatMaterial();
81 }
82 };
83
84 ///////////////////////////////////////////////////////////////////////
85 // Property Accessors
86 ///////////////////////////////////////////////////////////////////////
87 this.getStrokeWidth = function() {
88 return this._strokeWidth;
89 };
90
91 this.setStrokeWidth = function(w) {
92 this._strokeWidth = w;
93 };
94
95 this.getStrokeMaterial = function() {
96 return this._strokeMaterial;
97 };
98
99 this.setStrokeMaterial = function(m) {
100 this._strokeMaterial = m;
101 };
102
103 this.getFillMaterial = function() {
104 return this._fillMaterial;
105 };
106
107 this.setFillMaterial = function(m) {
108 this._fillMaterial = m;
109 };
110
111 this.getStrokeColor = function() {
112 return this._strokeColor;
113 };
114
115 //this.setStrokeColor = function(c) {
116 // this._strokeColor = c;
117 // };
118
119 this.getFillColor = function() {
120 return this._fillColor;
121 };
122
123 //this.setFillColor = function(c) {
124 // this._fillColor = c.slice(0);
125 // };
126
127 this.getTLRadius = function() {
128 return this._tlRadius;
129 };
130
131 this.setTLRadius = function(r) {
132 this._tlRadius = Math.min(r, (this._height - this._strokeWidth)/2, (this._width - this._strokeWidth)/2);
133 };
134
135 this.getTRRadius = function() {
136 return this._trRadius;
137 };
138
139 this.setTRRadius = function(r) {
140 this._trRadius = Math.min(r, (this._height - this._strokeWidth)/2, (this._width - this._strokeWidth)/2);
141 };
142
143 this.getBLRadius = function() {
144 return this._blRadius;
145 };
146
147 this.setBLRadius = function(r) {
148 this._blRadius = Math.min(r, (this._height - this._strokeWidth)/2, (this._width - this._strokeWidth)/2);
149 };
150
151 this.getBRRadius = function() {
152 return this._brRadius;
153 };
154
155 this.setBRRadius = function(r) {
156 this._brRadius = Math.min(r, (this._height - this._strokeWidth)/2, (this._width - this._strokeWidth)/2);
157 };
158
159 this.getStrokeStyle = function() {
160 return this._strokeStyle;
161 };
162
163 this.setStrokeStyle = function(s) {
164 this._strokeStyle = s;
165 };
166
167 this.getWidth = function() {
168 return this._width;
169 };
170
171 this.setWidth = function(w) {
172 this._width = w;
173 };
174
175 this.getHeight = function() {
176 return this._height;
177 };
178
179 this.setHeight = function(h) {
180 this._height = h;
181 };
182
183 this.geomType = function() {
184 return this.GEOM_TYPE_RECTANGLE;
185 };
186
187
188 ///////////////////////////////////////////////////////////////////////
189 // Methods
190 ///////////////////////////////////////////////////////////////////////
191 this.export = function() {
192 var rtnStr = "type: " + this.geomType() + "\n";
193
194 /////////////////////////////////////////////////////////////////////////
195 //
196 // world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor,
197 // tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle
198 //
199 /////////////////////////////////////////////////////////////////////////////
200
201 rtnStr += "xoff: " + this._xOffset + "\n";
202 rtnStr += "yoff: " + this._yOffset + "\n";
203 rtnStr += "width: " + this._width + "\n";
204 rtnStr += "height: " + this._height + "\n";
205 rtnStr += "strokeWidth: " + this._strokeWidth + "\n";
206 rtnStr += "strokeColor: " + String(this._strokeColor) + "\n";
207 rtnStr += "fillColor: " + String(this._fillColor) + "\n";
208 rtnStr += "tlRadius: " + this._tlRadius + "\n";
209 rtnStr += "trRadius: " + this._trRadius + "\n";
210 rtnStr += "blRadius: " + this._blRadius + "\n";
211 rtnStr += "brRadius: " + this._brRadius + "\n";
212 rtnStr += "innerRadius: " + this._innerRadius + "\n";
213 rtnStr += "strokeStyle: " + this._strokeStyle + "\n";
214
215 rtnStr += "strokeMat: ";
216 if (this._strokeMaterial) {
217 rtnStr += this._strokeMaterial.getName();
218 } else {