kopia lustrzana https://github.com/backface/turtlestitch
added "new costume" primitive reporter to "looks" category
rodzic
8e0c9fe0c2
commit
14822fb957
|
@ -2,7 +2,8 @@
|
|||
|
||||
## in development:
|
||||
* **New Features:**
|
||||
* added selectors for sprites' and the stage's bounding box (left, right, top, bottom) to MY dropdown
|
||||
* new primitive in "looks": NEW COSTUME from a list of pixels and dimensions, allowing CURRENT
|
||||
* added selectors for sprites' and the stage's bounding box (LEFT, RIGHT, TOP, BOTTOM) to MY dropdown
|
||||
* **Notable Changes:**
|
||||
* running STOP ALL now also toggles (pauses and resumes) all generic WHEN hat blocks (just like pressing the stop button)
|
||||
* **Notable Fixes:**
|
||||
|
@ -14,6 +15,7 @@
|
|||
### 2019-10-18
|
||||
* objects, blocks, threads: added dimension getters for the stage
|
||||
* German translation update (left, right, top, bottom selectors in MY)
|
||||
* blocks, objects, threads: added "new costume" primitive reporter to "looks" category
|
||||
|
||||
### 2019-10-17
|
||||
* objects, blocks, threads: added selectors for sprites' bounding box (left, right, top, bottom) to MY dropdown
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<link rel="shortcut icon" href="src/favicon.ico">
|
||||
<script type="text/javascript" src="src/morphic.js?version=2019-10-16"></script>
|
||||
<script type="text/javascript" src="src/widgets.js?version=2019-10-16"></script>
|
||||
<script type="text/javascript" src="src/blocks.js?version=2019-10-17"></script>
|
||||
<script type="text/javascript" src="src/threads.js?version=2019-10-17"></script>
|
||||
<script type="text/javascript" src="src/blocks.js?version=2019-10-18"></script>
|
||||
<script type="text/javascript" src="src/threads.js?version=2019-10-18"></script>
|
||||
<script type="text/javascript" src="src/objects.js?version=2019-10-18"></script>
|
||||
<script type="text/javascript" src="src/gui.js?version=2019-10-16"></script>
|
||||
<script type="text/javascript" src="src/paint.js?version=2019-06-27"></script>
|
||||
|
|
|
@ -148,7 +148,7 @@ CustomCommandBlockMorph, SymbolMorph, ToggleButtonMorph, DialMorph*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.blocks = '2019-October-17';
|
||||
modules.blocks = '2019-October-18';
|
||||
|
||||
var SyntaxElementMorph;
|
||||
var BlockMorph;
|
||||
|
@ -1139,6 +1139,16 @@ SyntaxElementMorph.prototype.labelPart = function (spec) {
|
|||
);
|
||||
part.setContents(1);
|
||||
break;
|
||||
case '%dim':
|
||||
part = new InputSlotMorph(
|
||||
null,
|
||||
true,
|
||||
{
|
||||
current : ['current']
|
||||
}
|
||||
);
|
||||
// part.setContents( ['current']);
|
||||
break;
|
||||
case '%rel':
|
||||
part = new InputSlotMorph(
|
||||
null, // text
|
||||
|
@ -2372,6 +2382,7 @@ SyntaxElementMorph.prototype.endLayout = function () {
|
|||
%inst - white roundish type-in slot with drop-down for instruments
|
||||
%ida - white roundish type-in slot with drop-down for list indices
|
||||
%idx - white roundish type-in slot for indices incl. "any"
|
||||
%dim - white roundish type-in slot for dimensinos incl. "current"
|
||||
%obj - specially drawn slot for object reporters
|
||||
%rel - chameleon colored rectangular drop-down for relation options
|
||||
%spr - chameleon colored rectangular drop-down for object-names
|
||||
|
|
|
@ -312,6 +312,11 @@ SpriteMorph.prototype.initBlocks = function () {
|
|||
spec: '%img of costume %cst',
|
||||
defaults: [['width']]
|
||||
},
|
||||
reportNewCostume: {
|
||||
type: 'reporter',
|
||||
category: 'looks',
|
||||
spec: 'new costume %l width: %dim height: %dim'
|
||||
},
|
||||
reportNewCostumeStretched: {
|
||||
type: 'reporter',
|
||||
category: 'looks',
|
||||
|
@ -2210,6 +2215,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push(block('doThink'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('reportGetImageAttribute'));
|
||||
blocks.push(block('reportNewCostume'));
|
||||
blocks.push(block('reportNewCostumeStretched'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('changeEffect'));
|
||||
|
@ -8268,6 +8274,7 @@ StageMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push(block('getCostumeIdx'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('reportGetImageAttribute'));
|
||||
blocks.push(block('reportNewCostume'));
|
||||
blocks.push(block('reportNewCostumeStretched'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('changeEffect'));
|
||||
|
|
|
@ -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-October-17';
|
||||
modules.threads = '2019-October-18';
|
||||
|
||||
var ThreadManager;
|
||||
var Process;
|
||||
|
@ -4915,11 +4915,6 @@ Process.prototype.reportGetImageAttribute = function (choice, name) {
|
|||
|
||||
Process.prototype.reportNewCostumeStretched = function (name, xP, yP) {
|
||||
var cst;
|
||||
if (!isFinite(+xP * +yP) || isNaN(+xP * +yP)) {
|
||||
throw new Error(
|
||||
'expecting a finite number\nbut getting Infinity or NaN'
|
||||
);
|
||||
}
|
||||
if (name instanceof List) {
|
||||
return this.reportNewCostume(name, xP, yP);
|
||||
}
|
||||
|
@ -4927,6 +4922,11 @@ Process.prototype.reportNewCostumeStretched = function (name, xP, yP) {
|
|||
if (!cst) {
|
||||
return new Costume();
|
||||
}
|
||||
if (!isFinite(+xP * +yP) || isNaN(+xP * +yP)) {
|
||||
throw new Error(
|
||||
'expecting a finite number\nbut getting Infinity or NaN'
|
||||
);
|
||||
}
|
||||
return cst.stretched(
|
||||
Math.round(cst.width() * +xP / 100),
|
||||
Math.round(cst.height() * +yP / 100)
|
||||
|
@ -4951,16 +4951,29 @@ Process.prototype.costumeNamed = function (name) {
|
|||
};
|
||||
|
||||
Process.prototype.reportNewCostume = function (pixels, width, height, name) {
|
||||
// private
|
||||
var rcvr = this.blockReceiver(),
|
||||
stage = rcvr.parentThatIsA(StageMorph),
|
||||
canvas, ctx, src, dta, i, k, px;
|
||||
|
||||
this.assertType(pixels, 'list');
|
||||
if (this.inputOption(width) === 'current') {
|
||||
width = rcvr.costume ? rcvr.costume.width() : stage.dimensions.x;
|
||||
}
|
||||
if (this.inputOption(height) === 'current') {
|
||||
height = rcvr.costume ? rcvr.costume.height() : stage.dimensions.y;
|
||||
}
|
||||
width = Math.abs(Math.floor(+width));
|
||||
height = Math.abs(Math.floor(+height));
|
||||
if (!isFinite(width * height) || isNaN(width * height)) {
|
||||
throw new Error(
|
||||
'expecting a finite number\nbut getting Infinity or NaN'
|
||||
);
|
||||
}
|
||||
|
||||
var canvas = newCanvas(new Point(width, height), true),
|
||||
ctx = canvas.getContext('2d'),
|
||||
src = pixels.asArray(),
|
||||
dta = ctx.createImageData(width, height),
|
||||
i, k, px;
|
||||
|
||||
canvas = newCanvas(new Point(width, height), true);
|
||||
ctx = canvas.getContext('2d');
|
||||
src = pixels.asArray();
|
||||
dta = ctx.createImageData(width, height);
|
||||
for (i = 0; i < src.length; i += 1) {
|
||||
px = src[i].asArray();
|
||||
for (k = 0; k < 4; k += 1) {
|
||||
|
@ -4970,7 +4983,7 @@ Process.prototype.reportNewCostume = function (pixels, width, height, name) {
|
|||
ctx.putImageData(dta, 0, 0);
|
||||
return new Costume(
|
||||
canvas,
|
||||
name || this.blockReceiver().newCostumeName(localize('snap'))
|
||||
name || rcvr.newCostumeName(localize('snap'))
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue