mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Fix problem where calling new Raster().setSize(size) threw an error.
This commit is contained in:
parent
15dab4c2db
commit
5777c7a772
1 changed files with 4 additions and 3 deletions
|
@ -114,14 +114,15 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{
|
|||
|
||||
setSize: function() {
|
||||
var size = Size.read(arguments);
|
||||
if (!this._size.equals(size)) {
|
||||
if (!this._size || !this._size.equals(size)) {
|
||||
// Get reference to image before changing canvas
|
||||
var element = this.getElement();
|
||||
// Setting canvas internally sets _size
|
||||
this.setCanvas(CanvasProvider.getCanvas(size));
|
||||
// Draw element back onto new canvas
|
||||
this.getContext(true).drawImage(element, 0, 0,
|
||||
size.width, size.height);
|
||||
if (element)
|
||||
this.getContext(true).drawImage(element, 0, 0,
|
||||
size.width, size.height);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue