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

Refinements to strokeUniform property #5527

Merged
merged 12 commits into from
Feb 17, 2019
Prev Previous commit
Next Next commit
trying the other function
asturur committed Jan 19, 2019
commit d6259c9028d46845d966fbbd27feea3d410a82e5
40 changes: 28 additions & 12 deletions src/mixins/object_geometry.mixin.js
Original file line number Diff line number Diff line change
@@ -588,18 +588,23 @@
if (typeof skewY === 'undefined') {
skewY = this.skewY;
}
var dimensions = this._getNonTransformedDimensions();
if (skewX === 0 && skewY === 0) {
return { x: dimensions.x * this.scaleX, y: dimensions.y * this.scaleY };
}
var dimX, dimY;
var dimensions = this._getNonTransformedDimensions(), dimX, dimY,
noSkew = skewX === 0 && skewY === 0;

if (this.strokeUniform) {
dimX = this.width / 2;
dimY = this.height / 2;
dimX = this.width;
dimY = this.height;
}
else {
dimX = dimensions.x;
dimY = dimensions.y;
}
if (noSkew) {
return this._finalizeDiemensions(dimX, dimY);
}
else {
dimX = dimensions.x / 2;
dimY = dimensions.y / 2;
dimX /= 2;
dimY /= 2;
}
var points = [
{
@@ -624,12 +629,23 @@
points[i] = fabric.util.transformPoint(points[i], transformMatrix);
}
bbox = fabric.util.makeBoundingBoxFromPoints(points);
return this._finalizeDiemensions(bbox.width, bbox.height);
},

/*
* Calculate object bounding boxdimensions from its properties scale, skew.
* @param Number width width of the bbox
* @param Number height height of the bbox
* @private
* @return {Object} .x finalized width dimension
* @return {Object} .y finalized height dimension
*/
_finalizeDiemensions: function(width, height) {
return this.strokeUniform ?
{ x: bbox.width + this.strokeWidth, y: bbox.height + this.strokeWidth }
{ x: width + this.strokeWidth, y: height + this.strokeWidth }
:
{ x: bbox.width, y: bbox.height };
{ x: width, y: height };
},

/*
* Calculate object dimensions for controls. include padding and canvas zoom
* private