Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix restore stroke gradient from object #2182

Merged
merged 2 commits into from
May 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,9 @@
if (options.fill && options.fill.colorStops && !(options.fill instanceof fabric.Gradient)) {
this.set('fill', new fabric.Gradient(options.fill));
}
if (options.stroke && options.stroke.colorStops && !(options.stroke instanceof fabric.Gradient)) {
this.set('stroke', new fabric.Gradient(options.stroke));
}
},

/**
Expand Down Expand Up @@ -1111,7 +1114,7 @@
return;
}

if (!this.shadow.affectStroke) {
if (this.shadow && !this.shadow.affectStroke) {
this._removeShadow(ctx);
}

Expand Down
7 changes: 7 additions & 0 deletions test/unit/rect.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
var rect = fabric.Rect.fromObject(REFERENCE_RECT);
ok(rect instanceof fabric.Rect);
deepEqual(rect.toObject(), REFERENCE_RECT);

var expectedObject = fabric.util.object.extend({ }, REFERENCE_RECT);
expectedObject.fill = {"type":"linear","coords":{"x1":0,"y1":0,"x2":200,"y2":0},"colorStops":[{"offset":"0","color":"rgb(255,0,0)","opacity":1},{"offset":"1","color":"rgb(0,0,255)","opacity":1}],"offsetX":0,"offsetY":0};
expectedObject.stroke = {"type":"linear","coords":{"x1":0,"y1":0,"x2":200,"y2":0},"colorStops":[{"offset":"0","color":"rgb(255,0,0)","opacity":1},{"offset":"1","color":"rgb(0,0,255)","opacity":1}],"offsetX":0,"offsetY":0};
rect = fabric.Rect.fromObject(expectedObject);
ok(rect.fill instanceof fabric.Gradient);
ok(rect.stroke instanceof fabric.Gradient);
});

test('fabric.Rect.fromElement', function() {
Expand Down