accept a list of pixels in the SWITCH TO COSTUME block

thanks, @DyslexicAwe for the idea!
pull/89/head
jmoenig 2019-10-11 08:45:45 +02:00
rodzic d4acdbbb9d
commit 6ff5dcd6bb
4 zmienionych plików z 28 dodań i 6 usunięć

Wyświetl plik

@ -3,6 +3,7 @@
## in development:
* **New Features:**
* new cloud-menu entry: "Open in Community Site", thanks, Michael!
* accept a list of pixels in the SWITCH TO COSTUME block
* **Notable Changes:**
* **Notable Fixes:**
* morphic collision detection off-by-1 fix, thanks, Dariusz!
@ -14,6 +15,9 @@
* Galician, thanks, Bernat
* Turkish, thanks, Turgut!
### 2019-10-11
* objects, threads: accept a list of pixels in the SWITCH TO COSTUME block
### 2019-10-09
* new dev version
* morphic: collision detection off-by-1 fix, thanks, @DarDoro

Wyświetl plik

@ -7,8 +7,8 @@
<script type="text/javascript" src="src/morphic.js?version=2019-08-06"></script>
<script type="text/javascript" src="src/widgets.js?version=2019-06-27"></script>
<script type="text/javascript" src="src/blocks.js?version=2019-08-07"></script>
<script type="text/javascript" src="src/threads.js?version=2019-08-07"></script>
<script type="text/javascript" src="src/objects.js?version=2019-08-08"></script>
<script type="text/javascript" src="src/threads.js?version=2019-10-11"></script>
<script type="text/javascript" src="src/objects.js?version=2019-10-11"></script>
<script type="text/javascript" src="src/gui.js?version=2019-10-09"></script>
<script type="text/javascript" src="src/paint.js?version=2019-06-27"></script>
<script type="text/javascript" src="src/lists.js?version=2019-07-01"></script>

Wyświetl plik

@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph,
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
HandleMorph, AlignmentMorph, Process, XML_Element, WorldMap*/
modules.objects = '2019-August-08';
modules.objects = '2019-October-11';
var SpriteMorph;
var StageMorph;
@ -3516,6 +3516,24 @@ SpriteMorph.prototype.doWearPreviousCostume = function () {
};
SpriteMorph.prototype.doSwitchToCostume = function (id, noShadow) {
var w, h;
if (id instanceof List) { // try to turn a list of pixels into a costume
if (this.costume) {
// recycle dimensions of current costume
w = this.costume.width();
h = this.costume.height();
} else {
// assume stage's dimensions
w = StageMorph.prototype.dimensions.x;
h = StageMorph.prototype.dimensions.y;
}
id = Process.prototype.reportNewCostume(
id,
w,
h,
this.newCostumeName(localize('snap'))
);
}
if (id instanceof Costume) { // allow first-class costumes
this.wearCostume(id, noShadow);
return;

Wyświetl plik

@ -61,7 +61,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy,
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph, Color,
TableFrameMorph, ColorSlotMorph, isSnapObject, Map, newCanvas, Symbol*/
modules.threads = '2019-August-07';
modules.threads = '2019-October-11';
var ThreadManager;
var Process;
@ -4933,7 +4933,7 @@ Process.prototype.costumeNamed = function (name) {
);
};
Process.prototype.reportNewCostume = function (pixels, width, height) {
Process.prototype.reportNewCostume = function (pixels, width, height, name) {
// private
width = Math.abs(Math.floor(+width));
height = Math.abs(Math.floor(+height));
@ -4953,7 +4953,7 @@ Process.prototype.reportNewCostume = function (pixels, width, height) {
ctx.putImageData(dta, 0, 0);
return new Costume(
canvas,
this.blockReceiver().newCostumeName(localize('snap'))
name || this.blockReceiver().newCostumeName(localize('snap'))
);
};