Use group creation without explicit array declaration, as that's been supported all along.

This commit is contained in:
Jürg Lehni 2012-11-06 20:37:50 -08:00
parent b1c24e2762
commit e9a9066d7f
6 changed files with 10 additions and 13 deletions

View file

@ -41,7 +41,7 @@
overlayColor.alpha = 0.5; overlayColor.alpha = 0.5;
var overlayGradient = new Gradient([new RgbColor(1, 1, 1, 0.5), new RgbColor(1, 1, 1, 1)]); var overlayGradient = new Gradient([new RgbColor(1, 1, 1, 0.5), new RgbColor(1, 1, 1, 1)]);
overlay.fillColor = new GradientColor(overlayGradient, overlayPos, overlayPos + this.radius / 2); overlay.fillColor = new GradientColor(overlayGradient, overlayPos, overlayPos + this.radius / 2);
this.item = new Group([compound, overlay]); this.item = new Group(compound, overlay);
}, },
iterate: function() { iterate: function() {

View file

@ -49,14 +49,14 @@
items = []; items = [];
var arrowVector = vector.normalize(10); var arrowVector = vector.normalize(10);
var end = vectorStart + vector; var end = vectorStart + vector;
vectorItem = new Group([ vectorItem = new Group(
new Path([vectorStart, end]), new Path(vectorStart, end),
new Path([ new Path(
end + arrowVector.rotate(135), end + arrowVector.rotate(135),
end, end,
end + arrowVector.rotate(-135) end + arrowVector.rotate(-135)
]) )
]); );
vectorItem.strokeWidth = 0.75; vectorItem.strokeWidth = 0.75;
vectorItem.strokeColor = '#e4141b'; vectorItem.strokeColor = '#e4141b';
// Display: // Display:

View file

@ -73,8 +73,7 @@ var Group = this.Group = Item.extend(/** @lends Group# */{
// Allow Group to have children and named children // Allow Group to have children and named children
this._children = []; this._children = [];
this._namedChildren = {}; this._namedChildren = {};
this.addChildren(!items || !Array.isArray(items) this.addChildren(Array.isArray(items) ? items : arguments);
|| items.length && typeof items[0] !== 'object' ? arguments : items);
}, },
_changed: function(flags) { _changed: function(flags) {

View file

@ -1157,7 +1157,7 @@ function(name) {
* its children list. You can use this function for groups, compound * its children list. You can use this function for groups, compound
* paths and layers. * paths and layers.
* *
* @param {item[]} items The items to be added as children * @param {Item[]} items The items to be added as children
*/ */
addChildren: function(items) { addChildren: function(items) {
this.insertChildren(this._children.length, items); this.insertChildren(this._children.length, items);

View file

@ -48,9 +48,7 @@ var CompoundPath = this.CompoundPath = PathItem.extend(/** @lends CompoundPath#
this._namedChildren = {}; this._namedChildren = {};
// Do not reassign to paths, since arguments would get modified, which // Do not reassign to paths, since arguments would get modified, which
// we potentially use as array, depending on what is passed. // we potentially use as array, depending on what is passed.
var items = !paths || !Array.isArray(paths) this.addChildren(Array.isArray(paths) ? paths : arguments);
|| typeof paths[0] !== 'object' ? arguments : paths;
this.addChildren(items);
}, },
insertChild: function(index, item) { insertChild: function(index, item) {

View file

@ -310,7 +310,7 @@ new function() {
// http://www.w3.org/TR/SVG/masking.html#ClipPathProperty // http://www.w3.org/TR/SVG/masking.html#ClipPathProperty
case 'clip-path': case 'clip-path':
var clipPath = getDefinition(value).clone().flatten(), var clipPath = getDefinition(value).clone().flatten(),
group = new Group([clipPath]); group = new Group(clipPath);
group.moveAbove(item); group.moveAbove(item);
group.addChild(item); group.addChild(item);
group.setClipped(true); group.setClipped(true);