Skip to content

Commit

Permalink
feat: ✨追加色碼積木
Browse files Browse the repository at this point in the history
  • Loading branch information
papple23g committed Jul 5, 2024
1 parent 7ca8a5a commit 9f6fba5
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 15 deletions.
6 changes: 6 additions & 0 deletions templates/ahkblockly.py
Original file line number Diff line number Diff line change
Expand Up @@ -4326,6 +4326,12 @@ def AHK_block(block_elt, get_all_comment=False, separate_comment=False):
f"__PosY:={value_posY_str}",
f"PixelGetColor, {value_color_id_str}, %__PosX%, %__PosY%\n",
])

elif block_elt.attrs['type'] == "color_id":
field_color_id_elt = FindCurrent(block_elt, 'field[name="color_id"]')
value_color_id_str = field_color_id_elt.text
com_str += value_color_id_str

# endregion 偵測圖片Blockly

# region 網頁操作
Expand Down
67 changes: 52 additions & 15 deletions templates/blocklyDiv.html
Original file line number Diff line number Diff line change
Expand Up @@ -1148,23 +1148,60 @@
</block>
</value>
</block>
<block type="mouse_get_pos" x="108" y="70">
<field name="posX" >滑鼠座標X</field>
<field name="posY" >滑鼠座標Y</field>
<block type="mouse_get_pos">
<field name="posX">滑鼠座標X</field>
<field name="posY">滑鼠座標Y</field>
<next>
<block type="pixel_get_color">
<field name="color_id">色碼</field>
<value name="posX">
<block type="variables_get">
<field name="VAR">滑鼠座標X</field>
</block>
</value>
<value name="posY">
<block type="variables_get">
<field name="VAR">滑鼠座標Y</field>
<block type="pixel_get_color">
<field name="color_id">色碼</field>
<value name="posX">
<block type="variables_get">
<field name="VAR">滑鼠座標X</field>
</block>
</value>
<value name="posY">
<block type="variables_get">
<field name="VAR">滑鼠座標Y</field>
</block>
</value>
<next>
<block type="msgbox">
<value name="NAME">
<block type="variables_get">
<field name="VAR">色碼</field>
</block>
</value>
<next>
<block type="controls_if">
<value name="IF0">
<block type="logic_compare">
<field name="OP">EQ</field>
<value name="A">
<block type="variables_get">
<field name="VAR">色碼</field>
</block>
</value>
<value name="B">
<block type="color_id">
<field name="color_id">0xFFFFFF</field>
</block>
</value>
</block>
</value>
<statement name="DO0">
<block type="msgbox">
<value name="NAME">
<block type="text">
<field name="TEXT">滑鼠指著白色像素!</field>
</block>
</value>
</block>
</statement>
</block>
</next>
</block>
</next>
</block>
</value>
</block>
</next>
</block>
</category>
Expand Down
12 changes: 12 additions & 0 deletions templates/blocks_definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -1846,4 +1846,16 @@ Blockly.Blocks['pixel_get_color'] = {
this.setTooltip("");
this.setHelpUrl("");
}
};
Blockly.Blocks['color_id'] = {
init: function() {
this.appendDummyInput()
.appendField("色碼")
.appendField(new Blockly.FieldTextInput("0xFFFFFF"), "color_id");
this.setInputsInline(true);
this.setOutput(true, null);
this.setColour(230);
this.setTooltip("");
this.setHelpUrl("");
}
};

0 comments on commit 9f6fba5

Please sign in to comment.