Skip to content

Commit

Permalink
feat: ✨追加積木: 獲取像素色碼
Browse files Browse the repository at this point in the history
  • Loading branch information
papple23g committed Jul 4, 2024
1 parent de95320 commit f8c9e11
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
19 changes: 18 additions & 1 deletion templates/ahkblockly.py
Original file line number Diff line number Diff line change
Expand Up @@ -4310,6 +4310,23 @@ def AHK_block(block_elt, get_all_comment=False, separate_comment=False):
'}\n',
])

elif block_elt.attrs['type'] == "pixel_get_color":
value_posX_elt = FindCurrent(block_elt, 'value[name="posX"]')
value_posX_str, value_posX_comment = AHK_value(value_posX_elt)
com_str += value_posX_comment

value_posY_elt = FindCurrent(block_elt, 'value[name="posY"]')
value_posY_str, value_posY_comment = AHK_value(value_posY_elt)
com_str += value_posY_comment

field_color_id_elt = FindCurrent(block_elt, 'field[name="color_id"]')
value_color_id_str = field_color_id_elt.text

com_str += "\n".join([
f"__PosX:={value_posX_str}",
f"__PosY:={value_posY_str}",
f"PixelGetColor, {value_color_id_str}, %__PosX%, %__PosY%\n",
])
# endregion 偵測圖片Blockly

# region 網頁操作
Expand Down Expand Up @@ -5398,7 +5415,7 @@ def reset_btn_text():
# 設置子頁面標頭DIV元素
div_title_elt = DIV()
# 設置標頭H1元素
VERSION = "1.13.1" # VER: 更新版本號
VERSION = "1.14.0" # VER: 更新版本號
h1_title_elt = H1(f"AutoHotKey 積木語法產生器 v{VERSION}", style={
"color": "rgb(220, 107, 57)", "font-size": "18px", "font-weight": "600", 'float': 'left'})
# 設置FB DIV元素
Expand Down
19 changes: 19 additions & 0 deletions templates/blocklyDiv.html
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,25 @@
</block>
</value>
</block>
<block type="mouse_get_pos" x="108" y="70">
<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>
</value>
</block>
</next>
</block>
</category>

<category name="🅰 文字" colour="#5BA58C">
Expand Down
20 changes: 20 additions & 0 deletions templates/blocks_definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -1826,4 +1826,24 @@ Blockly.Blocks['win_move'] = {
this.setTooltip("");
this.setHelpUrl("");
}
};

Blockly.Blocks['pixel_get_color'] = {
init: function() {
this.appendValueInput("posX")
.setCheck("Number")
.appendField("獲取座標(");
this.appendValueInput("posY")
.setCheck("Number")
.appendField(",");
this.appendDummyInput()
.appendField(")的色碼儲存至變數")
.appendField(new Blockly.FieldVariable("色碼"), "color_id");
this.setInputsInline(true);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour("#f5bfbf");
this.setTooltip("");
this.setHelpUrl("");
}
};

0 comments on commit f8c9e11

Please sign in to comment.