/***
 *
 * Paper.js
 *
 * A JavaScript Vector Graphics Library, based on Scriptographer.org and
 * designed to be largely API compatible.
 * http://paperjs.org/
 * http://scriptographer.org/
 *
 * Distributed under the MIT license. See LICENSE file for details.
 *
 * Copyright (c) 2011, Juerg Lehni & Jonathan Puckey
 * http://lehni.org/ & http://jonathanpuckey.com/
 *
 * All rights reserved.
 *
 ***
 *
 * Bootstrap.js JavaScript Framework.
 * http://bootstrapjs.org/
 *
 * Distributed under the MIT license.
 *
 * Copyright (c) 2006 - 2011 Juerg Lehni
 * http://lehni.org/
 *
 ***
 *
 * Parse-JS, A JavaScript tokenizer / parser / generator.
 *
 * Distributed under the BSD license.
 *
 * Copyright (c) 2010, Mihai Bazon <mihai.bazon@gmail.com>
 * http://mihai.bazon.net/blog/
 *
 ***/

var paper = new function() {
// Have a pointer to the paper object already during the 'bootstraping' so code
// can rely on it being there all the time.
var paper = this;

this.document = null;
this.documents = [];

this.install = function(scope) {
	for (var i in this) {
		scope[i] = this[i];
	}
};

// Inline Base core inside the paper scope first:
//#include "../lib/bootstrap.js"

Base.inject({
	statics: true,

	read: function(args, start, length) {
		var start = start || 0,
			length = length || args.length - start;
		var arg = args[start];
		// If the class defines _readNull, return null when nothing was provided
		if (arg instanceof this
				|| this.prototype._readNull && arg == null && length <= 1)
			return arg;
		var obj = new this(this.dont);
		obj = obj.initialize.apply(obj, start > 0 || length < args.length
			? Array.prototype.slice.call(args, start, start + length)
			: args) || obj;
		return obj;
	},

	readAll: function(args, start) {
		var res = [];
		for (var i = start || 0, l = args.length; i < l; i++)
			res.push(this.read(args, i, 1));
		return res;
	},

	capitalize: function(str) {
		return str.replace(/\b[a-z]/g, function(match) {
			return match.toUpperCase();
		});
	}
});

//#include "basic/Point.js"
//#include "basic/Size.js"
//#include "basic/Rectangle.js"
//#include "basic/Matrix.js"
//#include "basic/Line.js"

//#include "document/DocumentView.js"
//#include "document/Document.js"
//#include "document/Symbol.js"

//#include "item/Item.js"
//#include "item/Group.js"
//#include "item/Layer.js"
//#include "item/Raster.js"
//#include "item/PlacedSymbol.js"
//#include "item/PathStyle.js"

//#include "path/Segment.js"
//#include "path/SegmentPoint.js"
//#include "path/SelectionState.js"
//#include "path/Curve.js"
//#include "path/CurveLocation.js"
//#include "path/PathItem.js"
//#include "path/Path.js"
//#include "path/CompoundPath.js"
//#include "path/Path.Constructors.js"

//#include "color/Color.js"
//#include "color/RGBColor.js"
//#include "color/GrayColor.js"
//#include "color/GradientColor.js"
//#include "color/Gradient.js"
//#include "color/GradientStop.js"

//#include "tool/ToolEvent.js"
//#include "tool/ToolHandler.js"
//#include "tool/Tool.js"

//#ifdef BROWSER
//#include "browser/Element.js"
//#include "browser/Event.js"
//#endif // BROWSER

//#include "util/BlendMode.js"
//#include "util/CanvasProvider.js"
//#include "util/Numerical.js"
//#include "util/PaperScript.js"

//#ifdef BROWSER
//#include "ui/Key.js"
//#endif // BROWSER
};

@@ -1212,28 +1212,28 @@
 d: function(
-args
+list
 , start, len
@@ -1287,20 +1287,20 @@
 ngth %7C%7C 
-args
+list
 .length 
@@ -1320,20 +1320,20 @@
 r arg = 
-args
+list
 %5Bstart%5D;
@@ -1601,20 +1601,20 @@
 ength %3C 
-args
+list
 .length%0A
@@ -1645,20 +1645,20 @@
 ce.call(
-args
+list
 , start,
@@ -1679,20 +1679,20 @@
 h)%0A%09%09%09: 
-args
+list
 ) %7C%7C obj
@@ -1731,20 +1731,20 @@
 unction(
-args
+list
 , start)
@@ -1760,16 +1760,23 @@
 res = %5B%5D
+, entry
 ;%0A%09%09for 
@@ -1800,20 +1800,20 @@
  0, l = 
-args
+list
 .length;
@@ -1824,16 +1824,18 @@
  l; i++)
+ %7B
 %0A%09%09%09res.
@@ -1843,22 +1843,85 @@
 ush(
-this.read(args
+Array.isArray(entry = list%5Bi%5D)%0A%09%09%09%09? this.read(entry, 0)%0A%09%09%09%09: this.read(list
 , i,
@@ -1926,16 +1926,20 @@
 i, 1));%0A
+%09%09%7D%0A
 %09%09return

Improve Base.readAll() to check entries for arrays and pass them to constructors as arguments rather than their containing array.