aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom
diff options
context:
space:
mode:
authorhwc4872012-07-09 16:08:02 -0700
committerhwc4872012-07-09 16:08:02 -0700
commit5085d0f67df89a21715308956004164597a6ba79 (patch)
tree2c896163143a66331205a39b0a3b1b45d51bf12a /js/lib/geom
parent51f1691f792dbda9b740ded8aa0457c9406db156 (diff)
parent84b3327bd92faafab7954b5eb64c7abe24a3fe13 (diff)
downloadninja-5085d0f67df89a21715308956004164597a6ba79.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into GridFixes
Conflicts: js/helper-classes/3D/StageLine.js
Diffstat (limited to 'js/lib/geom')
-rwxr-xr-xjs/lib/geom/anchor-point.js12
-rwxr-xr-xjs/lib/geom/brush-stroke.js6
-rwxr-xr-xjs/lib/geom/circle.js298
-rwxr-xr-xjs/lib/geom/geom-obj.js65
-rwxr-xr-xjs/lib/geom/line.js123
-rwxr-xr-xjs/lib/geom/rectangle.js1187
-rw-r--r--js/lib/geom/shape-primitive.js463
-rwxr-xr-xjs/lib/geom/sub-path.js4
8 files changed, 1258 insertions, 900 deletions
diff --git a/js/lib/geom/anchor-point.js b/js/lib/geom/anchor-point.js
index a1fcfc0d..72eebd0d 100755
--- a/js/lib/geom/anchor-point.js
+++ b/js/lib/geom/anchor-point.js
@@ -30,14 +30,14 @@ POSSIBILITY OF SUCH DAMAGE.
30 30
31///////////////////////////////////////////// 31/////////////////////////////////////////////
32// Class GLAnchorPoint 32// Class GLAnchorPoint
33// GL representation of a point clicked 33// GL representation of a point clicked
34// and dragged during pen tool 34// and dragged during pen tool
35// 35//
36// 36//
37///////////////////////////////////////////// 37/////////////////////////////////////////////
38var GLAnchorPoint = function GLAnchorPoint() { 38var GLAnchorPoint = function GLAnchorPoint() {
39 ///////////////////////////////////////// 39 /////////////////////////////////////////
40 // Instance variables 40 // Instance variables
41 ///////////////////////////////////////// 41 /////////////////////////////////////////
42 this._x = 0.0; 42 this._x = 0.0;
43 this._y = 0.0; 43 this._y = 0.0;
@@ -99,7 +99,7 @@ GLAnchorPoint.prototype.translateNextFromPrev = function (tx, ty, tz) {
99 if (totalTransSq < 0.0000001) { 99 if (totalTransSq < 0.0000001) {
100 return; 100 return;
101 } 101 }
102 102
103 // *** compute the rotation of the prev vector *** 103 // *** compute the rotation of the prev vector ***
104 var oldP = [this._prevX + tx - this._x, this._prevY + ty - this._y, this._prevZ + tz - this._z]; 104 var oldP = [this._prevX + tx - this._x, this._prevY + ty - this._y, this._prevZ + tz - this._z];
105 var newP = [this._prevX - this._x, this._prevY - this._y, this._prevZ - this._z]; 105 var newP = [this._prevX - this._x, this._prevY - this._y, this._prevZ - this._z];
@@ -133,7 +133,7 @@ GLAnchorPoint.prototype.translatePrevFromNext = function (tx, ty, tz) {
133 if (totalTransSq < 0.0000001) { 133 if (totalTransSq < 0.0000001) {
134 return; 134 return;
135 } 135 }
136 136
137 // *** compute the rotation of the next vector *** 137 // *** compute the rotation of the next vector ***
138 var oldN = [this._nextX + tx - this._x, this._nextY + ty - this._y, this._nextZ + tz - this._z]; 138 var oldN = [this._nextX + tx - this._x, this._nextY + ty - this._y, this._nextZ + tz - this._z];
139 var newN = [this._nextX - this._x, this._nextY - this._y, this._nextZ - this._z]; 139 var newN = [this._nextX - this._x, this._nextY - this._y, this._nextZ - this._z];
diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js
index e553a1c6..6365d14c 100755
--- a/js/lib/geom/brush-stroke.js
+++ b/js/lib/geom/brush-stroke.js
@@ -52,7 +52,7 @@ var BrushStroke = function GLBrushStroke() {
52 this._BBoxMax = [0, 0, 0]; 52 this._BBoxMax = [0, 0, 0];
53 this._isDirty = true; 53 this._isDirty = true;
54 this._isInit = false; 54 this._isInit = false;
55 55
56 //the HTML5 canvas that holds this brush stroke 56 //the HTML5 canvas that holds this brush stroke
57 this._canvas = null; 57 this._canvas = null;
58 //flag indicating whether or not to freeze the size and position of canvas 58 //flag indicating whether or not to freeze the size and position of canvas
@@ -312,7 +312,7 @@ BrushStroke.prototype.setWidth = function (newW) {
312 } 312 }
313 var minWidth = 1+this._strokeWidth; 313 var minWidth = 1+this._strokeWidth;
314 if (newW<minWidth) { 314 if (newW<minWidth) {
315 newW=minWidth; 315 newW=minWidth;
316 } 316 }
317 317
318 if (oldCanvasWidth<minWidth) { 318 if (oldCanvasWidth<minWidth) {
@@ -731,7 +731,7 @@ BrushStroke.prototype.drawToContext = function(ctx, drawStageWorldPts, stageWorl
731 w = world.getViewportWidth(); 731 w = world.getViewportWidth();
732 h = world.getViewportHeight(); 732 h = world.getViewportHeight();
733 } 733 }
734 734
735 if (this._strokeUseCalligraphic) { 735 if (this._strokeUseCalligraphic) {
736 //build the stamp for the brush stroke 736 //build the stamp for the brush stroke
737 var t=0; 737 var t=0;
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index 39cde514..53847631 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -31,14 +31,14 @@ POSSIBILITY OF SUCH DAMAGE.
31var GeomObj = require("js/lib/geom/geom-obj").GeomObj; 31var GeomObj = require("js/lib/geom/geom-obj").GeomObj;
32var ShapePrimitive = require("js/lib/geom/shape-primitive").ShapePrimitive; 32var ShapePrimitive = require("js/lib/geom/shape-primitive").ShapePrimitive;
33var MaterialsModel = require("js/models/materials-model").MaterialsModel; 33var MaterialsModel = require("js/models/materials-model").MaterialsModel;
34var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils; 34var drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils;
35var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; 35var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils;
36 36
37/////////////////////////////////////////////////////////////////////// 37///////////////////////////////////////////////////////////////////////
38// Class GLCircle 38// Class GLCircle
39// GL representation of a circle. 39// GL representation of a circle.
40// Derived from class GLGeomObj 40// Derived from class GLGeomObj
41// The position and dimensions of the stroke, fill, and inner Radius should be in pixels 41// The position and dimensions of the stroke, fill, and inner Radius should be in pixels
42/////////////////////////////////////////////////////////////////////// 42///////////////////////////////////////////////////////////////////////
43exports.Circle = Object.create(GeomObj, { 43exports.Circle = Object.create(GeomObj, {
44 44
@@ -57,7 +57,7 @@ exports.Circle = Object.create(GeomObj, {
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;
@@ -85,14 +85,28 @@ exports.Circle = Object.create(GeomObj, {
85 } else { 85 } else {
86 this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); 86 this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup();
87 } 87 }
88 if (strokeColor && this._strokeMaterial.hasProperty( "color" )) this._strokeMaterial.setProperty( "color", this._strokeColor ); 88
89 if(strokeColor) {
90 if(this._strokeMaterial.hasProperty("color")) {
91 this._strokeMaterial.setProperty( "color", this._strokeColor );
92 } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) {
93 this._strokeMaterial.setGradientData(this._strokeColor.color);
94 }
95 }
89 96
90 if(fillMaterial) { 97 if(fillMaterial) {
91 this._fillMaterial = fillMaterial.dup(); 98 this._fillMaterial = fillMaterial.dup();
92 } else { 99 } else {
93 this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); 100 this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup();
94 } 101 }
95 if (fillColor && this._fillMaterial.hasProperty( "color" )) this._fillMaterial.setProperty( "color", this._fillColor ); 102
103 if(fillColor) {
104 if(this._fillMaterial.hasProperty("color")) {
105 this._fillMaterial.setProperty( "color", this._fillColor );
106 } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) {
107 this._fillMaterial.setGradientData(this._fillColor.color);
108 }
109 }
96 } 110 }
97 }, 111 },
98 112
@@ -203,7 +217,7 @@ exports.Circle = Object.create(GeomObj, {
203 }, 217 },
204 218
205 /////////////////////////////////////////////////////////////////////// 219 ///////////////////////////////////////////////////////////////////////
206 // update the "color of the material 220 // update the "color of the material
207 getFillColor: { 221 getFillColor: {
208 value: function() { 222 value: function() {
209 return this._fillColor; 223 return this._fillColor;
@@ -251,15 +265,15 @@ exports.Circle = Object.create(GeomObj, {
251 265
252 // get the normalized device coordinates (NDC) for 266 // get the normalized device coordinates (NDC) for
253 // all position and dimensions. 267 // all position and dimensions.
254 var vpw = world.getViewportWidth(), vph = world.getViewportHeight(); 268 var vpw = world.getViewportWidth(), vph = world.getViewportHeight();
255 var xNDC = 2*this._xOffset/vpw, yNDC = -2*this._yOffset/vph, 269 var xNDC = 2*this._xOffset/vpw, yNDC = -2*this._yOffset/vph,
256 xRadNDC = this._width/vpw, yRadNDC = this._height/vph, 270 xRadNDC = this._width/vpw, yRadNDC = this._height/vph,
257 xStrokeNDC = 2*this._strokeWidth/vpw, yStrokeNDC = 2*this._strokeWidth/vph, 271 xStrokeNDC = 2*this._strokeWidth/vpw, yStrokeNDC = 2*this._strokeWidth/vph,
258 xInnRadNDC = this._innerRadius*xRadNDC, yInnRadNDC = this._innerRadius*yRadNDC; 272 xInnRadNDC = this._innerRadius*xRadNDC, yInnRadNDC = this._innerRadius*yRadNDC;
259 273
260 var aspect = world.getAspect(); 274 var aspect = world.getAspect();
261 var zn = world.getZNear(), zf = world.getZFar(); 275 var zn = world.getZNear(), zf = world.getZFar();
262 var t = zn * Math.tan(world.getFOV() * Math.PI / 360.0), 276 var t = zn * Math.tan(world.getFOV() * Math.PI / 360.0),
263 b = -t, 277 b = -t,
264 r = aspect*t, 278 r = aspect*t,
265 l = -r; 279 l = -r;
@@ -308,7 +322,8 @@ exports.Circle = Object.create(GeomObj, {
308 innerStrokeScaleMat[0] = xInnRad - xStroke; 322 innerStrokeScaleMat[0] = xInnRad - xStroke;
309 innerStrokeScaleMat[5] = yInnRad - yStroke; 323 innerStrokeScaleMat[5] = yInnRad - yStroke;
310 324
311 var fillPrim, strokePrim0, strokePrim1; 325 var i;
326 var fillPrimArray, strokePrim0Array, strokePrim1Array;
312 var fillMaterial, strokeMaterial0, strokeMaterial2; 327 var fillMaterial, strokeMaterial0, strokeMaterial2;
313 328
314 this._primArray = []; 329 this._primArray = [];
@@ -321,43 +336,49 @@ exports.Circle = Object.create(GeomObj, {
321 if(this._strokeWidth > 0) { 336 if(this._strokeWidth > 0) {
322 var numStrokes = 1; 337 var numStrokes = 1;
323 if(this._innerRadius !== 0) { 338 if(this._innerRadius !== 0) {
324 strokeMaterial0 = this.makeStrokeMaterial(); 339 strokeMaterial0 = this.makeStrokeMaterial();
325 strokePrim0 = this.generateOvalRing(x, y, reverseRotMat, innerStrokeScaleMat, innerRadiusScaleMat, nTriangles, strokeMaterial0); 340 strokePrim0Array = this.generateOvalRing(x, y, reverseRotMat, innerStrokeScaleMat, innerRadiusScaleMat, nTriangles, strokeMaterial0);
326 } 341 }
327 342
328 strokeMaterial2 = this.makeStrokeMaterial(); 343 strokeMaterial2 = this.makeStrokeMaterial();
329 strokePrim1 = this.generateOvalRing(x, y, reverseRotMat, fillScaleMat, strokeScaleMat, nTriangles, strokeMaterial2); 344 strokePrim1Array = this.generateOvalRing(x, y, reverseRotMat, fillScaleMat, strokeScaleMat, nTriangles, strokeMaterial2);
330 } 345 }
331 346
332 if (strokePrim0) { 347 if (strokePrim0Array) {
333 strokeMaterial0.fitToPrimitive( strokePrim0 );