Bump version to v0.9.23

This commit is contained in:
Jürg Lehni 2015-06-23 16:23:54 +02:00
parent b58dd84501
commit b0255d9fc2
8 changed files with 25712 additions and 206 deletions

View file

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

431
dist/paper-core.js vendored
View file

@ -1,5 +1,5 @@
/*!
* Paper.js v0.9.22 - The Swiss Army Knife of Vector Graphics Scripting.
* Paper.js v0.9.23 - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/
*
* Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey
@ -9,7 +9,7 @@
*
* All rights reserved.
*
* Date: Sat Feb 28 19:20:48 2015 +0100
* Date: Tue Jun 23 16:22:48 2015 +0200
*
***
*
@ -161,19 +161,22 @@ var Base = new function() {
extend: function() {
var base = this,
ctor;
ctor,
proto;
for (var i = 0, l = arguments.length; i < l; i++)
if (ctor = arguments[i].initialize)
break;
ctor = ctor || function() {
base.apply(this, arguments);
};
ctor.prototype = create(this.prototype);
ctor.base = base;
define(ctor.prototype, 'constructor',
proto = ctor.prototype = create(this.prototype);
define(proto, 'constructor',
{ value: ctor, writable: true, configurable: true });
inject(ctor, this, true);
return arguments.length ? this.inject.apply(ctor, arguments) : ctor;
if (arguments.length)
this.inject.apply(ctor, arguments)
ctor.base = base;
return ctor;
}
}, true).inject({
inject: function() {
@ -457,24 +460,23 @@ Base.inject({
: res;
},
deserialize: function(json, create, _data) {
deserialize: function(json, create, _data, _isDictionary) {
var res = json,
isRoot = !_data;
_data = _data || {};
if (Array.isArray(json)) {
var type = json[0],
isDictionary = type === 'dictionary';
if (!isDictionary) {
if (_data.dictionary && json.length == 1 && /^#/.test(type))
return _data.dictionary[type];
type = Base.exports[type];
}
if (json.length == 1 && /^#/.test(type))
return _data.dictionary[type];
type = Base.exports[type];
res = [];
if (_isDictionary)
_data.dictionary = res;
for (var i = type ? 1 : 0, l = json.length; i < l; i++)
res.push(Base.deserialize(json[i], create, _data));
if (isDictionary) {
_data.dictionary = res[0];
} else if (type) {
res.push(Base.deserialize(json[i], create, _data,
isDictionary));
if (type) {
var args = res;
if (create) {
res = create(type, args);
@ -485,6 +487,8 @@ Base.inject({
}
} else if (Base.isPlainObject(json)) {
res = {};
if (_isDictionary)
_data.dictionary = res;
for (var key in json)
res[key] = Base.deserialize(json[key], create, _data);
}
@ -570,15 +574,14 @@ var Emitter = {
this.on(key, value);
}, this);
} else {
var entry = this._eventTypes[type];
if (entry) {
var handlers = this._callbacks = this._callbacks || {};
handlers = handlers[type] = handlers[type] || [];
if (handlers.indexOf(func) === -1) {
handlers.push(func);
if (entry.install && handlers.length == 1)
entry.install.call(this, type);
}
var types = this._eventTypes,
entry = types && types[type],
handlers = this._callbacks = this._callbacks || {};
handlers = handlers[type] = handlers[type] || [];
if (handlers.indexOf(func) === -1) {
handlers.push(func);
if (entry && entry.install && handlers.length == 1)
entry.install.call(this, type);
}
}
return this;
@ -591,13 +594,14 @@ var Emitter = {
}, this);
return;
}
var entry = this._eventTypes[type],
var types = this._eventTypes,
entry = types && types[type],
handlers = this._callbacks && this._callbacks[type],
index;
if (entry && handlers) {
if (handlers) {
if (!func || (index = handlers.indexOf(func)) !== -1
&& handlers.length === 1) {
if (entry.uninstall)
if (entry && entry.uninstall)
entry.uninstall.call(this, type);
delete this._callbacks[type];
} else if (index !== -1) {
@ -619,10 +623,11 @@ var Emitter = {
if (!handlers)
return false;
var args = [].slice.call(arguments, 1);
handlers = handlers.slice();
for (var i = 0, l = handlers.length; i < l; i++) {
if (handlers[i].apply(this, args) === false
&& event && event.stop) {
event.stop();
if (handlers[i].apply(this, args) === false) {
if (event && event.stop)
event.stop();
break;
}
}
@ -642,8 +647,9 @@ var Emitter = {
key = install ? 'install' : 'uninstall';
for (var type in handlers) {
if (handlers[type].length > 0) {
var entry = this._eventTypes[type],
func = entry[key];
var types = this._eventTypes,
entry = types && types[type],
func = entry && entry[key];
if (func)
func.call(this, type);
}
@ -732,7 +738,7 @@ var PaperScope = Base.extend({
}
},
version: '0.9.22',
version: '0.9.23',
getView: function() {
return this.project && this.project.getView();
@ -969,7 +975,7 @@ var Numerical = new function() {
D;
b /= 2;
D = b * b - a * c;
if (abs(D) < MACHINE_EPSILON) {
if (D !== 0 && abs(D) < MACHINE_EPSILON) {
var pow = Math.pow,
gmC = pow(abs(a*b*c), 1/3);
if (gmC < 1e-8) {
@ -1070,6 +1076,23 @@ var Numerical = new function() {
};
};
var UID = {
_id: 1,
_pools: {},
get: function(ctor) {
if (ctor) {
var name = ctor._class,
pool = this._pools[name];
if (!pool)
pool = this._pools[name] = { _id: 1 };
return pool._id++;
} else {
return this._id++;
}
}
};
var Point = Base.extend({
_class: 'Point',
_readIndex: true,
@ -1284,12 +1307,14 @@ var Point = Base.extend({
return this.getDistance(point) < tolerance;
},
isColinear: function(point) {
return Math.abs(this.cross(point)) < 1e-12;
isCollinear: function(point) {
return Math.abs(this.cross(point)) < 0.000001;
},
isColinear: '#isCollinear',
isOrthogonal: function(point) {
return Math.abs(this.dot(point)) < 1e-12;
return Math.abs(this.dot(point)) < 0.000001;
},
isZero: function() {
@ -2638,7 +2663,7 @@ var Symbol = Base.extend({
_class: 'Symbol',
initialize: function Symbol(item, dontCenter) {
this._id = Symbol._id = (Symbol._id || 0) + 1;
this._id = UID.get();
this.project = paper.project;
this.project.symbols.push(this);
if (item)
@ -2735,7 +2760,7 @@ var Item = Base.extend(Emitter, {
matrix = this._matrix = new Matrix(),
project = hasProps && props.project || paper.project;
if (!internal)
this._id = Item._id = (Item._id || 0) + 1;
this._id = UID.get();
this._applyMatrix = this._canApplyMatrix && paper.settings.applyMatrix;
if (point)
matrix.translate(point);
@ -3080,6 +3105,7 @@ var Item = Base.extend(Emitter, {
var children = this._children;
if (!children || children.length == 0)
return new Rectangle();
Item._updateBoundsCache(this, cacheItem);
var x1 = Infinity,
x2 = -x1,
y1 = x1,
@ -3120,18 +3146,7 @@ var Item = Base.extend(Emitter, {
matrix = matrix && matrix.orNullIfIdentity();
var _matrix = internalGetter ? null : this._matrix.orNullIfIdentity(),
cache = (!matrix || matrix.equals(_matrix)) && getter;
var cacheParent = this._parent || this._parentSymbol;
if (cacheParent) {
var id = cacheItem._id,
ref = cacheParent._boundsCache = cacheParent._boundsCache || {
ids: {},
list: []
};
if (!ref.ids[id]) {
ref.list.push(cacheItem);
ref.ids[id] = cacheItem;
}
}
Item._updateBoundsCache(this._parent || this._parentSymbol, cacheItem);
if (cache && this._bounds && this._bounds[cache])
return this._bounds[cache].clone();
var bounds = this._getBounds(internalGetter || getter,
@ -3146,11 +3161,25 @@ var Item = Base.extend(Emitter, {
},
statics: {
_updateBoundsCache: function(parent, item) {
if (parent) {
var id = item._id,
ref = parent._boundsCache = parent._boundsCache || {
ids: {},
list: []
};
if (!ref.ids[id]) {
ref.list.push(item);
ref.ids[id] = item;
}
}
},
_clearBoundsCache: function(item) {
var cache = item._boundsCache;
if (cache) {
item._bounds = item._position = item._boundsCache = undefined;
for (var i = 0, list = cache.list, l = list.length; i < l; i++) {
for (var i = 0, list = cache.list, l = list.length; i < l; i++){
var other = list[i];
if (other !== item) {
other._bounds = other._position = undefined;
@ -3340,24 +3369,26 @@ var Item = Base.extend(Emitter, {
return this._clone(new this.constructor(Item.NO_INSERT), insert);
},
_clone: function(copy, insert) {
copy.setStyle(this._style);
if (this._children) {
for (var i = 0, l = this._children.length; i < l; i++)
copy.addChild(this._children[i].clone(false), true);
}
if (insert || insert === undefined)
copy.insertAbove(this);
_clone: function(copy, insert, includeMatrix) {
var keys = ['_locked', '_visible', '_blendMode', '_opacity',
'_clipMask', '_guide', '_applyMatrix'];
'_clipMask', '_guide'],
children = this._children;
copy.setStyle(this._style);
for (var i = 0, l = children && children.length; i < l; i++) {
copy.addChild(children[i].clone(false), true);
}
for (var i = 0, l = keys.length; i < l; i++) {
var key = keys[i];
if (this.hasOwnProperty(key))
copy[key] = this[key];
}
copy._matrix.initialize(this._matrix);
copy._data = this._data ? Base.clone(this._data) : null;
if (includeMatrix !== false)
copy._matrix.initialize(this._matrix);
copy.setApplyMatrix(this._applyMatrix);
copy.setSelected(this._selected);
copy._data = this._data ? Base.clone(this._data) : null;
if (insert || insert === undefined)
copy.insertAbove(this);
if (this._name)
copy.setName(this._name, true);
return copy;
@ -4422,16 +4453,14 @@ var Shape = Item.extend({
},
toPath: function(insert) {
var path = new Path[Base.capitalize(this._type)]({
var path = this._clone(new Path[Base.capitalize(this._type)]({
center: new Point(),
size: this._size,
radius: this._radius,
insert: false
});
path.setStyle(this._style);
path.transform(this._matrix);
if (insert || insert === undefined)
path.insertAbove(this);
}), insert);
if (paper.settings.applyMatrix)
path.setApplyMatrix(true);
return path;
},
@ -4816,9 +4845,7 @@ var Raster = Item.extend({
if (image.naturalWidth && image.naturalHeight) {
setTimeout(loaded, 0);
} else {
DomEvent.add(image, {
load: loaded
});
DomEvent.add(image, { load: loaded });
if (!image.src)
image.src = src;
}
@ -5172,15 +5199,17 @@ var Segment = Base.extend({
}
},
isColinear: function(segment) {
isCollinear: function(segment) {
var next1 = this.getNext(),
next2 = segment.getNext();
return this._handleOut.isZero() && next1._handleIn.isZero()
&& segment._handleOut.isZero() && next2._handleIn.isZero()
&& next1._point.subtract(this._point).isColinear(
&& next1._point.subtract(this._point).isCollinear(
next2._point.subtract(segment._point));
},
isColinear: '#isCollinear',
isOrthogonal: function() {
var prev = this.getPrevious(),
next = this.getNext();
@ -5699,6 +5728,8 @@ statics: {
},
evaluate: function(v, t, type) {
if (t == null || t < 0 || t > 1)
return null;
var p1x = v[0], p1y = v[1],
c1x = v[2], c1y = v[3],
c2x = v[4], c2y = v[5],
@ -5791,17 +5822,20 @@ statics: {
sx = Curve.solveCubic(v, 0, x, txs, 0, 1),
sy = Curve.solveCubic(v, 1, y, tys, 0, 1),
tx, ty;
for (var cx = 0; sx == -1 || cx < sx;) {
if (sx == -1 || (tx = txs[cx++]) >= 0 && tx <= 1) {
for (var cy = 0; sy == -1 || cy < sy;) {
if (sy == -1 || (ty = tys[cy++]) >= 0 && ty <= 1) {
if (sx == -1) tx = ty;
else if (sy == -1) ty = tx;
for (var cx = 0; sx === -1 || cx < sx;) {
if (sx === -1 || (tx = txs[cx++]) > 0 && tx < 1) {
for (var cy = 0; sy === -1 || cy < sy;) {
if (sy === -1 || (ty = tys[cy++]) > 0 && ty < 1) {
if (sx === -1) {
tx = ty;
} else if (sy === -1) {
ty = tx;
}
if (Math.abs(tx - ty) < tolerance)
return (tx + ty) * 0.5;
}
}
if (sx == -1)
if (sx === -1)
break;
}
}
@ -5930,9 +5964,10 @@ statics: {
},
getLocationAt: function(offset, isParameter) {
if (!isParameter)
offset = this.getParameterAt(offset);
return offset >= 0 && offset <= 1 && new CurveLocation(this, offset);
var t = isParameter ? offset : this.getParameterAt(offset);
return t != null && t >= 0 && t <= 1
? new CurveLocation(this, t)
: null;
},
getLocationOf: function() {
@ -6034,14 +6069,19 @@ new function() {
start = offset < 0 ? 1 : 0
if (offset === 0)
return start;
var forward = offset > 0,
var tolerance = 0.000001,
abs = Math.abs,
forward = offset > 0,
a = forward ? start : 0,
b = forward ? 1 : start,
ds = getLengthIntegrand(v),
rangeLength = Numerical.integrate(ds, a, b,
getIterations(a, b));
if (Math.abs(offset) >= rangeLength)
if (abs(offset - rangeLength) < tolerance) {
return forward ? b : a;
} else if (abs(offset) > rangeLength) {
return null;
}
var guess = offset / rangeLength,
length = 0;
function f(t) {
@ -6051,7 +6091,7 @@ new function() {
return length - offset;
}
return Numerical.findRoot(f, ds, start + guess, a, b, 16,
0.000001);
tolerance);
}
};
}, new function() {
@ -6079,7 +6119,7 @@ new function() {
dp2 = getSignedDistance(q0x, q0y, q3x, q3y, v1[4], v1[5]),
dp3 = getSignedDistance(q0x, q0y, q3x, q3y, v1[6], v1[7]),
tMinNew, tMaxNew, tDiff;
if (q0x === q3x && uMax - uMin <= tolerance && recursion > 3) {
if (q0x === q3x && uMax - uMin < tolerance && recursion > 3) {
tMaxNew = tMinNew = (tMax + tMin) / 2;
tDiff = 0;
} else {
@ -6322,16 +6362,18 @@ var CurveLocation = Base.extend({
initialize: function CurveLocation(curve, parameter, point, _curve2,
_parameter2, _point2, _distance) {
this._id = CurveLocation._id = (CurveLocation._id || 0) + 1;
this._id = UID.get(CurveLocation);
var path = curve._path;
this._version = path ? path._version : 0;
this._curve = curve;
this._segment1 = curve._segment1;
this._segment2 = curve._segment2;
this._parameter = parameter;
this._point = point;
this._point = point || curve.getPointAt(parameter, true);
this._curve2 = _curve2;
this._parameter2 = _parameter2;
this._point2 = _point2;
this._distance = _distance;
this._segment1 = curve._segment1;
this._segment2 = curve._segment2;
},
getSegment: function(_preferFirst) {
@ -6354,24 +6396,22 @@ var CurveLocation = Base.extend({
return this._segment;
},
getCurve: function(_uncached) {
if (!this._curve || _uncached) {
this._curve = this._segment1.getCurve();
if (this._curve.getParameterOf(this._point) == null)
this._curve = this._segment2.getPrevious().getCurve();
getCurve: function() {
var curve = this._curve,
path = curve && curve._path;
if (path && path._version !== this._version) {
curve = null;
this._parameter = null;
}
return this._curve;
},
getIntersection: function() {
var intersection = this._intersection;
if (!intersection && this._curve2) {
var param = this._parameter2;
this._intersection = intersection = new CurveLocation(
this._curve2, param, this._point2 || this._point, this);
intersection._intersection = this;
if (!curve) {
curve = this._segment1.getCurve();
if (curve.getParameterOf(this._point) == null)
curve = this._segment2.getPrevious().getCurve();
this._curve = curve;
path = curve._path;
this._version = path ? path._version : 0;
}
return intersection;
return curve;
},
getPath: function() {
@ -6384,6 +6424,18 @@ var CurveLocation = Base.extend({
return curve && curve.getIndex();
},
getParameter: function() {
var curve = this.getCurve(),
parameter = this._parameter;
return curve && parameter == null
? this._parameter = curve.getParameterOf(this._point)
: parameter;
},
getPoint: function() {
return this._point;
},
getOffset: function() {
var path = this.getPath();
return path ? path._getOffset(this) : this.getCurveOffset();
@ -6395,20 +6447,14 @@ var CurveLocation = Base.extend({
return parameter != null && curve && curve.getPartLength(0, parameter);
},
getParameter: function(_uncached) {
if ((this._parameter == null || _uncached) && this._point) {
var curve = this.getCurve(_uncached);
this._parameter = curve && curve.getParameterOf(this._point);
getIntersection: function() {
var intersection = this._intersection;
if (!intersection && this._curve2) {
this._intersection = intersection = new CurveLocation(this._curve2,
this._parameter2, this._point2 || this._point, this);
intersection._intersection = this;
}
return this._parameter;
},
getPoint: function(_uncached) {
if ((!this._point || _uncached) && this._parameter != null) {
var curve = this.getCurve(_uncached);
this._point = curve && curve.getPointAt(this._parameter, true);
}
return this._point;
return intersection;
},
getDistance: function() {
@ -6416,24 +6462,24 @@ var CurveLocation = Base.extend({
},
divide: function() {
var curve = this.getCurve(true);
return curve && curve.divide(this.getParameter(true), true);
var curve = this.getCurve();
return curve && curve.divide(this.getParameter(), true);
},
split: function() {
var curve = this.getCurve(true);
return curve && curve.split(this.getParameter(true), true);
var curve = this.getCurve();
return curve && curve.split(this.getParameter(), true);
},
equals: function(loc) {
var abs = Math.abs,
tolerance = 0.000001;
return this === loc
|| loc
&& this._curve === loc._curve
|| loc instanceof CurveLocation
&& this.getCurve() === loc.getCurve()
&& abs(this.getParameter() - loc.getParameter()) < tolerance
&& this._curve2 === loc._curve2
&& abs(this._parameter - loc._parameter) <= tolerance
&& abs(this._parameter2 - loc._parameter2) <= tolerance
&& abs(this._parameter2 - loc._parameter2) < tolerance
|| false;
},
@ -6567,8 +6613,6 @@ var PathItem = Item.extend({
case 'm':
case 'l':
var move = lower === 'm';
if (move && previous && previous !== 'z')
this.closePath(true);
for (var j = 0; j < length; j += 2)
this[j === 0 && move ? 'moveTo' : 'lineTo'](
current = getPoint(j));
@ -6657,6 +6701,7 @@ var Path = PathItem.extend({
initialize: function Path(arg) {
this._closed = false;
this._segments = [];
this._version = 0;
var segments = Array.isArray(arg)
? typeof arg[0] === 'object'
? arg
@ -6699,8 +6744,10 @@ var Path = PathItem.extend({
if (parent)
parent._currentPath = undefined;
this._length = this._clockwise = undefined;
if (this._curves && !(flags & 16)) {
for (var i = 0, l = this._curves.length; i < l; i++)
if (flags & 16) {
this._version++;
} else if (this._curves) {
for (var i = 0, l = this._curves.length; i < l; i++)
this._curves[i]._changed();
}
this._monoCurves = undefined;
@ -7175,8 +7222,8 @@ var Path = PathItem.extend({
radius,
topCenter;
function isColinear(i, j) {
return segments[i].isColinear(segments[j]);
function isCollinear(i, j) {
return segments[i].isCollinear(segments[j]);
}
function isOrthogonal(i) {
@ -7192,12 +7239,12 @@ var Path = PathItem.extend({
}
if (this.isPolygon() && segments.length === 4
&& isColinear(0, 2) && isColinear(1, 3) && isOrthogonal(1)) {
&& isCollinear(0, 2) && isCollinear(1, 3) && isOrthogonal(1)) {
type = Shape.Rectangle;
size = new Size(getDistance(0, 3), getDistance(0, 1));
topCenter = segments[1]._point.add(segments[2]._point).divide(2);
} else if (segments.length === 8 && isArc(0) && isArc(2) && isArc(4)
&& isArc(6) && isColinear(1, 5) && isColinear(3, 7)) {
&& isArc(6) && isCollinear(1, 5) && isCollinear(3, 7)) {
type = Shape.Rectangle;
size = new Size(getDistance(1, 6), getDistance(0, 3));
radius = size.subtract(new Size(getDistance(0, 7),
@ -7217,16 +7264,13 @@ var Path = PathItem.extend({
if (type) {
var center = this.getPosition(true),
shape = new type({
shape = this._clone(new type({
center: center,
size: size,
radius: radius,
insert: false
});
}), insert, false);
shape.rotate(topCenter.subtract(center).getAngle() + 90);
shape.setStyle(this._style);
if (insert || insert === undefined)
shape.insertAbove(this);
return shape;
}
return null;
@ -7989,7 +8033,7 @@ statics: {
var handleIn = segment._handleIn,
handleOut = segment._handleOut;
if (join === 'round' || !handleIn.isZero() && !handleOut.isZero()
&& handleIn.isColinear(handleOut)) {
&& handleIn.isCollinear(handleOut)) {
addRound(segment);
} else {
Path._addBevelJoin(segment, join, radius, miterLimit, add);
@ -8526,13 +8570,13 @@ PathItem.inject(new function() {
var node = chain[k],
curveLength = node.length;
if (length <= curveLength) {
if (length <= tolerance
|| curveLength - length <= tolerance)
if (length < tolerance
|| curveLength - length < tolerance)
length = curveLength / 2;
var curve = node.segment.getCurve(),
pt = curve.getPointAt(length),
hor = curve.isLinear() && Math.abs(curve
.getTangentAt(0.5, true).y) <= tolerance,
.getTangentAt(0.5, true).y) < tolerance,
path = curve._path;
if (path._parent instanceof CompoundPath)
path = path._parent;
@ -8659,7 +8703,7 @@ PathItem.inject(new function() {
if (!(t > tMax
&& (i === l - 1 || curve.next !== curves[i + 1])
&& abs(Curve.evaluate(curve.next.values, 0, 0).x -x)
<= tolerance
< tolerance
|| i > 0 && curve.previous === curves[i - 1]
&& abs(prevX - x) < tolerance
&& prevT > tMax && t < tMin)) {
@ -9093,18 +9137,19 @@ var PathFitter = Base.extend({
}
var uPrime = this.chordLengthParameterize(first, last),
maxError = Math.max(this.error, this.error * this.error),
split;
split,
parametersInOrder = true;
for (var i = 0; i <= 4; i++) {
var curve = this.generateBezier(first, last, uPrime, tan1, tan2);
var max = this.findMaxError(first, last, curve, uPrime);
if (max.error < this.error) {
if (max.error < this.error && parametersInOrder) {
this.addCurve(curve);
return;
}
split = max.index;
if (max.error >= maxError)
break;
this.reparameterize(first, last, uPrime, curve);
parametersInOrder = this.reparameterize(first, last, uPrime, curve);
maxError = max.error;
}
var V1 = this.points[split - 1].subtract(this.points[split]),
@ -9168,20 +9213,35 @@ var PathFitter = Base.extend({
}
}
var segLength = pt2.getDistance(pt1);
epsilon *= segLength;
if (alpha1 < epsilon || alpha2 < epsilon) {
var segLength = pt2.getDistance(pt1),
eps = epsilon * segLength,
handle1,
handle2;
if (alpha1 < eps || alpha2 < eps) {
alpha1 = alpha2 = segLength / 3;
} else {
var line = pt2.subtract(pt1);
handle1 = tan1.normalize(alpha1);
handle2 = tan2.normalize(alpha2);
if (handle1.dot(line) - handle2.dot(line) > segLength * segLength) {
alpha1 = alpha2 = segLength / 3;
handle1 = handle2 = null;
}
}
return [pt1, pt1.add(tan1.normalize(alpha1)),
pt2.add(tan2.normalize(alpha2)), pt2];
return [pt1, pt1.add(handle1 || tan1.normalize(alpha1)),
pt2.add(handle2 || tan2.normalize(alpha2)), pt2];
},
reparameterize: function(first, last, u, curve) {
for (var i = first; i <= last; i++) {
u[i - first] = this.findRoot(curve, this.points[i], u[i - first]);
}
for (var i = 1, l = u.length; i < l; i++) {
if (u[i] <= u[i - 1])
return false;
}
return true;
},
findRoot: function(curve, point, u) {
@ -9266,9 +9326,9 @@ var TextItem = Item.extend({
return this._content === item._content;
},
_clone: function _clone(copy, insert) {
_clone: function _clone(copy, insert, includeMatrix) {
copy.setContent(this._content);
return _clone.base.call(this, copy, insert);
return _clone.base.call(this, copy, insert, includeMatrix);
},
getContent: function() {
@ -9547,11 +9607,8 @@ var Color = Base.extend(new function() {
this._properties = types[type];
this._type = type;
}
value = parser.call(this, value);
if (value != null) {
this._components[index] = value;
this._changed();
}
this._components[index] = parser.call(this, value);
this._changed();
};
}, this);
}, {
@ -9659,8 +9716,7 @@ var Color = Base.extend(new function() {
read = 1;
}
this._type = type || 'rgb';
if (type === 'gradient')
this._id = Color._id = (Color._id || 0) + 1;
this._id = UID.get(Color);
if (!components) {
this._components = components = [];
var parsers = componentParsers[this._type];
@ -9897,7 +9953,7 @@ var Gradient = Base.extend({
_class: 'Gradient',
initialize: function Gradient(stops, radial) {
this._id = Gradient._id = (Gradient._id || 0) + 1;
this._id = UID.get();
if (stops && this._set(stops))
stops = radial = null;
if (!this._stops)
@ -9938,7 +9994,7 @@ var Gradient = Base.extend({
var stops = [];
for (var i = 0, l = this._stops.length; i < l; i++)
stops[i] = this._stops[i].clone();
return new Gradient(stops);
return new Gradient(stops, this._radial);
},
getStops: function() {
@ -10919,9 +10975,9 @@ var CanvasView = View.extend({
return width;
},
update: function() {
update: function(force) {
var project = this._project;
if (!project || !project._needsUpdate)
if (!project || !force && !project._needsUpdate)
return false;
var ctx = this._context,
size = this._viewSize;
@ -11336,9 +11392,9 @@ var Tool = PaperScopeItem.extend({
setMinDistance: function(minDistance) {
this._minDistance = minDistance;
if (this._minDistance != null && this._maxDistance != null
&& this._minDistance > this._maxDistance) {
this._maxDistance = this._minDistance;
if (minDistance != null && this._maxDistance != null
&& minDistance > this._maxDistance) {
this._maxDistance = minDistance;
}
},
@ -11348,8 +11404,8 @@ var Tool = PaperScopeItem.extend({
setMaxDistance: function(maxDistance) {
this._maxDistance = maxDistance;
if (this._minDistance != null && this._maxDistance != null
&& this._maxDistance < this._minDistance) {
if (this._minDistance != null && maxDistance != null
&& maxDistance < this._minDistance) {
this._minDistance = maxDistance;
}
},
@ -11373,10 +11429,9 @@ var Tool = PaperScopeItem.extend({
distance = vector.getLength();
if (distance < minDist)
return false;
var maxDist = maxDistance != null ? maxDistance : 0;
if (maxDist != 0) {
if (distance > maxDist) {
point = this._point.add(vector.normalize(maxDist));
if (maxDistance != null && maxDistance != 0) {
if (distance > maxDistance) {
point = this._point.add(vector.normalize(maxDistance));
} else if (matchMaxDistance) {
return false;
}
@ -11470,10 +11525,11 @@ var Tool = PaperScopeItem.extend({
});
var Http = {
request: function(method, url, callback) {
request: function(method, url, callback, async) {
async = (async === undefined) ? true : async;
var xhr = new (window.ActiveXObject || XMLHttpRequest)(
'Microsoft.XMLHTTP');
xhr.open(method.toUpperCase(), url, true);
xhr.open(method.toUpperCase(), url, async);
if ('overrideMimeType' in xhr)
xhr.overrideMimeType('text/plain');
xhr.onreadystatechange = function() {
@ -12270,10 +12326,17 @@ new function() {
item = applyAttributes(item, node, isRoot);
project._currentStyle = item._style.clone();
}
if (isRoot) {
var defs = node.querySelectorAll('defs');
for (var i = 0, l = defs.length; i < l; i++) {
importSVG(defs[i], options, false);
}
}
for (var i = 0, l = nodes.length; i < l; i++) {
var childNode = nodes[i],
child;
if (childNode.nodeType === 1
&& childNode.nodeName.toLowerCase() !== 'defs'
&& (child = importSVG(childNode, options, false))
&& !(child instanceof Symbol))
children.push(child);
@ -12473,7 +12536,7 @@ new function() {
color.setAlpha(parseFloat(value));
}
var attributes = Base.each(SVGStyles, function(entry) {
var attributes = Base.set(Base.each(SVGStyles, function(entry) {
this[entry.attribute] = function(item, value) {
item[entry.set](convertValue(value, entry.type, entry.fromSVG));
if (entry.type === 'color' && item instanceof Shape) {
@ -12483,7 +12546,7 @@ new function() {
item.getPosition(true).negate()));
}
};
}, {
}, {}), {
id: function(item, value) {
definitions[value] = item;
if (item.setName)
@ -12657,7 +12720,7 @@ new function() {
}
if (isRoot) {
definitions = {};
if (applyMatrix && item)
if (item && Base.pick(options.applyMatrix, applyMatrix))
item.matrix.apply(true, true);
}
return item;

File diff suppressed because one or more lines are too long

1
dist/paper-full.js vendored
View file

@ -1 +0,0 @@
../src/load.js

13086
dist/paper-full.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
dist/paper-node.js vendored
View file

@ -1 +0,0 @@
../src/load.js

12359
dist/paper-node.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

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

View file

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