Skip to content

Commit

Permalink
Remove extra code from Circle/Triangle (fabricjs#4547)
Browse files Browse the repository at this point in the history
* removed code

* removed code

* removed code
  • Loading branch information
asturur authored Dec 9, 2017
1 parent 01e21cc commit 1331472
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
10 changes: 0 additions & 10 deletions src/shapes/circle.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@

cacheProperties: fabric.Object.prototype.cacheProperties.concat('radius'),

/**
* Constructor
* @param {Object} [options] Options object
* @return {fabric.Circle} thisArg
*/
initialize: function(options) {
this.callSuper('initialize', options);
this.set('radius', options && options.radius || 0);
},

/**
* @private
* @param {String} key
Expand Down
19 changes: 11 additions & 8 deletions src/shapes/triangle.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,18 @@
type: 'triangle',

/**
* Constructor
* @param {Object} [options] Options object
* @return {Object} thisArg
* Width is set to 100 to compensate the old initialize code that was setting it to 100
* @type Number
* @default
*/
initialize: function(options) {
this.callSuper('initialize', options);
this.set('width', options && options.width || 100)
.set('height', options && options.height || 100);
},
width: 100,

/**
* Height is set to 100 to compensate the old initialize code that was setting it to 100
* @type Number
* @default
*/
height: 100,

/**
* @private
Expand Down
7 changes: 7 additions & 0 deletions test/unit/circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
assert.deepEqual(circle.type, 'circle');
});

QUnit.test('constructor with radius', function(assert) {
assert.ok(fabric.Circle);
var circle = new fabric.Circle({ radius: 20 });
assert.equal(circle.width, 40, 'width is set');
assert.equal(circle.height, 40, 'height is set');
});

QUnit.test('getRadiusX, getRadiusY', function(assert) {
var circle = new fabric.Circle({ radius: 10 });

Expand Down

0 comments on commit 1331472

Please sign in to comment.