diff options
author | hwc487 | 2012-04-27 13:53:14 -0700 |
---|---|---|
committer | hwc487 | 2012-04-27 13:53:14 -0700 |
commit | b460ea23025d9d5067dc78e2ae97c71d0dce2d13 (patch) | |
tree | 67c3b549d83c490364ed4a4c0dc6304106595b69 /js/lib/geom/rectangle.js | |
parent | e73fba18b095f0c270f5d954e5993c155b488c73 (diff) | |
parent | 917668dbd753d69b346cb9fd2e665fbe257f5311 (diff) | |
download | ninja-b460ea23025d9d5067dc78e2ae97c71d0dce2d13.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Canvas-interaction
Diffstat (limited to 'js/lib/geom/rectangle.js')
-rwxr-xr-x | js/lib/geom/rectangle.js | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index 41c51e2f..490a9a6f 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js | |||
@@ -361,7 +361,9 @@ var Rectangle = function GLRectangle() { | |||
361 | // various declarations | 361 | // various declarations |
362 | var pt, rad, ctr, startPt, bPts; | 362 | var pt, rad, ctr, startPt, bPts; |
363 | var width = Math.round(this.getWidth()), | 363 | var width = Math.round(this.getWidth()), |
364 | height = Math.round(this.getHeight()); | 364 | height = Math.round(this.getHeight()), |
365 | hw = 0.5*width, | ||
366 | hh = 0.5*height; | ||
365 | 367 | ||
366 | pt = [inset, inset]; // top left corner | 368 | pt = [inset, inset]; // top left corner |
367 | 369 | ||
@@ -369,6 +371,12 @@ var Rectangle = function GLRectangle() { | |||
369 | var trRad = this._trRadius; | 371 | var trRad = this._trRadius; |
370 | var blRad = this._blRadius; | 372 | var blRad = this._blRadius; |
371 | var brRad = this._brRadius; | 373 | var brRad = this._brRadius; |
374 | // limit the radii to half the rectangle dimension | ||
375 | var minDimen = hw < hh ? hw : hh; | ||
376 | if (tlRad > minDimen) tlRad = minDimen; | ||
377 | if (blRad > minDimen) blRad = minDimen; | ||
378 | if (brRad > minDimen) brRad = minDimen; | ||
379 | if (trRad > minDimen) trRad = minDimen; | ||
372 | 380 | ||
373 | var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; | 381 | var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; |
374 | var world = this.getWorld(); | 382 | var world = this.getWorld(); |
@@ -467,13 +475,13 @@ var Rectangle = function GLRectangle() { | |||
467 | // render the fill | 475 | // render the fill |
468 | ctx.beginPath(); | 476 | ctx.beginPath(); |
469 | if (this._fillColor) { | 477 | if (this._fillColor) { |
470 | inset = Math.ceil( lw ) + 0.5; | 478 | inset = Math.ceil( lw ) - 0.5; |
471 | 479 | ||
472 | if(this._fillColor.gradientMode) { | 480 | if(this._fillColor.gradientMode) { |
473 | if(this._fillColor.gradientMode === "radial") { | 481 | if(this._fillColor.gradientMode === "radial") { |
474 | gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(w/2, h/2)-inset); | 482 | gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(w, h)/2); |
475 | } else { | 483 | } else { |
476 | gradient = ctx.createLinearGradient(inset, h/2, w-2*inset, h/2); | 484 | gradient = ctx.createLinearGradient(inset/2, h/2, w-inset, h/2); |
477 | } | 485 | } |
478 | colors = this._fillColor.color; | 486 | colors = this._fillColor.color; |
479 | 487 | ||
@@ -501,11 +509,11 @@ var Rectangle = function GLRectangle() { | |||
501 | // render the stroke | 509 | // render the stroke |
502 | ctx.beginPath(); | 510 | ctx.beginPath(); |
503 | if (this._strokeColor) { | 511 | if (this._strokeColor) { |
504 | inset = Math.ceil( 0.5*lw ) + 0.5; | 512 | inset = Math.ceil( 0.5*lw ) - 0.5; |
505 | 513 | ||
506 | if(this._strokeColor.gradientMode) { | 514 | if(this._strokeColor.gradientMode) { |
507 | if(this._strokeColor.gradientMode === "radial") { | 515 | if(this._strokeColor.gradientMode === "radial") { |
508 | gradient = ctx.createRadialGradient(w/2, h/2, Math.min(h/2, w/2)-inset, w/2, h/2, Math.max(h/2, w/2)); | 516 | gradient = ctx.createRadialGradient(w/2, h/2, Math.min(h, w)/2-inset, w/2, h/2, Math.max(h, w)/2); |
509 | } else { | 517 | } else { |
510 | gradient = ctx.createLinearGradient(0, h/2, w, h/2); | 518 | gradient = ctx.createLinearGradient(0, h/2, w, h/2); |
511 | } | 519 | } |