feat(boards): python3下turtle添加 stamp 方法
This commit is contained in:
@@ -171,7 +171,6 @@ export const turtle_setxy = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const turtle_pos_shape = {
|
export const turtle_pos_shape = {
|
||||||
|
|
||||||
init: function () {
|
init: function () {
|
||||||
this.setColour(TURTLE_HUE);
|
this.setColour(TURTLE_HUE);
|
||||||
var pos_shape =
|
var pos_shape =
|
||||||
@@ -200,6 +199,18 @@ export const turtle_pos_shape = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const turtle_stamp = {
|
||||||
|
init: function () {
|
||||||
|
this.setColour(TURTLE_HUE);
|
||||||
|
this.appendValueInput('TUR')
|
||||||
|
.setCheck('Turtle')
|
||||||
|
this.appendDummyInput()
|
||||||
|
.appendField(Blockly.Msg.TURTLE_STAMP);
|
||||||
|
this.setInputsInline(true);
|
||||||
|
this.setPreviousStatement(true);
|
||||||
|
this.setNextStatement(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const turtle_clear = {
|
export const turtle_clear = {
|
||||||
init: function () {
|
init: function () {
|
||||||
@@ -211,8 +222,6 @@ export const turtle_clear = {
|
|||||||
this.setColour(TURTLE_HUE);
|
this.setColour(TURTLE_HUE);
|
||||||
this.appendDummyInput("")
|
this.appendDummyInput("")
|
||||||
.appendField(new Blockly.FieldDropdown(clear_reset), 'DIR')
|
.appendField(new Blockly.FieldDropdown(clear_reset), 'DIR')
|
||||||
|
|
||||||
|
|
||||||
this.setInputsInline(true);
|
this.setInputsInline(true);
|
||||||
this.setPreviousStatement(true);
|
this.setPreviousStatement(true);
|
||||||
this.setNextStatement(true);
|
this.setNextStatement(true);
|
||||||
|
|||||||
@@ -75,6 +75,13 @@ export const turtle_pos_shape = function (_, generator) {
|
|||||||
return [code, generator.ORDER_ATOMIC];
|
return [code, generator.ORDER_ATOMIC];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const turtle_stamp = function (_, generator) {
|
||||||
|
generator.definitions_.import_turtle = "import turtle";
|
||||||
|
var varName = generator.valueToCode(this, 'TUR', generator.ORDER_ASSIGNMENT) || '0';
|
||||||
|
var code = varName + '.stamp()\n';
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
export const turtle_clear = function (_, generator) {
|
export const turtle_clear = function (_, generator) {
|
||||||
generator.definitions_.import_turtle = "import turtle";
|
generator.definitions_.import_turtle = "import turtle";
|
||||||
var varName = generator.valueToCode(this, 'TUR', generator.ORDER_ASSIGNMENT) || '0';
|
var varName = generator.valueToCode(this, 'TUR', generator.ORDER_ASSIGNMENT) || '0';
|
||||||
|
|||||||
@@ -1814,6 +1814,13 @@
|
|||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
|
<block type="turtle_stamp">
|
||||||
|
<value name="TUR">
|
||||||
|
<shadow type="variables_get">
|
||||||
|
<field name="VAR">tina</field>
|
||||||
|
</shadow>
|
||||||
|
</value>
|
||||||
|
</block>
|
||||||
<block type="turtle_clear">
|
<block type="turtle_clear">
|
||||||
<value name="TUR">
|
<value name="TUR">
|
||||||
<shadow type="variables_get">
|
<shadow type="variables_get">
|
||||||
|
|||||||
@@ -1777,6 +1777,13 @@
|
|||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
|
<block type="turtle_stamp">
|
||||||
|
<value name="TUR">
|
||||||
|
<shadow type="variables_get">
|
||||||
|
<field name="VAR">tina</field>
|
||||||
|
</shadow>
|
||||||
|
</value>
|
||||||
|
</block>
|
||||||
<block type="turtle_clear">
|
<block type="turtle_clear">
|
||||||
<value name="TUR">
|
<value name="TUR">
|
||||||
<shadow type="variables_get">
|
<shadow type="variables_get">
|
||||||
|
|||||||
@@ -1445,6 +1445,13 @@
|
|||||||
</shadow>
|
</shadow>
|
||||||
</value>
|
</value>
|
||||||
</block>
|
</block>
|
||||||
|
<block type="turtle_stamp">
|
||||||
|
<value name="TUR">
|
||||||
|
<shadow type="variables_get">
|
||||||
|
<field name="VAR">tina</field>
|
||||||
|
</shadow>
|
||||||
|
</value>
|
||||||
|
</block>
|
||||||
<block type="turtle_clear">
|
<block type="turtle_clear">
|
||||||
<value name="TUR">
|
<value name="TUR">
|
||||||
<shadow type="variables_get">
|
<shadow type="variables_get">
|
||||||
|
|||||||
@@ -1776,6 +1776,7 @@ En.TURTLE_POS_SHAPE = "Get the turtle currently";
|
|||||||
En.TURTLE_POS = "Get the current position of the turtle";
|
En.TURTLE_POS = "Get the current position of the turtle";
|
||||||
En.TURTLE_SHAPE = "shape";
|
En.TURTLE_SHAPE = "shape";
|
||||||
En.TURTLE_HEADING = "Heading";
|
En.TURTLE_HEADING = "Heading";
|
||||||
|
En.TURTLE_STAMP = "Stamp";
|
||||||
En.MIXLY_TOOLTIP_TURTEL_POS = 'Get the turtle\'s current position and return a tuple containing the current position x and y coordinates';
|
En.MIXLY_TOOLTIP_TURTEL_POS = 'Get the turtle\'s current position and return a tuple containing the current position x and y coordinates';
|
||||||
En.MIXLY_TOOLTIP_TURTEL_SHAPE = 'Get the turtle\'s current shape and return a string';
|
En.MIXLY_TOOLTIP_TURTEL_SHAPE = 'Get the turtle\'s current shape and return a string';
|
||||||
En.MIXLY_TOOLTIP_TURTEL_GET_SPEED = "get the turtles current speed and return an integer;";
|
En.MIXLY_TOOLTIP_TURTEL_GET_SPEED = "get the turtles current speed and return an integer;";
|
||||||
|
|||||||
@@ -1789,6 +1789,7 @@ ZhHans.TURTLE_POS_SHAPE = "获取海龟当前";
|
|||||||
ZhHans.TURTLE_POS = "位置";
|
ZhHans.TURTLE_POS = "位置";
|
||||||
ZhHans.TURTLE_SHAPE = "形状";
|
ZhHans.TURTLE_SHAPE = "形状";
|
||||||
ZhHans.TURTLE_HEADING = "朝向";
|
ZhHans.TURTLE_HEADING = "朝向";
|
||||||
|
ZhHans.TURTLE_STAMP = "留下印记";
|
||||||
ZhHans.MIXLY_TOOLTIP_TURTEL_POS = '获取海龟当前位置,返回一个包含当前位置x坐标和y坐标的元组';
|
ZhHans.MIXLY_TOOLTIP_TURTEL_POS = '获取海龟当前位置,返回一个包含当前位置x坐标和y坐标的元组';
|
||||||
ZhHans.MIXLY_TOOLTIP_TURTEL_SHAPE = '获取海龟当前形状,返回一个字符串';
|
ZhHans.MIXLY_TOOLTIP_TURTEL_SHAPE = '获取海龟当前形状,返回一个字符串';
|
||||||
ZhHans.MIXLY_TOOLTIP_TURTEL_GET_SPEED = '获取海龟当前速度,返回一个整数';
|
ZhHans.MIXLY_TOOLTIP_TURTEL_GET_SPEED = '获取海龟当前速度,返回一个整数';
|
||||||
|
|||||||
@@ -1789,6 +1789,7 @@ ZhHant.TURTLE_POS_SHAPE = "獲取海龜當前";
|
|||||||
ZhHant.TURTLE_POS = "位置";
|
ZhHant.TURTLE_POS = "位置";
|
||||||
ZhHant.TURTLE_SHAPE = "形狀";
|
ZhHant.TURTLE_SHAPE = "形狀";
|
||||||
ZhHant.TURTLE_HEADING = "朝向";
|
ZhHant.TURTLE_HEADING = "朝向";
|
||||||
|
ZhHant.TURTLE_STAMP = "留下印記";
|
||||||
ZhHant.MIXLY_TOOLTIP_TURTEL_POS = '獲取海龜當前位置,返回一個包含當前位置x座標和y座標的元組';
|
ZhHant.MIXLY_TOOLTIP_TURTEL_POS = '獲取海龜當前位置,返回一個包含當前位置x座標和y座標的元組';
|
||||||
ZhHant.MIXLY_TOOLTIP_TURTEL_SHAPE = '獲取海龜當前形狀,返回一個字符串';
|
ZhHant.MIXLY_TOOLTIP_TURTEL_SHAPE = '獲取海龜當前形狀,返回一個字符串';
|
||||||
ZhHant.MIXLY_TOOLTIP_TURTEL_GET_SPEED = '獲取海龜當前速度,返回一個整數';
|
ZhHant.MIXLY_TOOLTIP_TURTEL_GET_SPEED = '獲取海龜當前速度,返回一個整數';
|
||||||
|
|||||||
Reference in New Issue
Block a user