Skip to content

Commit

Permalink
fix(Fabric.ActiveSelection) Fix uniform stroke rendering for objects …
Browse files Browse the repository at this point in the history
…in groups (fabricjs#5950)

* fix uniform stroke rendering in groups
  • Loading branch information
korzo89 authored and Hristo Chakarov committed Jul 27, 2021
1 parent c9fff31 commit eac78a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/mixins/object_interactivity.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,16 @@
*/
drawBordersInGroup: function(ctx, options, styleOverride) {
styleOverride = styleOverride || {};
var p = this._getNonTransformedDimensions(),
var p = { x: options.width, y: options.height },
matrix = fabric.util.composeMatrix({
scaleX: options.scaleX,
scaleY: options.scaleY,
skewX: options.skewX
}),
wh = fabric.util.transformPoint(p, matrix),
strokeWidth = 1 / this.borderScaleFactor,
width = wh.x + strokeWidth,
height = wh.y + strokeWidth;
width = wh.x + strokeWidth / (this.strokeUniform ? options.scaleX : 1),
height = wh.y + strokeWidth / (this.strokeUniform ? options.scaleY : 1);

ctx.save();
this._setLineDash(ctx, styleOverride.borderDashArray || this.borderDashArray, null);
Expand Down
8 changes: 7 additions & 1 deletion src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,13 @@

ctx.save();
if (this.strokeUniform) {
ctx.scale(1 / this.scaleX, 1 / this.scaleY);
var scaleX = this.scaleX;
var scaleY = this.scaleY;
if (this.group) {
scaleX *= this.group.scaleX;
scaleY *= this.group.scaleY;
}
ctx.scale(1 / scaleX, 1 / scaleY);
}
this._setLineDash(ctx, this.strokeDashArray, this._renderDashedStroke);
if (this.stroke.toLive && this.stroke.gradientUnits === 'percentage') {
Expand Down

0 comments on commit eac78a8

Please sign in to comment.