aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/rectangle.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/geom/rectangle.js')
-rwxr-xr-xjs/lib/geom/rectangle.js20
1 files changed, 14 insertions, 6 deletions
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js
index 304b9c19..51db0dd0 100755
--- a/js/lib/geom/rectangle.js
+++ b/js/lib/geom/rectangle.js
@@ -360,7 +360,9 @@ var Rectangle = function GLRectangle()
360 // various declarations 360 // various declarations
361 var pt, rad, ctr, startPt, bPts; 361 var pt, rad, ctr, startPt, bPts;
362 var width = Math.round(this.getWidth()), 362 var width = Math.round(this.getWidth()),
363 height = Math.round(this.getHeight()); 363 height = Math.round(this.getHeight()),
364 hw = 0.5*width,
365 hh = 0.5*height;
364 366
365 pt = [inset, inset]; // top left corner 367 pt = [inset, inset]; // top left corner
366 368
@@ -368,6 +370,12 @@ var Rectangle = function GLRectangle()
368 var trRad = this._trRadius; 370 var trRad = this._trRadius;
369 var blRad = this._blRadius; 371 var blRad = this._blRadius;
370 var brRad = this._brRadius; 372 var brRad = this._brRadius;
373 // limit the radii to half the rectangle dimension
374 var minDimen = hw < hh ? hw : hh;
375 if (tlRad > minDimen) tlRad = minDimen;
376 if (blRad > minDimen) blRad = minDimen;
377 if (brRad > minDimen) brRad = minDimen;
378 if (trRad > minDimen) trRad = minDimen;
371 379
372 if ((tlRad <= 0) && (blRad <= 0) && (brRad <= 0) && (trRad <= 0)) { 380 if ((tlRad <= 0) && (blRad <= 0) && (brRad <= 0) && (trRad <= 0)) {
373 ctx.rect(pt[0], pt[1], width - 2*inset, height - 2*inset); 381 ctx.rect(pt[0], pt[1], width - 2*inset, height - 2*inset);
@@ -456,13 +464,13 @@ var Rectangle = function GLRectangle()
456 // render the fill 464 // render the fill
457 ctx.beginPath(); 465 ctx.beginPath();
458 if (this._fillColor) { 466 if (this._fillColor) {
459 inset = Math.ceil( lw ) + 0.5; 467 inset = Math.ceil( lw ) - 0.5;
460 468
461 if(this._fillColor.gradientMode) { 469 if(this._fillColor.gradientMode) {
462 if(this._fillColor.gradientMode === "radial") { 470 if(this._fillColor.gradientMode === "radial") {
463 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(w/2, h/2)-inset); 471 gradient = ctx.createRadialGradient(w/2, h/2, 0, w/2, h/2, Math.max(w, h)/2);
464 } else { 472 } else {
465 gradient = ctx.createLinearGradient(inset, h/2, w-2*inset, h/2); 473 gradient = ctx.createLinearGradient(inset/2, h/2, w-inset, h/2);
466 } 474 }
467 colors = this._fillColor.color; 475 colors = this._fillColor.color;
468 476
@@ -490,11 +498,11 @@ var Rectangle = function GLRectangle()
490 // render the stroke 498 // render the stroke
491 ctx.beginPath(); 499 ctx.beginPath();
492 if (this._strokeColor) { 500 if (this._strokeColor) {
493 inset = Math.ceil( 0.5*lw ) + 0.5; 501 inset = Math.ceil( 0.5*lw ) - 0.5;
494 502
495 if(this._strokeColor.gradientMode) { 503 if(this._strokeColor.gradientMode) {
496 if(this._strokeColor.gradientMode === "radial") { 504 if(this._strokeColor.gradientMode === "radial") {
497 gradient = ctx.createRadialGradient(w/2, h/2, Math.min(h/2, w/2)-inset, w/2, h/2, Math.max(h/2, w/2)); 505 gradient = ctx.createRadialGradient(w/2, h/2, Math.min(h, w)/2-inset, w/2, h/2, Math.max(h, w)/2);
498 } else { 506 } else {
499 gradient = ctx.createLinearGradient(0, h/2, w, h/2); 507 gradient = ctx.createLinearGradient(0, h/2, w, h/2);
500 } 508 }