<blocksapp="Snap! 5.0, http://snap.berkeley.edu"version="1"><block-definitions="label %'text' of size %'size'"type="command"category="pen"><commentx="0"y="0"w="90"collapsed="false">LABEL will stamp text on the stage at the given font size. The direction of the text is the direction the sprite is facing, and color will match the pen color.</comment><header></header><code></code><translations>de:drucke _ in Größe _
ca:etiqueta _ de mida _
es:etiqueta _ de tamaño _
fr:étiquette _ d'une taille de _
</translations><inputs><inputtype="%txt">Hello!</input><inputtype="%n">12</input></inputs><script><blocks="doRun"><blocks="reportJSFunction"><list><l>text</l><l>size</l><l>process</l></list><l>var stage = this.parentThatIsA(StageMorph);

if (this == stage) {
 throw new Error(
'LABEL cannot be used from the stage because the stage does not have a postion.\n'
 + 'Use LABEL from a sprite to draw text.');
}

if (typeof text !== 'string'&& typeof text !== 'number') {
 throw new Error('LABEL can only draw text or numbers, not a ' + process.reportTypeOf(text)); 
}

var context = stage.penTrails().getContext('2d'),
 rotation = radians(this.direction() - 90),
 trans = new Point(
 this.center().x - stage.left(),
 this.center().y - stage.top()
 ),
 isWarped = this.Warped,
 len,
 pos;

if (isWarped) {endWarp(); }
context.save();
context.font = size + 'px monospace';
context.textAlign = 'left';
context.textBaseline = 'alphabetic';
context.fillStyle = this.color.toString();
len = context.measureText(text).width;
trans = trans.multiplyBy(1 / stage.scale);
context.translate(trans.x, trans.y);
context.rotate(rotation);
context.fillText(text, 0, 0);
context.translate(-trans.x, -trans.y);
context.restore();
pos = new Point(
 len * Math.sin(radians(this.direction())),
 len * Math.cos(radians(this.direction())));
pos = pos.add(new Point(this.xPosition(), this.yPosition()));
this.gotoXY(pos.x, pos.y, false);
this.changed();
if (isWarped) {this.startWarp(); }
stage.changed();
</l></block><list><blockvar="text"/><blockvar="size"/></list></block></script></block-definition><block-definitions="empty? %'data'"type="predicate"category="lists"><header></header><code></code><translations>de:ist _ leer?
ca:_ buida?
es:_ vacía?
fr:_ vide?
</translations><inputs><inputtype="%l"></input></inputs><script><blocks="doReport"><blocks="reportEquals"><blockvar="data"/><blocks="reportNewList"><list></list></block></block></block></script></block-definition><block-definitions="keep items such that %'pred' from %'data'"type="reporter"category="lists"><header></header><code></code><translations>de:behalte Elemente, die _ aus _
ca:manté els elements on _ de _
es:mantener los elementos donde _ de _
fr:garder les items tels que _ de _
</translations><inputs><inputtype="%predRing"></input><inputtype="%l"></input></inputs><script><blocks="doIf"><custom-blocks="empty? %l"><blockvar="data"/></custom-block><script><blocks="doReport"><blocks="reportNewList"><list></list></block></block></script></block><blocks="doIfElse"><blocks="evaluate"><blockvar="pred"/><list><blocks="reportListItem"><l>1</l><blockvar="data"/></block></list></block><script><blocks="doReport"><blocks="reportCONS"><blocks="reportListItem"><l>1</l><blockvar="data"/></block><custom-blocks="keep items such that %predRing from %l"><blockvar="pred"/><blocks="reportCDR"><blockvar="data"/></block></custom-block></block></block></script><script><blocks="doReport"><custom-blocks="keep items such that %predRing from %l"><blockvar="pred"/><blocks="reportCDR"><blockvar="data"/></block></custom-block></block></script></block></script></block-definition><block