mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Bump version to v0.9.8
This commit is contained in:
parent
3ebfc94e87
commit
a9cf4a373b
8 changed files with 986 additions and 530 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "paper",
|
"name": "paper",
|
||||||
"version": "0.9.7",
|
"version": "0.9.8",
|
||||||
"main": "dist/paper.js",
|
"main": "dist/paper.js",
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"build",
|
"build",
|
||||||
|
|
351
dist/paper-core.js
vendored
351
dist/paper-core.js
vendored
|
@ -1,5 +1,5 @@
|
||||||
/*!
|
/*!
|
||||||
* Paper.js v0.9.7 - The Swiss Army Knife of Vector Graphics Scripting.
|
* Paper.js v0.9.8 - 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: Thu Jun 27 14:31:03 2013 -0700
|
* Date: Wed Jul 3 12:14:01 2013 -0700
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -92,7 +92,7 @@ var Base = new function() {
|
||||||
var val = val || (val = describe(src, name))
|
var val = val || (val = describe(src, name))
|
||||||
&& (val.get ? val : val.value);
|
&& (val.get ? val : val.value);
|
||||||
if (typeof val === 'string' && val[0] === '#')
|
if (typeof val === 'string' && val[0] === '#')
|
||||||
val = src[val.substring(1)] || val;
|
val = dest[val.substring(1)] || val;
|
||||||
var isFunc = typeof val === 'function',
|
var isFunc = typeof val === 'function',
|
||||||
res = val,
|
res = val,
|
||||||
prev = preserve || isFunc
|
prev = preserve || isFunc
|
||||||
|
@ -331,11 +331,11 @@ Base.inject({
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
read: function(list, start, length, readNull, clone) {
|
read: function(list, start, length, options) {
|
||||||
if (this === Base) {
|
if (this === Base) {
|
||||||
var value = this.peek(list, start);
|
var value = this.peek(list, start);
|
||||||
list._index++;
|
list._index++;
|
||||||
list._read = 1;
|
list.__read = 1;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
var proto = this.prototype,
|
var proto = this.prototype,
|
||||||
|
@ -344,21 +344,26 @@ Base.inject({
|
||||||
if (!length)
|
if (!length)
|
||||||
length = list.length - index;
|
length = list.length - index;
|
||||||
var obj = list[index];
|
var obj = list[index];
|
||||||
if (obj instanceof this || readNull && obj == null && length <= 1) {
|
if (obj instanceof this
|
||||||
|
|| options && options.readNull && obj == null && length <= 1) {
|
||||||
if (readIndex)
|
if (readIndex)
|
||||||
list._index = index + 1;
|
list._index = index + 1;
|
||||||
return obj && clone ? obj.clone() : obj;
|
return obj && options && options.clone ? obj.clone() : obj;
|
||||||
}
|
}
|
||||||
obj = Base.create(this);
|
obj = Base.create(this);
|
||||||
if (readIndex)
|
if (readIndex)
|
||||||
obj._read = true;
|
obj.__read = true;
|
||||||
|
if (options)
|
||||||
|
obj.__options = options;
|
||||||
obj = obj.initialize.apply(obj, index > 0 || length < list.length
|
obj = obj.initialize.apply(obj, index > 0 || length < list.length
|
||||||
? Array.prototype.slice.call(list, index, index + length)
|
? Array.prototype.slice.call(list, index, index + length)
|
||||||
: list) || obj;
|
: list) || obj;
|
||||||
if (readIndex) {
|
if (readIndex) {
|
||||||
list._index = index + obj._read;
|
list._index = index + obj.__read;
|
||||||
list._read = obj._read;
|
list.__read = obj.__read;
|
||||||
delete obj._read;
|
delete obj.__read;
|
||||||
|
if (options)
|
||||||
|
delete obj.__options;
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
},
|
},
|
||||||
|
@ -367,20 +372,20 @@ Base.inject({
|
||||||
return list[list._index = start || list._index || 0];
|
return list[list._index = start || list._index || 0];
|
||||||
},
|
},
|
||||||
|
|
||||||
readAll: function(list, start, readNull, clone) {
|
readAll: function(list, start, options) {
|
||||||
var res = [], entry;
|
var res = [], entry;
|
||||||
for (var i = start || 0, l = list.length; i < l; i++) {
|
for (var i = start || 0, l = list.length; i < l; i++) {
|
||||||
res.push(Array.isArray(entry = list[i])
|
res.push(Array.isArray(entry = list[i])
|
||||||
? this.read(entry, 0, 0, readNull, clone)
|
? this.read(entry, 0, 0, options)
|
||||||
: this.read(list, i, 1, readNull, clone));
|
: this.read(list, i, 1, options));
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
readNamed: function(list, name, start, length, readNull, clone) {
|
readNamed: function(list, name, start, length, options) {
|
||||||
var value = this.getNamed(list, name);
|
var value = this.getNamed(list, name);
|
||||||
return this.read(value != null ? [value] : list, start, length,
|
return this.read(value != null ? [value] : list, start, length,
|
||||||
readNull, clone);
|
options);
|
||||||
},
|
},
|
||||||
|
|
||||||
getNamed: function(list, name) {
|
getNamed: function(list, name) {
|
||||||
|
@ -670,7 +675,7 @@ var PaperScope = Base.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
version: '0.9.7',
|
version: '0.9.8',
|
||||||
|
|
||||||
getView: function() {
|
getView: function() {
|
||||||
return this.project && this.project.view;
|
return this.project && this.project.view;
|
||||||
|
@ -967,12 +972,12 @@ var Point = Base.extend({
|
||||||
var hasY = typeof arg1 === 'number';
|
var hasY = typeof arg1 === 'number';
|
||||||
this.x = arg0;
|
this.x = arg0;
|
||||||
this.y = hasY ? arg1 : arg0;
|
this.y = hasY ? arg1 : arg0;
|
||||||
if (this._read)
|
if (this.__read)
|
||||||
this._read = hasY ? 2 : 1;
|
this.__read = hasY ? 2 : 1;
|
||||||
} else if (type === 'undefined' || arg0 === null) {
|
} else if (type === 'undefined' || arg0 === null) {
|
||||||
this.x = this.y = 0;
|
this.x = this.y = 0;
|
||||||
if (this._read)
|
if (this.__read)
|
||||||
this._read = arg0 === null ? 1 : 0;
|
this.__read = arg0 === null ? 1 : 0;
|
||||||
} else {
|
} else {
|
||||||
if (Array.isArray(arg0)) {
|
if (Array.isArray(arg0)) {
|
||||||
this.x = arg0[0];
|
this.x = arg0[0];
|
||||||
|
@ -989,11 +994,11 @@ var Point = Base.extend({
|
||||||
this.setAngle(arg0.angle);
|
this.setAngle(arg0.angle);
|
||||||
} else {
|
} else {
|
||||||
this.x = this.y = 0;
|
this.x = this.y = 0;
|
||||||
if (this._read)
|
if (this.__read)
|
||||||
this._read = 0;
|
this.__read = 0;
|
||||||
}
|
}
|
||||||
if (this._read)
|
if (this.__read)
|
||||||
this._read = 1;
|
this.__read = 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1229,15 +1234,12 @@ var Point = Base.extend({
|
||||||
return new Point(Math.random(), Math.random());
|
return new Point(Math.random(), Math.random());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new function() {
|
}, Base.each(['round', 'ceil', 'floor', 'abs'], function(name) {
|
||||||
|
var op = Math[name];
|
||||||
return Base.each(['round', 'ceil', 'floor', 'abs'], function(name) {
|
this[name] = function() {
|
||||||
var op = Math[name];
|
return new Point(op(this.x), op(this.y));
|
||||||
this[name] = function() {
|
};
|
||||||
return new Point(op(this.x), op(this.y));
|
}, {}));
|
||||||
};
|
|
||||||
}, {});
|
|
||||||
});
|
|
||||||
|
|
||||||
var LinkedPoint = Point.extend({
|
var LinkedPoint = Point.extend({
|
||||||
initialize: function Point(x, y, owner, setter) {
|
initialize: function Point(x, y, owner, setter) {
|
||||||
|
@ -1284,12 +1286,12 @@ var Size = Base.extend({
|
||||||
var hasHeight = typeof arg1 === 'number';
|
var hasHeight = typeof arg1 === 'number';
|
||||||
this.width = arg0;
|
this.width = arg0;
|
||||||
this.height = hasHeight ? arg1 : arg0;
|
this.height = hasHeight ? arg1 : arg0;
|
||||||
if (this._read)
|
if (this.__read)
|
||||||
this._read = hasHeight ? 2 : 1;
|
this.__read = hasHeight ? 2 : 1;
|
||||||
} else if (type === 'undefined' || arg0 === null) {
|
} else if (type === 'undefined' || arg0 === null) {
|
||||||
this.width = this.height = 0;
|
this.width = this.height = 0;
|
||||||
if (this._read)
|
if (this.__read)
|
||||||
this._read = arg0 === null ? 1 : 0;
|
this.__read = arg0 === null ? 1 : 0;
|
||||||
} else {
|
} else {
|
||||||
if (Array.isArray(arg0)) {
|
if (Array.isArray(arg0)) {
|
||||||
this.width = arg0[0];
|
this.width = arg0[0];
|
||||||
|
@ -1302,11 +1304,11 @@ var Size = Base.extend({
|
||||||
this.height = arg0.y;
|
this.height = arg0.y;
|
||||||
} else {
|
} else {
|
||||||
this.width = this.height = 0;
|
this.width = this.height = 0;
|
||||||
if (this._read)
|
if (this.__read)
|
||||||
this._read = 0;
|
this.__read = 0;
|
||||||
}
|
}
|
||||||
if (this._read)
|
if (this.__read)
|
||||||
this._read = 1;
|
this.__read = 1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1393,15 +1395,12 @@ var Size = Base.extend({
|
||||||
return new Size(Math.random(), Math.random());
|
return new Size(Math.random(), Math.random());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new function() {
|
}, Base.each(['round', 'ceil', 'floor', 'abs'], function(name) {
|
||||||
|
var op = Math[name];
|
||||||
return Base.each(['round', 'ceil', 'floor', 'abs'], function(name) {
|
this[name] = function() {
|
||||||
var op = Math[name];
|
return new Size(op(this.width), op(this.height));
|
||||||
this[name] = function() {
|
};
|
||||||
return new Size(op(this.width), op(this.height));
|
}, {}));
|
||||||
};
|
|
||||||
}, {});
|
|
||||||
});
|
|
||||||
|
|
||||||
var LinkedSize = Size.extend({
|
var LinkedSize = Size.extend({
|
||||||
initialize: function Size(width, height, owner, setter) {
|
initialize: function Size(width, height, owner, setter) {
|
||||||
|
@ -1497,8 +1496,8 @@ var Rectangle = Base.extend({
|
||||||
}
|
}
|
||||||
read = arguments._index;
|
read = arguments._index;
|
||||||
}
|
}
|
||||||
if (this._read)
|
if (this.__read)
|
||||||
this._read = read;
|
this.__read = read;
|
||||||
},
|
},
|
||||||
|
|
||||||
set: function(x, y, width, height) {
|
set: function(x, y, width, height) {
|
||||||
|
@ -1886,7 +1885,7 @@ var Matrix = Base.extend({
|
||||||
|
|
||||||
scale: function() {
|
scale: function() {
|
||||||
var scale = Point.read(arguments),
|
var scale = Point.read(arguments),
|
||||||
center = Point.read(arguments, 0, 0, true);
|
center = Point.read(arguments, 0, 0, { readNull: true });
|
||||||
if (center)
|
if (center)
|
||||||
this.translate(center);
|
this.translate(center);
|
||||||
this._a *= scale.x;
|
this._a *= scale.x;
|
||||||
|
@ -1931,7 +1930,7 @@ var Matrix = Base.extend({
|
||||||
|
|
||||||
shear: function() {
|
shear: function() {
|
||||||
var point = Point.read(arguments),
|
var point = Point.read(arguments),
|
||||||
center = Point.read(arguments, 0, 0, true);
|
center = Point.read(arguments, 0, 0, { readNull: true });
|
||||||
if (center)
|
if (center)
|
||||||
this.translate(center);
|
this.translate(center);
|
||||||
var a = this._a,
|
var a = this._a,
|
||||||
|
@ -3071,6 +3070,10 @@ var Item = Base.extend(Callback, {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
importJSON: function(json) {
|
||||||
|
return this.addChild(Base.importJSON(json));
|
||||||
|
},
|
||||||
|
|
||||||
addChild: function(item, _preserve) {
|
addChild: function(item, _preserve) {
|
||||||
return this.insertChild(undefined, item, _preserve);
|
return this.insertChild(undefined, item, _preserve);
|
||||||
},
|
},
|
||||||
|
@ -3363,10 +3366,6 @@ var Item = Base.extend(Callback, {
|
||||||
this.setBounds(newBounds);
|
this.setBounds(newBounds);
|
||||||
},
|
},
|
||||||
|
|
||||||
importJSON: function(json) {
|
|
||||||
return this.addChild(Base.importJSON(json));
|
|
||||||
},
|
|
||||||
|
|
||||||
_setStyles: function(ctx) {
|
_setStyles: function(ctx) {
|
||||||
var style = this._style,
|
var style = this._style,
|
||||||
width = style.getStrokeWidth(),
|
width = style.getStrokeWidth(),
|
||||||
|
@ -3615,6 +3614,29 @@ var Shape = Item.extend({
|
||||||
this._size = size;
|
this._size = size;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getSize: function() {
|
||||||
|
var size = this._size;
|
||||||
|
return new LinkedSize(size.width, size.height, this, 'setSize');
|
||||||
|
},
|
||||||
|
|
||||||
|
setSize: function() {
|
||||||
|
var size = Size.read(arguments);
|
||||||
|
if (!this._size.equals(size)) {
|
||||||
|
this._size.set(size.width, size.height);
|
||||||
|
this._changed(5);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getRadius: function() {
|
||||||
|
var size = this._size;
|
||||||
|
return (size.width + size.height) / 4;
|
||||||
|
},
|
||||||
|
|
||||||
|
setRadius: function(radius) {
|
||||||
|
var size = radius * 2;
|
||||||
|
this.setSize(size, size);
|
||||||
|
},
|
||||||
|
|
||||||
_draw: function(ctx, param) {
|
_draw: function(ctx, param) {
|
||||||
var style = this._style,
|
var style = this._style,
|
||||||
size = this._size,
|
size = this._size,
|
||||||
|
@ -3776,7 +3798,8 @@ var Raster = Item.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getSize: function() {
|
getSize: function() {
|
||||||
return this._size;
|
var size = this._size;
|
||||||
|
return new LinkedSize(size.width, size.height, this, 'setSize');
|
||||||
},
|
},
|
||||||
|
|
||||||
setSize: function() {
|
setSize: function() {
|
||||||
|
@ -3996,7 +4019,7 @@ var Raster = Item.extend({
|
||||||
getImageData: function(rect) {
|
getImageData: function(rect) {
|
||||||
rect = Rectangle.read(arguments);
|
rect = Rectangle.read(arguments);
|
||||||
if (rect.isEmpty())
|
if (rect.isEmpty())
|
||||||
rect = new Rectangle(this.getSize());
|
rect = new Rectangle(this._size);
|
||||||
return this.getContext().getImageData(rect.x, rect.y,
|
return this.getContext().getImageData(rect.x, rect.y,
|
||||||
rect.width, rect.height);
|
rect.width, rect.height);
|
||||||
},
|
},
|
||||||
|
@ -4600,10 +4623,19 @@ var Curve = Base.extend({
|
||||||
return new Curve(this._segment2.reverse(), this._segment1.reverse());
|
return new Curve(this._segment2.reverse(), this._segment1.reverse());
|
||||||
},
|
},
|
||||||
|
|
||||||
divide: function(parameter) {
|
_getParameter: function(offset, isParameter) {
|
||||||
var res = null;
|
return isParameter
|
||||||
if (parameter && parameter.curve === this)
|
? offset
|
||||||
parameter = parameter.parameter;
|
: offset && offset.curve === this
|
||||||
|
? offset.parameter
|
||||||
|
: offset === undefined && isParameter === undefined
|
||||||
|
? 0.5
|
||||||
|
: this.getParameterAt(offset, 0);
|
||||||
|
},
|
||||||
|
|
||||||
|
divide: function(offset, isParameter) {
|
||||||
|
var parameter = this._getParameter(offset, isParameter),
|
||||||
|
res = null;
|
||||||
if (parameter > 0 && parameter < 1) {
|
if (parameter > 0 && parameter < 1) {
|
||||||
var parts = Curve.subdivide(this.getValues(), parameter),
|
var parts = Curve.subdivide(this.getValues(), parameter),
|
||||||
isLinear = this.isLinear(),
|
isLinear = this.isLinear(),
|
||||||
|
@ -4638,9 +4670,10 @@ var Curve = Base.extend({
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
split: function(parameter) {
|
split: function(offset, isParameter) {
|
||||||
return this._path
|
return this._path
|
||||||
? this._path.split(this._segment1._index, parameter)
|
? this._path.split(this._segment1._index,
|
||||||
|
this._getParameter(offset, isParameter))
|
||||||
: null;
|
: null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -4672,9 +4705,8 @@ statics: {
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
evaluate: function(v, offset, isParameter, type) {
|
evaluate: function(v, t, type) {
|
||||||
var t = isParameter ? offset : Curve.getParameterAt(v, offset, 0),
|
var p1x = v[0], p1y = v[1],
|
||||||
p1x = v[0], p1y = v[1],
|
|
||||||
c1x = v[2], c1y = v[3],
|
c1x = v[2], c1y = v[3],
|
||||||
c2x = v[4], c2y = v[5],
|
c2x = v[4], c2y = v[5],
|
||||||
p2x = v[6], p2y = v[7],
|
p2x = v[6], p2y = v[7],
|
||||||
|
@ -4829,7 +4861,7 @@ statics: {
|
||||||
abs = Math.abs;
|
abs = Math.abs;
|
||||||
|
|
||||||
function changesOrientation(tangent) {
|
function changesOrientation(tangent) {
|
||||||
return Curve.evaluate(prev, 1, true, 1).y
|
return Curve.evaluate(prev, 1, 1).y
|
||||||
* tangent.y > 0;
|
* tangent.y > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4840,9 +4872,9 @@ statics: {
|
||||||
for (var i = 0; i < count; i++) {
|
for (var i = 0; i < count; i++) {
|
||||||
var t = roots[i];
|
var t = roots[i];
|
||||||
if (t > -tolerance && t < 1 - tolerance) {
|
if (t > -tolerance && t < 1 - tolerance) {
|
||||||
var pt = Curve.evaluate(v, t, true, 0);
|
var pt = Curve.evaluate(v, t, 0);
|
||||||
if (x < pt.x + tolerance) {
|
if (x < pt.x + tolerance) {
|
||||||
var tan = Curve.evaluate(v, t, true, 1);
|
var tan = Curve.evaluate(v, t, 1);
|
||||||
if (abs(pt.x - x) < tolerance) {
|
if (abs(pt.x - x) < tolerance) {
|
||||||
var angle = tan.getAngle();
|
var angle = tan.getAngle();
|
||||||
if (angle > -180 && angle < 0
|
if (angle > -180 && angle < 0
|
||||||
|
@ -4902,13 +4934,15 @@ statics: {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
||||||
}), Base.each(['getPoint', 'getTangent', 'getNormal', 'getCurvatureAt'],
|
}), Base.each(['getPoint', 'getTangent', 'getNormal', 'getCurvature'],
|
||||||
function(name, index) {
|
function(name, index) {
|
||||||
this[name + 'At'] = function(offset, isParameter) {
|
this[name + 'At'] = function(offset, isParameter) {
|
||||||
return Curve.evaluate(this.getValues(), offset, isParameter, index);
|
var values = this.getValues();
|
||||||
|
return Curve.evaluate(values, isParameter
|
||||||
|
? offset : Curve.getParameterAt(values, offset, 0), index);
|
||||||
};
|
};
|
||||||
this[name] = function(parameter) {
|
this[name] = function(parameter) {
|
||||||
return Curve.evaluate(this.getValues(), parameter, true, index);
|
return Curve.evaluate(this.getValues(), parameter, index);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -4945,7 +4979,7 @@ statics: {
|
||||||
function refine(t) {
|
function refine(t) {
|
||||||
if (t >= 0 && t <= 1) {
|
if (t >= 0 && t <= 1) {
|
||||||
var dist = point.getDistance(
|
var dist = point.getDistance(
|
||||||
Curve.evaluate(values, t, true, 0), true);
|
Curve.evaluate(values, t, 0), true);
|
||||||
if (dist < minDist) {
|
if (dist < minDist) {
|
||||||
minDist = dist;
|
minDist = dist;
|
||||||
minT = t;
|
minT = t;
|
||||||
|
@ -4962,7 +4996,7 @@ statics: {
|
||||||
if (!refine(minT - step) && !refine(minT + step))
|
if (!refine(minT - step) && !refine(minT + step))
|
||||||
step /= 2;
|
step /= 2;
|
||||||
}
|
}
|
||||||
var pt = Curve.evaluate(values, minT, true, 0);
|
var pt = Curve.evaluate(values, minT, 0);
|
||||||
return new CurveLocation(this, minT, pt, null, null, null,
|
return new CurveLocation(this, minT, pt, null, null, null,
|
||||||
point.getDistance(pt));
|
point.getDistance(pt));
|
||||||
},
|
},
|
||||||
|
@ -5103,8 +5137,8 @@ new function() {
|
||||||
var t1 = (range1[0] + range1[1]) / 2,
|
var t1 = (range1[0] + range1[1]) / 2,
|
||||||
t2 = (range2[0] + range2[1]) / 2;
|
t2 = (range2[0] + range2[1]) / 2;
|
||||||
addLocation(locations,
|
addLocation(locations,
|
||||||
curve1, t1, Curve.evaluate(v1, t1, true, 0),
|
curve1, t1, Curve.evaluate(v1, t1, 0),
|
||||||
curve2, t2, Curve.evaluate(v2, t2, true, 0));
|
curve2, t2, Curve.evaluate(v2, t2, 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5239,11 +5273,11 @@ new function() {
|
||||||
for (var i = 0; i < count; i++) {
|
for (var i = 0; i < count; i++) {
|
||||||
var t = roots[i];
|
var t = roots[i];
|
||||||
if (t >= 0 && t <= 1) {
|
if (t >= 0 && t <= 1) {
|
||||||
var point = Curve.evaluate(vcr, t, true, 0);
|
var point = Curve.evaluate(vcr, t, 0);
|
||||||
if (point.x >= 0 && point.x <= rl2x)
|
if (point.x >= 0 && point.x <= rl2x)
|
||||||
addLocation(locations,
|
addLocation(locations,
|
||||||
flip ? curve2 : curve1,
|
flip ? curve2 : curve1,
|
||||||
t, Curve.evaluate(vc, t, true, 0),
|
t, Curve.evaluate(vc, t, 0),
|
||||||
flip ? curve1 : curve2);
|
flip ? curve1 : curve2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5874,7 +5908,7 @@ var Path = PathItem.extend({
|
||||||
split: function(index, parameter) {
|
split: function(index, parameter) {
|
||||||
if (parameter === null)
|
if (parameter === null)
|
||||||
return;
|
return;
|
||||||
if (arguments.length == 1) {
|
if (arguments.length === 1) {
|
||||||
var arg = index;
|
var arg = index;
|
||||||
if (typeof arg === 'number')
|
if (typeof arg === 'number')
|
||||||
arg = this.getLocationAt(arg);
|
arg = this.getLocationAt(arg);
|
||||||
|
@ -5938,12 +5972,13 @@ var Path = PathItem.extend({
|
||||||
last2 = path.getLastSegment();
|
last2 = path.getLastSegment();
|
||||||
if (last1._point.equals(last2._point))
|
if (last1._point.equals(last2._point))
|
||||||
path.reverse();
|
path.reverse();
|
||||||
var first2 = path.getFirstSegment();
|
var first1,
|
||||||
|
first2 = path.getFirstSegment();
|
||||||
if (last1._point.equals(first2._point)) {
|
if (last1._point.equals(first2._point)) {
|
||||||
last1.setHandleOut(first2._handleOut);
|
last1.setHandleOut(first2._handleOut);
|
||||||
this._add(segments.slice(1));
|
this._add(segments.slice(1));
|
||||||
} else {
|
} else {
|
||||||
var first1 = this.getFirstSegment();
|
first1 = this.getFirstSegment();
|
||||||
if (first1._point.equals(first2._point))
|
if (first1._point.equals(first2._point))
|
||||||
path.reverse();
|
path.reverse();
|
||||||
last2 = path.getLastSegment();
|
last2 = path.getLastSegment();
|
||||||
|
@ -5954,8 +5989,10 @@ var Path = PathItem.extend({
|
||||||
this._add(segments.slice());
|
this._add(segments.slice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (path.closed)
|
||||||
|
this._add([segments[0]]);
|
||||||
path.remove();
|
path.remove();
|
||||||
var first1 = this.getFirstSegment();
|
first1 = this.getFirstSegment();
|
||||||
last1 = this.getLastSegment();
|
last1 = this.getLastSegment();
|
||||||
if (last1._point.equals(first1._point)) {
|
if (last1._point.equals(first1._point)) {
|
||||||
first1.setHandleIn(last1._handleIn);
|
first1.setHandleIn(last1._handleIn);
|
||||||
|
@ -6846,7 +6883,8 @@ Path.inject({ statics: new function() {
|
||||||
|
|
||||||
function createRectangle() {
|
function createRectangle() {
|
||||||
var rect = Rectangle.readNamed(arguments, 'rectangle'),
|
var rect = Rectangle.readNamed(arguments, 'rectangle'),
|
||||||
radius = Size.readNamed(arguments, 'radius', 0, 0, true),
|
radius = Size.readNamed(arguments, 'radius', 0, 0,
|
||||||
|
{ readNull: true }),
|
||||||
bl = rect.getBottomLeft(true),
|
bl = rect.getBottomLeft(true),
|
||||||
tl = rect.getTopLeft(true),
|
tl = rect.getTopLeft(true),
|
||||||
tr = rect.getTopRight(true),
|
tr = rect.getTopRight(true),
|
||||||
|
@ -6916,14 +6954,6 @@ Path.inject({ statics: new function() {
|
||||||
).set(Base.getNamed(arguments));
|
).set(Base.getNamed(arguments));
|
||||||
},
|
},
|
||||||
|
|
||||||
Rectangle: createRectangle,
|
|
||||||
|
|
||||||
RoundRectangle: createRectangle,
|
|
||||||
|
|
||||||
Ellipse: createEllipse,
|
|
||||||
|
|
||||||
Oval: createEllipse,
|
|
||||||
|
|
||||||
Circle: function() {
|
Circle: function() {
|
||||||
var center = Point.readNamed(arguments, 'center'),
|
var center = Point.readNamed(arguments, 'center'),
|
||||||
radius = Base.readNamed(arguments, 'radius');
|
radius = Base.readNamed(arguments, 'radius');
|
||||||
|
@ -6932,6 +6962,14 @@ Path.inject({ statics: new function() {
|
||||||
.set(Base.getNamed(arguments));
|
.set(Base.getNamed(arguments));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Rectangle: createRectangle,
|
||||||
|
|
||||||
|
RoundRectangle: createRectangle,
|
||||||
|
|
||||||
|
Ellipse: createEllipse,
|
||||||
|
|
||||||
|
Oval: createEllipse,
|
||||||
|
|
||||||
Arc: function() {
|
Arc: function() {
|
||||||
var from = Point.readNamed(arguments, 'from'),
|
var from = Point.readNamed(arguments, 'from'),
|
||||||
through = Point.readNamed(arguments, 'through'),
|
through = Point.readNamed(arguments, 'through'),
|
||||||
|
@ -7230,7 +7268,7 @@ var PathFlattener = Base.extend({
|
||||||
|
|
||||||
evaluate: function(offset, type) {
|
evaluate: function(offset, type) {
|
||||||
var param = this.getParameterAt(offset);
|
var param = this.getParameterAt(offset);
|
||||||
return Curve.evaluate(this.curves[param.index], param.value, true, type);
|
return Curve.evaluate(this.curves[param.index], param.value, type);
|
||||||
},
|
},
|
||||||
|
|
||||||
drawPart: function(ctx, from, to) {
|
drawPart: function(ctx, from, to) {
|
||||||
|
@ -7723,7 +7761,7 @@ var Color = Base.extend(new function() {
|
||||||
gradient: ['gradient', 'origin', 'destination', 'highlight']
|
gradient: ['gradient', 'origin', 'destination', 'highlight']
|
||||||
};
|
};
|
||||||
|
|
||||||
var parsers = {},
|
var componentParsers = {},
|
||||||
colorCache = {},
|
colorCache = {},
|
||||||
colorCtx;
|
colorCtx;
|
||||||
|
|
||||||
|
@ -7861,16 +7899,16 @@ var Color = Base.extend(new function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
return Base.each(types, function(properties, type) {
|
return Base.each(types, function(properties, type) {
|
||||||
parsers[type] = [];
|
componentParsers[type] = [];
|
||||||
Base.each(properties, function(name, index) {
|
Base.each(properties, function(name, index) {
|
||||||
var part = Base.capitalize(name),
|
var part = Base.capitalize(name),
|
||||||
hasOverlap = /^(hue|saturation)$/.test(name),
|
hasOverlap = /^(hue|saturation)$/.test(name),
|
||||||
parser = parsers[type][index] = name === 'gradient'
|
parser = componentParsers[type][index] = name === 'gradient'
|
||||||
? function(value) {
|
? function(value) {
|
||||||
var current = this._components[0];
|
var current = this._components[0];
|
||||||
value = Gradient.read(
|
value = Gradient.read(
|
||||||
Array.isArray(value) ? value : arguments,
|
Array.isArray(value) ? value : arguments,
|
||||||
0, 0, true);
|
0, 0, { readNull: true });
|
||||||
if (current !== value) {
|
if (current !== value) {
|
||||||
if (current)
|
if (current)
|
||||||
current._removeOwner(this);
|
current._removeOwner(this);
|
||||||
|
@ -7886,8 +7924,10 @@ var Color = Base.extend(new function() {
|
||||||
}
|
}
|
||||||
: type === 'gradient'
|
: type === 'gradient'
|
||||||
? function() {
|
? function() {
|
||||||
return Point.read(arguments, 0, 0,
|
return Point.read(arguments, 0, 0, {
|
||||||
name === 'highlight', true);
|
readNull: name === 'highlight',
|
||||||
|
clone: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
: function(value) {
|
: function(value) {
|
||||||
return isNaN(value) ? 0
|
return isNaN(value) ? 0
|
||||||
|
@ -7905,6 +7945,7 @@ var Color = Base.extend(new function() {
|
||||||
if (this._type !== type
|
if (this._type !== type
|
||||||
&& !(hasOverlap && /^hs[bl]$/.test(this._type))) {
|
&& !(hasOverlap && /^hs[bl]$/.test(this._type))) {
|
||||||
this._components = this._convert(type);
|
this._components = this._convert(type);
|
||||||
|
this._properties = types[type];
|
||||||
this._type = type;
|
this._type = type;
|
||||||
}
|
}
|
||||||
value = parser.call(this, value);
|
value = parser.call(this, value);
|
||||||
|
@ -7922,6 +7963,7 @@ var Color = Base.extend(new function() {
|
||||||
var slice = Array.prototype.slice,
|
var slice = Array.prototype.slice,
|
||||||
args = arguments,
|
args = arguments,
|
||||||
read = 0,
|
read = 0,
|
||||||
|
parse = true,
|
||||||
type,
|
type,
|
||||||
components,
|
components,
|
||||||
alpha,
|
alpha,
|
||||||
|
@ -7938,13 +7980,14 @@ var Color = Base.extend(new function() {
|
||||||
components = arg;
|
components = arg;
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!components) {
|
if (!components) {
|
||||||
|
parse = !(this.__options && this.__options.dontParse);
|
||||||
values = argType === 'number'
|
values = argType === 'number'
|
||||||
? args
|
? args
|
||||||
: argType === 'object' && arg.length != null
|
: argType === 'object' && arg.length != null
|
||||||
|
@ -7957,7 +8000,7 @@ var Color = Base.extend(new function() {
|
||||||
: 'gray';
|
: 'gray';
|
||||||
var length = types[type].length;
|
var length = types[type].length;
|
||||||
alpha = values[length];
|
alpha = values[length];
|
||||||
if (this._read)
|
if (this.__read)
|
||||||
read += values === arguments
|
read += values === arguments
|
||||||
? length + (alpha != null ? 1 : 0)
|
? length + (alpha != null ? 1 : 0)
|
||||||
: 1;
|
: 1;
|
||||||
|
@ -7995,7 +8038,7 @@ var Color = Base.extend(new function() {
|
||||||
? 'gray'
|
? 'gray'
|
||||||
: 'rgb';
|
: 'rgb';
|
||||||
var properties = types[type];
|
var properties = types[type];
|
||||||
parse = parsers[type];
|
parsers = parse && componentParsers[type];
|
||||||
this._components = components = [];
|
this._components = components = [];
|
||||||
for (var i = 0, l = properties.length; i < l; i++) {
|
for (var i = 0, l = properties.length; i < l; i++) {
|
||||||
var value = arg[properties[i]];
|
var value = arg[properties[i]];
|
||||||
|
@ -8006,14 +8049,15 @@ var Color = Base.extend(new function() {
|
||||||
radial: arg.radial
|
radial: arg.radial
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
value = parse[i].call(this, value);
|
if (parse)
|
||||||
|
value = parsers[i].call(this, value);
|
||||||
if (value != null)
|
if (value != null)
|
||||||
components[i] = value;
|
components[i] = value;
|
||||||
}
|
}
|
||||||
alpha = arg.alpha;
|
alpha = arg.alpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this._read && type)
|
if (this.__read && type)
|
||||||
read = 1;
|
read = 1;
|
||||||
}
|
}
|
||||||
this._type = type || 'rgb';
|
this._type = type || 'rgb';
|
||||||
|
@ -8021,17 +8065,20 @@ var Color = Base.extend(new function() {
|
||||||
this._id = Color._id = (Color._id || 0) + 1;
|
this._id = Color._id = (Color._id || 0) + 1;
|
||||||
if (!components) {
|
if (!components) {
|
||||||
this._components = components = [];
|
this._components = components = [];
|
||||||
var parse = parsers[this._type];
|
var parsers = componentParsers[this._type];
|
||||||
for (var i = 0, l = parse.length; i < l; i++) {
|
for (var i = 0, l = parsers.length; i < l; i++) {
|
||||||
var value = parse[i].call(this, values && values[i]);
|
var value = values && values[i];
|
||||||
|
if (parse)
|
||||||
|
value = parsers[i].call(this, value);
|
||||||
if (value != null)
|
if (value != null)
|
||||||
components[i] = value;
|
components[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._components = components;
|
this._components = components;
|
||||||
|
this._properties = types[this._type];
|
||||||
this._alpha = alpha;
|
this._alpha = alpha;
|
||||||
if (this._read)
|
if (this.__read)
|
||||||
this._read = read;
|
this.__read = read;
|
||||||
},
|
},
|
||||||
|
|
||||||
_serialize: function(options, dictionary) {
|
_serialize: function(options, dictionary) {
|
||||||
|
@ -8074,6 +8121,7 @@ var Color = Base.extend(new function() {
|
||||||
|
|
||||||
setType: function(type) {
|
setType: function(type) {
|
||||||
this._components = this._convert(type);
|
this._components = this._convert(type);
|
||||||
|
this._properties = types[type];
|
||||||
this._type = type;
|
this._type = type;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -8107,7 +8155,7 @@ var Color = Base.extend(new function() {
|
||||||
},
|
},
|
||||||
|
|
||||||
toString: function() {
|
toString: function() {
|
||||||
var properties = types[this._type],
|
var properties = this._properties,
|
||||||
parts = [],
|
parts = [],
|
||||||
isGradient = this._type === 'gradient',
|
isGradient = this._type === 'gradient',
|
||||||
f = Formatter.instance;
|
f = Formatter.instance;
|
||||||
|
@ -8190,6 +8238,54 @@ var Color = Base.extend(new function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}, new function() {
|
||||||
|
function clamp(value, hue) {
|
||||||
|
return value < 0
|
||||||
|
? 0
|
||||||
|
: hue && value > 360
|
||||||
|
? 360
|
||||||
|
: !hue && value > 1
|
||||||
|
? 1
|
||||||
|
: value;
|
||||||
|
}
|
||||||
|
|
||||||
|
var operators = {
|
||||||
|
add: function(a, b, hue) {
|
||||||
|
return clamp(a + b, hue);
|
||||||
|
},
|
||||||
|
|
||||||
|
subtract: function(a, b, hue) {
|
||||||
|
return clamp(a - b, hue);
|
||||||
|
},
|
||||||
|
|
||||||
|
multiply: function(a, b, hue) {
|
||||||
|
return clamp(a * b, hue);
|
||||||
|
},
|
||||||
|
|
||||||
|
divide: function(a, b, hue) {
|
||||||
|
return clamp(a / b, hue);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return Base.each(operators, function(operator, name) {
|
||||||
|
var options = { dontParse: /^(multiply|divide)$/.test(name) };
|
||||||
|
|
||||||
|
this[name] = function(color) {
|
||||||
|
color = Color.read(arguments, 0, 0, options);
|
||||||
|
var type = this._type,
|
||||||
|
properties = this._properties,
|
||||||
|
components1 = this._components,
|
||||||
|
components2 = color._convert(type);
|
||||||
|
for (var i = 0, l = components1.length; i < l; i++)
|
||||||
|
components2[i] = operator(components1[i], components2[i],
|
||||||
|
properties[i] === 'hue');
|
||||||
|
return new Color(type, components2,
|
||||||
|
this._alpha != null
|
||||||
|
? operator(this._alpha, color.getAlpha())
|
||||||
|
: null);
|
||||||
|
};
|
||||||
|
}, {
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Base.each(Color._types, function(properties, type) {
|
Base.each(Color._types, function(properties, type) {
|
||||||
|
@ -8208,7 +8304,7 @@ Base.each(Color._types, function(properties, type) {
|
||||||
var acronym = type.toUpperCase();
|
var acronym = type.toUpperCase();
|
||||||
Color[acronym] = this[acronym + 'Color'] = ctor;
|
Color[acronym] = this[acronym + 'Color'] = ctor;
|
||||||
}
|
}
|
||||||
}, this);
|
}, Base.exports);
|
||||||
|
|
||||||
var Gradient = Base.extend({
|
var Gradient = Base.extend({
|
||||||
_class: 'Gradient',
|
_class: 'Gradient',
|
||||||
|
@ -8445,7 +8541,7 @@ var Style = Base.extend(new function() {
|
||||||
this._values[key] = value;
|
this._values[key] = value;
|
||||||
} else if (isColor && !(value && value.constructor === Color)) {
|
} else if (isColor && !(value && value.constructor === Color)) {
|
||||||
this._values[key] = value = Color.read(
|
this._values[key] = value = Color.read(
|
||||||
[value], 0, 0, true, true);
|
[value], 0, 0, { readNull: true, clone: true });
|
||||||
if (value)
|
if (value)
|
||||||
value._owner = this._item;
|
value._owner = this._item;
|
||||||
}
|
}
|
||||||
|
@ -10219,7 +10315,7 @@ var SVGNamespaces = {
|
||||||
};
|
};
|
||||||
|
|
||||||
new function() {
|
new function() {
|
||||||
var formatter = Formatter.instance;
|
var formatter;
|
||||||
|
|
||||||
function setAttributes(node, attrs) {
|
function setAttributes(node, attrs) {
|
||||||
for (var key in attrs) {
|
for (var key in attrs) {
|
||||||
|
@ -10619,7 +10715,7 @@ new function() {
|
||||||
definitions.svgs[type + '-' + item._id] = node;
|
definitions.svgs[type + '-' + item._id] = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportDefinitions(node) {
|
function exportDefinitions(node, options) {
|
||||||
if (!definitions)
|
if (!definitions)
|
||||||
return node;
|
return node;
|
||||||
var svg = node.nodeName.toLowerCase() === 'svg' && node,
|
var svg = node.nodeName.toLowerCase() === 'svg' && node,
|
||||||
|
@ -10635,7 +10731,9 @@ new function() {
|
||||||
defs.appendChild(definitions.svgs[i]);
|
defs.appendChild(definitions.svgs[i]);
|
||||||
}
|
}
|
||||||
definitions = null;
|
definitions = null;
|
||||||
return svg;
|
return options && options.asString
|
||||||
|
? new XMLSerializer().serializeToString(svg)
|
||||||
|
: svg;
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportSVG(item) {
|
function exportSVG(item) {
|
||||||
|
@ -10646,14 +10744,22 @@ new function() {
|
||||||
return node && applyStyle(item, node);
|
return node && applyStyle(item, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setOptions(options) {
|
||||||
|
formatter = options && options.precision
|
||||||
|
? new Formatter(options.precision)
|
||||||
|
: Formatter.instance;
|
||||||
|
}
|
||||||
|
|
||||||
Item.inject({
|
Item.inject({
|
||||||
exportSVG: function() {
|
exportSVG: function(options) {
|
||||||
return exportDefinitions(exportSVG(this));
|
setOptions(options);
|
||||||
|
return exportDefinitions(exportSVG(this), options);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Project.inject({
|
Project.inject({
|
||||||
exportSVG: function() {
|
exportSVG: function(options) {
|
||||||
|
setOptions(options);
|
||||||
var layers = this.layers,
|
var layers = this.layers,
|
||||||
size = this.view.getSize(),
|
size = this.view.getSize(),
|
||||||
node = createElement('svg', {
|
node = createElement('svg', {
|
||||||
|
@ -10667,7 +10773,7 @@ new function() {
|
||||||
});
|
});
|
||||||
for (var i = 0, l = layers.length; i < l; i++)
|
for (var i = 0, l = layers.length; i < l; i++)
|
||||||
node.appendChild(exportSVG(layers[i]));
|
node.appendChild(exportSVG(layers[i]));
|
||||||
return exportDefinitions(node);
|
return exportDefinitions(node, options);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -11064,4 +11170,3 @@ if (typeof define === 'function' && define.amd)
|
||||||
|
|
||||||
return paper;
|
return paper;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
14
dist/paper-core.min.js
vendored
14
dist/paper-core.min.js
vendored
File diff suppressed because one or more lines are too long
377
dist/paper-full.js
vendored
377
dist/paper-full.js
vendored
File diff suppressed because one or more lines are too long
16
dist/paper-full.min.js
vendored
16
dist/paper-full.min.js
vendored
File diff suppressed because one or more lines are too long
377
dist/paper-node.js
vendored
377
dist/paper-node.js
vendored
File diff suppressed because one or more lines are too long
377
dist/paper.js
vendored
377
dist/paper.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "paper",
|
"name": "paper",
|
||||||
"version": "0.9.7",
|
"version": "0.9.8",
|
||||||
"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",
|
||||||
|
|
Loading…
Reference in a new issue