mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-04 03:45:58 -05:00
Merge remote branch 'origin/master'
Conflicts: test/lib/helpers.js
This commit is contained in:
commit
0a86c2b34e
5 changed files with 16 additions and 12 deletions
|
@ -36,9 +36,8 @@ var Item = this.Item = Base.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
_clone: function(copy) {
|
_clone: function(copy) {
|
||||||
// If this item has a pathStyle, copy it:
|
// Copy over style
|
||||||
if (this._style)
|
copy.setStyle(this._style);
|
||||||
copy.setStyle(this._style);
|
|
||||||
// If this item has children, clone and append each of them:
|
// If this item has children, clone and append each of them:
|
||||||
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++)
|
||||||
|
|
|
@ -63,7 +63,7 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
||||||
} else {
|
} else {
|
||||||
var old = this['_' + key];
|
var old = this['_' + key];
|
||||||
if (old != value && !(old && old.equals && old.equals(value))) {
|
if (old != value && !(old && old.equals && old.equals(value))) {
|
||||||
this['_' + key] = value;
|
this['_' + key] = value && value.clone ? value.clone() : value;
|
||||||
if (this._item) {
|
if (this._item) {
|
||||||
this._item._changed(ChangeFlags.STYLE
|
this._item._changed(ChangeFlags.STYLE
|
||||||
| (strokeFlags[key] ? ChangeFlags.STROKE : 0));
|
| (strokeFlags[key] ? ChangeFlags.STROKE : 0));
|
||||||
|
@ -83,7 +83,8 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
||||||
var childStyle = children[i]._style[get]();
|
var childStyle = children[i]._style[get]();
|
||||||
if (!style) {
|
if (!style) {
|
||||||
style = childStyle;
|
style = childStyle;
|
||||||
} else if (style != childStyle) {
|
} else if (style != childStyle && !(style && style.equals
|
||||||
|
&& style.equals(childStyle))) {
|
||||||
// If there is another item with a different style,
|
// If there is another item with a different style,
|
||||||
// the style is not defined:
|
// the style is not defined:
|
||||||
// PORT: Change this in Sg (currently returns null)
|
// PORT: Change this in Sg (currently returns null)
|
||||||
|
@ -96,6 +97,7 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Style-getters and setters for Item:
|
||||||
// 'this' = the Base.each() side-car = the object that is returned from
|
// 'this' = the Base.each() side-car = the object that is returned from
|
||||||
// Base.each and injected into Item above:
|
// Base.each and injected into Item above:
|
||||||
this[set] = function(value) {
|
this[set] = function(value) {
|
||||||
|
|
|
@ -55,17 +55,20 @@ var SegmentPoint = Point.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
statics: {
|
statics: {
|
||||||
create: function(segment, x, y) {
|
create: function(segment, x, y, selected) {
|
||||||
if (y === undefined) {
|
if (y === undefined) {
|
||||||
// Use the normal point constructor to read in point values
|
// Use the normal point constructor to read in point values
|
||||||
var tmp = new Point(x);
|
var pt = x instanceof Point ? x : new Point(x);
|
||||||
x = tmp.x;
|
x = pt.x;
|
||||||
y = tmp.y;
|
y = pt.y;
|
||||||
|
selected = pt.selected;
|
||||||
}
|
}
|
||||||
var point = new SegmentPoint(SegmentPoint.dont);
|
var point = new SegmentPoint(SegmentPoint.dont);
|
||||||
point._x = x;
|
point._x = x;
|
||||||
point._y = y;
|
point._y = y;
|
||||||
point._owner = segment;
|
point._owner = segment;
|
||||||
|
if (selected)
|
||||||
|
point.setSelected(true);
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ test('Path#clone()', function() {
|
||||||
path.locked = true;
|
path.locked = true;
|
||||||
path.visible = false;
|
path.visible = false;
|
||||||
path.blendMode = 'blend';
|
path.blendMode = 'blend';
|
||||||
path._clipMask = true;
|
path.clipMask = true;
|
||||||
path.selected = true;
|
path.selected = true;
|
||||||
cloneAndCompare(path);
|
cloneAndCompare(path);
|
||||||
});
|
});
|
||||||
|
|
|
@ -95,7 +95,7 @@ test('appendTop / appendBottom / nesting', function() {
|
||||||
return project.layers.length;
|
return project.layers.length;
|
||||||
}, 2);
|
}, 2);
|
||||||
equals(function() {
|
equals(function() {
|
||||||
return project.layers[0] == firstLayer
|
return project.layers[0] == secondLayer
|
||||||
&& project.layers[1] == secondLayer;
|
&& project.layers[1] == firstLayer;
|
||||||
}, true);
|
}, true);
|
||||||
});
|
});
|
Loading…
Reference in a new issue