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

move backgroundColor to all classes #3248

Merged
merged 1 commit into from
Sep 11, 2016
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
28 changes: 26 additions & 2 deletions src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1097,20 +1097,44 @@
if (!noTransform) {
this.transform(ctx);
}
this._setOpacity(ctx);
this._setShadow(ctx);
this._renderBackground(ctx);
this._setStrokeStyles(ctx);
this._setFillStyles(ctx);
if (this.transformMatrix) {
ctx.transform.apply(ctx, this.transformMatrix);
}
this._setOpacity(ctx);
this._setShadow(ctx);
this.clipTo && fabric.util.clipContext(this, ctx);
this._render(ctx, noTransform);
this.clipTo && ctx.restore();

ctx.restore();
},

/**
* Draws a background for the object big as its width and height;
* @private
* @param {CanvasRenderingContext2D} ctx Context to render on
*/
_renderBackground: function(ctx) {
if (!this.backgroundColor) {
return;
}

ctx.fillStyle = this.backgroundColor;

ctx.fillRect(
-this.width / 2,
-this.height / 2,
this.width,
this.height
);
// if there is background color no other shadows
// should be casted
this._removeShadow(ctx);
},

/**
* @private
* @param {CanvasRenderingContext2D} ctx Context to render on
Expand Down
24 changes: 1 addition & 23 deletions src/shapes/text.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,32 +634,10 @@
* @param {CanvasRenderingContext2D} ctx Context to render on
*/
_renderTextBackground: function(ctx) {
this._renderTextBoxBackground(ctx);
this._renderBackground(ctx);
this._renderTextLinesBackground(ctx);
},

/**
* @private
* @param {CanvasRenderingContext2D} ctx Context to render on
*/
_renderTextBoxBackground: function(ctx) {
if (!this.backgroundColor) {
return;
}

ctx.fillStyle = this.backgroundColor;

ctx.fillRect(
this._getLeftOffset(),
this._getTopOffset(),
this.width,
this.height
);
// if there is background color no other shadows
// should be casted
this._removeShadow(ctx);
},

/**
* @private
* @param {CanvasRenderingContext2D} ctx Context to render on
Expand Down