mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Have Raster constructor set Raster#_size to [0, 0] if it was not set.
This commit is contained in:
parent
5777c7a772
commit
0d3f746c10
2 changed files with 8 additions and 1 deletions
|
@ -88,6 +88,8 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
|
|||
this.setImage(object);
|
||||
}
|
||||
}
|
||||
if (!this._size)
|
||||
this._size = new Size();
|
||||
},
|
||||
|
||||
clone: function() {
|
||||
|
@ -114,7 +116,7 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
|
|||
|
||||
setSize: function() {
|
||||
var size = Size.read(arguments);
|
||||
if (!this._size || !this._size.equals(size)) {
|
||||
if (!this._size.equals(size)) {
|
||||
// Get reference to image before changing canvas
|
||||
var element = this.getElement();
|
||||
// Setting canvas internally sets _size
|
||||
|
|
|
@ -12,6 +12,11 @@
|
|||
|
||||
module('Raster');
|
||||
|
||||
test('Create a raster without a source and check its size', function() {
|
||||
var raster = new Raster();
|
||||
equals(raster.size.toString(), new Size(0, 0).toString(), true);
|
||||
});
|
||||
|
||||
test('Create a raster without a source and set its size', function() {
|
||||
var raster = new Raster();
|
||||
raster.size = [640, 480];
|
||||
|
|
Loading…
Reference in a new issue