updated text-costumes library

(removed "label", because it's now a primitive)
pull/89/head
jmoenig 2019-04-11 17:47:03 +02:00
rodzic 038181064f
commit 080bc54043
2 zmienionych plików z 2 dodań i 1 usunięć

Wyświetl plik

@ -72,6 +72,7 @@
* German translation update
* re- renamed minus selector back to "neg"
* updated tools library (removed "label", because it's now a primitive)
* updated text-costumes library (removed "label", because it's now a primitive)
### 2019-04-10
* Objects: took out MAP and FOREACH primitives (available in dev mode)

Wyświetl plik

@ -1 +1 @@
<blocks app="Snap! 5.0, http://snap.berkeley.edu" version="1"><block-definition s="label %&apos;text&apos; of size %&apos;size&apos;" type="command" category="pen"><comment x="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 _&#xD;ca:etiqueta _ de mida _&#xD;es:etiqueta _ de tamaño _&#xD;fr:étiquette _ d&apos;une taille de _&#xD;</translations><inputs><input type="%txt">Hello!</input><input type="%n">12</input></inputs><script><block s="doRun"><block s="reportJSFunction"><list><l>text</l><l>size</l><l>process</l></list><l>var stage = this.parentThatIsA(StageMorph);&#xD;&#xD;if (this == stage) {&#xD; throw new Error(&#xD; &apos;LABEL cannot be used from the stage because the stage does not have a postion.\n&apos;&#xD; + &apos;Use LABEL from a sprite to draw text.&apos;);&#xD;}&#xD;&#xD;if (typeof text !== &apos;string&apos; &amp;&amp; typeof text !== &apos;number&apos;) {&#xD; throw new Error(&apos;LABEL can only draw text or numbers, not a &apos; + process.reportTypeOf(text)); &#xD;}&#xD;&#xD;var context = stage.penTrails().getContext(&apos;2d&apos;),&#xD; rotation = radians(this.direction() - 90),&#xD; trans = new Point(&#xD; this.center().x - stage.left(),&#xD; this.center().y - stage.top()&#xD; ),&#xD; isWarped = this.Warped,&#xD; len,&#xD; pos;&#xD;&#xD;if (isWarped) {endWarp(); }&#xD;context.save();&#xD;context.font = size + &apos;px monospace&apos;;&#xD;context.textAlign = &apos;left&apos;;&#xD;context.textBaseline = &apos;alphabetic&apos;;&#xD;context.fillStyle = this.color.toString();&#xD;len = context.measureText(text).width;&#xD;trans = trans.multiplyBy(1 / stage.scale);&#xD;context.translate(trans.x, trans.y);&#xD;context.rotate(rotation);&#xD;context.fillText(text, 0, 0);&#xD;context.translate(-trans.x, -trans.y);&#xD;context.restore();&#xD;pos = new Point(&#xD; len * Math.sin(radians(this.direction())),&#xD; len * Math.cos(radians(this.direction())));&#xD;pos = pos.add(new Point(this.xPosition(), this.yPosition()));&#xD;this.gotoXY(pos.x, pos.y, false);&#xD;this.changed();&#xD;if (isWarped) {this.startWarp(); }&#xD;stage.changed();&#xD;</l></block><list><block var="text"/><block var="size"/></list></block></script></block-definition><block-definition s="costume from text %&apos;text&apos; size %&apos;size&apos;" type="reporter" category="looks"><header></header><code></code><translations>de:Kostüm aus Text _ Größe _&#xD;</translations><inputs><input type="%s">A</input><input type="%n">72</input></inputs><script><block s="doDeclareVariables"><list><l>costume</l><l>x</l><l>y</l><l>dir</l><l>cst</l><l>trails</l></list></block><block s="doSetVar"><l>x</l><block s="xPosition"></block></block><block s="doSetVar"><l>y</l><block s="yPosition"></block></block><block s="doSetVar"><l>dir</l><block s="direction"></block></block><block s="doSetVar"><l>cst</l><block s="getCostumeIdx"></block></block><block s="up"></block><block s="gotoXY"><l>0</l><l>0</l></block><block s="setHeading"><l>90</l></block><block s="doSwitchToCostume"><l><option>Turtle</option></l></block><block s="doSetVar"><l>trails</l><block s="reportPenTrailsAsCostume"></block></block><block s="clear"></block><custom-block s="label %txt of size %n"><block var="text"/><block var="size"/></custom-block><block s="doSetVar"><l>costume</l><block s="reportPenTrailsAsCostume"></block></block><block s="clear"></block><block s="doRun"><block s="reportJSFunction"><list><l>costume</l><l>name</l></list><l>costume.name = name;</l></block><list><block var="costume"/><block var="text"/></list></block><block s="gotoXY"><l>0</l><l>0</l></block><block s="doSwitchToCostume"><block var="trails"/></block><block s="doStamp"></block><block s="doSwitchToCostume"><block var="cst"/></block><block s="gotoXY"><block var="x"/><block var="y"/></block><block s="setHeading"><block var="dir"/></block><block s="doReport"><block var="costume"/></block></script></block-definition></blocks>
<blocks app="Snap! 5.0, http://snap.berkeley.edu" version="1"><block-definition s="costume from text %&apos;text&apos; size %&apos;size&apos;" type="reporter" category="looks"><header></header><code></code><translations>de:Kostüm aus Text _ Größe _&#xD;</translations><inputs><input type="%s">A</input><input type="%n">72</input></inputs><script><block s="doDeclareVariables"><list><l>costume</l><l>x</l><l>y</l><l>dir</l><l>cst</l><l>trails</l></list></block><block s="doSetVar"><l>x</l><block s="xPosition"></block></block><block s="doSetVar"><l>y</l><block s="yPosition"></block></block><block s="doSetVar"><l>dir</l><block s="direction"></block></block><block s="doSetVar"><l>cst</l><block s="getCostumeIdx"></block></block><block s="up"></block><block s="gotoXY"><l>0</l><l>0</l></block><block s="setHeading"><l>90</l></block><block s="doSwitchToCostume"><l><option>Turtle</option></l></block><block s="doSetVar"><l>trails</l><block s="reportPenTrailsAsCostume"></block></block><block s="clear"></block><block s="write"><block var="text"/><block var="size"/></block><block s="doSetVar"><l>costume</l><block s="reportPenTrailsAsCostume"></block></block><block s="clear"></block><block s="doRun"><block s="reportJSFunction"><list><l>costume</l><l>name</l></list><l>costume.name = name;</l></block><list><block var="costume"/><block var="text"/></list></block><block s="gotoXY"><l>0</l><l>0</l></block><block s="doSwitchToCostume"><block var="trails"/></block><block s="doStamp"></block><block s="doSwitchToCostume"><block var="cst"/></block><block s="gotoXY"><block var="x"/><block var="y"/></block><block s="setHeading"><block var="dir"/></block><block s="doReport"><block var="costume"/></block></script></block-definition></blocks>