kopia lustrzana https://github.com/backface/turtlestitch
new "Pixels" library for MediaComp
rodzic
2cbc839005
commit
51998503a3
|
@ -3671,6 +3671,7 @@ Fixes:
|
|||
* Blocks: made "import script" undoable
|
||||
* Objects: make sure inheritance hierarchies are consistently made temporary
|
||||
* new "Animation" library
|
||||
* new "Pixels" library for MediaComp
|
||||
|
||||
|
||||
v4.1 Features:
|
||||
|
@ -3707,6 +3708,7 @@ v4.1 Features:
|
|||
* "Make a block" button in every category
|
||||
* experimental "download script" feature
|
||||
* new "Animation" library
|
||||
* new "Pixels" library for MediaComp
|
||||
|
||||
Fixes:
|
||||
* changed keyboard shortcut indicator for “find blocks” to “^”
|
||||
|
|
|
@ -13,3 +13,4 @@ multiline.xml Allow multi-line text input to a block In general, text inputs all
|
|||
Eisenbergification.xml Provide getters and setters for all GUI-controlled global settings Eisenberg's Law: Anything that can be done from the GUI should be doable from the programming language, and vice versa.
|
||||
bignumbers.xml Infinite precision integers, exact rationals, complex The full Scheme numeric tower. "USE BIGNUMS <True>" to enable.
|
||||
animation_module.xml Animation glide, grow and rotate using easing functions.
|
||||
pixel_module.xml Pixels manipulate costumes pixel-wise.
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<blocks app="Snap! 4.1, http://snap.berkeley.edu" version="1"><block-definition s="pixels in %'costume'" type="reporter" category="sensing"><comment x="0" y="0" w="187" collapsed="false">reports a list of all pixels in the given costume. Each pixel is represented by a 4-item sublist of RGBA values</comment><header></header><code></code><inputs><input type="%obj"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>costume</l></list><l> var i,
 pixels = [],
 src = costume.contents.getContext('2d').getImageData(
 0,
 0,
 costume.width(),
 costume.height()
 );
 for (i = 0; i < src.data.length; i += 4) {
 pixels.push(new List([
 src.data[i],
 src.data[i + 1],
 src.data[i + 2],
 src.data[i + 3]
 ]));
 }
 return new List(pixels);</l></block><list><block var="costume"/></list></block></block></script></block-definition><block-definition s="update %'costume' with %'pixels'" type="command" category="looks"><comment x="0" y="0" w="286" collapsed="false">overwrite the pixels in the given costume with another list of pixels.

Caution! This operation directly changes the costume. Make sure to use a copy in case you would like to revert changes later.</comment><header></header><code></code><inputs><input type="%obj"></input><input type="%l"></input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>costume</l><l>pixels</l></list><l> var i, k,
 ctx = costume.contents.getContext('2d'),
 src = pixels.asArray(),
 dta = ctx.createImageData(costume.width(), costume.height());
 for (i = 0; i < src.length; i += 1) {
 px = src[i].asArray();
 for (k = 0; k < 4; k += 1) {
 dta.data[(i * 4) + k] = px[k];
 }
 }
 ctx.putImageData(dta, 0, 0);</l></block><list><block var="costume"/><block var="pixels"/></list></block></script></block-definition><block-definition s="current costume" type="reporter" category="looks"><comment x="0" y="0" w="178" collapsed="false">reports the sprite's actual current costume, which may or may not be part of its wardrobe e.g. if it is a copy</comment><header></header><code></code><inputs></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list></list><l>return this.costume;</l></block><list></list></block></block></script></block-definition><block-definition s="copy of %'costume'" type="reporter" category="looks"><comment x="0" y="0" w="206" collapsed="false">reports a copy of the given costume. This is especially useful when modifying a costume, so you can keep the original around</comment><header></header><code></code><inputs><input type="%obj"></input></inputs><script><block s="doReport"><block s="evaluate"><block s="reportJSFunction"><list><l>costume</l></list><l>return costume.copy();</l></block><list><block var="costume"/></list></block></block></script></block-definition><block-definition s="show picture %'bitmap'" type="command" category="looks"><comment x="0" y="0" w="88" collapsed="false">display the given bitmap in a copy of the current costume (so you can switch back to the original costume again)</comment><header></header><code></code><inputs><input type="%l"></input></inputs><script><custom-block s="let %upvar be %s"><l>copy</l><custom-block s="copy of %obj"><custom-block s="current costume"></custom-block></custom-block></custom-block><custom-block s="update %obj with %l"><block var="copy"/><block var="bitmap"/></custom-block><block s="doSwitchToCostume"><block var="copy"/></block></script></block-definition><block-definition s="let %'var' be %'value'" type="command" category="other"><header></header><code></code><inputs><input type="%upvar"></input><input type="%s"></input></inputs><script><block s="doSetVar"><l>var</l><block var="value"/></block></script></block-definition></blocks>
|
Ładowanie…
Reference in New Issue