mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 06:00:56 -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 {Rectangle} rect
|
||||||
* @param {Size} size the size of the rounded corners
|
* @param {Size} size the size of the rounded corners
|
||||||
|
@ -125,14 +125,16 @@ Path.inject({ statics: new function() {
|
||||||
*/
|
*/
|
||||||
RoundRectangle: function(rect, size) {
|
RoundRectangle: function(rect, size) {
|
||||||
var _rect = Rectangle.read(arguments),
|
var _rect = Rectangle.read(arguments),
|
||||||
_size = Size.min(Size.read(arguments),
|
_size = Size.read(arguments);
|
||||||
_rect.getSize(true).divide(2)),
|
if (_size.isZero())
|
||||||
path = new Path(),
|
return Path.Rectangle(rect);
|
||||||
uSize = _size.multiply(kappa * 2),
|
_size = Size.min(_size, _rect.getSize(true).divide(2));
|
||||||
bl = _rect.getBottomLeft(true),
|
var bl = _rect.getBottomLeft(true),
|
||||||
tl = _rect.getTopLeft(true),
|
tl = _rect.getTopLeft(true),
|
||||||
tr = _rect.getTopRight(true),
|
tr = _rect.getTopRight(true),
|
||||||
br = _rect.getBottomRight(true);
|
br = _rect.getBottomRight(true),
|
||||||
|
uSize = _size.multiply(kappa * 2),
|
||||||
|
path = new Path();
|
||||||
path._add([
|
path._add([
|
||||||
new Segment(bl.add(_size.width, 0), null, [-uSize.width, 0]),
|
new Segment(bl.add(_size.width, 0), null, [-uSize.width, 0]),
|
||||||
new Segment(bl.subtract(0, _size.height), [0, uSize.height], null),
|
new Segment(bl.subtract(0, _size.height), [0, uSize.height], null),
|
||||||
|
|
Loading…
Reference in a new issue