Bump version to v0.9.14

This commit is contained in:
Jürg Lehni 2013-11-28 19:46:12 +01:00
parent c0e8285c07
commit afb326d16e
8 changed files with 665 additions and 338 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "paper", "name": "paper",
"version": "0.9.13", "version": "0.9.14",
"main": "dist/paper.js", "main": "dist/paper.js",
"ignore": [ "ignore": [
"build", "build",

225
dist/paper-core.js vendored
View file

@ -1,5 +1,5 @@
/*! /*!
* Paper.js v0.9.13 - The Swiss Army Knife of Vector Graphics Scripting. * Paper.js v0.9.14 - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/ * http://paperjs.org/
* *
* Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey * Copyright (c) 2011 - 2013, Juerg Lehni & Jonathan Puckey
@ -9,7 +9,7 @@
* *
* All rights reserved. * All rights reserved.
* *
* Date: Tue Nov 26 17:33:03 2013 +0100 * Date: Thu Nov 28 18:03:41 2013 +0100
* *
*** ***
* *
@ -630,11 +630,28 @@ var Callback = {
var handlers = this._handlers && this._handlers[type]; var handlers = this._handlers && this._handlers[type];
if (!handlers) if (!handlers)
return false; return false;
var args = [].slice.call(arguments, 1); var args = [].slice.call(arguments, 1),
Base.each(handlers, function(func) { PaperScript = paper.PaperScript,
if (func.apply(this, args) === false && event && event.stop) handleException = PaperScript && PaperScript.handleException,
event.stop(); that = this;
}, this);
function callHandlers() {
for (var i in handlers) {
if (handlers[i].apply(that, args) === false
&& event && event.stop)
event.stop();
}
}
if (handleException) {
try {
callHandlers();
} catch (e) {
handleException(e);
}
} else {
callHandlers();
}
return true; return true;
}, },
@ -705,7 +722,7 @@ var PaperScope = Base.extend({
} }
}, },
version: '0.9.13', version: '0.9.14',
getView: function() { getView: function() {
return this.project && this.project.view; return this.project && this.project.view;
@ -1172,9 +1189,9 @@ var Point = Base.extend({
getAngleInRadians: function() { getAngleInRadians: function() {
if (arguments[0] === undefined) { if (arguments[0] === undefined) {
if (this._angle == null) return this.isZero()
this._angle = Math.atan2(this.y, this.x); ? this._angle || 0
return this._angle; : this._angle = Math.atan2(this.y, this.x);
} else { } else {
var point = Point.read(arguments), var point = Point.read(arguments),
div = this.getLength() * point.getLength(); div = this.getLength() * point.getLength();
@ -1298,10 +1315,10 @@ var LinkedPoint = Point.extend({
this._setter = setter; this._setter = setter;
}, },
set: function(x, y, dontNotify) { set: function(x, y, _dontNotify) {
this._x = x; this._x = x;
this._y = y; this._y = y;
if (!dontNotify) if (!_dontNotify)
this._owner[this._setter](this); this._owner[this._setter](this);
return this; return this;
}, },
@ -1459,10 +1476,10 @@ var LinkedSize = Size.extend({
this._setter = setter; this._setter = setter;
}, },
set: function(width, height, dontNotify) { set: function(width, height, _dontNotify) {
this._width = width; this._width = width;
this._height = height; this._height = height;
if (!dontNotify) if (!_dontNotify)
this._owner[this._setter](this); this._owner[this._setter](this);
return this; return this;
}, },
@ -1815,12 +1832,12 @@ var LinkedRectangle = Rectangle.extend({
this._setter = setter; this._setter = setter;
}, },
set: function(x, y, width, height, dontNotify) { set: function(x, y, width, height, _dontNotify) {
this._x = x; this._x = x;
this._y = y; this._y = y;
this._width = width; this._width = width;
this._height = height; this._height = height;
if (!dontNotify) if (!_dontNotify)
this._owner[this._setter](this); this._owner[this._setter](this);
return this; return this;
} }
@ -1892,13 +1909,15 @@ var Matrix = Base.extend({
throw new Error('Unsupported matrix parameters'); throw new Error('Unsupported matrix parameters');
}, },
set: function(a, c, b, d, tx, ty) { set: function(a, c, b, d, tx, ty, _dontNotify) {
this._a = a; this._a = a;
this._c = c; this._c = c;
this._b = b; this._b = b;
this._d = d; this._d = d;
this._tx = tx; this._tx = tx;
this._ty = ty; this._ty = ty;
if (!_dontNotify)
this._changed();
return this; return this;
}, },
@ -1906,6 +1925,11 @@ var Matrix = Base.extend({
return Base.serialize(this.getValues(), options); return Base.serialize(this.getValues(), options);
}, },
_changed: function() {
if (this._owner)
this._owner._changed(5);
},
clone: function() { clone: function() {
return new Matrix(this._a, this._c, this._b, this._d, return new Matrix(this._a, this._c, this._b, this._d,
this._tx, this._ty); this._tx, this._ty);
@ -1929,6 +1953,7 @@ var Matrix = Base.extend({
reset: function() { reset: function() {
this._a = this._d = 1; this._a = this._d = 1;
this._c = this._b = this._tx = this._ty = 0; this._c = this._b = this._tx = this._ty = 0;
this._changed();
return this; return this;
}, },
@ -1943,6 +1968,7 @@ var Matrix = Base.extend({
this._d *= scale.y; this._d *= scale.y;
if (center) if (center)
this.translate(center.negate()); this.translate(center.negate());
this._changed();
return this; return this;
}, },
@ -1952,6 +1978,7 @@ var Matrix = Base.extend({
y = point.y; y = point.y;
this._tx += x * this._a + y * this._b; this._tx += x * this._a + y * this._b;
this._ty += x * this._c + y * this._d; this._ty += x * this._c + y * this._d;
this._changed();
return this; return this;
}, },
@ -1974,6 +2001,7 @@ var Matrix = Base.extend({
this._d = -sin * c + cos * d; this._d = -sin * c + cos * d;
this._tx += tx * a + ty * b; this._tx += tx * a + ty * b;
this._ty += tx * c + ty * d; this._ty += tx * c + ty * d;
this._changed();
return this; return this;
}, },
@ -1990,6 +2018,7 @@ var Matrix = Base.extend({
this._d += point.x * c; this._d += point.x * c;
if (center) if (center)
this.translate(center.negate()); this.translate(center.negate());
this._changed();
return this; return this;
}, },
@ -2004,6 +2033,7 @@ var Matrix = Base.extend({
this._d = mx._b * c + mx._d * d; this._d = mx._b * c + mx._d * d;
this._tx += mx._tx * a + mx._ty * b; this._tx += mx._tx * a + mx._ty * b;
this._ty += mx._tx * c + mx._ty * d; this._ty += mx._tx * c + mx._ty * d;
this._changed();
return this; return this;
}, },
@ -2020,12 +2050,13 @@ var Matrix = Base.extend({
this._d = mx._c * b + mx._d * d; this._d = mx._c * b + mx._d * d;
this._tx = mx._a * tx + mx._b * ty + mx._tx; this._tx = mx._a * tx + mx._b * ty + mx._tx;
this._ty = mx._c * tx + mx._d * ty + mx._ty; this._ty = mx._c * tx + mx._d * ty + mx._ty;
this._changed();
return this; return this;
}, },
isIdentity: function() { isIdentity: function() {
return this._a == 1 && this._c == 0 && this._b == 0 && this._d == 1 return this._a === 1 && this._c === 0 && this._b === 0 && this._d === 1
&& this._tx == 0 && this._ty == 0; && this._tx === 0 && this._ty === 0;
}, },
isInvertible: function() { isInvertible: function() {
@ -2042,7 +2073,7 @@ var Matrix = Base.extend({
: this._transformCoordinates(src, srcOffset, dst, dstOffset, count); : this._transformCoordinates(src, srcOffset, dst, dstOffset, count);
}, },
_transformPoint: function(point, dest, dontNotify) { _transformPoint: function(point, dest, _dontNotify) {
var x = point.x, var x = point.x,
y = point.y; y = point.y;
if (!dest) if (!dest)
@ -2050,7 +2081,7 @@ var Matrix = Base.extend({
return dest.set( return dest.set(
x * this._a + y * this._b + this._tx, x * this._a + y * this._b + this._tx,
x * this._c + y * this._d + this._ty, x * this._c + y * this._d + this._ty,
dontNotify _dontNotify
); );
}, },
@ -2076,7 +2107,7 @@ var Matrix = Base.extend({
return this._transformCoordinates(coords, 0, coords, 0, 4); return this._transformCoordinates(coords, 0, coords, 0, 4);
}, },
_transformBounds: function(bounds, dest, dontNotify) { _transformBounds: function(bounds, dest, _dontNotify) {
var coords = this._transformCorners(bounds), var coords = this._transformCorners(bounds),
min = coords.slice(0, 2), min = coords.slice(0, 2),
max = coords.slice(); max = coords.slice();
@ -2091,7 +2122,7 @@ var Matrix = Base.extend({
if (!dest) if (!dest)
dest = new Rectangle(); dest = new Rectangle();
return dest.set(min[0], min[1], max[0] - min[0], max[1] - min[1], return dest.set(min[0], min[1], max[0] - min[0], max[1] - min[1],
dontNotify); _dontNotify);
}, },
inverseTransform: function() { inverseTransform: function() {
@ -2105,7 +2136,7 @@ var Matrix = Base.extend({
? det : null; ? det : null;
}, },
_inverseTransform: function(point, dest, dontNotify) { _inverseTransform: function(point, dest, _dontNotify) {
var det = this._getDeterminant(); var det = this._getDeterminant();
if (!det) if (!det)
return null; return null;
@ -2116,7 +2147,7 @@ var Matrix = Base.extend({
return dest.set( return dest.set(
(x * this._d - y * this._b) / det, (x * this._d - y * this._b) / det,
(y * this._a - x * this._c) / det, (y * this._a - x * this._c) / det,
dontNotify _dontNotify
); );
}, },
@ -2161,14 +2192,36 @@ var Matrix = Base.extend({
return new Point(this._tx, this._ty); return new Point(this._tx, this._ty);
}, },
setTranslation: function() {
var point = Point.read(arguments);
this._tx = point.x;
this._ty = point.y;
this._changed();
},
getScaling: function() { getScaling: function() {
return (this.decompose() || {}).scaling; return (this.decompose() || {}).scaling;
}, },
setScaling: function() {
var scaling = this.getScaling();
if (scaling != null) {
var scale = Point.read(arguments);
(this._owner || this).scale(
scale.x / scaling.x, scale.y / scaling.y);
}
},
getRotation: function() { getRotation: function() {
return (this.decompose() || {}).rotation; return (this.decompose() || {}).rotation;
}, },
setRotation: function(angle) {
var rotation = this.getRotation();
if (rotation != null)
(this._owner || this).rotate(angle - rotation);
},
inverted: function() { inverted: function() {
var det = this._getDeterminant(); var det = this._getDeterminant();
return det && new Matrix( return det && new Matrix(
@ -2202,6 +2255,7 @@ var Matrix = Base.extend({
}; };
this['set' + name] = function(value) { this['set' + name] = function(value) {
this[prop] = value; this[prop] = value;
this._changed();
}; };
}, {}); }, {});
}); });
@ -2608,9 +2662,10 @@ var Item = Base.extend(Callback, {
} }
} }
this._style = new Style(this._project._currentStyle, this); this._style = new Style(this._project._currentStyle, this);
this._matrix = new Matrix(); var matrix = this._matrix = new Matrix();
if (point) if (point)
this._matrix.translate(point); matrix.translate(point);
matrix._owner = this;
return props ? this._set(props, { insert: true }) : true; return props ? this._set(props, { insert: true }) : true;
}, },
@ -2663,10 +2718,10 @@ var Item = Base.extend(Callback, {
}, { }, {
onFrame: { onFrame: {
install: function() { install: function() {
this._project.view._animateItem(this, true); this._animateItem(true);
}, },
uninstall: function() { uninstall: function() {
this._project.view._animateItem(this, false); this._animateItem(false);
} }
}, },
@ -2675,6 +2730,10 @@ var Item = Base.extend(Callback, {
); );
}, },
_animateItem: function(animate) {
this._project.view._animateItem(this, animate);
},
_serialize: function(options, dictionary) { _serialize: function(options, dictionary) {
var props = {}, var props = {},
that = this; that = this;
@ -2894,36 +2953,6 @@ var Item = Base.extend(Callback, {
setPosition: function() { setPosition: function() {
this.translate(Point.read(arguments).subtract(this.getPosition(true))); this.translate(Point.read(arguments).subtract(this.getPosition(true)));
},
getMatrix: function() {
return this._matrix;
},
setMatrix: function(matrix) {
this._matrix.initialize(matrix);
if (this._transformContent)
this.applyMatrix(true);
this._changed(5);
},
getGlobalMatrix: function() {
return this._drawCount === this._project._drawCount
&& this._globalMatrix || null;
},
globalToLocal: function() {
var matrix = this.getGlobalMatrix();
return matrix && matrix._transformPoint(Point.read(arguments));
},
localToGlobal: function() {
var matrix = this.getGlobalMatrix();
return matrix && matrix._inverseTransform(Point.read(arguments));
},
isEmpty: function() {
return !this._children || this._children.length == 0;
} }
}, Base.each(['getBounds', 'getStrokeBounds', 'getHandleBounds', 'getRoughBounds'], }, Base.each(['getBounds', 'getStrokeBounds', 'getHandleBounds', 'getRoughBounds'],
function(name) { function(name) {
@ -3020,13 +3049,44 @@ var Item = Base.extend(Callback, {
} }
}), { }), {
getMatrix: function() {
return this._matrix;
},
setMatrix: function(matrix) {
this._matrix.initialize(matrix);
if (this._transformContent)
this.applyMatrix(true);
this._changed(5);
},
getGlobalMatrix: function() {
return this._drawCount === this._project._drawCount
&& this._globalMatrix || null;
},
getTransformContent: function() {
return this._transformContent;
},
setTransformContent: function(transform) {
this._transformContent = transform;
if (transform)
this.applyMatrix();
},
getProject: function() { getProject: function() {
return this._project; return this._project;
}, },
_setProject: function(project) { _setProject: function(project) {
if (this._project != project) { if (this._project != project) {
var hasOnFrame = this.responds('frame');
if (hasOnFrame)
this._animateItem(false);
this._project = project; this._project = project;
if (hasOnFrame)
this._animateItem(true);
if (this._children) { if (this._children) {
for (var i = 0, l = this._children.length; i < l; i++) { for (var i = 0, l = this._children.length; i < l; i++) {
this._children[i]._setProject(project); this._children[i]._setProject(project);
@ -3413,6 +3473,8 @@ var Item = Base.extend(Callback, {
this._removeNamed(); this._removeNamed();
if (this._index != null) if (this._index != null)
Base.splice(this._parent._children, null, this._index, 1); Base.splice(this._parent._children, null, this._index, 1);
if (this.responds('frame'))
this._animateItem(false);
if (notify) if (notify)
this._parent._changed(7); this._parent._changed(7);
this._parent = null; this._parent = null;
@ -3449,6 +3511,10 @@ var Item = Base.extend(Callback, {
} }
}, },
isEmpty: function() {
return !this._children || this._children.length == 0;
},
isEditable: function() { isEditable: function() {
var item = this; var item = this;
while (item) { while (item) {
@ -3598,6 +3664,16 @@ var Item = Base.extend(Callback, {
this._changed(5); this._changed(5);
}, },
globalToLocal: function() {
var matrix = this.getGlobalMatrix();
return matrix && matrix._transformPoint(Point.read(arguments));
},
localToGlobal: function() {
var matrix = this.getGlobalMatrix();
return matrix && matrix._inverseTransform(Point.read(arguments));
},
fitBounds: function(rectangle, fill) { fitBounds: function(rectangle, fill) {
rectangle = Rectangle.read(arguments); rectangle = Rectangle.read(arguments);
var bounds = this.getBounds(), var bounds = this.getBounds(),
@ -3773,16 +3849,6 @@ var Group = Item.extend({
return this._clipItem = null; return this._clipItem = null;
}, },
getTransformContent: function() {
return this._transformContent;
},
setTransformContent: function(transform) {
this._transformContent = transform;
if (transform)
this.applyMatrix();
},
isClipped: function() { isClipped: function() {
return !!this._getClipItem(); return !!this._getClipItem();
}, },
@ -3933,6 +3999,7 @@ var Shape = Item.extend({
if (radius === this._radius) if (radius === this._radius)
return; return;
var size = radius * 2; var size = radius * 2;
this._radius = radius;
this._size.set(size, size); this._size.set(size, size);
} else { } else {
radius = Size.read(arguments); radius = Size.read(arguments);
@ -6832,7 +6899,7 @@ var Path = PathItem.extend({
} }
} }
} }
return !loc && options.fill && this.hasFill() && this.contains(point) return !loc && options.fill && this.hasFill() && this._contains(point)
? new HitResult('fill', this) ? new HitResult('fill', this)
: loc : loc
? new HitResult('stroke', this, { location: loc }) ? new HitResult('stroke', this, { location: loc })
@ -9583,7 +9650,7 @@ var View = Base.extend(Callback, {
View._views.push(this); View._views.push(this);
View._viewsById[this._id] = this; View._viewsById[this._id] = this;
this._viewSize = size; this._viewSize = size;
this._matrix = new Matrix(); (this._matrix = new Matrix())._owner = this;
this._zoom = 1; this._zoom = 1;
if (!View._focused) if (!View._focused)
View._focused = this; View._focused = this;
@ -9611,10 +9678,9 @@ var View = Base.extend(Callback, {
_events: { _events: {
onFrame: { onFrame: {
install: function() { install: function() {
if (!this._requested) { this._animate = true;
this._animate = true; if (!this._requested)
this._requestFrame(); this._requestFrame();
}
}, },
uninstall: function() { uninstall: function() {
@ -9631,6 +9697,7 @@ var View = Base.extend(Callback, {
_requestFrame: function() { _requestFrame: function() {
var that = this; var that = this;
this._requested = true;
DomEvent.requestAnimationFrame(function() { DomEvent.requestAnimationFrame(function() {
that._requested = false; that._requested = false;
if (!that._animate) if (!that._animate)
@ -9638,7 +9705,6 @@ var View = Base.extend(Callback, {
that._requestFrame(); that._requestFrame();
that._handleFrame(); that._handleFrame();
}, this._element); }, this._element);
this._requested = true;
}, },
_handleFrame: function() { _handleFrame: function() {
@ -9697,6 +9763,11 @@ var View = Base.extend(Callback, {
} }
}, },
_changed: function(flags) {
if (flags & 1)
this._project._needsRedraw = true;
},
_transform: function(matrix) { _transform: function(matrix) {
this._matrix.concatenate(matrix); this._matrix.concatenate(matrix);
this._bounds = null; this._bounds = null;
@ -10148,7 +10219,7 @@ var Key = new function() {
if ((name = Base.camelize(key)) in modifiers) if ((name = Base.camelize(key)) in modifiers)
modifiers[name] = true; modifiers[name] = true;
charCodeMap[code] = 0; charCodeMap[code] = 0;
handleKey(true, code, null, event); handleKey(true, code, code, event);
} else { } else {
downCode = code; downCode = code;
} }

File diff suppressed because one or more lines are too long

259
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

222
dist/paper-node.js vendored

File diff suppressed because one or more lines are too long

259
dist/paper.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{ {
"name": "paper", "name": "paper",
"version": "0.9.13", "version": "0.9.14",
"description": "The Swiss Army Knife of Vector Graphics Scripting", "description": "The Swiss Army Knife of Vector Graphics Scripting",
"homepage": "http://paperjs.org", "homepage": "http://paperjs.org",
"repository": "git://github.com/paperjs/paper.js", "repository": "git://github.com/paperjs/paper.js",