diff --git a/src/mixins/object_origin.mixin.js b/src/mixins/object_origin.mixin.js
index eaf55cef..327b4c69 100644
--- a/src/mixins/object_origin.mixin.js
+++ b/src/mixins/object_origin.mixin.js
@@ -13,21 +13,20 @@
*/
translateToCenterPoint: function(point, originX, originY) {
var cx = point.x,
- cy = point.y,
- strokeWidth = this.stroke ? this.strokeWidth : 0;
+ cy = point.y;
if (originX === 'left') {
- cx = point.x + (this.getWidth() + strokeWidth * this.scaleX) / 2;
+ cx = point.x + (this.getWidth() + this.strokeWidth * this.scaleX) / 2;
}
else if (originX === 'right') {
- cx = point.x - (this.getWidth() + strokeWidth * this.scaleX) / 2;
+ cx = point.x - (this.getWidth() + this.strokeWidth * this.scaleX) / 2;
}
if (originY === 'top') {
- cy = point.y + (this.getHeight() + strokeWidth * this.scaleY) / 2;
+ cy = point.y + (this.getHeight() + this.strokeWidth * this.scaleY) / 2;
}
else if (originY === 'bottom') {
- cy = point.y - (this.getHeight() + strokeWidth * this.scaleY) / 2;
+ cy = point.y - (this.getHeight() + this.strokeWidth * this.scaleY) / 2;
}
// Apply the reverse rotation to the point (it's already scaled properly)
@@ -43,21 +42,20 @@
*/
translateToOriginPoint: function(center, originX, originY) {
var x = center.x,
- y = center.y,
- strokeWidth = this.stroke ? this.strokeWidth : 0;
+ y = center.y;
// Get the point coordinates
if (originX === 'left') {
- x = center.x - (this.getWidth() + strokeWidth * this.scaleX) / 2;
+ x = center.x - (this.getWidth() + this.strokeWidth * this.scaleX) / 2;
}
else if (originX === 'right') {
- x = center.x + (this.getWidth() + strokeWidth * this.scaleX) / 2;
+ x = center.x + (this.getWidth() + this.strokeWidth * this.scaleX) / 2;
}
if (originY === 'top') {
- y = center.y - (this.getHeight() + strokeWidth * this.scaleY) / 2;
+ y = center.y - (this.getHeight() + this.strokeWidth * this.scaleY) / 2;
}
else if (originY === 'bottom') {
- y = center.y + (this.getHeight() + strokeWidth * this.scaleY) / 2;
+ y = center.y + (this.getHeight() + this.strokeWidth * this.scaleY) / 2;
}
// Apply the rotation to the point (it's already scaled properly)
@@ -102,25 +100,24 @@
*/
toLocalPoint: function(point, originX, originY) {
var center = this.getCenterPoint(),
- strokeWidth = this.stroke ? this.strokeWidth : 0,
x, y;
if (originX && originY) {
if (originX === 'left') {
- x = center.x - (this.getWidth() + strokeWidth * this.scaleX) / 2;
+ x = center.x - (this.getWidth() + this.strokeWidth * this.scaleX) / 2;
}
else if (originX === 'right') {
- x = center.x + (this.getWidth() + strokeWidth * this.scaleX) / 2;
+ x = center.x + (this.getWidth() + this.strokeWidth * this.scaleX) / 2;
}
else {
x = center.x;
}
if (originY === 'top') {
- y = center.y - (this.getHeight() + strokeWidth * this.scaleY) / 2;
+ y = center.y - (this.getHeight() + this.strokeWidth * this.scaleY) / 2;
}
else if (originY === 'bottom') {
- y = center.y + (this.getHeight() + strokeWidth * this.scaleY) / 2;
+ y = center.y + (this.getHeight() + this.strokeWidth * this.scaleY) / 2;
}
else {
y = center.y;
diff --git a/src/shapes/group.class.js b/src/shapes/group.class.js
index ee5de529..fde9cbba 100644
--- a/src/shapes/group.class.js
+++ b/src/shapes/group.class.js
@@ -41,6 +41,13 @@
*/
type: 'group',
+ /**
+ * Width of stroke
+ * @type Number
+ * @default
+ */
+ strokeWidth: 0,
+
/**
* Constructor
* @param {Object} objects Group objects
diff --git a/test/unit/group.js b/test/unit/group.js
index e5a0541a..b436b293 100644
--- a/test/unit/group.js
+++ b/test/unit/group.js
@@ -201,7 +201,6 @@ test('toObject without default values', function() {
'top': 100,
'width': 80,
'height': 60,
- 'strokeWidth': 0,
'objects': clone.objects
};
diff --git a/test/unit/object.js b/test/unit/object.js
index 751b8604..0fa7213a 100644
--- a/test/unit/object.js
+++ b/test/unit/object.js
@@ -368,29 +368,29 @@ test('getBoundingRectWithStroke', function() {
cObj.setCoords();
boundingRect = cObj.getBoundingRect();
- equal(boundingRect.left.toFixed(2), -0.5);
- equal(boundingRect.top.toFixed(2), -0.5);
+ equal(boundingRect.left.toFixed(2), 0);
+ equal(boundingRect.top.toFixed(2), 0);
equal(boundingRect.width.toFixed(2), 1);
equal(boundingRect.height.toFixed(2), 1);
cObj.set('width', 123).setCoords();
boundingRect = cObj.getBoundingRect();
- equal(boundingRect.left.toFixed(2), -0.5);
- equal(boundingRect.top.toFixed(2), -0.5);
+ equal(boundingRect.left.toFixed(2), 0);
+ equal(boundingRect.top.toFixed(2), 0);
equal(boundingRect.width.toFixed(2), 124);
equal(boundingRect.height.toFixed(2), 1);
cObj.set('height', 167).setCoords();
boundingRect = cObj.getBoundingRect();
- equal(boundingRect.left.toFixed(2), -0.5);
- equal(boundingRect.top.toFixed(2), -0.5);
+ equal(boundingRect.left.toFixed(2), 0);
+ equal(boundingRect.top.toFixed(2), 0);
equal(boundingRect.width.toFixed(2), 124);
equal(boundingRect.height.toFixed(2), 168);
cObj.scale(2).setCoords();
boundingRect = cObj.getBoundingRect();
- equal(boundingRect.left.toFixed(2), -1);
- equal(boundingRect.top.toFixed(2), -1);
+ equal(boundingRect.left.toFixed(2), 0);
+ equal(boundingRect.top.toFixed(2), 0);
equal(boundingRect.width.toFixed(2), 248);
equal(boundingRect.height.toFixed(2), 336);
});
@@ -951,7 +951,7 @@ test('toDataURL & reference to canvas', function() {
test('center', function() {
var object = new fabric.Object();
-
+ object.strokeWidth = 0;
ok(typeof object.center == 'function');
canvas.add(object);
@@ -963,7 +963,7 @@ test('toDataURL & reference to canvas', function() {
test('centerH', function() {
var object = new fabric.Object();
-
+ object.strokeWidth = 0;
ok(typeof object.centerH == 'function');
canvas.add(object);
@@ -974,7 +974,7 @@ test('toDataURL & reference to canvas', function() {
test('centerV', function() {
var object = new fabric.Object();
-
+ object.strokeWidth = 0;
ok(typeof object.centerV == 'function');
canvas.add(object);
diff --git a/test/unit/path_group.js b/test/unit/path_group.js
index 5480383f..11e9fe07 100644
--- a/test/unit/path_group.js
+++ b/test/unit/path_group.js
@@ -243,13 +243,14 @@
ok(fabric.PathGroup);
getPathGroupObject(function(pathGroup) {
ok(typeof pathGroup.toSVG == 'function');
+ pathGroup.strokeWidth = 0;
pathGroup.originX = 'center';
pathGroup.originY = 'center';
pathGroup.width = 700;
pathGroup.height = 600;
pathGroup.left = 350;
pathGroup.top = 300;
- equal(pathGroup.toSVG(), REFERENCE_PATH_GROUP_SVG);
+ equal(pathGroup.toSVG(), REFERENCE_PATH_GROUP_SVG.replace('stroke-width: 1', 'stroke-width: 0'));
start();
});
});
diff --git a/test/unit/rect.js b/test/unit/rect.js
index 7e1f5bcc..76c6333b 100644
--- a/test/unit/rect.js
+++ b/test/unit/rect.js
@@ -131,10 +131,10 @@
});
test('toSVG with rounded corners', function() {
- var rect = new fabric.Rect({ width: 100, height: 100, rx: 20, ry: 30 });
+ var rect = new fabric.Rect({ width: 100, height: 100, rx: 20, ry: 30, strokeWidth: 0 });
var svg = rect.toSVG();
- equal(svg, '\n');
+ equal(svg, '\n');
});
test('toObject without default values', function() {
diff --git a/test/unit/text.js b/test/unit/text.js
index 336a0bed..c457de3e 100644
--- a/test/unit/text.js
+++ b/test/unit/text.js
@@ -46,7 +46,7 @@
'globalCompositeOperation': 'source-over'
};
- var TEXT_SVG = '\t\n\t\tx\n\t\n';
+ var TEXT_SVG = '\t\n\t\tx\n\t\n';
test('constructor', function() {
ok(fabric.Text);