kopia lustrzana https://github.com/backface/turtlestitch
tweaked and optimized reportNewCostume() primitive
rodzic
14822fb957
commit
2aab0294ba
|
@ -4951,15 +4951,17 @@ Process.prototype.costumeNamed = function (name) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Process.prototype.reportNewCostume = function (pixels, width, height, name) {
|
Process.prototype.reportNewCostume = function (pixels, width, height, name) {
|
||||||
var rcvr = this.blockReceiver(),
|
var rcvr, stage, canvas, ctx, src, dta, i, k, px;
|
||||||
stage = rcvr.parentThatIsA(StageMorph),
|
|
||||||
canvas, ctx, src, dta, i, k, px;
|
|
||||||
|
|
||||||
this.assertType(pixels, 'list');
|
this.assertType(pixels, 'list');
|
||||||
if (this.inputOption(width) === 'current') {
|
if (this.inputOption(width) === 'current') {
|
||||||
|
rcvr = this.blockReceiver();
|
||||||
|
stage = rcvr.parentThatIsA(StageMorph);
|
||||||
width = rcvr.costume ? rcvr.costume.width() : stage.dimensions.x;
|
width = rcvr.costume ? rcvr.costume.width() : stage.dimensions.x;
|
||||||
}
|
}
|
||||||
if (this.inputOption(height) === 'current') {
|
if (this.inputOption(height) === 'current') {
|
||||||
|
rcvr = rcvr || this.blockReceiver();
|
||||||
|
stage = stage || rcvr.parentThatIsA(StageMorph);
|
||||||
height = rcvr.costume ? rcvr.costume.height() : stage.dimensions.y;
|
height = rcvr.costume ? rcvr.costume.height() : stage.dimensions.y;
|
||||||
}
|
}
|
||||||
width = Math.abs(Math.floor(+width));
|
width = Math.abs(Math.floor(+width));
|
||||||
|
@ -4983,7 +4985,7 @@ Process.prototype.reportNewCostume = function (pixels, width, height, name) {
|
||||||
ctx.putImageData(dta, 0, 0);
|
ctx.putImageData(dta, 0, 0);
|
||||||
return new Costume(
|
return new Costume(
|
||||||
canvas,
|
canvas,
|
||||||
name || rcvr.newCostumeName(localize('snap'))
|
name || (rcvr || this.blockReceiver()).newCostumeName(localize('snap'))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue