mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Optimize Shape constructors by passing along point.
This commit is contained in:
parent
e8695dee9b
commit
acd3236989
1 changed files with 12 additions and 7 deletions
|
@ -20,8 +20,8 @@
|
|||
var Shape = this.Shape = Item.extend(/** @lends Shape# */{
|
||||
_class: 'Shape',
|
||||
|
||||
initialize: function(type, size) {
|
||||
this.base();
|
||||
initialize: function(type, point, size) {
|
||||
this.base(point);
|
||||
this._type = type;
|
||||
this._size = size;
|
||||
},
|
||||
|
@ -70,23 +70,28 @@ var Shape = this.Shape = Item.extend(/** @lends Shape# */{
|
|||
return matrix ? matrix._transformBounds(rect) : rect;
|
||||
},
|
||||
|
||||
_hitTest: function(point, options) {
|
||||
// TODO: Implement!
|
||||
if (point.isInside(this._getBounds())) {
|
||||
}
|
||||
},
|
||||
|
||||
statics: {
|
||||
Circle: function(/* center, radius */) {
|
||||
var center = Point.readNamed(arguments, 'center'),
|
||||
radius = Base.readNamed(arguments, 'radius');
|
||||
return new Shape('circle', new Size(radius)).translate(center);
|
||||
return new Shape('circle', center, new Size(radius));
|
||||
},
|
||||
|
||||
Rectangle: function(/* rectangle */) {
|
||||
var rect = Rectangle.readNamed(arguments, 'rectangle');
|
||||
return new Shape('rect', rect.getSize(true)).translate(
|
||||
rect.getCenter(true));
|
||||
return new Shape('rect', rect.getCenter(true), rect.getSize(true));
|
||||
},
|
||||
|
||||
Ellipse: function(/* rectangle */) {
|
||||
var rect = Rectangle.readNamed(arguments, 'rectangle');
|
||||
return new Shape('ellipse', rect.getSize(true)).translate(
|
||||
rect.getCenter(true));
|
||||
return new Shape('ellipse', rect.getCenter(true),
|
||||
rect.getSize(true));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue