Calculate rotation center if it's not supplied

When a new skin is added, previously the rotation center was set to `[0, 0]`.  In the case of costumes and backdrops added from libraries, the center should be calculated from the bounding box of the imported skin.

Toward LLK/scratch-gui#18
This commit is contained in:
Ray Schamp
2017-01-13 13:10:20 -05:00
parent 51e8aa9b1a
commit 875a5a3ec1
4 changed files with 25 additions and 6 deletions

View File

@@ -83,6 +83,14 @@ class Skin extends EventEmitter {
}
}
/**
* Get the center of the current bounding box
* @return {[number,number]} the center of the current bounding box
*/
calculateRotationCenter () {
return [this.size[0] / 2, this.size[1] / 2];
}
/**
* @abstract
* @param {[number,number]} scale - The scaling factors to be used.