mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Keep min and max scale in relative bounds as in Scratch 2.0 (#333)
This commit is contained in:
commit
0994d3f22b
1 changed files with 11 additions and 2 deletions
|
@ -249,9 +249,18 @@ RenderedTarget.prototype.setSize = function (size) {
|
|||
if (this.isStage) {
|
||||
return;
|
||||
}
|
||||
// Keep size between 5% and 535%.
|
||||
this.size = MathUtil.clamp(size, 5, 535);
|
||||
if (this.renderer) {
|
||||
// Clamp to scales relative to costume and stage size.
|
||||
// See original ScratchSprite.as:setSize.
|
||||
var costumeSize = this.renderer.getSkinSize(this.drawableID);
|
||||
var origW = Math.round(costumeSize[0]);
|
||||
var origH = Math.round(costumeSize[1]);
|
||||
var minScale = Math.min(1, Math.max(5 / origW, 5 / origH));
|
||||
var maxScale = Math.min(
|
||||
(1.5 * this.runtime.constructor.STAGE_WIDTH) / origW,
|
||||
(1.5 * this.runtime.constructor.STAGE_HEIGHT) / origH
|
||||
);
|
||||
this.size = Math.round(MathUtil.clamp(size / 100, minScale, maxScale) * 100);
|
||||
var renderedDirectionScale = this._getRenderedDirectionAndScale();
|
||||
this.renderer.updateDrawableProperties(this.drawableID, {
|
||||
direction: renderedDirectionScale.direction,
|
||||
|
|
Loading…
Reference in a new issue