aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE/GLLine.js
diff options
context:
space:
mode:
authorPushkar Joshi2012-03-02 12:36:34 -0800
committerPushkar Joshi2012-03-02 12:36:34 -0800
commitdc3c813320c8d3fb837d5d18e70ab35a53b116c1 (patch)
treeda417684de5e302d302ea617854015bd9a8ca17a /js/helper-classes/RDGE/GLLine.js
parentd7d78d4a4e8cf82c56379d25efbe679b3b823abc (diff)
parent4419209a1fd850ab468209b562b66b0242b42a9c (diff)
downloadninja-dc3c813320c8d3fb837d5d18e70ab35a53b116c1.tar.gz
Merge branch 'brushtool' into pentool
Diffstat (limited to 'js/helper-classes/RDGE/GLLine.js')
-rwxr-xr-xjs/helper-classes/RDGE/GLLine.js67
1 files changed, 33 insertions, 34 deletions
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js
index f715a43c..65e6ab1c 100755
--- a/js/helper-classes/RDGE/GLLine.js
+++ b/js/helper-classes/RDGE/GLLine.js
@@ -11,6 +11,10 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
11/////////////////////////////////////////////////////////////////////// 11///////////////////////////////////////////////////////////////////////
12function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj) 12function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj)
13{ 13{
14 // initialize the inherited members
15 this.inheritedFrom = GLGeomObj;
16 this.inheritedFrom();
17
14 /////////////////////////////////////////////////////////////////////// 18 ///////////////////////////////////////////////////////////////////////
15 // Instance variables 19 // Instance variables
16 /////////////////////////////////////////////////////////////////////// 20 ///////////////////////////////////////////////////////////////////////
@@ -43,7 +47,7 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
43 47
44 this._slope = slope; 48 this._slope = slope;
45 this._strokeWidth = strokeSize; 49 this._strokeWidth = strokeSize;
46 this._strokeColor = strokeColor; 50 if (strokeColor) this._strokeColor = strokeColor.slice();
47 51
48 this._strokeStyle = strokeStyle; 52 this._strokeStyle = strokeStyle;
49 this._scaleX = (world.getViewportWidth())/(world.getViewportHeight()); 53 this._scaleX = (world.getViewportWidth())/(world.getViewportHeight());
@@ -57,10 +61,6 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
57 this._materialDiffuse = [0.4, 0.4, 0.4, 1.0]; 61 this._materialDiffuse = [0.4, 0.4, 0.4, 1.0];
58 this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; 62 this._materialSpecular = [0.4, 0.4, 0.4, 1.0];
59 63
60 // initialize the inherited members
61 this.inheritedFrom = GLGeomObj;
62 this.inheritedFrom();
63
64 if(strokeMaterial) 64 if(strokeMaterial)
65 { 65 {
66 this._strokeMaterial = strokeMaterial; 66 this._strokeMaterial = strokeMaterial;
@@ -364,41 +364,40 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro
364 var lineWidth = this._strokeWidth; 364 var lineWidth = this._strokeWidth;
365 ctx.beginPath(); 365 ctx.beginPath();
366 ctx.lineWidth = lineWidth; 366 ctx.lineWidth = lineWidth;
367 ctx.strokeStyle = "#0000ff";
368 if (this._strokeColor) 367 if (this._strokeColor)
369 { 368 {
370 var c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")"; 369 var c = "rgba(" + 255*this._strokeColor[0] + "," + 255*this._strokeColor[1] + "," + 255*this._strokeColor[2] + "," + this._strokeColor[3] + ")";
371 ctx.strokeStyle = c; 370 ctx.strokeStyle = c;
372 }
373 371
374 // get the points 372 // get the points
375 var p0, p1; 373 var p0, p1;
376 var w = this._width, h = this._height; 374 var w = this._width, h = this._height;
377 if(this._slope === "vertical") 375 if(this._slope === "vertical")
378 { 376 {
379 p0 = [0.5*w, 0]; 377 p0 = [0.5*w, 0];
380 p1 = [0.5*w, h]; 378 p1 = [0.5*w, h];
381 } 379 }
382 else if(this._slope === "horizontal") 380 else if(this._slope === "horizontal")
383 { 381 {
384 p0 = [0, 0.5*h]; 382 p0 = [0, 0.5*h];
385 p1 = [w, 0.5*h]; 383 p1 = [w, 0.5*h];
386 } 384 }
387 else if(this._slope > 0) 385 else if(this._slope > 0)
388 { 386 {
389 p0 = [this._xAdj, this._yAdj]; 387 p0 = [this._xAdj, this._yAdj];
390 p1 = [w - this._xAdj, h - this._yAdj]; 388 p1 = [w - this._xAdj, h - this._yAdj];
391 } 389 }
392 else 390 else
393 { 391 {
394 p0 = [this._xAdj, h - this._yAdj]; 392 p0 = [this._xAdj, h - this._yAdj];
395 p1 = [w - this._xAdj, this._yAdj]; 393 p1 = [w - this._xAdj, this._yAdj];
396 } 394 }
397 395
398 // draw the line 396 // draw the line
399 ctx.moveTo( p0[0], p0[1] ); 397 ctx.moveTo( p0[0], p0[1] );
400 ctx.lineTo( p1[0], p1[1] ); 398 ctx.lineTo( p1[0], p1[1] );
401 ctx.stroke(); 399 ctx.stroke();
400 }
402 } 401 }
403 402
404 403