mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Stop using style beans internally.
This commit is contained in:
parent
1d866ecb6c
commit
1d858147ec
3 changed files with 17 additions and 16 deletions
|
@ -3,7 +3,7 @@ var Item = this.Item = Base.extend({
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
paper.document.activeLayer.appendTop(this);
|
paper.document.activeLayer.appendTop(this);
|
||||||
this.style = this.document.getCurrentStyle();
|
this.setStyle(this.document.getCurrentStyle());
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,29 +19,30 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Item.inject(Base.each(keys, function(key) {
|
Item.inject(Base.each(keys, function(key) {
|
||||||
|
var isColor = !!(key.match(/Color$/)),
|
||||||
|
set = 'set' + Base.capitalize(key),
|
||||||
|
get = 'get' + Base.capitalize(key);
|
||||||
|
|
||||||
var isColor = !!(key.match(/Color$/));
|
fields[set] = function(value) {
|
||||||
fields['set' + Base.capitalize(key)] = function(value) {
|
|
||||||
if (this.item && this.item.children) {
|
if (this.item && this.item.children) {
|
||||||
for (var i = 0, l = this.item.children.length; i < l; i++) {
|
for (var i = 0, l = this.item.children.length; i < l; i++) {
|
||||||
this.item.children[i].style[key] = value;
|
this.item.children[i].getStyle()[set](value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this['_' + key] = isColor ? Color.read(arguments) : value;
|
this['_' + key] = isColor ? Color.read(arguments) : value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fields['get' + Base.capitalize(key)] = function() {
|
fields[get] = function() {
|
||||||
if (this.item && this.item.children) {
|
if (this.item && this.item.children) {
|
||||||
var style;
|
var style;
|
||||||
for (var i = 0, l = this.item.children.length; i < l; i++) {
|
for (var i = 0, l = this.item.children.length; i < l; i++) {
|
||||||
|
var s = this.item.children[i].getStyle()[get]();
|
||||||
if (!style) {
|
if (!style) {
|
||||||
style = this.item.children[i].style[key];
|
style = s;
|
||||||
} else if (style != this.item.children[i].style[key]) {
|
} else if (style != s) {
|
||||||
// If there is another item with a different style:
|
// If there is another item with a different style:
|
||||||
// TODO: Shouldn't this be undefined instead? null often
|
return undefined;
|
||||||
// has meaning for styles.
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return style;
|
return style;
|
||||||
|
@ -50,12 +51,12 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this['set' + Base.capitalize(key)] = function(value) {
|
this[set] = function(value) {
|
||||||
this.style[key] = value;
|
this.getStyle()[set](value);
|
||||||
};
|
};
|
||||||
|
|
||||||
this['get' + Base.capitalize(key)] = function() {
|
this[get] = function() {
|
||||||
return this.style[key];
|
return this.getStyle()[get]();
|
||||||
};
|
};
|
||||||
}, { beans: true }));
|
}, { beans: true }));
|
||||||
|
|
||||||
|
|
|
@ -243,10 +243,10 @@ var Raster = this.Raster = Item.extend({
|
||||||
var delta = bounds.topLeft.multiply(-1);
|
var delta = bounds.topLeft.multiply(-1);
|
||||||
ctx.translate(delta.x, delta.y);
|
ctx.translate(delta.x, delta.y);
|
||||||
if (path) {
|
if (path) {
|
||||||
var style = object.style;
|
var style = object.getStyle();
|
||||||
path.draw(ctx);
|
path.draw(ctx);
|
||||||
ctx.clip();
|
ctx.clip();
|
||||||
path.style = style;
|
path.setStyle(style);
|
||||||
}
|
}
|
||||||
var matrix = this.matrix.clone();
|
var matrix = this.matrix.clone();
|
||||||
var transMatrix = Matrix.getTranslateInstance(delta);
|
var transMatrix = Matrix.getTranslateInstance(delta);
|
||||||
|
|
Loading…
Reference in a new issue