Skip to content

Commit

Permalink
refactor(): remove drawBordersInGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 committed May 10, 2022
1 parent 1d40cd9 commit d257c99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 26 deletions.
31 changes: 11 additions & 20 deletions src/mixins/object_interactivity.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,33 +146,24 @@
* Requires public properties: width, height
* Requires public options: padding, borderColor
* @param {CanvasRenderingContext2D} ctx Context to draw on
* @param {Object} styleOverride object to override the object style
* @return {fabric.Object} thisArg
* @chainable
*/
drawBorders: function (ctx, styleOverride) {
var size = this._calculateCurrentDimensions().scalarAddEquals(this.borderScaleFactor);
this._drawBorders(ctx, size, styleOverride);
return this;
},

/**
* Draws borders of an object's bounding box when it is inside a group.
* Requires public properties: width, height
* Requires public options: padding, borderColor
* @param {CanvasRenderingContext2D} ctx Context to draw on
* @param {object} options object representing current object parameters
* @param {Object} styleOverride object to override the object style
* @param {Object} [styleOverride] object to override the object style
* @return {fabric.Object} thisArg
* @chainable
*/
drawBordersInGroup: function (ctx, options, styleOverride) {
var bbox = fabric.util.sizeAfterTransform(this.width, this.height, options),
drawBorders: function (ctx, options, styleOverride) {
var size;
if ((styleOverride && styleOverride.forActiveSelection) || this.group) {
var bbox = fabric.util.sizeAfterTransform(this.width, this.height, options),
strokeFactor = this.strokeUniform ?
new fabric.Point(0, 0).scalarAddEquals(this.canvas.getZoom()) :
new fabric.Point(options.scaleX, options.scaleY),
stroke = strokeFactor.scalarMultiplyEquals(this.strokeWidth),
size = bbox.addEquals(stroke).scalarAddEquals(this.borderScaleFactor);
stroke = strokeFactor.scalarMultiplyEquals(this.strokeWidth);
size = bbox.addEquals(stroke).scalarAddEquals(this.borderScaleFactor);
}
else {
size = this._calculateCurrentDimensions().scalarAddEquals(this.borderScaleFactor);
}
this._drawBorders(ctx, size, styleOverride);
return this;
},
Expand Down
7 changes: 1 addition & 6 deletions src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1402,12 +1402,7 @@
options.angle -= 180;
}
ctx.rotate(degreesToRadians(this.group ? options.angle : this.angle));
if (drawBorders && (styleOverride.forActiveSelection || this.group)) {
this.drawBordersInGroup(ctx, options, styleOverride);
}
else if (drawBorders) {
this.drawBorders(ctx, styleOverride);
}
drawBorders && this.drawBorders(ctx, options, styleOverride);
drawControls && this.drawControls(ctx, styleOverride);
ctx.restore();
},
Expand Down

0 comments on commit d257c99

Please sign in to comment.