diff options
author | Valerio Virgillito | 2012-02-28 13:19:52 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-28 13:19:52 -0800 |
commit | 2ab07cb8ac76a06606ce455bb2e6b4889e3ddc65 (patch) | |
tree | aed095ad5f21f7cec5dbb779afda5c05ff5cb7c5 /js/helper-classes/RDGE/GLLine.js | |
parent | e5b1102f0cff7f5ba7074840ccf29dc1c02ced8e (diff) | |
parent | 347fc28227d822e9fea3fa823fae79cf14ea041c (diff) | |
download | ninja-2ab07cb8ac76a06606ce455bb2e6b4889e3ddc65.tar.gz |
Merge branch 'integration' of https://github.com/ericmueller/ninja-internal into integration-candidate
Diffstat (limited to 'js/helper-classes/RDGE/GLLine.js')
-rwxr-xr-x | js/helper-classes/RDGE/GLLine.js | 67 |
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 | /////////////////////////////////////////////////////////////////////// |
12 | function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, strokeColor, strokeMaterial, strokeStyle, xAdj, yAdj) | 12 | function 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 | ||