Bump version to v0.9.20

This commit is contained in:
Jürg Lehni 2014-08-25 14:48:05 +02:00
parent 99b06b061c
commit 73751040b7
9 changed files with 415 additions and 400 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "paper", "name": "paper",
"version": "0.9.19", "version": "0.9.20",
"description": "The Swiss Army Knife of Vector Graphics Scripting", "description": "The Swiss Army Knife of Vector Graphics Scripting",
"license": "MIT", "license": "MIT",
"homepage": "http://paperjs.org", "homepage": "http://paperjs.org",

View file

@ -1,6 +1,6 @@
{ {
"name": "paper", "name": "paper",
"version": "0.9.19", "version": "0.9.20",
"description": "The Swiss Army Knife of Vector Graphics Scripting", "description": "The Swiss Army Knife of Vector Graphics Scripting",
"license": "MIT", "license": "MIT",
"repo": "paperjs/paper.js", "repo": "paperjs/paper.js",

227
dist/paper-core.js vendored
View file

@ -1,5 +1,5 @@
/*! /*!
* Paper.js v0.9.19 - The Swiss Army Knife of Vector Graphics Scripting. * Paper.js v0.9.20 - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/ * http://paperjs.org/
* *
* Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey
@ -9,7 +9,7 @@
* *
* All rights reserved. * All rights reserved.
* *
* Date: Sat Aug 16 18:31:16 2014 +0200 * Date: Mon Aug 25 14:21:13 2014 +0200
* *
*** ***
* *
@ -283,7 +283,7 @@ Base.inject({
statics: { statics: {
exports: { exports: {
enumerable: true enumerable: true
}, },
extend: function extend() { extend: function extend() {
@ -581,7 +581,7 @@ var Callback = {
if (entry) { if (entry) {
var handlers = this._handlers = this._handlers || {}; var handlers = this._handlers = this._handlers || {};
handlers = handlers[type] = handlers[type] || []; handlers = handlers[type] = handlers[type] || [];
if (handlers.indexOf(func) == -1) { if (handlers.indexOf(func) == -1) {
handlers.push(func); handlers.push(func);
if (entry.install && handlers.length == 1) if (entry.install && handlers.length == 1)
entry.install.call(this, type); entry.install.call(this, type);
@ -716,7 +716,7 @@ var PaperScope = Base.extend({
} }
}, },
version: '0.9.19', version: '0.9.20',
getView: function() { getView: function() {
return this.project && this.project.getView(); return this.project && this.project.getView();
@ -932,7 +932,7 @@ var Numerical = new function() {
B = A + a, B = A + a,
i = 0, i = 0,
m = (n + 1) >> 1, m = (n + 1) >> 1,
sum = n & 1 ? w[i++] * f(B) : 0; sum = n & 1 ? w[i++] * f(B) : 0;
while (i < m) { while (i < m) {
var Ax = A * x[i]; var Ax = A * x[i];
sum += w[i++] * (f(B + Ax) + f(B - Ax)); sum += w[i++] * (f(B + Ax) + f(B - Ax));
@ -964,7 +964,7 @@ var Numerical = new function() {
if (abs(a) < EPSILON) { if (abs(a) < EPSILON) {
if (abs(b) >= EPSILON) if (abs(b) >= EPSILON)
return add(-c / b); return add(-c / b);
return abs(c) < EPSILON ? -1 : 0; return abs(c) < EPSILON ? -1 : 0;
} }
var p = b / (2 * a); var p = b / (2 * a);
var q = c / a; var q = c / a;
@ -993,14 +993,14 @@ var Numerical = new function() {
D = q * q - ppp; D = q * q - ppp;
b /= 3; b /= 3;
if (abs(D) < EPSILON) { if (abs(D) < EPSILON) {
if (abs(q) < EPSILON) if (abs(q) < EPSILON)
return add(-b); return add(-b);
var sqp = sqrt(p), var sqp = sqrt(p),
snq = q > 0 ? 1 : -1; snq = q > 0 ? 1 : -1;
add(-snq * 2 * sqp - b); add(-snq * 2 * sqp - b);
return add(snq * sqp - b); return add(snq * sqp - b);
} }
if (D < 0) { if (D < 0) {
var sqp = sqrt(p), var sqp = sqrt(p),
phi = Math.acos(q / (sqp * sqp * sqp)) / 3, phi = Math.acos(q / (sqp * sqp * sqp)) / 3,
t = -2 * sqp, t = -2 * sqp,
@ -2376,9 +2376,9 @@ var Line = Base.extend({
} }
var v2x = x - px, var v2x = x - px,
v2y = y - py, v2y = y - py,
ccw = v2x * vy - v2y * vx; ccw = v2x * vy - v2y * vx;
if (ccw === 0) { if (ccw === 0) {
ccw = v2x * vx + v2y * vy; ccw = v2x * vx + v2y * vy;
if (ccw > 0) { if (ccw > 0) {
v2x -= vx; v2x -= vx;
v2y -= vy; v2y -= vy;
@ -2395,8 +2395,8 @@ var Line = Base.extend({
vx -= px; vx -= px;
vy -= py; vy -= py;
} }
var m = vy / vx, var m = vy / vx,
b = py - m * px; b = py - m * px;
return (y - (m * x) - b) / Math.sqrt(m * m + 1); return (y - (m * x) - b) / Math.sqrt(m * m + 1);
} }
} }
@ -2545,7 +2545,7 @@ var Project = PaperScopeItem.extend({
offset: new Point(0, 0), offset: new Point(0, 0),
pixelRatio: pixelRatio, pixelRatio: pixelRatio,
viewMatrix: matrix.isIdentity() ? null : matrix, viewMatrix: matrix.isIdentity() ? null : matrix,
matrices: [new Matrix()], matrices: [new Matrix()],
updateMatrix: true updateMatrix: true
}); });
for (var i = 0, layers = this.layers, l = layers.length; i < l; i++) for (var i = 0, layers = this.layers, l = layers.length; i < l; i++)
@ -3920,7 +3920,7 @@ var Item = Base.extend(Callback, {
normalBlend = blendMode === 'normal', normalBlend = blendMode === 'normal',
nativeBlend = BlendMode.nativeModes[blendMode], nativeBlend = BlendMode.nativeModes[blendMode],
direct = normalBlend && opacity === 1 direct = normalBlend && opacity === 1
|| param.dontStart || param.dontStart
|| param.clip || param.clip
|| (nativeBlend || normalBlend && opacity < 1) || (nativeBlend || normalBlend && opacity < 1)
&& this._canComposite(), && this._canComposite(),
@ -4118,7 +4118,7 @@ var Layer = Group.extend({
initialize: function Layer(arg) { initialize: function Layer(arg) {
var props = Base.isPlainObject(arg) var props = Base.isPlainObject(arg)
? new Base(arg) ? new Base(arg)
: { children: Array.isArray(arg) ? arg : arguments }, : { children: Array.isArray(arg) ? arg : arguments },
insert = props.insert; insert = props.insert;
props.insert = false; props.insert = false;
@ -4378,7 +4378,7 @@ var Shape = Item.extend({
return matrix ? matrix._transformBounds(rect) : rect; return matrix ? matrix._transformBounds(rect) : rect;
} }
}, },
new function() { new function() {
function getCornerCenter(that, point, expand) { function getCornerCenter(that, point, expand) {
var radius = that._radius; var radius = that._radius;
@ -4905,8 +4905,7 @@ var HitResult = Base.extend({
center: false, center: false,
bounds: false, bounds: false,
guides: false, guides: false,
selected: false, selected: false
callback: null
}, options); }, options);
} }
} }
@ -4934,7 +4933,7 @@ var Segment = Base.extend({
point = arg0; point = arg0;
handleIn = arg1; handleIn = arg1;
handleOut = arg2; handleOut = arg2;
} else { } else {
point = arg0 !== undefined ? [ arg0, arg1 ] : null; point = arg0 !== undefined ? [ arg0, arg1 ] : null;
handleIn = arg2 !== undefined ? [ arg2, arg3 ] : null; handleIn = arg2 !== undefined ? [ arg2, arg3 ] : null;
handleOut = arg4 !== undefined ? [ arg4, arg5 ] : null; handleOut = arg4 !== undefined ? [ arg4, arg5 ] : null;
@ -5057,7 +5056,7 @@ var Segment = Base.extend({
setSelected: function(selected, _point) { setSelected: function(selected, _point) {
var path = this._path, var path = this._path,
selected = !!selected, selected = !!selected,
state = this._selectionState, state = this._selectionState,
oldState = state, oldState = state,
flag = !_point ? 7 flag = !_point ? 7
@ -5152,7 +5151,7 @@ var Segment = Base.extend({
_transformCoordinates: function(matrix, coords, change) { _transformCoordinates: function(matrix, coords, change) {
var point = this._point, var point = this._point,
handleIn = !change || !this._handleIn.isZero() handleIn = !change || !this._handleIn.isZero()
? this._handleIn : null, ? this._handleIn : null,
handleOut = !change || !this._handleOut.isZero() handleOut = !change || !this._handleOut.isZero()
? this._handleOut : null, ? this._handleOut : null,
@ -5205,7 +5204,7 @@ var SegmentPoint = Point.extend({
var x, y, selected; var x, y, selected;
if (!point) { if (!point) {
x = y = 0; x = y = 0;
} else if ((x = point[0]) !== undefined) { } else if ((x = point[0]) !== undefined) {
y = point[1]; y = point[1];
} else { } else {
var pt = point; var pt = point;
@ -5442,7 +5441,7 @@ var Curve = Base.extend({
: offset && offset.curve === this : offset && offset.curve === this
? offset.parameter ? offset.parameter
: offset === undefined && isParameter === undefined : offset === undefined && isParameter === undefined
? 0.5 ? 0.5
: this.getParameterAt(offset, 0); : this.getParameterAt(offset, 0);
}, },
@ -5474,7 +5473,7 @@ var Curve = Base.extend({
} else { } else {
this._path.insert(this._segment2._index, segment); this._path.insert(this._segment2._index, segment);
} }
res = this; res = this;
} else { } else {
var end = this._segment2; var end = this._segment2;
this._segment2 = segment; this._segment2 = segment;
@ -5601,8 +5600,8 @@ statics: {
p7x = u * p4x + t * p5x, p7y = u * p4y + t * p5y, p7x = u * p4x + t * p5x, p7y = u * p4y + t * p5y,
p8x = u * p6x + t * p7x, p8y = u * p6y + t * p7y; p8x = u * p6x + t * p7x, p8y = u * p6y + t * p7y;
return [ return [
[p1x, p1y, p3x, p3y, p6x, p6y, p8x, p8y], [p1x, p1y, p3x, p3y, p6x, p6y, p8x, p8y],
[p8x, p8y, p7x, p7y, p5x, p5y, p2x, p2y] [p8x, p8y, p7x, p7y, p5x, p5y, p2x, p2y]
]; ];
}, },
@ -5647,9 +5646,9 @@ statics: {
getPart: function(v, from, to) { getPart: function(v, from, to) {
if (from > 0) if (from > 0)
v = Curve.subdivide(v, from)[1]; v = Curve.subdivide(v, from)[1];
if (to < 1) if (to < 1)
v = Curve.subdivide(v, (to - from) / (1 - from))[0]; v = Curve.subdivide(v, (to - from) / (1 - from))[0];
return v; return v;
}, },
@ -5686,8 +5685,8 @@ statics: {
}, },
getBounds: function(v) { getBounds: function(v) {
var min = v.slice(0, 2), var min = v.slice(0, 2),
max = min.slice(), max = min.slice(),
roots = [0, 0]; roots = [0, 0];
for (var i = 0; i < 2; i++) for (var i = 0; i < 2; i++)
Curve._addBounds(v[i], v[i + 2], v[i + 4], v[i + 6], Curve._addBounds(v[i], v[i + 2], v[i + 4], v[i + 6],
@ -5815,7 +5814,7 @@ statics: {
} }
}), }),
new function() { new function() {
function getLengthIntegrand(v) { function getLengthIntegrand(v) {
var p1x = v[0], p1y = v[1], var p1x = v[0], p1y = v[1],
@ -5854,8 +5853,8 @@ new function() {
if (a === 0 && b === 1 if (a === 0 && b === 1
&& isZero(v[0] - v[2]) && isZero(v[1] - v[3]) && isZero(v[0] - v[2]) && isZero(v[1] - v[3])
&& isZero(v[6] - v[4]) && isZero(v[7] - v[5])) { && isZero(v[6] - v[4]) && isZero(v[7] - v[5])) {
var dx = v[6] - v[0], var dx = v[6] - v[0],
dy = v[7] - v[1]; dy = v[7] - v[1];
return Math.sqrt(dx * dx + dy * dy); return Math.sqrt(dx * dx + dy * dy);
} }
var ds = getLengthIntegrand(v); var ds = getLengthIntegrand(v);
@ -5885,11 +5884,11 @@ new function() {
return length - offset; return length - offset;
} }
return Numerical.findRoot(f, ds, return Numerical.findRoot(f, ds,
forward ? a + guess : b - guess, forward ? a + guess : b - guess,
a, b, 16, 0.00001); a, b, 16, 0.00001);
} }
}; };
}, new function() { }, new function() {
function addLocation(locations, include, curve1, t1, point1, curve2, t2, function addLocation(locations, include, curve1, t1, point1, curve2, t2,
point2) { point2) {
var loc = new CurveLocation(curve1, t1, point1, curve2, t2, point2); var loc = new CurveLocation(curve1, t1, point1, curve2, t2, point2);
@ -5967,7 +5966,7 @@ new function() {
curve1, t1, Curve.evaluate(v1, t1, 0), curve1, t1, Curve.evaluate(v1, t1, 0),
curve2, t2, Curve.evaluate(v2, t2, 0)); curve2, t2, Curve.evaluate(v2, t2, 0));
} }
} else { } else {
addCurveIntersections(v2, v1, curve2, curve1, locations, include, addCurveIntersections(v2, v1, curve2, curve1, locations, include,
uMin, uMax, tMinNew, tMaxNew, tDiff, !reverse, ++recursion); uMin, uMax, tMinNew, tMaxNew, tDiff, !reverse, ++recursion);
} }
@ -6019,7 +6018,7 @@ new function() {
} else if (qy <= dMax) { } else if (qy <= dMax) {
px = hullBottom[i][0]; px = hullBottom[i][0];
qx = hullBottom[i + 1][0]; qx = hullBottom[i + 1][0];
tProxy = px + (dMax - py) * (qx - px) / (qy - py); tProxy = px + (dMax - py) * (qx - px) / (qy - py);
} else { } else {
continue; continue;
} }
@ -6499,7 +6498,7 @@ var Path = PathItem.extend({
if (segments && segments.length > 0) { if (segments && segments.length > 0) {
this.setSegments(segments); this.setSegments(segments);
} else { } else {
this._curves = undefined; this._curves = undefined;
this._selectedSegmentState = 0; this._selectedSegmentState = 0;
if (!segments && typeof arg === 'string') { if (!segments && typeof arg === 'string') {
this.setPathData(arg); this.setPathData(arg);
@ -6782,7 +6781,7 @@ var Path = PathItem.extend({
to = Base.pick(to, this._segments.length); to = Base.pick(to, this._segments.length);
var segments = this._segments, var segments = this._segments,
curves = this._curves, curves = this._curves,
count = segments.length, count = segments.length,
removed = segments.splice(from, to - from), removed = segments.splice(from, to - from),
amount = removed.length; amount = removed.length;
if (!amount) if (!amount)
@ -7154,7 +7153,7 @@ var Path = PathItem.extend({
if (parameter === 0 || parameter === 1 && numSegments > 1) { if (parameter === 0 || parameter === 1 && numSegments > 1) {
if (!checkSegmentStroke(loc.getSegment())) if (!checkSegmentStroke(loc.getSegment()))
loc = null; loc = null;
} else if (!isCloseEnough(loc.getPoint(), strokePadding)) { } else if (!isCloseEnough(loc.getPoint(), strokePadding)) {
loc = null; loc = null;
} }
} }
@ -7219,7 +7218,7 @@ var Path = PathItem.extend({
var curves = this.getCurves(), var curves = this.getCurves(),
length = 0; length = 0;
if (isParameter) { if (isParameter) {
var index = ~~offset; var index = ~~offset;
return curves[index].getLocationAt(offset - index, true); return curves[index].getLocationAt(offset - index, true);
} }
for (var i = 0, l = curves.length; i < l; i++) { for (var i = 0, l = curves.length; i < l; i++) {
@ -7268,7 +7267,7 @@ var Path = PathItem.extend({
getNearestPoint: function() { getNearestPoint: function() {
return this.getNearestLocation.apply(this, arguments).getPoint(); return this.getNearestLocation.apply(this, arguments).getPoint();
} }
}, new function() { }, new function() {
function drawHandles(ctx, segments, matrix, size) { function drawHandles(ctx, segments, matrix, size) {
var half = size / 2; var half = size / 2;
@ -7431,12 +7430,12 @@ var Path = PathItem.extend({
drawHandles(ctx, this._segments, matrix, paper.settings.handleSize); drawHandles(ctx, this._segments, matrix, paper.settings.handleSize);
} }
}; };
}, new function() { }, new function() {
function getFirstControlPoints(rhs) { function getFirstControlPoints(rhs) {
var n = rhs.length, var n = rhs.length,
x = [], x = [],
tmp = [], tmp = [],
b = 2; b = 2;
x[0] = rhs[0] / b; x[0] = rhs[0] / b;
for (var i = 1; i < n; i++) { for (var i = 1; i < n; i++) {
@ -7524,7 +7523,7 @@ var Path = PathItem.extend({
} }
} }
}; };
}, new function() { }, new function() {
function getCurrentSegment(that) { function getCurrentSegment(that) {
var segments = that._segments; var segments = that._segments;
if (segments.length === 0) if (segments.length === 0)
@ -7668,7 +7667,7 @@ var Path = PathItem.extend({
} }
} }
var ext = Math.abs(extent), var ext = Math.abs(extent),
count = ext >= 360 ? 4 : Math.ceil(ext / 90), count = ext >= 360 ? 4 : Math.ceil(ext / 90),
inc = extent / count, inc = extent / count,
half = inc * Math.PI / 360, half = inc * Math.PI / 360,
z = 4 / 3 * Math.sin(half) / (1 + Math.cos(half)), z = 4 / 3 * Math.sin(half) / (1 + Math.cos(half)),
@ -7748,7 +7747,7 @@ var Path = PathItem.extend({
this.join(); this.join();
} }
}; };
}, { }, {
_getBounds: function(getter, matrix) { _getBounds: function(getter, matrix) {
return Path[getter](this._segments, this._closed, this.getStyle(), return Path[getter](this._segments, this._closed, this.getStyle(),
@ -7773,18 +7772,18 @@ statics: {
return new Rectangle(); return new Rectangle();
var coords = new Array(6), var coords = new Array(6),
prevCoords = first._transformCoordinates(matrix, new Array(6), false), prevCoords = first._transformCoordinates(matrix, new Array(6), false),
min = prevCoords.slice(0, 2), min = prevCoords.slice(0, 2),
max = min.slice(), max = min.slice(),
roots = new Array(2); roots = new Array(2);
function processSegment(segment) { function processSegment(segment) {
segment._transformCoordinates(matrix, coords, false); segment._transformCoordinates(matrix, coords, false);
for (var i = 0; i < 2; i++) { for (var i = 0; i < 2; i++) {
Curve._addBounds( Curve._addBounds(
prevCoords[i], prevCoords[i],
prevCoords[i + 4], prevCoords[i + 4],
coords[i + 2], coords[i + 2],
coords[i], coords[i],
i, strokePadding ? strokePadding[i] : 0, min, max, roots); i, strokePadding ? strokePadding[i] : 0, min, max, roots);
} }
var tmp = prevCoords; var tmp = prevCoords;
@ -8234,7 +8233,7 @@ var CompoundPath = PathItem.extend({
: matrix.chain(mx)); : matrix.chain(mx));
} }
} }
}, new function() { }, new function() {
function getCurrentPath(that, check) { function getCurrentPath(that, check) {
var children = that._children; var children = that._children;
if (check && children.length === 0) if (check && children.length === 0)
@ -8491,7 +8490,7 @@ PathItem.inject(new function() {
var path = new Path(Item.NO_INSERT), var path = new Path(Item.NO_INSERT),
inter = seg._intersection, inter = seg._intersection,
startInterSeg = inter && inter._segment, startInterSeg = inter && inter._segment,
added = false, added = false,
dir = 1; dir = 1;
do { do {
var handleIn = dir > 0 ? seg._handleIn : seg._handleOut, var handleIn = dir > 0 ? seg._handleIn : seg._handleOut,
@ -8604,12 +8603,12 @@ Path.inject({
curve = { curve = {
values: v, values: v,
winding: y0 === y1 winding: y0 === y1
? 0 ? 0
: y0 > y1 : y0 > y1
? -1 ? -1
: 1, : 1,
previous: prevCurve, previous: prevCurve,
next: null next: null
}; };
if (prevCurve) if (prevCurve)
prevCurve.next = curve; prevCurve.next = curve;
@ -8707,7 +8706,7 @@ Path.inject({
CompoundPath.inject({ CompoundPath.inject({
_getMonoCurves: function() { _getMonoCurves: function() {
var children = this._children, var children = this._children,
monoCurves = []; monoCurves = [];
for (var i = 0, l = children.length; i < l; i++) for (var i = 0, l = children.length; i < l; i++)
monoCurves.push.apply(monoCurves, children[i]._getMonoCurves()); monoCurves.push.apply(monoCurves, children[i]._getMonoCurves());
@ -8720,7 +8719,7 @@ CompoundPath.inject({
}); });
this.addChildren(children); this.addChildren(children);
var clockwise = children[0].isClockwise(); var clockwise = children[0].isClockwise();
for (var i = 1, l = children.length; i < l; i++) { for (var i = 1, l = children.length; i < l; i++) {
var point = children[i].getInteriorPoint(), var point = children[i].getInteriorPoint(),
counters = 0; counters = 0;
for (var j = i - 1; j >= 0; j--) { for (var j = i - 1; j >= 0; j--) {
@ -8735,9 +8734,9 @@ CompoundPath.inject({
var PathFlattener = Base.extend({ var PathFlattener = Base.extend({
initialize: function(path, matrix) { initialize: function(path, matrix) {
this.curves = []; this.curves = [];
this.parts = []; this.parts = [];
this.length = 0; this.length = 0;
this.index = 0; this.index = 0;
var segments = path._segments, var segments = path._segments,
@ -8797,7 +8796,7 @@ var PathFlattener = Base.extend({
prevLen = prev ? prev.offset : 0; prevLen = prev ? prev.offset : 0;
return { return {
value: prevVal + (part.value - prevVal) value: prevVal + (part.value - prevVal)
* (offset - prevLen) / (part.offset - prevLen), * (offset - prevLen) / (part.offset - prevLen),
index: part.index index: part.index
}; };
} }
@ -8924,8 +8923,8 @@ var PathFitter = Base.extend({
var detC0C1 = C[0][0] * C[1][1] - C[1][0] * C[0][1], var detC0C1 = C[0][0] * C[1][1] - C[1][0] * C[0][1],
alpha1, alpha2; alpha1, alpha2;
if (Math.abs(detC0C1) > epsilon) { if (Math.abs(detC0C1) > epsilon) {
var detC0X = C[0][0] * X[1] - C[1][0] * X[0], var detC0X = C[0][0] * X[1] - C[1][0] * X[0],
detXC1 = X[0] * C[1][1] - X[1] * C[0][1]; detXC1 = X[0] * C[1][1] - X[1] * C[0][1];
alpha1 = detXC1 / detC0C1; alpha1 = detXC1 / detC0C1;
alpha2 = detC0X / detC0C1; alpha2 = detC0X / detC0C1;
} else { } else {
@ -9003,7 +9002,7 @@ var PathFitter = Base.extend({
for (var i = first + 1; i < last; i++) { for (var i = first + 1; i < last; i++) {
var P = this.evaluate(3, curve, u[i - first]); var P = this.evaluate(3, curve, u[i - first]);
var v = P.subtract(this.points[i]); var v = P.subtract(this.points[i]);
var dist = v.x * v.x + v.y * v.y; var dist = v.x * v.x + v.y * v.y;
if (dist >= maxDist) { if (dist >= maxDist) {
maxDist = dist; maxDist = dist;
index = i; index = i;
@ -9177,12 +9176,12 @@ var Color = Base.extend(new function() {
} }
var hsbIndices = [ var hsbIndices = [
[0, 3, 1], [0, 3, 1],
[2, 0, 1], [2, 0, 1],
[1, 0, 3], [1, 0, 3],
[1, 2, 0], [1, 2, 0],
[3, 1, 0], [3, 1, 0],
[0, 1, 2] [0, 1, 2]
]; ];
var converters = { var converters = {
@ -9191,22 +9190,22 @@ var Color = Base.extend(new function() {
min = Math.min(r, g, b), min = Math.min(r, g, b),
delta = max - min, delta = max - min,
h = delta === 0 ? 0 h = delta === 0 ? 0
: ( max == r ? (g - b) / delta + (g < b ? 6 : 0) : ( max == r ? (g - b) / delta + (g < b ? 6 : 0)
: max == g ? (b - r) / delta + 2 : max == g ? (b - r) / delta + 2
: (r - g) / delta + 4) * 60; : (r - g) / delta + 4) * 60;
return [h, max === 0 ? 0 : delta / max, max]; return [h, max === 0 ? 0 : delta / max, max];
}, },
'hsb-rgb': function(h, s, b) { 'hsb-rgb': function(h, s, b) {
h = (((h / 60) % 6) + 6) % 6; h = (((h / 60) % 6) + 6) % 6;
var i = Math.floor(h), var i = Math.floor(h),
f = h - i, f = h - i,
i = hsbIndices[i], i = hsbIndices[i],
v = [ v = [
b, b,
b * (1 - s), b * (1 - s),
b * (1 - s * f), b * (1 - s * f),
b * (1 - s * (1 - f)) b * (1 - s * (1 - f))
]; ];
return [v[i[0]], v[i[1]], v[i[2]]]; return [v[i[0]], v[i[1]], v[i[2]]];
}, },
@ -9217,9 +9216,9 @@ var Color = Base.extend(new function() {
delta = max - min, delta = max - min,
achromatic = delta === 0, achromatic = delta === 0,
h = achromatic ? 0 h = achromatic ? 0
: ( max == r ? (g - b) / delta + (g < b ? 6 : 0) : ( max == r ? (g - b) / delta + (g < b ? 6 : 0)
: max == g ? (b - r) / delta + 2 : max == g ? (b - r) / delta + 2
: (r - g) / delta + 4) * 60, : (r - g) / delta + 4) * 60,
l = (max + min) / 2, l = (max + min) / 2,
s = achromatic ? 0 : l < 0.5 s = achromatic ? 0 : l < 0.5
? delta / (max + min) ? delta / (max + min)
@ -9351,7 +9350,7 @@ var Color = Base.extend(new function() {
alpha = args[2]; alpha = args[2];
} else { } else {
if (this.__read) if (this.__read)
read = 1; read = 1;
args = slice.call(args, 1); args = slice.call(args, 1);
argType = typeof arg; argType = typeof arg;
} }
@ -9747,7 +9746,7 @@ var Gradient = Base.extend({
equals: function(gradient) { equals: function(gradient) {
if (gradient === this) if (gradient === this)
return true; return true;
if (gradient && this._class === gradient._class if (gradient && this._class === gradient._class
&& this._stops.length === gradient._stops.length) { && this._stops.length === gradient._stops.length) {
for (var i = 0, l = this._stops.length; i < l; i++) { for (var i = 0, l = this._stops.length; i < l; i++) {
if (!this._stops[i].equals(gradient._stops[i])) if (!this._stops[i].equals(gradient._stops[i]))
@ -9843,7 +9842,7 @@ var Style = Base.extend(new function() {
fontFamily: 'sans-serif', fontFamily: 'sans-serif',
fontWeight: 'normal', fontWeight: 'normal',
fontSize: 12, fontSize: 12,
font: 'sans-serif', font: 'sans-serif',
leading: null, leading: null,
justification: 'left' justification: 'left'
}; };
@ -9857,7 +9856,7 @@ var Style = Base.extend(new function() {
fontFamily: 9, fontFamily: 9,
fontWeight: 9, fontWeight: 9,
fontSize: 9, fontSize: 9,
font: 9, font: 9,
leading: 9, leading: 9,
justification: 9 justification: 9
}; };
@ -9866,7 +9865,7 @@ var Style = Base.extend(new function() {
fields = { fields = {
_defaults: defaults, _defaults: defaults,
_textDefaults: new Base(defaults, { _textDefaults: new Base(defaults, {
fillColor: new Color() fillColor: new Color()
}), }),
beans: true beans: true
}; };
@ -10163,7 +10162,7 @@ var DomElement = new function() {
rect = { left: 0, top: 0, width: 0, height: 0 }; rect = { left: 0, top: 0, width: 0, height: 0 };
} }
var x = rect.left - (html.clientLeft || body.clientLeft || 0), var x = rect.left - (html.clientLeft || body.clientLeft || 0),
y = rect.top - (html.clientTop || body.clientTop || 0); y = rect.top - (html.clientTop || body.clientTop || 0);
if (!viewport) { if (!viewport) {
var view = doc.defaultView; var view = doc.defaultView;
x += view.pageXOffset || html.scrollLeft || body.scrollLeft; x += view.pageXOffset || html.scrollLeft || body.scrollLeft;
@ -10522,7 +10521,7 @@ var View = Base.extend(Callback, {
return; return;
this._viewSize.set(size.width, size.height); this._viewSize.set(size.width, size.height);
this._setViewSize(size); this._setViewSize(size);
this._bounds = null; this._bounds = null;
this.fire('resize', { this.fire('resize', {
size: size, size: size,
delta: delta delta: delta
@ -10603,6 +10602,8 @@ var View = Base.extend(Callback, {
_id: 0, _id: 0,
create: function(project, element) { create: function(project, element) {
if (typeof element === 'string')
element = document.getElementById(element);
return new CanvasView(project, element); return new CanvasView(project, element);
} }
} }
@ -10810,7 +10811,7 @@ var CanvasView = View.extend({
project._needsUpdate = false; project._needsUpdate = false;
return true; return true;
} }
}, new function() { }, new function() {
var downPoint, var downPoint,
lastPoint, lastPoint,
@ -10984,14 +10985,14 @@ var Key = new function() {
40: 'down', 40: 'down',
46: 'delete', 46: 'delete',
91: 'command', 91: 'command',
93: 'command', 93: 'command',
224: 'command' 224: 'command'
}, },
specialChars = { specialChars = {
9: true, 9: true,
13: true, 13: true,
32: true 32: true
}, },
modifiers = new Base({ modifiers = new Base({
@ -11003,9 +11004,9 @@ var Key = new function() {
space: false space: false
}), }),
charCodeMap = {}, charCodeMap = {},
keyMap = {}, keyMap = {},
downCode; downCode;
function handleKey(down, keyCode, charCode, event) { function handleKey(down, keyCode, charCode, event) {
var character = charCode ? String.fromCharCode(charCode) : '', var character = charCode ? String.fromCharCode(charCode) : '',
@ -11146,7 +11147,7 @@ var ToolEvent = Event.extend({
getDelta: function() { getDelta: function() {
return !this._delta && this.tool._lastPoint return !this._delta && this.tool._lastPoint
? this.tool._point.subtract(this.tool._lastPoint) ? this.tool._point.subtract(this.tool._lastPoint)
: this._delta; : this._delta;
}, },
@ -11413,9 +11414,9 @@ var BlendMode = new function() {
var min = Math.min, var min = Math.min,
max = Math.max, max = Math.max,
abs = Math.abs, abs = Math.abs,
sr, sg, sb, sa, sr, sg, sb, sa,
br, bg, bb, ba, br, bg, bb, ba,
dr, dg, db; dr, dg, db;
function getLum(r, g, b) { function getLum(r, g, b) {
return 0.2989 * r + 0.587 * g + 0.114 * b; return 0.2989 * r + 0.587 * g + 0.114 * b;
@ -11450,9 +11451,9 @@ var BlendMode = new function() {
function setSat(r, g, b, s) { function setSat(r, g, b, s) {
var col = [r, g, b], var col = [r, g, b],
mx = max(r, g, b), mx = max(r, g, b),
mn = min(r, g, b), mn = min(r, g, b),
md; md;
mn = mn === r ? 0 : mn === g ? 1 : 2; mn = mn === r ? 0 : mn === g ? 1 : 2;
mx = mx === r ? 0 : mx === g ? 1 : 2; mx = mx === r ? 0 : mx === g ? 1 : 2;
md = min(mn, mx) === 0 ? max(mn, mx) === 1 ? 2 : 1 : 0; md = min(mn, mx) === 0 ? max(mn, mx) === 1 ? 2 : 1 : 0;
@ -11632,8 +11633,8 @@ var BlendMode = new function() {
return; return;
var dstData = dstContext.getImageData(offset.x, offset.y, var dstData = dstContext.getImageData(offset.x, offset.y,
srcCanvas.width, srcCanvas.height), srcCanvas.width, srcCanvas.height),
dst = dstData.data, dst = dstData.data,
src = srcContext.getImageData(0, 0, src = srcContext.getImageData(0, 0,
srcCanvas.width, srcCanvas.height).data; srcCanvas.width, srcCanvas.height).data;
for (var i = 0, l = dst.length; i < l; i += 4) { for (var i = 0, l = dst.length; i < l; i += 4) {
sr = src[i]; sr = src[i];
@ -11667,7 +11668,7 @@ var SVGStyles = Base.each({
true: 'none', true: 'none',
false: 'non-scaling-stroke' false: 'non-scaling-stroke'
}, function(item, value) { }, function(item, value) {
return !value return !value
&& (item instanceof PathItem && (item instanceof PathItem
|| item instanceof Shape || item instanceof Shape
|| item instanceof TextItem); || item instanceof TextItem);
@ -11836,7 +11837,7 @@ new function() {
radius = item._radius, radius = item._radius,
attrs = getTransform(item._matrix, true, type !== 'rectangle'); attrs = getTransform(item._matrix, true, type !== 'rectangle');
if (type === 'rectangle') { if (type === 'rectangle') {
type = 'rect'; type = 'rect';
var size = item._size, var size = item._size,
width = size.width, width = size.width,
height = size.height; height = size.height;
@ -12565,7 +12566,7 @@ paper = new (PaperScope.inject(Base.exports, {
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
define('paper', paper); define('paper', paper);
} else if (typeof module === 'object' && module } else if (typeof module === 'object' && module
&& typeof module.exports === 'object') { && typeof module.exports === 'object') {
module.exports = paper; module.exports = paper;
} }

File diff suppressed because one or more lines are too long

329
dist/paper-full.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

223
dist/paper-node.js vendored
View file

@ -1,5 +1,5 @@
/*! /*!
* Paper.js v0.9.19 - The Swiss Army Knife of Vector Graphics Scripting. * Paper.js v0.9.20 - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/ * http://paperjs.org/
* *
* Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey
@ -9,7 +9,7 @@
* *
* All rights reserved. * All rights reserved.
* *
* Date: Sat Aug 16 18:31:16 2014 +0200 * Date: Mon Aug 25 14:21:13 2014 +0200
* *
*** ***
* *
@ -273,7 +273,7 @@ Base.inject({
statics: { statics: {
exports: { exports: {
enumerable: true enumerable: true
}, },
extend: function extend() { extend: function extend() {
@ -571,7 +571,7 @@ var Callback = {
if (entry) { if (entry) {
var handlers = this._handlers = this._handlers || {}; var handlers = this._handlers = this._handlers || {};
handlers = handlers[type] = handlers[type] || []; handlers = handlers[type] = handlers[type] || [];
if (handlers.indexOf(func) == -1) { if (handlers.indexOf(func) == -1) {
handlers.push(func); handlers.push(func);
if (entry.install && handlers.length == 1) if (entry.install && handlers.length == 1)
entry.install.call(this, type); entry.install.call(this, type);
@ -706,7 +706,7 @@ var PaperScope = Base.extend({
} }
}, },
version: '0.9.19', version: '0.9.20',
getView: function() { getView: function() {
return this.project && this.project.getView(); return this.project && this.project.getView();
@ -922,7 +922,7 @@ var Numerical = new function() {
B = A + a, B = A + a,
i = 0, i = 0,
m = (n + 1) >> 1, m = (n + 1) >> 1,
sum = n & 1 ? w[i++] * f(B) : 0; sum = n & 1 ? w[i++] * f(B) : 0;
while (i < m) { while (i < m) {
var Ax = A * x[i]; var Ax = A * x[i];
sum += w[i++] * (f(B + Ax) + f(B - Ax)); sum += w[i++] * (f(B + Ax) + f(B - Ax));
@ -954,7 +954,7 @@ var Numerical = new function() {
if (abs(a) < EPSILON) { if (abs(a) < EPSILON) {
if (abs(b) >= EPSILON) if (abs(b) >= EPSILON)
return add(-c / b); return add(-c / b);
return abs(c) < EPSILON ? -1 : 0; return abs(c) < EPSILON ? -1 : 0;
} }
var p = b / (2 * a); var p = b / (2 * a);
var q = c / a; var q = c / a;
@ -983,14 +983,14 @@ var Numerical = new function() {
D = q * q - ppp; D = q * q - ppp;
b /= 3; b /= 3;
if (abs(D) < EPSILON) { if (abs(D) < EPSILON) {
if (abs(q) < EPSILON) if (abs(q) < EPSILON)
return add(-b); return add(-b);
var sqp = sqrt(p), var sqp = sqrt(p),
snq = q > 0 ? 1 : -1; snq = q > 0 ? 1 : -1;
add(-snq * 2 * sqp - b); add(-snq * 2 * sqp - b);
return add(snq * sqp - b); return add(snq * sqp - b);
} }
if (D < 0) { if (D < 0) {
var sqp = sqrt(p), var sqp = sqrt(p),
phi = Math.acos(q / (sqp * sqp * sqp)) / 3, phi = Math.acos(q / (sqp * sqp * sqp)) / 3,
t = -2 * sqp, t = -2 * sqp,
@ -2366,9 +2366,9 @@ var Line = Base.extend({
} }
var v2x = x - px, var v2x = x - px,
v2y = y - py, v2y = y - py,
ccw = v2x * vy - v2y * vx; ccw = v2x * vy - v2y * vx;
if (ccw === 0) { if (ccw === 0) {
ccw = v2x * vx + v2y * vy; ccw = v2x * vx + v2y * vy;
if (ccw > 0) { if (ccw > 0) {
v2x -= vx; v2x -= vx;
v2y -= vy; v2y -= vy;
@ -2385,8 +2385,8 @@ var Line = Base.extend({
vx -= px; vx -= px;
vy -= py; vy -= py;
} }
var m = vy / vx, var m = vy / vx,
b = py - m * px; b = py - m * px;
return (y - (m * x) - b) / Math.sqrt(m * m + 1); return (y - (m * x) - b) / Math.sqrt(m * m + 1);
} }
} }
@ -2535,7 +2535,7 @@ var Project = PaperScopeItem.extend({
offset: new Point(0, 0), offset: new Point(0, 0),
pixelRatio: pixelRatio, pixelRatio: pixelRatio,
viewMatrix: matrix.isIdentity() ? null : matrix, viewMatrix: matrix.isIdentity() ? null : matrix,
matrices: [new Matrix()], matrices: [new Matrix()],
updateMatrix: true updateMatrix: true
}); });
for (var i = 0, layers = this.layers, l = layers.length; i < l; i++) for (var i = 0, layers = this.layers, l = layers.length; i < l; i++)
@ -3910,7 +3910,7 @@ var Item = Base.extend(Callback, {
normalBlend = blendMode === 'normal', normalBlend = blendMode === 'normal',
nativeBlend = BlendMode.nativeModes[blendMode], nativeBlend = BlendMode.nativeModes[blendMode],
direct = normalBlend && opacity === 1 direct = normalBlend && opacity === 1
|| param.dontStart || param.dontStart
|| param.clip || param.clip
|| (nativeBlend || normalBlend && opacity < 1) || (nativeBlend || normalBlend && opacity < 1)
&& this._canComposite(), && this._canComposite(),
@ -4108,7 +4108,7 @@ var Layer = Group.extend({
initialize: function Layer(arg) { initialize: function Layer(arg) {
var props = Base.isPlainObject(arg) var props = Base.isPlainObject(arg)
? new Base(arg) ? new Base(arg)
: { children: Array.isArray(arg) ? arg : arguments }, : { children: Array.isArray(arg) ? arg : arguments },
insert = props.insert; insert = props.insert;
props.insert = false; props.insert = false;
@ -4368,7 +4368,7 @@ var Shape = Item.extend({
return matrix ? matrix._transformBounds(rect) : rect; return matrix ? matrix._transformBounds(rect) : rect;
} }
}, },
new function() { new function() {
function getCornerCenter(that, point, expand) { function getCornerCenter(that, point, expand) {
var radius = that._radius; var radius = that._radius;
@ -4646,7 +4646,7 @@ var Raster = Item.extend({
} else if (/^https?:\/\//.test(src)) { } else if (/^https?:\/\//.test(src)) {
require('request').get({ require('request').get({
url: src, url: src,
encoding: null encoding: null
}, function (err, response, data) { }, function (err, response, data) {
if (err) if (err)
throw err; throw err;
@ -4910,8 +4910,7 @@ var HitResult = Base.extend({
center: false, center: false,
bounds: false, bounds: false,
guides: false, guides: false,
selected: false, selected: false
callback: null
}, options); }, options);
} }
} }
@ -4939,7 +4938,7 @@ var Segment = Base.extend({
point = arg0; point = arg0;
handleIn = arg1; handleIn = arg1;
handleOut = arg2; handleOut = arg2;
} else { } else {
point = arg0 !== undefined ? [ arg0, arg1 ] : null; point = arg0 !== undefined ? [ arg0, arg1 ] : null;
handleIn = arg2 !== undefined ? [ arg2, arg3 ] : null; handleIn = arg2 !== undefined ? [ arg2, arg3 ] : null;
handleOut = arg4 !== undefined ? [ arg4, arg5 ] : null; handleOut = arg4 !== undefined ? [ arg4, arg5 ] : null;
@ -5062,7 +5061,7 @@ var Segment = Base.extend({
setSelected: function(selected, _point) { setSelected: function(selected, _point) {
var path = this._path, var path = this._path,
selected = !!selected, selected = !!selected,
state = this._selectionState, state = this._selectionState,
oldState = state, oldState = state,
flag = !_point ? 7 flag = !_point ? 7
@ -5157,7 +5156,7 @@ var Segment = Base.extend({
_transformCoordinates: function(matrix, coords, change) { _transformCoordinates: function(matrix, coords, change) {
var point = this._point, var point = this._point,
handleIn = !change || !this._handleIn.isZero() handleIn = !change || !this._handleIn.isZero()
? this._handleIn : null, ? this._handleIn : null,
handleOut = !change || !this._handleOut.isZero() handleOut = !change || !this._handleOut.isZero()
? this._handleOut : null, ? this._handleOut : null,
@ -5210,7 +5209,7 @@ var SegmentPoint = Point.extend({
var x, y, selected; var x, y, selected;
if (!point) { if (!point) {
x = y = 0; x = y = 0;
} else if ((x = point[0]) !== undefined) { } else if ((x = point[0]) !== undefined) {
y = point[1]; y = point[1];
} else { } else {
var pt = point; var pt = point;
@ -5447,7 +5446,7 @@ var Curve = Base.extend({
: offset && offset.curve === this : offset && offset.curve === this
? offset.parameter ? offset.parameter
: offset === undefined && isParameter === undefined : offset === undefined && isParameter === undefined
? 0.5 ? 0.5
: this.getParameterAt(offset, 0); : this.getParameterAt(offset, 0);
}, },
@ -5479,7 +5478,7 @@ var Curve = Base.extend({
} else { } else {
this._path.insert(this._segment2._index, segment); this._path.insert(this._segment2._index, segment);
} }
res = this; res = this;
} else { } else {
var end = this._segment2; var end = this._segment2;
this._segment2 = segment; this._segment2 = segment;
@ -5606,8 +5605,8 @@ statics: {
p7x = u * p4x + t * p5x, p7y = u * p4y + t * p5y, p7x = u * p4x + t * p5x, p7y = u * p4y + t * p5y,
p8x = u * p6x + t * p7x, p8y = u * p6y + t * p7y; p8x = u * p6x + t * p7x, p8y = u * p6y + t * p7y;
return [ return [
[p1x, p1y, p3x, p3y, p6x, p6y, p8x, p8y], [p1x, p1y, p3x, p3y, p6x, p6y, p8x, p8y],
[p8x, p8y, p7x, p7y, p5x, p5y, p2x, p2y] [p8x, p8y, p7x, p7y, p5x, p5y, p2x, p2y]
]; ];
}, },
@ -5652,9 +5651,9 @@ statics: {
getPart: function(v, from, to) { getPart: function(v, from, to) {
if (from > 0) if (from > 0)
v = Curve.subdivide(v, from)[1]; v = Curve.subdivide(v, from)[1];
if (to < 1) if (to < 1)
v = Curve.subdivide(v, (to - from) / (1 - from))[0]; v = Curve.subdivide(v, (to - from) / (1 - from))[0];
return v; return v;
}, },
@ -5691,8 +5690,8 @@ statics: {
}, },
getBounds: function(v) { getBounds: function(v) {
var min = v.slice(0, 2), var min = v.slice(0, 2),
max = min.slice(), max = min.slice(),
roots = [0, 0]; roots = [0, 0];
for (var i = 0; i < 2; i++) for (var i = 0; i < 2; i++)
Curve._addBounds(v[i], v[i + 2], v[i + 4], v[i + 6], Curve._addBounds(v[i], v[i + 2], v[i + 4], v[i + 6],
@ -5820,7 +5819,7 @@ statics: {
} }
}), }),
new function() { new function() {
function getLengthIntegrand(v) { function getLengthIntegrand(v) {
var p1x = v[0], p1y = v[1], var p1x = v[0], p1y = v[1],
@ -5859,8 +5858,8 @@ new function() {
if (a === 0 && b === 1 if (a === 0 && b === 1
&& isZero(v[0] - v[2]) && isZero(v[1] - v[3]) && isZero(v[0] - v[2]) && isZero(v[1] - v[3])
&& isZero(v[6] - v[4]) && isZero(v[7] - v[5])) { && isZero(v[6] - v[4]) && isZero(v[7] - v[5])) {
var dx = v[6] - v[0], var dx = v[6] - v[0],
dy = v[7] - v[1]; dy = v[7] - v[1];
return Math.sqrt(dx * dx + dy * dy); return Math.sqrt(dx * dx + dy * dy);
} }
var ds = getLengthIntegrand(v); var ds = getLengthIntegrand(v);
@ -5890,11 +5889,11 @@ new function() {
return length - offset; return length - offset;
} }
return Numerical.findRoot(f, ds, return Numerical.findRoot(f, ds,
forward ? a + guess : b - guess, forward ? a + guess : b - guess,
a, b, 16, 0.00001); a, b, 16, 0.00001);
} }
}; };
}, new function() { }, new function() {
function addLocation(locations, include, curve1, t1, point1, curve2, t2, function addLocation(locations, include, curve1, t1, point1, curve2, t2,
point2) { point2) {
var loc = new CurveLocation(curve1, t1, point1, curve2, t2, point2); var loc = new CurveLocation(curve1, t1, point1, curve2, t2, point2);
@ -5972,7 +5971,7 @@ new function() {
curve1, t1, Curve.evaluate(v1, t1, 0), curve1, t1, Curve.evaluate(v1, t1, 0),
curve2, t2, Curve.evaluate(v2, t2, 0)); curve2, t2, Curve.evaluate(v2, t2, 0));
} }
} else { } else {
addCurveIntersections(v2, v1, curve2, curve1, locations, include, addCurveIntersections(v2, v1, curve2, curve1, locations, include,
uMin, uMax, tMinNew, tMaxNew, tDiff, !reverse, ++recursion); uMin, uMax, tMinNew, tMaxNew, tDiff, !reverse, ++recursion);
} }
@ -6024,7 +6023,7 @@ new function() {
} else if (qy <= dMax) { } else if (qy <= dMax) {
px = hullBottom[i][0]; px = hullBottom[i][0];
qx = hullBottom[i + 1][0]; qx = hullBottom[i + 1][0];
tProxy = px + (dMax - py) * (qx - px) / (qy - py); tProxy = px + (dMax - py) * (qx - px) / (qy - py);
} else { } else {
continue; continue;
} }
@ -6504,7 +6503,7 @@ var Path = PathItem.extend({
if (segments && segments.length > 0) { if (segments && segments.length > 0) {
this.setSegments(segments); this.setSegments(segments);
} else { } else {
this._curves = undefined; this._curves = undefined;
this._selectedSegmentState = 0; this._selectedSegmentState = 0;
if (!segments && typeof arg === 'string') { if (!segments && typeof arg === 'string') {
this.setPathData(arg); this.setPathData(arg);
@ -6787,7 +6786,7 @@ var Path = PathItem.extend({
to = Base.pick(to, this._segments.length); to = Base.pick(to, this._segments.length);
var segments = this._segments, var segments = this._segments,
curves = this._curves, curves = this._curves,
count = segments.length, count = segments.length,
removed = segments.splice(from, to - from), removed = segments.splice(from, to - from),
amount = removed.length; amount = removed.length;
if (!amount) if (!amount)
@ -7159,7 +7158,7 @@ var Path = PathItem.extend({
if (parameter === 0 || parameter === 1 && numSegments > 1) { if (parameter === 0 || parameter === 1 && numSegments > 1) {
if (!checkSegmentStroke(loc.getSegment())) if (!checkSegmentStroke(loc.getSegment()))
loc = null; loc = null;
} else if (!isCloseEnough(loc.getPoint(), strokePadding)) { } else if (!isCloseEnough(loc.getPoint(), strokePadding)) {
loc = null; loc = null;
} }
} }
@ -7224,7 +7223,7 @@ var Path = PathItem.extend({
var curves = this.getCurves(), var curves = this.getCurves(),
length = 0; length = 0;
if (isParameter) { if (isParameter) {
var index = ~~offset; var index = ~~offset;
return curves[index].getLocationAt(offset - index, true); return curves[index].getLocationAt(offset - index, true);
} }
for (var i = 0, l = curves.length; i < l; i++) { for (var i = 0, l = curves.length; i < l; i++) {
@ -7273,7 +7272,7 @@ var Path = PathItem.extend({
getNearestPoint: function() { getNearestPoint: function() {
return this.getNearestLocation.apply(this, arguments).getPoint(); return this.getNearestLocation.apply(this, arguments).getPoint();
} }
}, new function() { }, new function() {
function drawHandles(ctx, segments, matrix, size) { function drawHandles(ctx, segments, matrix, size) {
var half = size / 2; var half = size / 2;
@ -7436,12 +7435,12 @@ var Path = PathItem.extend({
drawHandles(ctx, this._segments, matrix, paper.settings.handleSize); drawHandles(ctx, this._segments, matrix, paper.settings.handleSize);
} }
}; };
}, new function() { }, new function() {
function getFirstControlPoints(rhs) { function getFirstControlPoints(rhs) {
var n = rhs.length, var n = rhs.length,
x = [], x = [],
tmp = [], tmp = [],
b = 2; b = 2;
x[0] = rhs[0] / b; x[0] = rhs[0] / b;
for (var i = 1; i < n; i++) { for (var i = 1; i < n; i++) {
@ -7529,7 +7528,7 @@ var Path = PathItem.extend({
} }
} }
}; };
}, new function() { }, new function() {
function getCurrentSegment(that) { function getCurrentSegment(that) {
var segments = that._segments; var segments = that._segments;
if (segments.length === 0) if (segments.length === 0)
@ -7673,7 +7672,7 @@ var Path = PathItem.extend({
} }
} }
var ext = Math.abs(extent), var ext = Math.abs(extent),
count = ext >= 360 ? 4 : Math.ceil(ext / 90), count = ext >= 360 ? 4 : Math.ceil(ext / 90),
inc = extent / count, inc = extent / count,
half = inc * Math.PI / 360, half = inc * Math.PI / 360,
z = 4 / 3 * Math.sin(half) / (1 + Math.cos(half)), z = 4 / 3 * Math.sin(half) / (1 + Math.cos(half)),
@ -7753,7 +7752,7 @@ var Path = PathItem.extend({
this.join(); this.join();
} }
}; };
}, { }, {
_getBounds: function(getter, matrix) { _getBounds: function(getter, matrix) {
return Path[getter](this._segments, this._closed, this.getStyle(), return Path[getter](this._segments, this._closed, this.getStyle(),
@ -7778,18 +7777,18 @@ statics: {
return new Rectangle(); return new Rectangle();
var coords = new Array(6), var coords = new Array(6),
prevCoords = first._transformCoordinates(matrix, new Array(6), false), prevCoords = first._transformCoordinates(matrix, new Array(6), false),
min = prevCoords.slice(0, 2), min = prevCoords.slice(0, 2),
max = min.slice(), max = min.slice(),
roots = new Array(2); roots = new Array(2);
function processSegment(segment) { function processSegment(segment) {
segment._transformCoordinates(matrix, coords, false); segment._transformCoordinates(matrix, coords, false);
for (var i = 0; i < 2; i++) { for (var i = 0; i < 2; i++) {
Curve._addBounds( Curve._addBounds(
prevCoords[i], prevCoords[i],
prevCoords[i + 4], prevCoords[i + 4],
coords[i + 2], coords[i + 2],
coords[i], coords[i],
i, strokePadding ? strokePadding[i] : 0, min, max, roots); i, strokePadding ? strokePadding[i] : 0, min, max, roots);
} }
var tmp = prevCoords; var tmp = prevCoords;
@ -8239,7 +8238,7 @@ var CompoundPath = PathItem.extend({
: matrix.chain(mx)); : matrix.chain(mx));
} }
} }
}, new function() { }, new function() {
function getCurrentPath(that, check) { function getCurrentPath(that, check) {
var children = that._children; var children = that._children;
if (check && children.length === 0) if (check && children.length === 0)
@ -8496,7 +8495,7 @@ PathItem.inject(new function() {
var path = new Path(Item.NO_INSERT), var path = new Path(Item.NO_INSERT),
inter = seg._intersection, inter = seg._intersection,
startInterSeg = inter && inter._segment, startInterSeg = inter && inter._segment,
added = false, added = false,
dir = 1; dir = 1;
do { do {
var handleIn = dir > 0 ? seg._handleIn : seg._handleOut, var handleIn = dir > 0 ? seg._handleIn : seg._handleOut,
@ -8609,12 +8608,12 @@ Path.inject({
curve = { curve = {
values: v, values: v,
winding: y0 === y1 winding: y0 === y1
? 0 ? 0
: y0 > y1 : y0 > y1
? -1 ? -1
: 1, : 1,
previous: prevCurve, previous: prevCurve,
next: null next: null
}; };
if (prevCurve) if (prevCurve)
prevCurve.next = curve; prevCurve.next = curve;
@ -8712,7 +8711,7 @@ Path.inject({
CompoundPath.inject({ CompoundPath.inject({
_getMonoCurves: function() { _getMonoCurves: function() {
var children = this._children, var children = this._children,
monoCurves = []; monoCurves = [];
for (var i = 0, l = children.length; i < l; i++) for (var i = 0, l = children.length; i < l; i++)
monoCurves.push.apply(monoCurves, children[i]._getMonoCurves()); monoCurves.push.apply(monoCurves, children[i]._getMonoCurves());
@ -8725,7 +8724,7 @@ CompoundPath.inject({
}); });
this.addChildren(children); this.addChildren(children);
var clockwise = children[0].isClockwise(); var clockwise = children[0].isClockwise();
for (var i = 1, l = children.length; i < l; i++) { for (var i = 1, l = children.length; i < l; i++) {
var point = children[i].getInteriorPoint(), var point = children[i].getInteriorPoint(),
counters = 0; counters = 0;
for (var j = i - 1; j >= 0; j--) { for (var j = i - 1; j >= 0; j--) {
@ -8740,9 +8739,9 @@ CompoundPath.inject({
var PathFlattener = Base.extend({ var PathFlattener = Base.extend({
initialize: function(path, matrix) { initialize: function(path, matrix) {
this.curves = []; this.curves = [];
this.parts = []; this.parts = [];
this.length = 0; this.length = 0;
this.index = 0; this.index = 0;
var segments = path._segments, var segments = path._segments,
@ -8802,7 +8801,7 @@ var PathFlattener = Base.extend({
prevLen = prev ? prev.offset : 0; prevLen = prev ? prev.offset : 0;
return { return {
value: prevVal + (part.value - prevVal) value: prevVal + (part.value - prevVal)
* (offset - prevLen) / (part.offset - prevLen), * (offset - prevLen) / (part.offset - prevLen),
index: part.index index: part.index
}; };
} }
@ -8929,8 +8928,8 @@ var PathFitter = Base.extend({
var detC0C1 = C[0][0] * C[1][1] - C[1][0] * C[0][1], var detC0C1 = C[0][0] * C[1][1] - C[1][0] * C[0][1],
alpha1, alpha2; alpha1, alpha2;
if (Math.abs(detC0C1) > epsilon) { if (Math.abs(detC0C1) > epsilon) {
var detC0X = C[0][0] * X[1] - C[1][0] * X[0], var detC0X = C[0][0] * X[1] - C[1][0] * X[0],
detXC1 = X[0] * C[1][1] - X[1] * C[0][1]; detXC1 = X[0] * C[1][1] - X[1] * C[0][1];
alpha1 = detXC1 / detC0C1; alpha1 = detXC1 / detC0C1;
alpha2 = detC0X / detC0C1; alpha2 = detC0X / detC0C1;
} else { } else {
@ -9008,7 +9007,7 @@ var PathFitter = Base.extend({
for (var i = first + 1; i < last; i++) { for (var i = first + 1; i < last; i++) {
var P = this.evaluate(3, curve, u[i - first]); var P = this.evaluate(3, curve, u[i - first]);
var v = P.subtract(this.points[i]); var v = P.subtract(this.points[i]);
var dist = v.x * v.x + v.y * v.y; var dist = v.x * v.x + v.y * v.y;
if (dist >= maxDist) { if (dist >= maxDist) {
maxDist = dist; maxDist = dist;
index = i; index = i;
@ -9182,12 +9181,12 @@ var Color = Base.extend(new function() {
} }
var hsbIndices = [ var hsbIndices = [
[0, 3, 1], [0, 3, 1],
[2, 0, 1], [2, 0, 1],
[1, 0, 3], [1, 0, 3],
[1, 2, 0], [1, 2, 0],
[3, 1, 0], [3, 1, 0],
[0, 1, 2] [0, 1, 2]
]; ];
var converters = { var converters = {
@ -9196,22 +9195,22 @@ var Color = Base.extend(new function() {
min = Math.min(r, g, b), min = Math.min(r, g, b),
delta = max - min, delta = max - min,
h = delta === 0 ? 0 h = delta === 0 ? 0
: ( max == r ? (g - b) / delta + (g < b ? 6 : 0) : ( max == r ? (g - b) / delta + (g < b ? 6 : 0)
: max == g ? (b - r) / delta + 2 : max == g ? (b - r) / delta + 2
: (r - g) / delta + 4) * 60; : (r - g) / delta + 4) * 60;
return [h, max === 0 ? 0 : delta / max, max]; return [h, max === 0 ? 0 : delta / max, max];
}, },
'hsb-rgb': function(h, s, b) { 'hsb-rgb': function(h, s, b) {
h = (((h / 60) % 6) + 6) % 6; h = (((h / 60) % 6) + 6) % 6;
var i = Math.floor(h), var i = Math.floor(h),
f = h - i, f = h - i,
i = hsbIndices[i], i = hsbIndices[i],
v = [ v = [
b, b,
b * (1 - s), b * (1 - s),
b * (1 - s * f), b * (1 - s * f),
b * (1 - s * (1 - f)) b * (1 - s * (1 - f))
]; ];
return [v[i[0]], v[i[1]], v[i[2]]]; return [v[i[0]], v[i[1]], v[i[2]]];
}, },
@ -9222,9 +9221,9 @@ var Color = Base.extend(new function() {
delta = max - min, delta = max - min,
achromatic = delta === 0, achromatic = delta === 0,
h = achromatic ? 0 h = achromatic ? 0
: ( max == r ? (g - b) / delta + (g < b ? 6 : 0) : ( max == r ? (g - b) / delta + (g < b ? 6 : 0)
: max == g ? (b - r) / delta + 2 : max == g ? (b - r) / delta + 2
: (r - g) / delta + 4) * 60, : (r - g) / delta + 4) * 60,
l = (max + min) / 2, l = (max + min) / 2,
s = achromatic ? 0 : l < 0.5 s = achromatic ? 0 : l < 0.5
? delta / (max + min) ? delta / (max + min)
@ -9356,7 +9355,7 @@ var Color = Base.extend(new function() {
alpha = args[2]; alpha = args[2];
} else { } else {
if (this.__read) if (this.__read)
read = 1; read = 1;
args = slice.call(args, 1); args = slice.call(args, 1);
argType = typeof arg; argType = typeof arg;
} }
@ -9752,7 +9751,7 @@ var Gradient = Base.extend({
equals: function(gradient) { equals: function(gradient) {
if (gradient === this) if (gradient === this)
return true; return true;
if (gradient && this._class === gradient._class if (gradient && this._class === gradient._class
&& this._stops.length === gradient._stops.length) { && this._stops.length === gradient._stops.length) {
for (var i = 0, l = this._stops.length; i < l; i++) { for (var i = 0, l = this._stops.length; i < l; i++) {
if (!this._stops[i].equals(gradient._stops[i])) if (!this._stops[i].equals(gradient._stops[i]))
@ -9848,7 +9847,7 @@ var Style = Base.extend(new function() {
fontFamily: 'sans-serif', fontFamily: 'sans-serif',
fontWeight: 'normal', fontWeight: 'normal',
fontSize: 12, fontSize: 12,
font: 'sans-serif', font: 'sans-serif',
leading: null, leading: null,
justification: 'left' justification: 'left'
}; };
@ -9862,7 +9861,7 @@ var Style = Base.extend(new function() {
fontFamily: 9, fontFamily: 9,
fontWeight: 9, fontWeight: 9,
fontSize: 9, fontSize: 9,
font: 9, font: 9,
leading: 9, leading: 9,
justification: 9 justification: 9
}; };
@ -9871,7 +9870,7 @@ var Style = Base.extend(new function() {
fields = { fields = {
_defaults: defaults, _defaults: defaults,
_textDefaults: new Base(defaults, { _textDefaults: new Base(defaults, {
fillColor: new Color() fillColor: new Color()
}), }),
beans: true beans: true
}; };
@ -10024,7 +10023,7 @@ var jsdom = require('jsdom'),
domToHtml = require('jsdom/lib/jsdom/browser/domtohtml').domToHtml, domToHtml = require('jsdom/lib/jsdom/browser/domtohtml').domToHtml,
Canvas = require('canvas'), Canvas = require('canvas'),
document = jsdom.jsdom('<html><body></body></html>'), document = jsdom.jsdom('<html><body></body></html>'),
window = document.createWindow(), window = document.parentWindow,
navigator = window.navigator, navigator = window.navigator,
HTMLCanvasElement = Canvas, HTMLCanvasElement = Canvas,
Image = Canvas.Image; Image = Canvas.Image;
@ -10203,7 +10202,7 @@ var DomElement = new function() {
rect = { left: 0, top: 0, width: 0, height: 0 }; rect = { left: 0, top: 0, width: 0, height: 0 };
} }
var x = rect.left - (html.clientLeft || body.clientLeft || 0), var x = rect.left - (html.clientLeft || body.clientLeft || 0),
y = rect.top - (html.clientTop || body.clientTop || 0); y = rect.top - (html.clientTop || body.clientTop || 0);
if (!viewport) { if (!viewport) {
var view = doc.defaultView; var view = doc.defaultView;
x += view.pageXOffset || html.scrollLeft || body.scrollLeft; x += view.pageXOffset || html.scrollLeft || body.scrollLeft;
@ -10405,7 +10404,7 @@ var View = Base.extend(Callback, {
return; return;
this._viewSize.set(size.width, size.height); this._viewSize.set(size.width, size.height);
this._setViewSize(size); this._setViewSize(size);
this._bounds = null; this._bounds = null;
this.fire('resize', { this.fire('resize', {
size: size, size: size,
delta: delta delta: delta
@ -10554,7 +10553,7 @@ var CanvasView = View.extend({
project._needsUpdate = false; project._needsUpdate = false;
return true; return true;
} }
}, new function() { }, new function() {
var downPoint, var downPoint,
lastPoint, lastPoint,
@ -10747,7 +10746,7 @@ var CanvasProvider = {
canvas = this.canvases.pop(); canvas = this.canvases.pop();
} else { } else {
canvas = new Canvas(width, height); canvas = new Canvas(width, height);
clear = false; clear = false;
} }
var ctx = canvas.getContext('2d'); var ctx = canvas.getContext('2d');
if (canvas.width === width && canvas.height === height) { if (canvas.width === width && canvas.height === height) {
@ -10776,9 +10775,9 @@ var BlendMode = new function() {
var min = Math.min, var min = Math.min,
max = Math.max, max = Math.max,
abs = Math.abs, abs = Math.abs,
sr, sg, sb, sa, sr, sg, sb, sa,
br, bg, bb, ba, br, bg, bb, ba,
dr, dg, db; dr, dg, db;
function getLum(r, g, b) { function getLum(r, g, b) {
return 0.2989 * r + 0.587 * g + 0.114 * b; return 0.2989 * r + 0.587 * g + 0.114 * b;
@ -10813,9 +10812,9 @@ var BlendMode = new function() {
function setSat(r, g, b, s) { function setSat(r, g, b, s) {
var col = [r, g, b], var col = [r, g, b],
mx = max(r, g, b), mx = max(r, g, b),
mn = min(r, g, b), mn = min(r, g, b),
md; md;
mn = mn === r ? 0 : mn === g ? 1 : 2; mn = mn === r ? 0 : mn === g ? 1 : 2;
mx = mx === r ? 0 : mx === g ? 1 : 2; mx = mx === r ? 0 : mx === g ? 1 : 2;
md = min(mn, mx) === 0 ? max(mn, mx) === 1 ? 2 : 1 : 0; md = min(mn, mx) === 0 ? max(mn, mx) === 1 ? 2 : 1 : 0;
@ -10995,8 +10994,8 @@ var BlendMode = new function() {
return; return;
var dstData = dstContext.getImageData(offset.x, offset.y, var dstData = dstContext.getImageData(offset.x, offset.y,
srcCanvas.width, srcCanvas.height), srcCanvas.width, srcCanvas.height),
dst = dstData.data, dst = dstData.data,
src = srcContext.getImageData(0, 0, src = srcContext.getImageData(0, 0,
srcCanvas.width, srcCanvas.height).data; srcCanvas.width, srcCanvas.height).data;
for (var i = 0, l = dst.length; i < l; i += 4) { for (var i = 0, l = dst.length; i < l; i += 4) {
sr = src[i]; sr = src[i];
@ -11030,7 +11029,7 @@ var SVGStyles = Base.each({
true: 'none', true: 'none',
false: 'non-scaling-stroke' false: 'non-scaling-stroke'
}, function(item, value) { }, function(item, value) {
return !value return !value
&& (item instanceof PathItem && (item instanceof PathItem
|| item instanceof Shape || item instanceof Shape
|| item instanceof TextItem); || item instanceof TextItem);
@ -11199,7 +11198,7 @@ new function() {
radius = item._radius, radius = item._radius,
attrs = getTransform(item._matrix, true, type !== 'rectangle'); attrs = getTransform(item._matrix, true, type !== 'rectangle');
if (type === 'rectangle') { if (type === 'rectangle') {
type = 'rect'; type = 'rect';
var size = item._size, var size = item._size,
width = size.width, width = size.width,
height = size.height; height = size.height;
@ -12024,7 +12023,7 @@ Base.exports.PaperScript = (function() {
} }
} }
switch (node.type) { switch (node.type) {
case 'UnaryExpression': case 'UnaryExpression':
if (node.operator in unaryOperators if (node.operator in unaryOperators
&& node.argument.type !== 'Literal') { && node.argument.type !== 'Literal') {
var arg = getCode(node.argument); var arg = getCode(node.argument);
@ -12032,7 +12031,7 @@ Base.exports.PaperScript = (function() {
+ arg + ')'); + arg + ')');
} }
break; break;
case 'BinaryExpression': case 'BinaryExpression':
if (node.operator in binaryOperators if (node.operator in binaryOperators
&& node.left.type !== 'Literal') { && node.left.type !== 'Literal') {
var left = getCode(node.left), var left = getCode(node.left),
@ -12041,8 +12040,8 @@ Base.exports.PaperScript = (function() {
+ '", ' + right + ')'); + '", ' + right + ')');
} }
break; break;
case 'UpdateExpression': case 'UpdateExpression':
case 'AssignmentExpression': case 'AssignmentExpression':
var parentType = parent && parent.type; var parentType = parent && parent.type;
if (!( if (!(
parentType === 'ForStatement' parentType === 'ForStatement'
@ -12059,7 +12058,7 @@ Base.exports.PaperScript = (function() {
|| parentType === 'VariableDeclarator')) || parentType === 'VariableDeclarator'))
str = arg + '; ' + str; str = arg + '; ' + str;
replaceCode(node, str); replaceCode(node, str);
} else { } else {
if (/^.=$/.test(node.operator) if (/^.=$/.test(node.operator)
&& node.left.type !== 'Literal') { && node.left.type !== 'Literal') {
var left = getCode(node.left), var left = getCode(node.left),
@ -12090,7 +12089,7 @@ Base.exports.PaperScript = (function() {
code = compile(code, url, options); code = compile(code, url, options);
function expose(scope, hidden) { function expose(scope, hidden) {
for (var key in scope) { for (var key in scope) {
if ((hidden || !/^_/.test(key)) && new RegExp('[\\b\\s\\W]' if ((hidden || !/^_/.test(key)) && new RegExp('([\\b\\s\\W]|^)'
+ key.replace(/\$/g, '\\$') + '\\b').test(code)) { + key.replace(/\$/g, '\\$') + '\\b').test(code)) {
params.push(key); params.push(key);
args.push(scope[key]); args.push(scope[key]);

View file

@ -1,6 +1,6 @@
{ {
"name": "paper", "name": "paper",
"version": "0.9.19", "version": "0.9.20",
"description": "The Swiss Army Knife of Vector Graphics Scripting", "description": "The Swiss Army Knife of Vector Graphics Scripting",
"license": "MIT", "license": "MIT",
"homepage": "http://paperjs.org", "homepage": "http://paperjs.org",

View file

@ -17,7 +17,7 @@
// The paper.js version. // The paper.js version.
// NOTE: Adjust value here before calling publish.sh, which then updates and // NOTE: Adjust value here before calling publish.sh, which then updates and
// publishes the various JSON package files automatically. // publishes the various JSON package files automatically.
var version = '0.9.19'; var version = '0.9.20';
var __options = { var __options = {
// If this file is loaded in the browser, we're in dev mode through load.js // If this file is loaded in the browser, we're in dev mode through load.js