kopia lustrzana https://github.com/backface/turtlestitch
experimental "column _ of _" reporter relabelling option for "item _ of _"
rodzic
33ba6f46e3
commit
9ee7c9287b
|
@ -5,6 +5,7 @@
|
||||||
* **Notable Changes:**
|
* **Notable Changes:**
|
||||||
* hyperized image attribute reporter primitive (monadic)
|
* hyperized image attribute reporter primitive (monadic)
|
||||||
* when constructing a costume from a pixel list handle single values as greyscale
|
* when constructing a costume from a pixel list handle single values as greyscale
|
||||||
|
* experimental "column _ of _" reporter relabelling option for "item _ of _"
|
||||||
* **Notable Fixes:**
|
* **Notable Fixes:**
|
||||||
* fixed a glitch in the animation library's "sine in-out" easing function
|
* fixed a glitch in the animation library's "sine in-out" easing function
|
||||||
* fixed a postMessage glitch in the API, thanks, Bernat!
|
* fixed a postMessage glitch in the API, thanks, Bernat!
|
||||||
|
@ -13,6 +14,7 @@
|
||||||
|
|
||||||
### 2021-01-26
|
### 2021-01-26
|
||||||
* threads: handle single values as greyscale when constructing a costume from a pixel list
|
* threads: handle single values as greyscale when constructing a costume from a pixel list
|
||||||
|
* threads, objects experimental "column _ of _" reporter relabelling option for "item _ of _"
|
||||||
|
|
||||||
### 2021-01-25
|
### 2021-01-25
|
||||||
* threads: hyperized image attribute reporter primitive (monadic)
|
* threads: hyperized image attribute reporter primitive (monadic)
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<script src="src/widgets.js?version=2021-01-05"></script>
|
<script src="src/widgets.js?version=2021-01-05"></script>
|
||||||
<script src="src/blocks.js?version=2020-12-22"></script>
|
<script src="src/blocks.js?version=2020-12-22"></script>
|
||||||
<script src="src/threads.js?version=2021-01-26"></script>
|
<script src="src/threads.js?version=2021-01-26"></script>
|
||||||
<script src="src/objects.js?version=2021-01-05"></script>
|
<script src="src/objects.js?version=2021-01-26"></script>
|
||||||
<script src="src/gui.js?version=2021-01-21"></script>
|
<script src="src/gui.js?version=2021-01-21"></script>
|
||||||
<script src="src/paint.js?version=2020-05-17"></script>
|
<script src="src/paint.js?version=2020-05-17"></script>
|
||||||
<script src="src/lists.js?version=2020-12-01"></script>
|
<script src="src/lists.js?version=2020-12-01"></script>
|
||||||
|
|
|
@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph,
|
||||||
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
|
localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph,
|
||||||
AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/
|
AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/
|
||||||
|
|
||||||
modules.objects = '2021-January-05';
|
modules.objects = '2021-January-26';
|
||||||
|
|
||||||
var SpriteMorph;
|
var SpriteMorph;
|
||||||
var StageMorph;
|
var StageMorph;
|
||||||
|
@ -1318,6 +1318,12 @@ SpriteMorph.prototype.initBlocks = function () {
|
||||||
spec: 'item %idx of %l',
|
spec: 'item %idx of %l',
|
||||||
defaults: [1]
|
defaults: [1]
|
||||||
},
|
},
|
||||||
|
reportTableColumn: {
|
||||||
|
type: 'reporter',
|
||||||
|
category: 'lists',
|
||||||
|
spec: 'column %idx of %l',
|
||||||
|
defaults: [1]
|
||||||
|
},
|
||||||
reportCDR: {
|
reportCDR: {
|
||||||
type: 'reporter',
|
type: 'reporter',
|
||||||
category: 'lists',
|
category: 'lists',
|
||||||
|
@ -1710,7 +1716,11 @@ SpriteMorph.prototype.blockAlternatives = {
|
||||||
doShowVar: ['doHideVar'],
|
doShowVar: ['doHideVar'],
|
||||||
doHideVar: ['doShowVar'],
|
doHideVar: ['doShowVar'],
|
||||||
|
|
||||||
// lists - HOFs
|
// lists
|
||||||
|
reportListItem: ['reportTableColumn'],
|
||||||
|
reportTableColumn: ['reportListItem'],
|
||||||
|
|
||||||
|
// HOFs
|
||||||
reportMap: ['reportKeep', 'reportFindFirst'],
|
reportMap: ['reportKeep', 'reportFindFirst'],
|
||||||
reportKeep: ['reportFindFirst', 'reportMap'],
|
reportKeep: ['reportFindFirst', 'reportMap'],
|
||||||
reportFindFirst: ['reportKeep', 'reportMap'],
|
reportFindFirst: ['reportKeep', 'reportMap'],
|
||||||
|
|
|
@ -2008,6 +2008,35 @@ Process.prototype.reportItems = function (indices, list) {
|
||||||
|
|
||||||
// Process - other basic list accessors
|
// Process - other basic list accessors
|
||||||
|
|
||||||
|
Process.prototype.reportTableColumn = function (index, list) {
|
||||||
|
// experimental and probably controversial as a primitive,
|
||||||
|
// because it's so nice and easy to write in Snap!
|
||||||
|
var col;
|
||||||
|
|
||||||
|
function columns() {
|
||||||
|
return Math.max(...list.itemsArray().map(row =>
|
||||||
|
row instanceof List ? row.length() : 0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.isMatrix(list)) {
|
||||||
|
throw new Error(
|
||||||
|
'expecting ' + 'table' + ' but getting ' + this.reportTypeOf(list)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (index === '') {
|
||||||
|
return new List(new Array(list.length()));
|
||||||
|
}
|
||||||
|
if (this.inputOption(index) === 'any') {
|
||||||
|
col = this.reportBasicRandom(1, columns());
|
||||||
|
return list.map(row => row.at(col));
|
||||||
|
}
|
||||||
|
if (this.inputOption(index) === 'last') {
|
||||||
|
return list.map(row => row.at(columns()));
|
||||||
|
}
|
||||||
|
return list.map(row => row.at(index));
|
||||||
|
};
|
||||||
|
|
||||||
Process.prototype.reportListLength = function (list) {
|
Process.prototype.reportListLength = function (list) {
|
||||||
this.assertType(list, 'list');
|
this.assertType(list, 'list');
|
||||||
return list.length();
|
return list.length();
|
||||||
|
|
Ładowanie…
Reference in New Issue