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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user