mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Fix reading of rectangle in Path.Constructor.
And all tests are green again.
This commit is contained in:
parent
7294c5499c
commit
7b7168feb1
1 changed files with 3 additions and 13 deletions
|
@ -12,18 +12,8 @@
|
|||
|
||||
Path.inject({ statics: new function() {
|
||||
|
||||
function readRectangle(list) {
|
||||
var props = Base.getNamed(list);
|
||||
return props
|
||||
? 'from' in props
|
||||
? new Rectangle(Point.readNamed(list, 'from'),
|
||||
Point.readNamed(list, 'to'))
|
||||
: new Rectangle(props)
|
||||
: Rectangle.read(list);
|
||||
}
|
||||
|
||||
function createRectangle(/* rect */) {
|
||||
var rect = readRectangle(arguments),
|
||||
var rect = Rectangle.readNamed(arguments, 'rectangle'),
|
||||
left = rect.getLeft(),
|
||||
top = rect.getTop(),
|
||||
right = rect.getRight(),
|
||||
|
@ -50,7 +40,7 @@ Path.inject({ statics: new function() {
|
|||
];
|
||||
|
||||
function createEllipse(/* rect */) {
|
||||
var rect = readRectangle(arguments),
|
||||
var rect = Rectangle.readNamed(arguments, 'rectangle'),
|
||||
path = new Path(Base.getNamed(arguments)),
|
||||
point = rect.getPoint(true),
|
||||
size = rect.getSize(true),
|
||||
|
@ -163,7 +153,7 @@ Path.inject({ statics: new function() {
|
|||
* path.strokeColor = 'black';
|
||||
*/
|
||||
RoundRectangle: function(/* rect, radius */) {
|
||||
var rect = readRectangle(arguments),
|
||||
var rect = Rectangle.readNamed(arguments, 'rectangle'),
|
||||
radius = Size.readNamed(arguments, 'radius');
|
||||
if (radius.isZero())
|
||||
return createRectangle(rect);
|
||||
|
|
Loading…
Reference in a new issue