mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 06:00:56 -05:00
Merge branch 'master' of github.com:paperjs/paper.js
This commit is contained in:
commit
e9985a04a8
5 changed files with 53 additions and 8240 deletions
|
@ -19,4 +19,8 @@
|
|||
|
||||
echo "// Paper.js loader for development, as produced by the build/load.sh script
|
||||
document.write('<script type=\"text/javascript\" src=\"../../lib/prepro.js\"></script>');
|
||||
document.write('<script type=\"text/javascript\" src=\"../../src/load.js\"></script>');" > ../dist/paper.js;
|
||||
document.write('<script type=\"text/javascript\" src=\"../../src/load.js\"></script>');
|
||||
|
||||
// For more information on building the library please refer to the
|
||||
// 'Building the Library' section of README.md:
|
||||
// https://github.com/paperjs/paper.js#building-the-library" > ../dist/paper.js;
|
8242
dist/paper.js
vendored
8242
dist/paper.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "paper",
|
||||
"description": "Vector graphics scripting framework",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.2",
|
||||
"contributors": [{
|
||||
"name" : "Jürg Lehni",
|
||||
"url" : "http://lehni.org"
|
||||
|
|
|
@ -1143,8 +1143,7 @@ function(name) {
|
|||
* @param {item[]} items The items to be added as children
|
||||
*/
|
||||
addChildren: function(items) {
|
||||
for (var i = 0, l = items && items.length; i < l; i++)
|
||||
this.insertChild(undefined, items[i]);
|
||||
this.insertChildren(this._children.length, items);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1156,6 +1155,10 @@ function(name) {
|
|||
* @param {Item[]} items The items to be appended as children
|
||||
*/
|
||||
insertChildren: function(index, items) {
|
||||
// We need to clone items because it might be
|
||||
// an Item#children array. Use Array.prototype.slice because
|
||||
// in certain cases items is an arguments object
|
||||
items = items && Array.prototype.slice.apply(items);
|
||||
for (var i = 0, l = items && items.length; i < l; i++) {
|
||||
if (this.insertChild(index, items[i]))
|
||||
index++;
|
||||
|
|
|
@ -52,4 +52,40 @@ test('Group bounds', function() {
|
|||
group.rotate(20, new Point(50, 50));
|
||||
compareRectangles(group.bounds, { x: 39.70692, y: 114.99196, width: 170.00412, height: 180.22401 }, 'rotated group.bounds');
|
||||
compareRectangles(group.strokeBounds, { x: 37.20692, y: 112.49196, width: 175.00412, height: 185.22401 }, 'rotated group.strokeBounds');
|
||||
});
|
||||
|
||||
test('group.addChildren(otherGroup.children)', function() {
|
||||
var group = new Group();
|
||||
group.addChild(new Path());
|
||||
group.addChild(new Path());
|
||||
equals(function() {
|
||||
return group.children.length;
|
||||
}, 2);
|
||||
|
||||
var secondGroup = new Group();
|
||||
secondGroup.addChildren(group.children);
|
||||
equals(function() {
|
||||
return secondGroup.children.length;
|
||||
}, 2);
|
||||
equals(function() {
|
||||
return group.children.length;
|
||||
}, 0);
|
||||
});
|
||||
|
||||
test('group.insertChildren(0, otherGroup.children)', function() {
|
||||
var group = new Group();
|
||||
group.addChild(new Path());
|
||||
group.addChild(new Path());
|
||||
equals(function() {
|
||||
return group.children.length;
|
||||
}, 2);
|
||||
|
||||
var secondGroup = new Group();
|
||||
secondGroup.insertChildren(0, group.children);
|
||||
equals(function() {
|
||||
return secondGroup.children.length;
|
||||
}, 2);
|
||||
equals(function() {
|
||||
return group.children.length;
|
||||
}, 0);
|
||||
});
|
Loading…
Reference in a new issue