mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Do not create extra points when asked to produce a round rectangle with no radius.
This commit is contained in:
parent
089b9f9387
commit
ab02023adf
1 changed files with 9 additions and 7 deletions
|
@ -110,7 +110,7 @@ Path.inject({ statics: new function() {
|
|||
},
|
||||
|
||||
/**
|
||||
* Creates a rectangular Path Item with rounded corners.
|
||||
* Creates a rectangular Path Item with rounded corners.
|
||||
*
|
||||
* @param {Rectangle} rect
|
||||
* @param {Size} size the size of the rounded corners
|
||||
|
@ -125,14 +125,16 @@ Path.inject({ statics: new function() {
|
|||
*/
|
||||
RoundRectangle: function(rect, size) {
|
||||
var _rect = Rectangle.read(arguments),
|
||||
_size = Size.min(Size.read(arguments),
|
||||
_rect.getSize(true).divide(2)),
|
||||
path = new Path(),
|
||||
uSize = _size.multiply(kappa * 2),
|
||||
bl = _rect.getBottomLeft(true),
|
||||
_size = Size.read(arguments);
|
||||
if (_size.isZero())
|
||||
return Path.Rectangle(rect);
|
||||
_size = Size.min(_size, _rect.getSize(true).divide(2));
|
||||
var bl = _rect.getBottomLeft(true),
|
||||
tl = _rect.getTopLeft(true),
|
||||
tr = _rect.getTopRight(true),
|
||||
br = _rect.getBottomRight(true);
|
||||
br = _rect.getBottomRight(true),
|
||||
uSize = _size.multiply(kappa * 2),
|
||||
path = new Path();
|
||||
path._add([
|
||||
new Segment(bl.add(_size.width, 0), null, [-uSize.width, 0]),
|
||||
new Segment(bl.subtract(0, _size.height), [0, uSize.height], null),
|
||||
|
|
Loading…
Reference in a new issue