mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Bump version to v0.9.9
This commit is contained in:
parent
98697eb003
commit
4e98036828
8 changed files with 755 additions and 640 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "paper",
|
"name": "paper",
|
||||||
"version": "0.9.8",
|
"version": "0.9.9",
|
||||||
"main": "dist/paper.js",
|
"main": "dist/paper.js",
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"build",
|
"build",
|
||||||
|
|
333
dist/paper-core.js
vendored
333
dist/paper-core.js
vendored
|
@ -1,5 +1,5 @@
|
||||||
/*!
|
/*!
|
||||||
* Paper.js v0.9.8 - The Swiss Army Knife of Vector Graphics Scripting.
|
* Paper.js v0.9.9 - 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: Wed Jul 3 12:14:01 2013 -0700
|
* Date: Sun Jul 21 16:44:30 2013 -0700
|
||||||
*
|
*
|
||||||
***
|
***
|
||||||
*
|
*
|
||||||
|
@ -275,10 +275,11 @@ Base.inject({
|
||||||
return Base.serialize(this);
|
return Base.serialize(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
_set: function(props) {
|
_set: function(props, exclude) {
|
||||||
if (props && Base.isPlainObject(props)) {
|
if (props && Base.isPlainObject(props)) {
|
||||||
for (var key in props)
|
for (var key in props)
|
||||||
if (props.hasOwnProperty(key) && key in this)
|
if (props.hasOwnProperty(key) && key in this
|
||||||
|
&& (!exclude || !exclude[key]))
|
||||||
this[key] = props[key];
|
this[key] = props[key];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -675,7 +676,7 @@ var PaperScope = Base.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
version: '0.9.8',
|
version: '0.9.9',
|
||||||
|
|
||||||
getView: function() {
|
getView: function() {
|
||||||
return this.project && this.project.view;
|
return this.project && this.project.view;
|
||||||
|
@ -715,6 +716,10 @@ var PaperScope = Base.extend({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
activate: function() {
|
||||||
|
paper = this;
|
||||||
|
},
|
||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
for (var i = this.projects.length - 1; i >= 0; i--)
|
for (var i = this.projects.length - 1; i >= 0; i--)
|
||||||
this.projects[i].remove();
|
this.projects[i].remove();
|
||||||
|
@ -2459,7 +2464,7 @@ var Symbol = Base.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
clone: function() {
|
clone: function() {
|
||||||
return new Symbol(this._definition.clone());
|
return new Symbol(this._definition.clone(false));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2493,20 +2498,25 @@ var Item = Base.extend(Callback, {
|
||||||
data: {}
|
data: {}
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function Item(point) {
|
initialize: function Item() {
|
||||||
|
},
|
||||||
|
|
||||||
|
_initialize: function(props, point) {
|
||||||
this._id = Item._id = (Item._id || 0) + 1;
|
this._id = Item._id = (Item._id || 0) + 1;
|
||||||
if (!this._project) {
|
if (!this._project) {
|
||||||
var project = paper.project,
|
var project = paper.project,
|
||||||
layer = project.activeLayer;
|
layer = project.activeLayer;
|
||||||
if (layer)
|
if (layer && !(props && props.insert === false)) {
|
||||||
layer.addChild(this);
|
layer.addChild(this);
|
||||||
else
|
} else {
|
||||||
this._setProject(project);
|
this._setProject(project);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this._style = new Style(this._project._currentStyle, this);
|
this._style = new Style(this._project._currentStyle, this);
|
||||||
this._matrix = new Matrix();
|
this._matrix = new Matrix();
|
||||||
if (point)
|
if (point)
|
||||||
this._matrix.translate(point);
|
this._matrix.translate(point);
|
||||||
|
return props ? this._set(props, { insert: true }) : true;
|
||||||
},
|
},
|
||||||
|
|
||||||
_events: new function() {
|
_events: new function() {
|
||||||
|
@ -2590,32 +2600,37 @@ var Item = Base.extend(Callback, {
|
||||||
},
|
},
|
||||||
|
|
||||||
_changed: function(flags) {
|
_changed: function(flags) {
|
||||||
|
var parent = this._parent,
|
||||||
|
project = this._project,
|
||||||
|
symbol = this._parentSymbol;
|
||||||
if (flags & 4) {
|
if (flags & 4) {
|
||||||
delete this._bounds;
|
delete this._bounds;
|
||||||
delete this._position;
|
delete this._position;
|
||||||
}
|
}
|
||||||
if (this._parent
|
if (parent && (flags
|
||||||
&& (flags & (4 | 8))) {
|
& (4 | 8))) {
|
||||||
this._parent._clearBoundsCache();
|
parent._clearBoundsCache();
|
||||||
}
|
}
|
||||||
if (flags & 2) {
|
if (flags & 2) {
|
||||||
this._clearBoundsCache();
|
this._clearBoundsCache();
|
||||||
}
|
}
|
||||||
if (flags & 1) {
|
if (project) {
|
||||||
this._project._needsRedraw = true;
|
if (flags & 1) {
|
||||||
}
|
project._needsRedraw = true;
|
||||||
if (this._parentSymbol)
|
}
|
||||||
this._parentSymbol._changed(flags);
|
if (project._changes) {
|
||||||
if (this._project._changes) {
|
var entry = project._changesById[this._id];
|
||||||
var entry = this._project._changesById[this._id];
|
if (entry) {
|
||||||
if (entry) {
|
entry.flags |= flags;
|
||||||
entry.flags |= flags;
|
} else {
|
||||||
} else {
|
entry = { item: this, flags: flags };
|
||||||
entry = { item: this, flags: flags };
|
project._changesById[this._id] = entry;
|
||||||
this._project._changesById[this._id] = entry;
|
project._changes.push(entry);
|
||||||
this._project._changes.push(entry);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (symbol)
|
||||||
|
symbol._changed(flags);
|
||||||
},
|
},
|
||||||
|
|
||||||
set: function(props) {
|
set: function(props) {
|
||||||
|
@ -2950,16 +2965,18 @@ var Item = Base.extend(Callback, {
|
||||||
return this._parent ? this._parent.isInserted() : false;
|
return this._parent ? this._parent.isInserted() : false;
|
||||||
},
|
},
|
||||||
|
|
||||||
clone: function() {
|
clone: function(insert) {
|
||||||
return this._clone(new this.constructor());
|
return this._clone(new this.constructor({ insert: false }), insert);
|
||||||
},
|
},
|
||||||
|
|
||||||
_clone: function(copy) {
|
_clone: function(copy, insert) {
|
||||||
copy.setStyle(this._style);
|
copy.setStyle(this._style);
|
||||||
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++)
|
||||||
copy.addChild(this._children[i].clone(), true);
|
copy.addChild(this._children[i].clone(false), true);
|
||||||
}
|
}
|
||||||
|
if (insert || insert === undefined)
|
||||||
|
copy.insertAbove(this);
|
||||||
var keys = ['_locked', '_visible', '_blendMode', '_opacity',
|
var keys = ['_locked', '_visible', '_blendMode', '_opacity',
|
||||||
'_clipMask', '_guide'];
|
'_clipMask', '_guide'];
|
||||||
for (var i = 0, l = keys.length; i < l; i++) {
|
for (var i = 0, l = keys.length; i < l; i++) {
|
||||||
|
@ -2987,14 +3004,17 @@ var Item = Base.extend(Callback, {
|
||||||
rasterize: function(resolution) {
|
rasterize: function(resolution) {
|
||||||
var bounds = this.getStrokeBounds(),
|
var bounds = this.getStrokeBounds(),
|
||||||
scale = (resolution || 72) / 72,
|
scale = (resolution || 72) / 72,
|
||||||
canvas = CanvasProvider.getCanvas(bounds.getSize().multiply(scale)),
|
topLeft = bounds.getTopLeft().floor(),
|
||||||
|
bottomRight = bounds.getBottomRight().ceil()
|
||||||
|
size = new Size(bottomRight.subtract(topLeft)),
|
||||||
|
canvas = CanvasProvider.getCanvas(size),
|
||||||
ctx = canvas.getContext('2d'),
|
ctx = canvas.getContext('2d'),
|
||||||
matrix = new Matrix().scale(scale).translate(-bounds.x, -bounds.y);
|
matrix = new Matrix().scale(scale).translate(topLeft.negate());
|
||||||
ctx.save();
|
ctx.save();
|
||||||
matrix.applyToContext(ctx);
|
matrix.applyToContext(ctx);
|
||||||
this.draw(ctx, Base.merge({ transforms: [matrix] }));
|
this.draw(ctx, Base.merge({ transforms: [matrix] }));
|
||||||
var raster = new Raster(canvas);
|
var raster = new Raster(canvas);
|
||||||
raster.setBounds(bounds);
|
raster.setPosition(topLeft.add(size.divide(2)));
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
return raster;
|
return raster;
|
||||||
},
|
},
|
||||||
|
@ -3065,7 +3085,7 @@ var Item = Base.extend(Callback, {
|
||||||
for (var i = this._children.length - 1, res; i >= 0; i--)
|
for (var i = this._children.length - 1, res; i >= 0; i--)
|
||||||
if (res = this._children[i].hitTest(point, options))
|
if (res = this._children[i].hitTest(point, options))
|
||||||
return res;
|
return res;
|
||||||
} else if (this.hasFill() && this._contains(point)) {
|
} else if (options.fill && this.hasFill() && this._contains(point)) {
|
||||||
return new HitResult('fill', this);
|
return new HitResult('fill', this);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -3113,20 +3133,23 @@ var Item = Base.extend(Callback, {
|
||||||
return items;
|
return items;
|
||||||
},
|
},
|
||||||
|
|
||||||
insertAbove: function(item, _preserve) {
|
_insert: function(above, item, _preserve) {
|
||||||
var index = item._index;
|
if (!item._parent)
|
||||||
if (item._parent == this._parent && index < this._index)
|
return null;
|
||||||
index++;
|
var index = item._index + (above ? 1 : 0);
|
||||||
return item._parent.insertChild(index, this, _preserve);
|
if (item._parent === this._parent && index > this._index)
|
||||||
},
|
|
||||||
|
|
||||||
insertBelow: function(item, _preserve) {
|
|
||||||
var index = item._index;
|
|
||||||
if (item._parent == this._parent && index > this._index)
|
|
||||||
index--;
|
index--;
|
||||||
return item._parent.insertChild(index, this, _preserve);
|
return item._parent.insertChild(index, this, _preserve);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
insertAbove: function(item, _preserve) {
|
||||||
|
return this._insert(true, item, _preserve);
|
||||||
|
},
|
||||||
|
|
||||||
|
insertBelow: function(item, _preserve) {
|
||||||
|
return this._insert(false, item, _preserve);
|
||||||
|
},
|
||||||
|
|
||||||
sendToBack: function() {
|
sendToBack: function() {
|
||||||
return this._parent.insertChild(0, this);
|
return this._parent.insertChild(0, this);
|
||||||
},
|
},
|
||||||
|
@ -3236,19 +3259,19 @@ var Item = Base.extend(Callback, {
|
||||||
},
|
},
|
||||||
|
|
||||||
isAbove: function(item) {
|
isAbove: function(item) {
|
||||||
return this._getOrder(item) == -1;
|
return this._getOrder(item) === -1;
|
||||||
},
|
},
|
||||||
|
|
||||||
isBelow: function(item) {
|
isBelow: function(item) {
|
||||||
return this._getOrder(item) == 1;
|
return this._getOrder(item) === 1;
|
||||||
},
|
},
|
||||||
|
|
||||||
isParent: function(item) {
|
isParent: function(item) {
|
||||||
return this._parent == item;
|
return this._parent === item;
|
||||||
},
|
},
|
||||||
|
|
||||||
isChild: function(item) {
|
isChild: function(item) {
|
||||||
return item && item._parent == this;
|
return item && item._parent === this;
|
||||||
},
|
},
|
||||||
|
|
||||||
isDescendant: function(item) {
|
isDescendant: function(item) {
|
||||||
|
@ -3374,8 +3397,7 @@ var Item = Base.extend(Callback, {
|
||||||
limit = style.getMiterLimit(),
|
limit = style.getMiterLimit(),
|
||||||
fillColor = style.getFillColor(),
|
fillColor = style.getFillColor(),
|
||||||
strokeColor = style.getStrokeColor(),
|
strokeColor = style.getStrokeColor(),
|
||||||
dashArray = style.getDashArray(),
|
shadowColor = style.getShadowColor();
|
||||||
dashOffset = style.getDashOffset();
|
|
||||||
if (width != null)
|
if (width != null)
|
||||||
ctx.lineWidth = width;
|
ctx.lineWidth = width;
|
||||||
if (join)
|
if (join)
|
||||||
|
@ -3388,6 +3410,8 @@ var Item = Base.extend(Callback, {
|
||||||
ctx.fillStyle = fillColor.toCanvasStyle(ctx);
|
ctx.fillStyle = fillColor.toCanvasStyle(ctx);
|
||||||
if (strokeColor) {
|
if (strokeColor) {
|
||||||
ctx.strokeStyle = strokeColor.toCanvasStyle(ctx);
|
ctx.strokeStyle = strokeColor.toCanvasStyle(ctx);
|
||||||
|
var dashArray = style.getDashArray(),
|
||||||
|
dashOffset = style.getDashOffset();
|
||||||
if (paper.support.nativeDash && dashArray && dashArray.length) {
|
if (paper.support.nativeDash && dashArray && dashArray.length) {
|
||||||
if ('setLineDash' in ctx) {
|
if ('setLineDash' in ctx) {
|
||||||
ctx.setLineDash(dashArray);
|
ctx.setLineDash(dashArray);
|
||||||
|
@ -3398,10 +3422,17 @@ var Item = Base.extend(Callback, {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (shadowColor) {
|
||||||
|
ctx.shadowColor = shadowColor.toCanvasStyle(ctx);
|
||||||
|
ctx.shadowBlur = style.getShadowBlur();
|
||||||
|
var offset = this.getShadowOffset();
|
||||||
|
ctx.shadowOffsetX = offset.x;
|
||||||
|
ctx.shadowOffsetY = offset.y;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
draw: function(ctx, param) {
|
draw: function(ctx, param) {
|
||||||
if (!this._visible || this._opacity == 0)
|
if (!this._visible || this._opacity === 0)
|
||||||
return;
|
return;
|
||||||
this._drawCount = this._project._drawCount;
|
this._drawCount = this._project._drawCount;
|
||||||
var transforms = param.transforms,
|
var transforms = param.transforms,
|
||||||
|
@ -3410,9 +3441,11 @@ var Item = Base.extend(Callback, {
|
||||||
transforms.push(this._globalMatrix = globalMatrix);
|
transforms.push(this._globalMatrix = globalMatrix);
|
||||||
var blendMode = this._blendMode,
|
var blendMode = this._blendMode,
|
||||||
opacity = this._opacity,
|
opacity = this._opacity,
|
||||||
|
normalBlend = blendMode === 'normal',
|
||||||
nativeBlend = BlendMode.nativeModes[blendMode],
|
nativeBlend = BlendMode.nativeModes[blendMode],
|
||||||
direct = blendMode === 'normal' && opacity === 1
|
direct = normalBlend && opacity === 1
|
||||||
|| (nativeBlend || opacity < 1) && this._canComposite(),
|
|| (nativeBlend || normalBlend && opacity < 1)
|
||||||
|
&& this._canComposite(),
|
||||||
mainCtx, itemOffset, prevOffset;
|
mainCtx, itemOffset, prevOffset;
|
||||||
if (!direct) {
|
if (!direct) {
|
||||||
var bounds = this.getStrokeBounds(parentMatrix);
|
var bounds = this.getStrokeBounds(parentMatrix);
|
||||||
|
@ -3480,10 +3513,9 @@ var Group = Item.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function Group(arg) {
|
initialize: function Group(arg) {
|
||||||
Item.call(this);
|
|
||||||
this._children = [];
|
this._children = [];
|
||||||
this._namedChildren = {};
|
this._namedChildren = {};
|
||||||
if (arg && !this._set(arg))
|
if (!this._initialize(arg))
|
||||||
this.addChildren(Array.isArray(arg) ? arg : arguments);
|
this.addChildren(Array.isArray(arg) ? arg : arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -3582,34 +3614,25 @@ var Layer = Group.extend({
|
||||||
|
|
||||||
activate: function() {
|
activate: function() {
|
||||||
this._project.activeLayer = this;
|
this._project.activeLayer = this;
|
||||||
}
|
},
|
||||||
}, new function () {
|
|
||||||
function insert(above) {
|
|
||||||
return function insert(item) {
|
|
||||||
if (item instanceof Layer && !item._parent
|
|
||||||
&& this._remove(true)) {
|
|
||||||
Base.splice(item._project.layers, [this],
|
|
||||||
item._index + (above ? 1 : 0), 0);
|
|
||||||
this._setProject(item._project);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return insert.base.call(this, item);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
_insert: function _insert(above, item, _preserve) {
|
||||||
insertAbove: insert(true),
|
if (item instanceof Layer && !item._parent && this._remove(true)) {
|
||||||
|
Base.splice(item._project.layers, [this],
|
||||||
insertBelow: insert(false)
|
item._index + (above ? 1 : 0), 0);
|
||||||
};
|
this._setProject(item._project);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
return _insert.base.call(this, above, item, _preserve);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var Shape = Item.extend({
|
var Shape = Item.extend({
|
||||||
_class: 'Shape',
|
_class: 'Shape',
|
||||||
_transformContent: false,
|
_transformContent: false,
|
||||||
|
|
||||||
initialize: function Shape(type, point, size) {
|
initialize: function Shape(type, point, size, props) {
|
||||||
Item.call(this, point);
|
this._initialize(props, point);
|
||||||
this._type = type;
|
this._type = type;
|
||||||
this._size = size;
|
this._size = size;
|
||||||
},
|
},
|
||||||
|
@ -3733,11 +3756,7 @@ var Shape = Item.extend({
|
||||||
|
|
||||||
statics: new function() {
|
statics: new function() {
|
||||||
function createShape(type, point, size, args) {
|
function createShape(type, point, size, args) {
|
||||||
var shape = new Shape(type, point, size),
|
return new Shape(type, point, size, Base.getNamed(args));
|
||||||
named = Base.getNamed(args);
|
|
||||||
if (named)
|
|
||||||
shape._set(named);
|
|
||||||
return shape;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -3773,8 +3792,8 @@ var Raster = Item.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function Raster(object, position) {
|
initialize: function Raster(object, position) {
|
||||||
Item.call(this, position !== undefined && Point.read(arguments, 1));
|
if (!this._initialize(object,
|
||||||
if (object && !this._set(object)) {
|
position !== undefined && Point.read(arguments, 1))) {
|
||||||
if (object.getContext) {
|
if (object.getContext) {
|
||||||
this.setCanvas(object);
|
this.setCanvas(object);
|
||||||
} else if (typeof object === 'string') {
|
} else if (typeof object === 'string') {
|
||||||
|
@ -3787,14 +3806,16 @@ var Raster = Item.extend({
|
||||||
this._size = new Size();
|
this._size = new Size();
|
||||||
},
|
},
|
||||||
|
|
||||||
clone: function() {
|
clone: function(insert) {
|
||||||
var element = this._image;
|
var param = { insert: false },
|
||||||
if (!element) {
|
image = this._image;
|
||||||
element = CanvasProvider.getCanvas(this._size);
|
if (image) {
|
||||||
element.getContext('2d').drawImage(this._canvas, 0, 0);
|
param.image = image;
|
||||||
|
} else if (this._canvas) {
|
||||||
|
var canvas = param.canvas = CanvasProvider.getCanvas(this._size);
|
||||||
|
canvas.getContext('2d').drawImage(this._canvas, 0, 0);
|
||||||
}
|
}
|
||||||
var copy = new Raster(element);
|
return this._clone(new Raster(param), insert);
|
||||||
return this._clone(copy);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getSize: function() {
|
getSize: function() {
|
||||||
|
@ -3882,7 +3903,7 @@ var Raster = Item.extend({
|
||||||
if (this._canvas)
|
if (this._canvas)
|
||||||
CanvasProvider.release(this._canvas);
|
CanvasProvider.release(this._canvas);
|
||||||
this._image = image;
|
this._image = image;
|
||||||
this._size = new Size(image.naturalWidth, image.naturalHeight);
|
this._size = new Size(image.width, image.height);
|
||||||
this._canvas = null;
|
this._canvas = null;
|
||||||
this._context = null;
|
this._context = null;
|
||||||
this._changed(5);
|
this._changed(5);
|
||||||
|
@ -3895,20 +3916,22 @@ var Raster = Item.extend({
|
||||||
setSource: function(src) {
|
setSource: function(src) {
|
||||||
var that = this,
|
var that = this,
|
||||||
image = document.getElementById(src) || new Image();
|
image = document.getElementById(src) || new Image();
|
||||||
|
|
||||||
function loaded() {
|
function loaded() {
|
||||||
that.fire('load');
|
that.fire('load');
|
||||||
if (that._project.view)
|
if (that._project.view)
|
||||||
that._project.view.draw(true);
|
that._project.view.draw(true);
|
||||||
}
|
}
|
||||||
DomEvent.add(image, {
|
|
||||||
load: function() {
|
|
||||||
that.setImage(image);
|
|
||||||
loaded();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (image.width && image.height) {
|
if (image.width && image.height) {
|
||||||
setTimeout(loaded, 0);
|
setTimeout(loaded, 0);
|
||||||
} else if (!image.src) {
|
} else if (!image.src) {
|
||||||
|
DomEvent.add(image, {
|
||||||
|
load: function() {
|
||||||
|
that.setImage(image);
|
||||||
|
loaded();
|
||||||
|
}
|
||||||
|
});
|
||||||
image.src = src;
|
image.src = src;
|
||||||
}
|
}
|
||||||
this.setImage(image);
|
this.setImage(image);
|
||||||
|
@ -4072,8 +4095,8 @@ var PlacedSymbol = Item.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function PlacedSymbol(arg0, arg1) {
|
initialize: function PlacedSymbol(arg0, arg1) {
|
||||||
Item.call(this, arg1 !== undefined && Point.read(arguments, 1));
|
if (!this._initialize(arg0,
|
||||||
if (arg0 && !this._set(arg0))
|
arg1 !== undefined && Point.read(arguments, 1)))
|
||||||
this.setSymbol(arg0 instanceof Symbol ? arg0 : new Symbol(arg0));
|
this.setSymbol(arg0 instanceof Symbol ? arg0 : new Symbol(arg0));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -4088,8 +4111,11 @@ var PlacedSymbol = Item.extend({
|
||||||
symbol._instances[this._id] = this;
|
symbol._instances[this._id] = this;
|
||||||
},
|
},
|
||||||
|
|
||||||
clone: function() {
|
clone: function(insert) {
|
||||||
return this._clone(new PlacedSymbol(this.symbol));
|
return this._clone(new PlacedSymbol({
|
||||||
|
symbol: this.symbol,
|
||||||
|
insert: false
|
||||||
|
}), insert);
|
||||||
},
|
},
|
||||||
|
|
||||||
isEmpty: function() {
|
isEmpty: function() {
|
||||||
|
@ -5416,12 +5442,12 @@ var CurveLocation = Base.extend({
|
||||||
|
|
||||||
divide: function() {
|
divide: function() {
|
||||||
var curve = this.getCurve(true);
|
var curve = this.getCurve(true);
|
||||||
return curve && curve.divide(this.getParameter(true));
|
return curve && curve.divide(this.getParameter(true), true);
|
||||||
},
|
},
|
||||||
|
|
||||||
split: function() {
|
split: function() {
|
||||||
var curve = this.getCurve(true);
|
var curve = this.getCurve(true);
|
||||||
return curve && curve.split(this.getParameter(true));
|
return curve && curve.split(this.getParameter(true), true);
|
||||||
},
|
},
|
||||||
|
|
||||||
toString: function() {
|
toString: function() {
|
||||||
|
@ -5446,7 +5472,6 @@ var PathItem = Item.extend({
|
||||||
_class: 'PathItem',
|
_class: 'PathItem',
|
||||||
|
|
||||||
initialize: function PathItem() {
|
initialize: function PathItem() {
|
||||||
Item.apply(this, arguments);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getIntersections: function(path) {
|
getIntersections: function(path) {
|
||||||
|
@ -5575,29 +5600,31 @@ var Path = PathItem.extend({
|
||||||
initialize: function Path(arg) {
|
initialize: function Path(arg) {
|
||||||
this._closed = false;
|
this._closed = false;
|
||||||
this._segments = [];
|
this._segments = [];
|
||||||
Item.call(this);
|
|
||||||
var segments = Array.isArray(arg)
|
var segments = Array.isArray(arg)
|
||||||
? typeof arg[0] === 'object'
|
? typeof arg[0] === 'object'
|
||||||
? arg
|
? arg
|
||||||
: arguments
|
: arguments
|
||||||
: arg && (arg.point !== undefined || arg.x !== undefined)
|
: arg && (arg.point !== undefined && arg.size === undefined
|
||||||
|
|| arg.x !== undefined)
|
||||||
? arguments
|
? arguments
|
||||||
: null;
|
: null;
|
||||||
this.setSegments(segments || []);
|
this.setSegments(segments || []);
|
||||||
if (arg && !segments)
|
this._initialize(!segments && arg);
|
||||||
this._set(arg);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
clone: function() {
|
clone: function(insert) {
|
||||||
var copy = this._clone(new Path(this._segments));
|
var copy = this._clone(new Path({
|
||||||
|
segments: this._segments,
|
||||||
|
insert: false
|
||||||
|
}), insert);
|
||||||
copy._closed = this._closed;
|
copy._closed = this._closed;
|
||||||
if (this._clockwise !== undefined)
|
if (this._clockwise !== undefined)
|
||||||
copy._clockwise = this._clockwise;
|
copy._clockwise = this._clockwise;
|
||||||
return copy;
|
return copy;
|
||||||
},
|
},
|
||||||
|
|
||||||
_changed: function(flags) {
|
_changed: function _changed(flags) {
|
||||||
Item.prototype._changed.call(this, flags);
|
_changed.base.call(this, flags);
|
||||||
if (flags & 4) {
|
if (flags & 4) {
|
||||||
delete this._length;
|
delete this._length;
|
||||||
delete this._clockwise;
|
delete this._clockwise;
|
||||||
|
@ -5922,7 +5949,7 @@ var Path = PathItem.extend({
|
||||||
var curves = this.getCurves();
|
var curves = this.getCurves();
|
||||||
if (index >= 0 && index < curves.length) {
|
if (index >= 0 && index < curves.length) {
|
||||||
if (parameter > 0) {
|
if (parameter > 0) {
|
||||||
curves[index++].divide(parameter);
|
curves[index++].divide(parameter, true);
|
||||||
}
|
}
|
||||||
var segs = this.removeSegments(index, this._segments.length, true),
|
var segs = this.removeSegments(index, this._segments.length, true),
|
||||||
path;
|
path;
|
||||||
|
@ -6874,11 +6901,7 @@ statics: {
|
||||||
Path.inject({ statics: new function() {
|
Path.inject({ statics: new function() {
|
||||||
|
|
||||||
function createPath(args) {
|
function createPath(args) {
|
||||||
var path = new Path(),
|
return new Path(Base.getNamed(args));
|
||||||
named = Base.getNamed(args);
|
|
||||||
if (named)
|
|
||||||
path._set(named);
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRectangle() {
|
function createRectangle() {
|
||||||
|
@ -7026,10 +7049,9 @@ var CompoundPath = PathItem.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function CompoundPath(arg) {
|
initialize: function CompoundPath(arg) {
|
||||||
PathItem.call(this);
|
|
||||||
this._children = [];
|
this._children = [];
|
||||||
this._namedChildren = {};
|
this._namedChildren = {};
|
||||||
if (arg && !this._set(arg))
|
if (!this._initialize(arg))
|
||||||
this.addChildren(Array.isArray(arg) ? arg : arguments);
|
this.addChildren(Array.isArray(arg) ? arg : arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -7521,8 +7543,8 @@ PathItem.inject(new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeBoolean(path1, path2, operator, subtract) {
|
function computeBoolean(path1, path2, operator, subtract) {
|
||||||
path1 = reorientPath(path1.clone());
|
path1 = reorientPath(path1.clone(false));
|
||||||
path2 = reorientPath(path2.clone());
|
path2 = reorientPath(path2.clone(false));
|
||||||
var path1Clockwise = path1.isClockwise(),
|
var path1Clockwise = path1.isClockwise(),
|
||||||
path2Clockwise = path2.isClockwise(),
|
path2Clockwise = path2.isClockwise(),
|
||||||
intersections = path1.getIntersections(path2);
|
intersections = path1.getIntersections(path2);
|
||||||
|
@ -7650,13 +7672,11 @@ var TextItem = Item.extend({
|
||||||
_boundsGetter: 'getBounds',
|
_boundsGetter: 'getBounds',
|
||||||
|
|
||||||
initialize: function TextItem(arg) {
|
initialize: function TextItem(arg) {
|
||||||
var hasProperties = arg && Base.isPlainObject(arg)
|
|
||||||
&& arg.x === undefined && arg.y === undefined;
|
|
||||||
Item.call(this, hasProperties ? null : Point.read(arguments));
|
|
||||||
this._content = '';
|
this._content = '';
|
||||||
this._lines = [];
|
this._lines = [];
|
||||||
if (hasProperties)
|
var hasProps = arg && Base.isPlainObject(arg)
|
||||||
this._set(arg);
|
&& arg.x === undefined && arg.y === undefined;
|
||||||
|
this._initialize(hasProps && arg, !hasProps && Point.read(arguments));
|
||||||
},
|
},
|
||||||
|
|
||||||
_clone: function _clone(copy) {
|
_clone: function _clone(copy) {
|
||||||
|
@ -7692,8 +7712,8 @@ var PointText = TextItem.extend({
|
||||||
TextItem.apply(this, arguments);
|
TextItem.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
clone: function() {
|
clone: function(insert) {
|
||||||
return this._clone(new PointText());
|
return this._clone(new PointText({ insert: false }), insert);
|
||||||
},
|
},
|
||||||
|
|
||||||
getPoint: function() {
|
getPoint: function() {
|
||||||
|
@ -8467,13 +8487,16 @@ var Style = Base.extend(new function() {
|
||||||
var defaults = {
|
var defaults = {
|
||||||
fillColor: undefined,
|
fillColor: undefined,
|
||||||
strokeColor: undefined,
|
strokeColor: undefined,
|
||||||
selectedColor: undefined,
|
|
||||||
strokeWidth: 1,
|
strokeWidth: 1,
|
||||||
strokeCap: 'butt',
|
strokeCap: 'butt',
|
||||||
strokeJoin: 'miter',
|
strokeJoin: 'miter',
|
||||||
miterLimit: 10,
|
miterLimit: 10,
|
||||||
dashOffset: 0,
|
dashOffset: 0,
|
||||||
dashArray: [],
|
dashArray: [],
|
||||||
|
shadowColor: undefined,
|
||||||
|
shadowBlur: 0,
|
||||||
|
shadowOffset: new Point(),
|
||||||
|
selectedColor: undefined,
|
||||||
font: 'sans-serif',
|
font: 'sans-serif',
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
leading: null,
|
leading: null,
|
||||||
|
@ -8969,7 +8992,7 @@ var View = Base.extend(Callback, {
|
||||||
install: function() {
|
install: function() {
|
||||||
if (!this._requested) {
|
if (!this._requested) {
|
||||||
this._animate = true;
|
this._animate = true;
|
||||||
this._handleFrame(true);
|
this._requestFrame();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -8985,18 +9008,20 @@ var View = Base.extend(Callback, {
|
||||||
_time: 0,
|
_time: 0,
|
||||||
_count: 0,
|
_count: 0,
|
||||||
|
|
||||||
_handleFrame: function(request) {
|
_requestFrame: function() {
|
||||||
this._requested = false;
|
var that = this;
|
||||||
if (!this._animate)
|
DomEvent.requestAnimationFrame(function() {
|
||||||
return;
|
that._requested = false;
|
||||||
|
if (!that._animate)
|
||||||
|
return;
|
||||||
|
that._requestFrame();
|
||||||
|
that._handleFrame();
|
||||||
|
}, this._element);
|
||||||
|
this._requested = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
_handleFrame: function() {
|
||||||
paper = this._scope;
|
paper = this._scope;
|
||||||
if (request) {
|
|
||||||
this._requested = true;
|
|
||||||
var that = this;
|
|
||||||
DomEvent.requestAnimationFrame(function() {
|
|
||||||
that._handleFrame(true);
|
|
||||||
}, this._element);
|
|
||||||
}
|
|
||||||
var now = Date.now() / 1000,
|
var now = Date.now() / 1000,
|
||||||
delta = this._before ? now - this._before : 0;
|
delta = this._before ? now - this._before : 0;
|
||||||
this._before = now;
|
this._before = now;
|
||||||
|
@ -9020,11 +9045,11 @@ var View = Base.extend(Callback, {
|
||||||
time: 0,
|
time: 0,
|
||||||
count: 0
|
count: 0
|
||||||
};
|
};
|
||||||
if (++this._frameItemCount == 1)
|
if (++this._frameItemCount === 1)
|
||||||
this.attach('frame', this._handleFrameItems);
|
this.attach('frame', this._handleFrameItems);
|
||||||
} else {
|
} else {
|
||||||
delete items[item._id];
|
delete items[item._id];
|
||||||
if (--this._frameItemCount == 0) {
|
if (--this._frameItemCount === 0) {
|
||||||
this.detach('frame', this._handleFrameItems);
|
this.detach('frame', this._handleFrameItems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9788,7 +9813,7 @@ var ToolEvent = Event.extend({
|
||||||
if (!this._middlePoint && this.tool._lastPoint) {
|
if (!this._middlePoint && this.tool._lastPoint) {
|
||||||
return this.tool._point.add(this.tool._lastPoint).divide(2);
|
return this.tool._point.add(this.tool._lastPoint).divide(2);
|
||||||
}
|
}
|
||||||
return this.middlePoint;
|
return this._middlePoint;
|
||||||
},
|
},
|
||||||
|
|
||||||
setMiddlePoint: function(middlePoint) {
|
setMiddlePoint: function(middlePoint) {
|
||||||
|
@ -10211,8 +10236,16 @@ var BlendMode = new function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var nativeModes = this.nativeModes = Base.each([
|
||||||
|
'source-over', 'source-in', 'source-out', 'source-atop',
|
||||||
|
'destination-over', 'destination-in', 'destination-out',
|
||||||
|
'destination-atop', 'lighter', 'darker', 'copy', 'xor'
|
||||||
|
], function(mode) {
|
||||||
|
this[mode] = true;
|
||||||
|
}, {});
|
||||||
|
|
||||||
var ctx = CanvasProvider.getContext(1, 1);
|
var ctx = CanvasProvider.getContext(1, 1);
|
||||||
function testMode(mode) {
|
Base.each(modes, function(func, mode) {
|
||||||
ctx.save();
|
ctx.save();
|
||||||
var darken = mode === 'darken',
|
var darken = mode === 'darken',
|
||||||
ok = false;
|
ok = false;
|
||||||
|
@ -10224,19 +10257,15 @@ var BlendMode = new function() {
|
||||||
ctx.fillRect(0, 0, 1, 1);
|
ctx.fillRect(0, 0, 1, 1);
|
||||||
ok = ctx.getImageData(0, 0, 1, 1).data[0] !== (darken ? 170 : 51);
|
ok = ctx.getImageData(0, 0, 1, 1).data[0] !== (darken ? 170 : 51);
|
||||||
}
|
}
|
||||||
|
nativeModes[mode] = ok;
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
return ok;
|
});
|
||||||
}
|
|
||||||
this.nativeModes = testMode('multiply') && Base.each(modes,
|
|
||||||
function(func, mode) {
|
|
||||||
this[mode] = testMode(mode);
|
|
||||||
}, {});
|
|
||||||
CanvasProvider.release(ctx);
|
CanvasProvider.release(ctx);
|
||||||
|
|
||||||
this.process = function(mode, srcContext, dstContext, alpha, offset) {
|
this.process = function(mode, srcContext, dstContext, alpha, offset) {
|
||||||
var srcCanvas = srcContext.canvas,
|
var srcCanvas = srcContext.canvas,
|
||||||
normal = mode === 'normal';
|
normal = mode === 'normal';
|
||||||
if (normal || this.nativeModes[mode]) {
|
if (normal || nativeModes[mode]) {
|
||||||
dstContext.save();
|
dstContext.save();
|
||||||
dstContext.setTransform(1, 0, 0, 1, 0, 0);
|
dstContext.setTransform(1, 0, 0, 1, 0, 0);
|
||||||
dstContext.globalAlpha = alpha;
|
dstContext.globalAlpha = alpha;
|
||||||
|
|
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
344
dist/paper-full.js
vendored
344
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
340
dist/paper-node.js
vendored
340
dist/paper-node.js
vendored
File diff suppressed because one or more lines are too long
344
dist/paper.js
vendored
344
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.8",
|
"version": "0.9.9",
|
||||||
"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