mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Fix wrong default fillColor on TextItems.
This commit is contained in:
parent
cb0dcf1719
commit
34ad9045cc
2 changed files with 16 additions and 11 deletions
|
@ -72,8 +72,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
else
|
||||
this._setProject(project);
|
||||
}
|
||||
this._style = new Style(this._project._currentStyle);
|
||||
this._style._item = this;
|
||||
this._style = new Style(this._project._currentStyle, this);
|
||||
this._matrix = new Matrix();
|
||||
if (point)
|
||||
this._matrix.translate(point);
|
||||
|
@ -382,7 +381,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
|
|||
},
|
||||
|
||||
setStyle: function(style) {
|
||||
this._style.initialize(style);
|
||||
this._style.set(style);
|
||||
},
|
||||
|
||||
hasFill: function() {
|
||||
|
|
|
@ -202,17 +202,23 @@ var Style = Base.extend(new function() {
|
|||
Item.inject(item);
|
||||
return fields;
|
||||
}, /** @lends Style# */{
|
||||
initialize: function Style(style) {
|
||||
initialize: function Style(style, _item) {
|
||||
// We keep values in a separate object that we can iterate over.
|
||||
this._values = {};
|
||||
if (this._item instanceof TextItem)
|
||||
this._item = _item;
|
||||
if (_item instanceof TextItem)
|
||||
this._defaults = this._textDefaults;
|
||||
if (style) {
|
||||
// If the passed style object is also a Style, clone its clonable
|
||||
// fields rather than simply copying them.
|
||||
var isStyle = style instanceof Style,
|
||||
// Use the other stlyle's _values object for iteration
|
||||
values = isStyle ? style._values : style;
|
||||
if (style)
|
||||
this.set(style);
|
||||
},
|
||||
|
||||
set: function(style) {
|
||||
// If the passed style object is also a Style, clone its clonable
|
||||
// fields rather than simply copying them.
|
||||
var isStyle = style instanceof Style,
|
||||
// Use the other stlyle's _values object for iteration
|
||||
values = isStyle ? style._values : style;
|
||||
if (values) {
|
||||
for (var key in values) {
|
||||
if (key in this._defaults) {
|
||||
var value = values[key];
|
||||
|
|
Loading…
Reference in a new issue