diff --git a/atom_babies_ja.m5b b/atom_babies_ja.m5b index 2d0a75a..3431742 100644 --- a/atom_babies_ja.m5b +++ b/atom_babies_ja.m5b @@ -1 +1 @@ -{"category":"ATOM_Babies","color":"#115f07","blocks":["__ATOM_Babies_initAtomBabies","__ATOM_Babies_showFace","__ATOM_Babies_clearFace","__ATOM_Babies_RGB","__ATOM_Babies_setOrientationNormal","__ATOM_Babies_setOrientationRight","__ATOM_Babies_setOrientationUpsideDown","__ATOM_Babies_setOrientationLeft","__ATOM_Babies_setFacePositionNormal","__ATOM_Babies_setFacePositionRight","__ATOM_Babies_setFacePositionDown","__ATOM_Babies_setFacePositionLeft","__ATOM_Babies_setFacePositionUp","__ATOM_Babies_setFacePositionTop","__ATOM_Babies_setFacePositionBottom","__ATOM_Babies_openEyes","__ATOM_Babies_closeEyes","__ATOM_Babies_showCheeks","__ATOM_Babies_clearCheeks","__ATOM_Babies_startBlink","__ATOM_Babies_stopBlink","__ATOM_Babies_startBlinkWithFunction","__ATOM_Babies_getBlinkIntervalValues"],"jscode":"// Block __ATOM_Babies_initAtomBabies\nvar __ATOM_Babies_initAtomBabies_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"ATOM Babiesを初期化する\"\n }\n ],\n \"message1\": \"%1 %2\",\n \"args1\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_eye_color\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_eye_color\"\n }\n ],\n \"message2\": \"%1 %2\",\n \"args2\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_cheek_color\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_cheek_color\"\n }\n ],\n \"message3\": \"%1 %2\",\n \"args3\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_background_color\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_background_color\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_initAtomBabies'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_initAtomBabies_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_initAtomBabies'] = function(block) {\n var _eye_color = Blockly.Python.valueToCode(block, '_eye_color', Blockly.Python.ORDER_NONE);\nvar _cheek_color = Blockly.Python.valueToCode(block, '_cheek_color', Blockly.Python.ORDER_NONE);\nvar _background_color = Blockly.Python.valueToCode(block, '_background_color', Blockly.Python.ORDER_NONE);\n return `import _thread as _ab_t\nimport re\nimport time\n\n_ab_const = {\n 'MIN_LED_POS': 1,\n 'MAX_LED_POS': 25,\n 'EYE_POSITIONS': {\n 'POS_TOP': [2, 4],\n 'POS_UP': [7, 9],\n 'POS_NORMAL':[12, 14],\n 'POS_RIGHT': [11, 13],\n 'POS_LEFT': [13, 15],\n 'POS_DOWN': [17, 19],\n 'POS_BOTTOM': [22, 24],\n },\n 'CHEEK_POSITIONS': {\n 'POS_TOP': [6, 10],\n 'POS_UP': [11, 15],\n 'POS_NORMAL': [16, 20],\n 'POS_RIGHT': [19],\n 'POS_LEFT': [17],\n 'POS_DOWN': [21, 25],\n 'POS_BOTTOM': [],\n },\n 'ORIENTATIONS': {\n 'ORI_NORMAL': [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],\n 'ORI_RIGHT': [21, 16, 11, 6, 1, 22, 17, 12, 7, 2, 23, 18, 13, 8, 3, 24, 19, 14, 9, 4, 25, 20, 15, 10, 5],\n 'ORI_UPSIDE_DOWN': [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],\n 'ORI_LEFT': [ 5, 10, 15, 20, 25, 4, 9, 14, 19, 24, 3, 8, 13, 18, 23, 2, 7, 12, 17, 22, 1, 6, 11, 16, 21],\n },\n 'BLINK_INTERVAL': {\n 'LOOP': 1,\n 'OPEN': 500,\n 'CLOSE': 100,\n 'INTERVAL': 1000,\n },\n 'DEFAULT_BLINK_INTERVAL_FUNCTION': '_ab_get_blink_interval'\n}\n\ndef _ab_get_const(key):\n return _ab_const[key]\n\ndef _ab_get_rgb(r, g, b):\n return int('0x{:02x}{:02x}{:02x}'.format(r, g, b))\n\n_ab_global = {\n 'eye_color': ${_eye_color},\n 'cheek_color': ${_cheek_color},\n 'background_color': ${_background_color},\n 'position': 'POS_NORMAL',\n 'orientation': 'ORI_NORMAL',\n 'blink_thread_running': False,\n 'blink_running': False,\n 'blink_interval_function': _ab_get_const('DEFAULT_BLINK_INTERVAL_FUNCTION'),\n}\n\ndef _ab_get_global(key):\n return _ab_global[key]\n\ndef _ab_set_global(key, val):\n _ab_global[key] = val\n\ndef _ab_get_led_position(orientation, position):\n return _ab_get_const('ORIENTATIONS')[orientation][position - 1]\n\ndef _ab_fill(color):\n rgb.setColorFrom(_ab_get_const('MIN_LED_POS'), _ab_get_const('MAX_LED_POS'), color)\n\ndef _ab_set_color(pos, color, orientation):\n rgb.setColor(_ab_get_led_position(orientation, pos), color)\n\ndef _ab_get_eye_position(pos):\n return _ab_get_const('EYE_POSITIONS')[pos]\n\ndef _ab_get_cheek_position(pos):\n return _ab_get_const('CHEEK_POSITIONS')[pos]\n\ndef _ab_set_eyes(pos, color, orientation):\n for _p in _ab_get_eye_position(pos):\n _ab_set_color(_p, color, orientation)\n\ndef _ab_set_cheeks(pos, color, orientation):\n for _p in _ab_get_cheek_position(pos):\n _ab_set_color(_p, color, orientation)\n\ndef _ab_set_face(pos, eye_color, cheek_color, orientation):\n _ab_set_eyes(pos, eye_color, orientation)\n _ab_set_cheeks(pos, cheek_color, orientation)\n\ndef _ab_show_face():\n _ab_fill(_ab_get_background_color())\n _ab_set_face(_ab_get_position(), _ab_get_eye_color(), _ab_get_cheek_color(), _ab_get_orientation())\n\ndef _ab_clear_face():\n _bg_color = _ab_get_background_color()\n _ab_set_face(_ab_get_position(), _bg_color, _bg_color, _ab_get_orientation())\n\ndef _ab_open_eyes():\n _ab_set_eyes(_ab_get_position(), _ab_get_eye_color(), _ab_get_orientation())\n\ndef _ab_close_eyes():\n _ab_set_eyes(_ab_get_position(), _ab_get_background_color(), _ab_get_orientation())\n\ndef _ab_set_eye_color(color):\n _ab_set_global('eye_color', color)\n\ndef _ab_get_eye_color():\n return _ab_get_global('eye_color')\n\ndef _ab_set_cheek_color(color):\n _ab_set_global('cheek_color', color)\n\ndef _ab_get_cheek_color():\n return _ab_get_global('cheek_color')\n\ndef _ab_set_background_color(color):\n _ab_set_global('background_color', color)\n\ndef _ab_get_background_color():\n return _ab_get_global('background_color')\n\ndef _ab_set_orientation(orientation):\n _ab_set_global('orientation', orientation)\n\ndef _ab_get_orientation():\n return _ab_get_global('orientation')\n\ndef _ab_set_face_position(position):\n _ab_set_global('position', position)\n\ndef _ab_get_face_position():\n return _ab_get_global('position')\n\ndef _ab_is_ascii(s):\n return all(ord(c) < 128 for c in s)\n\ndef _ab_get_function_name(name):\n if _ab_is_ascii(name):\n return name\n else:\n return ''.join(['_{:02X}'.format(b) for b in name.encode()])\n\n_ab_lock = _ab_t.allocate_lock()\n\ndef _ab_blink_task():\n while _ab_get_global('blink_thread_running'):\n if _ab_get_global('blink_running'):\n with _ab_lock:\n _func = _ab_get_function_name(_ab_get_global('blink_interval_function'))\n _intervals = globals()[_func]()\n for _ in range(_intervals.get('LOOP', 1)):\n time.sleep_ms(_intervals.get('OPEN', 500))\n _ab_close_eyes()\n time.sleep_ms(_intervals.get('CLOSE', 100))\n _ab_open_eyes()\n time.sleep_ms(_intervals.get('INTERVAL', 1000))\n else:\n time.sleep_ms(1)\n\ndef _ab_set_blink_interval(interval):\n _ab_set_global('blink_interval', interval)\n\ndef _ab_start_blink(func = None):\n if not _ab_get_global('blink_thread_running'):\n _ab_set_global('blink_thread_running', True)\n _ab_t.start_new_thread(_ab_blink_task, ())\n _ab_set_global('blink_interval_function', func or '_ab_get_blink_interval')\n _ab_set_global('blink_running', True)\n\ndef _ab_stop_blink():\n _ab_set_global('blink_running', False)\n\ndef _ab_terminate_blink():\n _ab_set_global('blink_thread_running', False)\n\ndef _ab_get_blink_interval():\n return _ab_const('BLINK_INTERVAL')\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_showFace\nvar __ATOM_Babies_showFace_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔を表示する\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_showFace'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_showFace_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_showFace'] = function(block) {\n return `_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_clearFace\nvar __ATOM_Babies_clearFace_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔を消す\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_clearFace'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_clearFace_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_clearFace'] = function(block) {\n return `_ab_clear_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_RGB\nvar __ATOM_Babies_RGB_json = {\n \"output\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"色を指定する\"\n }\n ],\n \"message1\": \"%1 %2\",\n \"args1\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_r\"\n },\n {\n \"type\": \"field_number\",\n \"value\": 0,\n \"name\": \"_r\"\n }\n ],\n \"message2\": \"%1 %2\",\n \"args2\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_g\"\n },\n {\n \"type\": \"field_number\",\n \"value\": 0,\n \"name\": \"_g\"\n }\n ],\n \"message3\": \"%1 %2\",\n \"args3\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_b\"\n },\n {\n \"type\": \"field_number\",\n \"value\": 0,\n \"name\": \"_b\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_RGB'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_RGB_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_RGB'] = function(block) {\n var _r = block.getFieldValue('_r');\nvar _g = block.getFieldValue('_g');\nvar _b = block.getFieldValue('_b');\n return [`_ab_get_rgb(${_r}, ${_g}, ${_b})`, Blockly.Python.ORDER_CONDITIONAL]\n};\n\n// Block __ATOM_Babies_setOrientationNormal\nvar __ATOM_Babies_setOrientationNormal_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の向きを通常にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setOrientationNormal'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setOrientationNormal_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setOrientationNormal'] = function(block) {\n return `_ab_set_orientation('ORI_NORMAL')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setOrientationRight\nvar __ATOM_Babies_setOrientationRight_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の向きを右にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setOrientationRight'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setOrientationRight_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setOrientationRight'] = function(block) {\n return `_ab_set_orientation('ORI_RIGHT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setOrientationUpsideDown\nvar __ATOM_Babies_setOrientationUpsideDown_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の向きを逆にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setOrientationUpsideDown'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setOrientationUpsideDown_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setOrientationUpsideDown'] = function(block) {\n return `_ab_set_orientation('ORI_UPSIDE_DOWN')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setOrientationLeft\nvar __ATOM_Babies_setOrientationLeft_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の向きを左にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setOrientationLeft'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setOrientationLeft_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setOrientationLeft'] = function(block) {\n return `_ab_set_orientation('ORI_LEFT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setFacePositionNormal\nvar __ATOM_Babies_setFacePositionNormal_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の位置を通常にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setFacePositionNormal'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setFacePositionNormal_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setFacePositionNormal'] = function(block) {\n return `_ab_set_face_position('POS_NORMAL')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setFacePositionRight\nvar __ATOM_Babies_setFacePositionRight_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の位置を右にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setFacePositionRight'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setFacePositionRight_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setFacePositionRight'] = function(block) {\n return `_ab_set_face_position('POS_RIGHT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setFacePositionDown\nvar __ATOM_Babies_setFacePositionDown_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の位置を下にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setFacePositionDown'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setFacePositionDown_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setFacePositionDown'] = function(block) {\n return `_ab_set_face_position('POS_DOWN')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setFacePositionLeft\nvar __ATOM_Babies_setFacePositionLeft_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の位置を左にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setFacePositionLeft'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setFacePositionLeft_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setFacePositionLeft'] = function(block) {\n return `_ab_set_face_position('POS_LEFT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setFacePositionUp\nvar __ATOM_Babies_setFacePositionUp_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の位置を上にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setFacePositionUp'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setFacePositionUp_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setFacePositionUp'] = function(block) {\n return `_ab_set_face_position('POS_UP')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setFacePositionTop\nvar __ATOM_Babies_setFacePositionTop_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の位置を真上にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setFacePositionTop'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setFacePositionTop_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setFacePositionTop'] = function(block) {\n return `_ab_set_face_position('POS_TOP')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setFacePositionBottom\nvar __ATOM_Babies_setFacePositionBottom_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の位置を真下にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setFacePositionBottom'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setFacePositionBottom_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setFacePositionBottom'] = function(block) {\n return `_ab_set_face_position('POS_BOTTOM')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_openEyes\nvar __ATOM_Babies_openEyes_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"目を開ける\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_openEyes'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_openEyes_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_openEyes'] = function(block) {\n return `_ab_open_eyes()` + \"\\n\";\n};\n\n// Block __ATOM_Babies_closeEyes\nvar __ATOM_Babies_closeEyes_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"目を閉じる\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_closeEyes'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_closeEyes_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_closeEyes'] = function(block) {\n return `_ab_close_eyes()\n\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_showCheeks\nvar __ATOM_Babies_showCheeks_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"ほっぺを表示する\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_showCheeks'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_showCheeks_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_showCheeks'] = function(block) {\n return `_ab_set_cheeks(_ab_get_position(), _ab_get_cheek_color(), _ab_get_orientation())\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_clearCheeks\nvar __ATOM_Babies_clearCheeks_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"ほっぺを消す\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_clearCheeks'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_clearCheeks_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_clearCheeks'] = function(block) {\n return `_ab_set_cheeks(_ab_get_position(), _ab_get_background_color(), _ab_get_orientation())\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_startBlink\nvar __ATOM_Babies_startBlink_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"まばたきを始める\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_startBlink'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_startBlink_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_startBlink'] = function(block) {\n return `_ab_start_blink()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_stopBlink\nvar __ATOM_Babies_stopBlink_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"まばたきを止める\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_stopBlink'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_stopBlink_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_stopBlink'] = function(block) {\n return `_ab_stop_blink()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_startBlinkWithFunction\nvar __ATOM_Babies_startBlinkWithFunction_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"まばたきを始める\"\n }\n ],\n \"message1\": \"%1 %2\",\n \"args1\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_interval_function_name\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_interval_function_name\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_startBlinkWithFunction'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_startBlinkWithFunction_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_startBlinkWithFunction'] = function(block) {\n var _interval_function_name = Blockly.Python.valueToCode(block, '_interval_function_name', Blockly.Python.ORDER_NONE);\n return `_ab_start_blink(${_interval_function_name})\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_getBlinkIntervalValues\nvar __ATOM_Babies_getBlinkIntervalValues_json = {\n \"output\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"まばたきの設定値\"\n }\n ],\n \"message1\": \"%1 %2\",\n \"args1\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_loop\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_loop\"\n }\n ],\n \"message2\": \"%1 %2\",\n \"args2\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_open\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_open\"\n }\n ],\n \"message3\": \"%1 %2\",\n \"args3\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_close\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_close\"\n }\n ],\n \"message4\": \"%1 %2\",\n \"args4\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_interval\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_interval\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_getBlinkIntervalValues'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_getBlinkIntervalValues_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_getBlinkIntervalValues'] = function(block) {\n var _loop = Blockly.Python.valueToCode(block, '_loop', Blockly.Python.ORDER_NONE);\nvar _open = Blockly.Python.valueToCode(block, '_open', Blockly.Python.ORDER_NONE);\nvar _close = Blockly.Python.valueToCode(block, '_close', Blockly.Python.ORDER_NONE);\nvar _interval = Blockly.Python.valueToCode(block, '_interval', Blockly.Python.ORDER_NONE);\n return [`{\n \"LOOP\": ${_loop},\n \"OPEN\": ${_open},\n \"CLOSE\": ${_close},\n \"INTERVAL\": ${_interval}\n}`, Blockly.Python.ORDER_CONDITIONAL]\n};\n\n","code":{"initAtomBabies":["window['Blockly'].Python['__ATOM_Babies_initAtomBabies'] = function(block) {\n var _eye_color = Blockly.Python.valueToCode(block, '_eye_color', Blockly.Python.ORDER_NONE);\nvar _cheek_color = Blockly.Python.valueToCode(block, '_cheek_color', Blockly.Python.ORDER_NONE);\nvar _background_color = Blockly.Python.valueToCode(block, '_background_color', Blockly.Python.ORDER_NONE);\n return `import _thread as _ab_t\nimport re\nimport time\n\n_ab_const = {\n 'MIN_LED_POS': 1,\n 'MAX_LED_POS': 25,\n 'EYE_POSITIONS': {\n 'POS_TOP': [2, 4],\n 'POS_UP': [7, 9],\n 'POS_NORMAL':[12, 14],\n 'POS_RIGHT': [11, 13],\n 'POS_LEFT': [13, 15],\n 'POS_DOWN': [17, 19],\n 'POS_BOTTOM': [22, 24],\n },\n 'CHEEK_POSITIONS': {\n 'POS_TOP': [6, 10],\n 'POS_UP': [11, 15],\n 'POS_NORMAL': [16, 20],\n 'POS_RIGHT': [19],\n 'POS_LEFT': [17],\n 'POS_DOWN': [21, 25],\n 'POS_BOTTOM': [],\n },\n 'ORIENTATIONS': {\n 'ORI_NORMAL': [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],\n 'ORI_RIGHT': [21, 16, 11, 6, 1, 22, 17, 12, 7, 2, 23, 18, 13, 8, 3, 24, 19, 14, 9, 4, 25, 20, 15, 10, 5],\n 'ORI_UPSIDE_DOWN': [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],\n 'ORI_LEFT': [ 5, 10, 15, 20, 25, 4, 9, 14, 19, 24, 3, 8, 13, 18, 23, 2, 7, 12, 17, 22, 1, 6, 11, 16, 21],\n },\n 'BLINK_INTERVAL': {\n 'LOOP': 1,\n 'OPEN': 500,\n 'CLOSE': 100,\n 'INTERVAL': 1000,\n },\n 'DEFAULT_BLINK_INTERVAL_FUNCTION': '_ab_get_blink_interval'\n}\n\ndef _ab_get_const(key):\n return _ab_const[key]\n\ndef _ab_get_rgb(r, g, b):\n return int('0x{:02x}{:02x}{:02x}'.format(r, g, b))\n\n_ab_global = {\n 'eye_color': ${_eye_color},\n 'cheek_color': ${_cheek_color},\n 'background_color': ${_background_color},\n 'position': 'POS_NORMAL',\n 'orientation': 'ORI_NORMAL',\n 'blink_thread_running': False,\n 'blink_running': False,\n 'blink_interval_function': _ab_get_const('DEFAULT_BLINK_INTERVAL_FUNCTION'),\n}\n\ndef _ab_get_global(key):\n return _ab_global[key]\n\ndef _ab_set_global(key, val):\n _ab_global[key] = val\n\ndef _ab_get_led_position(orientation, position):\n return _ab_get_const('ORIENTATIONS')[orientation][position - 1]\n\ndef _ab_fill(color):\n rgb.setColorFrom(_ab_get_const('MIN_LED_POS'), _ab_get_const('MAX_LED_POS'), color)\n\ndef _ab_set_color(pos, color, orientation):\n rgb.setColor(_ab_get_led_position(orientation, pos), color)\n\ndef _ab_get_eye_position(pos):\n return _ab_get_const('EYE_POSITIONS')[pos]\n\ndef _ab_get_cheek_position(pos):\n return _ab_get_const('CHEEK_POSITIONS')[pos]\n\ndef _ab_set_eyes(pos, color, orientation):\n for _p in _ab_get_eye_position(pos):\n _ab_set_color(_p, color, orientation)\n\ndef _ab_set_cheeks(pos, color, orientation):\n for _p in _ab_get_cheek_position(pos):\n _ab_set_color(_p, color, orientation)\n\ndef _ab_set_face(pos, eye_color, cheek_color, orientation):\n _ab_set_eyes(pos, eye_color, orientation)\n _ab_set_cheeks(pos, cheek_color, orientation)\n\ndef _ab_show_face():\n _ab_fill(_ab_get_background_color())\n _ab_set_face(_ab_get_position(), _ab_get_eye_color(), _ab_get_cheek_color(), _ab_get_orientation())\n\ndef _ab_clear_face():\n _bg_color = _ab_get_background_color()\n _ab_set_face(_ab_get_position(), _bg_color, _bg_color, _ab_get_orientation())\n\ndef _ab_open_eyes():\n _ab_set_eyes(_ab_get_position(), _ab_get_eye_color(), _ab_get_orientation())\n\ndef _ab_close_eyes():\n _ab_set_eyes(_ab_get_position(), _ab_get_background_color(), _ab_get_orientation())\n\ndef _ab_set_eye_color(color):\n _ab_set_global('eye_color', color)\n\ndef _ab_get_eye_color():\n return _ab_get_global('eye_color')\n\ndef _ab_set_cheek_color(color):\n _ab_set_global('cheek_color', color)\n\ndef _ab_get_cheek_color():\n return _ab_get_global('cheek_color')\n\ndef _ab_set_background_color(color):\n _ab_set_global('background_color', color)\n\ndef _ab_get_background_color():\n return _ab_get_global('background_color')\n\ndef _ab_set_orientation(orientation):\n _ab_set_global('orientation', orientation)\n\ndef _ab_get_orientation():\n return _ab_get_global('orientation')\n\ndef _ab_set_face_position(position):\n _ab_set_global('position', position)\n\ndef _ab_get_face_position():\n return _ab_get_global('position')\n\ndef _ab_is_ascii(s):\n return all(ord(c) < 128 for c in s)\n\ndef _ab_get_function_name(name):\n if _ab_is_ascii(name):\n return name\n else:\n return ''.join(['_{:02X}'.format(b) for b in name.encode()])\n\n_ab_lock = _ab_t.allocate_lock()\n\ndef _ab_blink_task():\n while _ab_get_global('blink_thread_running'):\n if _ab_get_global('blink_running'):\n with _ab_lock:\n _func = _ab_get_function_name(_ab_get_global('blink_interval_function'))\n _intervals = globals()[_func]()\n for _ in range(_intervals.get('LOOP', 1)):\n time.sleep_ms(_intervals.get('OPEN', 500))\n _ab_close_eyes()\n time.sleep_ms(_intervals.get('CLOSE', 100))\n _ab_open_eyes()\n time.sleep_ms(_intervals.get('INTERVAL', 1000))\n else:\n time.sleep_ms(1)\n\ndef _ab_set_blink_interval(interval):\n _ab_set_global('blink_interval', interval)\n\ndef _ab_start_blink(func = None):\n if not _ab_get_global('blink_thread_running'):\n _ab_set_global('blink_thread_running', True)\n _ab_t.start_new_thread(_ab_blink_task, ())\n _ab_set_global('blink_interval_function', func or '_ab_get_blink_interval')\n _ab_set_global('blink_running', True)\n\ndef _ab_stop_blink():\n _ab_set_global('blink_running', False)\n\ndef _ab_terminate_blink():\n _ab_set_global('blink_thread_running', False)\n\ndef _ab_get_blink_interval():\n return _ab_const('BLINK_INTERVAL')\n` + \"\\n\";\n};\n\n","import _thread as _ab_t\nimport re\nimport time\n\n_ab_const = {\n 'MIN_LED_POS': 1,\n 'MAX_LED_POS': 25,\n 'EYE_POSITIONS': {\n 'POS_TOP': [2, 4],\n 'POS_UP': [7, 9],\n 'POS_NORMAL':[12, 14],\n 'POS_RIGHT': [11, 13],\n 'POS_LEFT': [13, 15],\n 'POS_DOWN': [17, 19],\n 'POS_BOTTOM': [22, 24],\n },\n 'CHEEK_POSITIONS': {\n 'POS_TOP': [6, 10],\n 'POS_UP': [11, 15],\n 'POS_NORMAL': [16, 20],\n 'POS_RIGHT': [19],\n 'POS_LEFT': [17],\n 'POS_DOWN': [21, 25],\n 'POS_BOTTOM': [],\n },\n 'ORIENTATIONS': {\n 'ORI_NORMAL': [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],\n 'ORI_RIGHT': [21, 16, 11, 6, 1, 22, 17, 12, 7, 2, 23, 18, 13, 8, 3, 24, 19, 14, 9, 4, 25, 20, 15, 10, 5],\n 'ORI_UPSIDE_DOWN': [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],\n 'ORI_LEFT': [ 5, 10, 15, 20, 25, 4, 9, 14, 19, 24, 3, 8, 13, 18, 23, 2, 7, 12, 17, 22, 1, 6, 11, 16, 21],\n },\n 'BLINK_INTERVAL': {\n 'LOOP': 1,\n 'OPEN': 500,\n 'CLOSE': 100,\n 'INTERVAL': 1000,\n },\n 'DEFAULT_BLINK_INTERVAL_FUNCTION': '_ab_get_blink_interval'\n}\n\ndef _ab_get_const(key):\n return _ab_const[key]\n\ndef _ab_get_rgb(r, g, b):\n return int('0x{:02x}{:02x}{:02x}'.format(r, g, b))\n\n_ab_global = {\n 'eye_color': ${_eye_color},\n 'cheek_color': ${_cheek_color},\n 'background_color': ${_background_color},\n 'position': 'POS_NORMAL',\n 'orientation': 'ORI_NORMAL',\n 'blink_thread_running': False,\n 'blink_running': False,\n 'blink_interval_function': _ab_get_const('DEFAULT_BLINK_INTERVAL_FUNCTION'),\n}\n\ndef _ab_get_global(key):\n return _ab_global[key]\n\ndef _ab_set_global(key, val):\n _ab_global[key] = val\n\ndef _ab_get_led_position(orientation, position):\n return _ab_get_const('ORIENTATIONS')[orientation][position - 1]\n\ndef _ab_fill(color):\n rgb.setColorFrom(_ab_get_const('MIN_LED_POS'), _ab_get_const('MAX_LED_POS'), color)\n\ndef _ab_set_color(pos, color, orientation):\n rgb.setColor(_ab_get_led_position(orientation, pos), color)\n\ndef _ab_get_eye_position(pos):\n return _ab_get_const('EYE_POSITIONS')[pos]\n\ndef _ab_get_cheek_position(pos):\n return _ab_get_const('CHEEK_POSITIONS')[pos]\n\ndef _ab_set_eyes(pos, color, orientation):\n for _p in _ab_get_eye_position(pos):\n _ab_set_color(_p, color, orientation)\n\ndef _ab_set_cheeks(pos, color, orientation):\n for _p in _ab_get_cheek_position(pos):\n _ab_set_color(_p, color, orientation)\n\ndef _ab_set_face(pos, eye_color, cheek_color, orientation):\n _ab_set_eyes(pos, eye_color, orientation)\n _ab_set_cheeks(pos, cheek_color, orientation)\n\ndef _ab_show_face():\n _ab_fill(_ab_get_background_color())\n _ab_set_face(_ab_get_position(), _ab_get_eye_color(), _ab_get_cheek_color(), _ab_get_orientation())\n\ndef _ab_clear_face():\n _bg_color = _ab_get_background_color()\n _ab_set_face(_ab_get_position(), _bg_color, _bg_color, _ab_get_orientation())\n\ndef _ab_open_eyes():\n _ab_set_eyes(_ab_get_position(), _ab_get_eye_color(), _ab_get_orientation())\n\ndef _ab_close_eyes():\n _ab_set_eyes(_ab_get_position(), _ab_get_background_color(), _ab_get_orientation())\n\ndef _ab_set_eye_color(color):\n _ab_set_global('eye_color', color)\n\ndef _ab_get_eye_color():\n return _ab_get_global('eye_color')\n\ndef _ab_set_cheek_color(color):\n _ab_set_global('cheek_color', color)\n\ndef _ab_get_cheek_color():\n return _ab_get_global('cheek_color')\n\ndef _ab_set_background_color(color):\n _ab_set_global('background_color', color)\n\ndef _ab_get_background_color():\n return _ab_get_global('background_color')\n\ndef _ab_set_orientation(orientation):\n _ab_set_global('orientation', orientation)\n\ndef _ab_get_orientation():\n return _ab_get_global('orientation')\n\ndef _ab_set_face_position(position):\n _ab_set_global('position', position)\n\ndef _ab_get_face_position():\n return _ab_get_global('position')\n\ndef _ab_is_ascii(s):\n return all(ord(c) < 128 for c in s)\n\ndef _ab_get_function_name(name):\n if _ab_is_ascii(name):\n return name\n else:\n return ''.join(['_{:02X}'.format(b) for b in name.encode()])\n\n_ab_lock = _ab_t.allocate_lock()\n\ndef _ab_blink_task():\n while _ab_get_global('blink_thread_running'):\n if _ab_get_global('blink_running'):\n with _ab_lock:\n _func = _ab_get_function_name(_ab_get_global('blink_interval_function'))\n _intervals = globals()[_func]()\n for _ in range(_intervals.get('LOOP', 1)):\n time.sleep_ms(_intervals.get('OPEN', 500))\n _ab_close_eyes()\n time.sleep_ms(_intervals.get('CLOSE', 100))\n _ab_open_eyes()\n time.sleep_ms(_intervals.get('INTERVAL', 1000))\n else:\n time.sleep_ms(1)\n\ndef _ab_set_blink_interval(interval):\n _ab_set_global('blink_interval', interval)\n\ndef _ab_start_blink(func = None):\n if not _ab_get_global('blink_thread_running'):\n _ab_set_global('blink_thread_running', True)\n _ab_t.start_new_thread(_ab_blink_task, ())\n _ab_set_global('blink_interval_function', func or '_ab_get_blink_interval')\n _ab_set_global('blink_running', True)\n\ndef _ab_stop_blink():\n _ab_set_global('blink_running', False)\n\ndef _ab_terminate_blink():\n _ab_set_global('blink_thread_running', False)\n\ndef _ab_get_blink_interval():\n return _ab_const('BLINK_INTERVAL')\n"],"showFace":["window['Blockly'].Python['__ATOM_Babies_showFace'] = function(block) {\n return `_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_show_face()\n"],"clearFace":["window['Blockly'].Python['__ATOM_Babies_clearFace'] = function(block) {\n return `_ab_clear_face()\n` + \"\\n\";\n};\n\n","_ab_clear_face()\n"],"RGB":["window['Blockly'].Python['__ATOM_Babies_RGB'] = function(block) {\n var _r = block.getFieldValue('_r');\nvar _g = block.getFieldValue('_g');\nvar _b = block.getFieldValue('_b');\n return [`_ab_get_rgb(${_r}, ${_g}, ${_b})`, Blockly.Python.ORDER_CONDITIONAL]\n};\n\n","_ab_get_rgb(${_r}, ${_g}, ${_b})"],"setOrientationNormal":["window['Blockly'].Python['__ATOM_Babies_setOrientationNormal'] = function(block) {\n return `_ab_set_orientation('ORI_NORMAL')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_orientation('ORI_NORMAL')\n_ab_show_face()\n"],"setOrientationRight":["window['Blockly'].Python['__ATOM_Babies_setOrientationRight'] = function(block) {\n return `_ab_set_orientation('ORI_RIGHT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_orientation('ORI_RIGHT')\n_ab_show_face()\n"],"setOrientationUpsideDown":["window['Blockly'].Python['__ATOM_Babies_setOrientationUpsideDown'] = function(block) {\n return `_ab_set_orientation('ORI_UPSIDE_DOWN')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_orientation('ORI_UPSIDE_DOWN')\n_ab_show_face()\n"],"setOrientationLeft":["window['Blockly'].Python['__ATOM_Babies_setOrientationLeft'] = function(block) {\n return `_ab_set_orientation('ORI_LEFT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_orientation('ORI_LEFT')\n_ab_show_face()\n"],"setFacePositionNormal":["window['Blockly'].Python['__ATOM_Babies_setFacePositionNormal'] = function(block) {\n return `_ab_set_face_position('POS_NORMAL')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_face_position('POS_NORMAL')\n_ab_show_face()\n"],"setFacePositionRight":["window['Blockly'].Python['__ATOM_Babies_setFacePositionRight'] = function(block) {\n return `_ab_set_face_position('POS_RIGHT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_face_position('POS_RIGHT')\n_ab_show_face()\n"],"setFacePositionDown":["window['Blockly'].Python['__ATOM_Babies_setFacePositionDown'] = function(block) {\n return `_ab_set_face_position('POS_DOWN')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_face_position('POS_DOWN')\n_ab_show_face()\n"],"setFacePositionLeft":["window['Blockly'].Python['__ATOM_Babies_setFacePositionLeft'] = function(block) {\n return `_ab_set_face_position('POS_LEFT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_face_position('POS_LEFT')\n_ab_show_face()\n"],"setFacePositionUp":["window['Blockly'].Python['__ATOM_Babies_setFacePositionUp'] = function(block) {\n return `_ab_set_face_position('POS_UP')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_face_position('POS_UP')\n_ab_show_face()\n"],"setFacePositionTop":["window['Blockly'].Python['__ATOM_Babies_setFacePositionTop'] = function(block) {\n return `_ab_set_face_position('POS_TOP')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_face_position('POS_TOP')\n_ab_show_face()\n"],"setFacePositionBottom":["window['Blockly'].Python['__ATOM_Babies_setFacePositionBottom'] = function(block) {\n return `_ab_set_face_position('POS_BOTTOM')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_face_position('POS_BOTTOM')\n_ab_show_face()\n"],"openEyes":["window['Blockly'].Python['__ATOM_Babies_openEyes'] = function(block) {\n return `_ab_open_eyes()` + \"\\n\";\n};\n\n","_ab_open_eyes()"],"closeEyes":["window['Blockly'].Python['__ATOM_Babies_closeEyes'] = function(block) {\n return `_ab_close_eyes()\n\n` + \"\\n\";\n};\n\n","_ab_close_eyes()\n\n"],"showCheeks":["window['Blockly'].Python['__ATOM_Babies_showCheeks'] = function(block) {\n return `_ab_set_cheeks(_ab_get_position(), _ab_get_cheek_color(), _ab_get_orientation())\n` + \"\\n\";\n};\n\n","_ab_set_cheeks(_ab_get_position(), _ab_get_cheek_color(), _ab_get_orientation())\n"],"clearCheeks":["window['Blockly'].Python['__ATOM_Babies_clearCheeks'] = function(block) {\n return `_ab_set_cheeks(_ab_get_position(), _ab_get_background_color(), _ab_get_orientation())\n` + \"\\n\";\n};\n\n","_ab_set_cheeks(_ab_get_position(), _ab_get_background_color(), _ab_get_orientation())\n"],"startBlink":["window['Blockly'].Python['__ATOM_Babies_startBlink'] = function(block) {\n return `_ab_start_blink()\n` + \"\\n\";\n};\n\n","_ab_start_blink()\n"],"stopBlink":["window['Blockly'].Python['__ATOM_Babies_stopBlink'] = function(block) {\n return `_ab_stop_blink()\n` + \"\\n\";\n};\n\n","_ab_stop_blink()\n"],"startBlinkWithFunction":["window['Blockly'].Python['__ATOM_Babies_startBlinkWithFunction'] = function(block) {\n var _interval_function_name = Blockly.Python.valueToCode(block, '_interval_function_name', Blockly.Python.ORDER_NONE);\n return `_ab_start_blink(${_interval_function_name})\n` + \"\\n\";\n};\n\n","_ab_start_blink(${_interval_function_name})\n"],"getBlinkIntervalValues":["window['Blockly'].Python['__ATOM_Babies_getBlinkIntervalValues'] = function(block) {\n var _loop = Blockly.Python.valueToCode(block, '_loop', Blockly.Python.ORDER_NONE);\nvar _open = Blockly.Python.valueToCode(block, '_open', Blockly.Python.ORDER_NONE);\nvar _close = Blockly.Python.valueToCode(block, '_close', Blockly.Python.ORDER_NONE);\nvar _interval = Blockly.Python.valueToCode(block, '_interval', Blockly.Python.ORDER_NONE);\n return [`{\n \"LOOP\": ${_loop},\n \"OPEN\": ${_open},\n \"CLOSE\": ${_close},\n \"INTERVAL\": ${_interval}\n}`, Blockly.Python.ORDER_CONDITIONAL]\n};\n\n","{\n \"LOOP\": ${_loop},\n \"OPEN\": ${_open},\n \"CLOSE\": ${_close},\n \"INTERVAL\": ${_interval}\n}"]}} \ No newline at end of file +{"category":"ATOM_Babies","color":"#115f07","blocks":["__ATOM_Babies_initAtomBabies","__ATOM_Babies_showFace","__ATOM_Babies_clearFace","__ATOM_Babies_RGB","__ATOM_Babies_setOrientationNormal","__ATOM_Babies_setOrientationRight","__ATOM_Babies_setOrientationUpsideDown","__ATOM_Babies_setOrientationLeft","__ATOM_Babies_setFacePositionNormal","__ATOM_Babies_setFacePositionRight","__ATOM_Babies_setFacePositionDown","__ATOM_Babies_setFacePositionLeft","__ATOM_Babies_setFacePositionUp","__ATOM_Babies_setFacePositionTop","__ATOM_Babies_setFacePositionBottom","__ATOM_Babies_openEyes","__ATOM_Babies_closeEyes","__ATOM_Babies_showCheeks","__ATOM_Babies_clearCheeks","__ATOM_Babies_startBlink","__ATOM_Babies_stopBlink","__ATOM_Babies_startBlinkWithFunction","__ATOM_Babies_getBlinkIntervalValues"],"jscode":"// Block __ATOM_Babies_initAtomBabies\nvar __ATOM_Babies_initAtomBabies_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"ATOM Babiesを初期化する\"\n }\n ],\n \"message1\": \"%1 %2\",\n \"args1\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_eye_color\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_eye_color\"\n }\n ],\n \"message2\": \"%1 %2\",\n \"args2\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_cheek_color\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_cheek_color\"\n }\n ],\n \"message3\": \"%1 %2\",\n \"args3\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_background_color\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_background_color\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_initAtomBabies'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_initAtomBabies_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_initAtomBabies'] = function(block) {\n var _eye_color = Blockly.Python.valueToCode(block, '_eye_color', Blockly.Python.ORDER_NONE);\nvar _cheek_color = Blockly.Python.valueToCode(block, '_cheek_color', Blockly.Python.ORDER_NONE);\nvar _background_color = Blockly.Python.valueToCode(block, '_background_color', Blockly.Python.ORDER_NONE);\n return `import _thread as _ab_t\nimport re\nimport time\n\n_ab_const = {\n 'MIN_LED_POS': 1,\n 'MAX_LED_POS': 25,\n 'EYE_POSITIONS': {\n 'POS_TOP': [2, 4],\n 'POS_UP': [7, 9],\n 'POS_NORMAL':[12, 14],\n 'POS_RIGHT': [11, 13],\n 'POS_LEFT': [13, 15],\n 'POS_DOWN': [17, 19],\n 'POS_BOTTOM': [22, 24],\n },\n 'CHEEK_POSITIONS': {\n 'POS_TOP': [6, 10],\n 'POS_UP': [11, 15],\n 'POS_NORMAL': [16, 20],\n 'POS_RIGHT': [19],\n 'POS_LEFT': [17],\n 'POS_DOWN': [21, 25],\n 'POS_BOTTOM': [],\n },\n 'ORIENTATIONS': {\n 'ORI_NORMAL': [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],\n 'ORI_RIGHT': [21, 16, 11, 6, 1, 22, 17, 12, 7, 2, 23, 18, 13, 8, 3, 24, 19, 14, 9, 4, 25, 20, 15, 10, 5],\n 'ORI_UPSIDE_DOWN': [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],\n 'ORI_LEFT': [ 5, 10, 15, 20, 25, 4, 9, 14, 19, 24, 3, 8, 13, 18, 23, 2, 7, 12, 17, 22, 1, 6, 11, 16, 21],\n },\n 'BLINK_INTERVAL': {\n 'LOOP': 1,\n 'OPEN': 500,\n 'CLOSE': 100,\n 'INTERVAL': 1000,\n },\n 'DEFAULT_BLINK_INTERVAL_FUNCTION': '_ab_get_blink_interval'\n}\n\ndef _ab_get_const(key):\n return _ab_const[key]\n\ndef _ab_get_rgb(r, g, b):\n return int('0x{:02x}{:02x}{:02x}'.format(r, g, b))\n\n_ab_global = {\n 'eye_color': ${_eye_color},\n 'cheek_color': ${_cheek_color},\n 'background_color': ${_background_color},\n 'position': 'POS_NORMAL',\n 'orientation': 'ORI_NORMAL',\n 'blink_thread_running': False,\n 'blink_running': False,\n 'blink_interval_function': _ab_get_const('DEFAULT_BLINK_INTERVAL_FUNCTION'),\n}\n\ndef _ab_get_global(key):\n return _ab_global[key]\n\ndef _ab_set_global(key, val):\n _ab_global[key] = val\n\ndef _ab_get_led_position(orientation, position):\n return _ab_get_const('ORIENTATIONS')[orientation][position - 1]\n\ndef _ab_fill(color):\n rgb.setColorFrom(_ab_get_const('MIN_LED_POS'), _ab_get_const('MAX_LED_POS'), color)\n\ndef _ab_set_color(pos, color, orientation):\n rgb.setColor(_ab_get_led_position(orientation, pos), color)\n\ndef _ab_get_eye_position(pos):\n return _ab_get_const('EYE_POSITIONS')[pos]\n\ndef _ab_get_cheek_position(pos):\n return _ab_get_const('CHEEK_POSITIONS')[pos]\n\ndef _ab_set_eyes(pos, color, orientation):\n for _p in _ab_get_eye_position(pos):\n _ab_set_color(_p, color, orientation)\n\ndef _ab_set_cheeks(pos, color, orientation):\n for _p in _ab_get_cheek_position(pos):\n _ab_set_color(_p, color, orientation)\n\ndef _ab_set_face(pos, eye_color, cheek_color, orientation):\n _ab_set_eyes(pos, eye_color, orientation)\n _ab_set_cheeks(pos, cheek_color, orientation)\n\ndef _ab_show_face():\n _ab_fill(_ab_get_background_color())\n _ab_set_face(_ab_get_face_position(), _ab_get_eye_color(), _ab_get_cheek_color(), _ab_get_orientation())\n\ndef _ab_clear_face():\n _bg_color = _ab_get_background_color()\n _ab_set_face(_ab_get_face_position(), _bg_color, _bg_color, _ab_get_orientation())\n\ndef _ab_open_eyes():\n _ab_set_eyes(_ab_get_face_position(), _ab_get_eye_color(), _ab_get_orientation())\n\ndef _ab_close_eyes():\n _ab_set_eyes(_ab_get_face_position(), _ab_get_background_color(), _ab_get_orientation())\n\ndef _ab_set_eye_color(color):\n _ab_set_global('eye_color', color)\n\ndef _ab_get_eye_color():\n return _ab_get_global('eye_color')\n\ndef _ab_set_cheek_color(color):\n _ab_set_global('cheek_color', color)\n\ndef _ab_get_cheek_color():\n return _ab_get_global('cheek_color')\n\ndef _ab_set_background_color(color):\n _ab_set_global('background_color', color)\n\ndef _ab_get_background_color():\n return _ab_get_global('background_color')\n\ndef _ab_set_orientation(orientation):\n _ab_set_global('orientation', orientation)\n\ndef _ab_get_orientation():\n return _ab_get_global('orientation')\n\ndef _ab_set_face_position(position):\n _ab_set_global('position', position)\n\ndef _ab_get_face_position():\n return _ab_get_global('position')\n\ndef _ab_is_ascii(s):\n return all(ord(c) < 128 for c in s)\n\ndef _ab_get_function_name(name):\n if _ab_is_ascii(name):\n return name\n else:\n return ''.join(['_{:02X}'.format(b) for b in name.encode()])\n\n_ab_lock = _ab_t.allocate_lock()\n\ndef _ab_blink_task():\n while _ab_get_global('blink_thread_running'):\n if _ab_get_global('blink_running'):\n with _ab_lock:\n _func = _ab_get_function_name(_ab_get_global('blink_interval_function'))\n _intervals = globals()[_func]()\n for _ in range(_intervals.get('LOOP', 1)):\n time.sleep_ms(_intervals.get('OPEN', 500))\n _ab_close_eyes()\n time.sleep_ms(_intervals.get('CLOSE', 100))\n _ab_open_eyes()\n time.sleep_ms(_intervals.get('INTERVAL', 1000))\n else:\n time.sleep_ms(1)\n\ndef _ab_set_blink_interval(interval):\n _ab_set_global('blink_interval', interval)\n\ndef _ab_start_blink(func = None):\n if not _ab_get_global('blink_thread_running'):\n _ab_set_global('blink_thread_running', True)\n _ab_t.start_new_thread(_ab_blink_task, ())\n _ab_set_global('blink_interval_function', func or '_ab_get_blink_interval')\n _ab_set_global('blink_running', True)\n\ndef _ab_stop_blink():\n _ab_set_global('blink_running', False)\n\ndef _ab_terminate_blink():\n _ab_set_global('blink_thread_running', False)\n\ndef _ab_get_blink_interval():\n return _ab_const('BLINK_INTERVAL')\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_showFace\nvar __ATOM_Babies_showFace_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔を表示する\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_showFace'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_showFace_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_showFace'] = function(block) {\n return `_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_clearFace\nvar __ATOM_Babies_clearFace_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔を消す\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_clearFace'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_clearFace_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_clearFace'] = function(block) {\n return `_ab_clear_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_RGB\nvar __ATOM_Babies_RGB_json = {\n \"output\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"色を指定する\"\n }\n ],\n \"message1\": \"%1 %2\",\n \"args1\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_r\"\n },\n {\n \"type\": \"field_number\",\n \"value\": 0,\n \"name\": \"_r\"\n }\n ],\n \"message2\": \"%1 %2\",\n \"args2\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_g\"\n },\n {\n \"type\": \"field_number\",\n \"value\": 0,\n \"name\": \"_g\"\n }\n ],\n \"message3\": \"%1 %2\",\n \"args3\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_b\"\n },\n {\n \"type\": \"field_number\",\n \"value\": 0,\n \"name\": \"_b\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_RGB'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_RGB_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_RGB'] = function(block) {\n var _r = block.getFieldValue('_r');\nvar _g = block.getFieldValue('_g');\nvar _b = block.getFieldValue('_b');\n return [`_ab_get_rgb(${_r}, ${_g}, ${_b})`, Blockly.Python.ORDER_CONDITIONAL]\n};\n\n// Block __ATOM_Babies_setOrientationNormal\nvar __ATOM_Babies_setOrientationNormal_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の向きを通常にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setOrientationNormal'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setOrientationNormal_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setOrientationNormal'] = function(block) {\n return `_ab_set_orientation('ORI_NORMAL')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setOrientationRight\nvar __ATOM_Babies_setOrientationRight_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の向きを右にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setOrientationRight'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setOrientationRight_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setOrientationRight'] = function(block) {\n return `_ab_set_orientation('ORI_RIGHT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setOrientationUpsideDown\nvar __ATOM_Babies_setOrientationUpsideDown_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の向きを逆にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setOrientationUpsideDown'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setOrientationUpsideDown_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setOrientationUpsideDown'] = function(block) {\n return `_ab_set_orientation('ORI_UPSIDE_DOWN')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setOrientationLeft\nvar __ATOM_Babies_setOrientationLeft_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の向きを左にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setOrientationLeft'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setOrientationLeft_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setOrientationLeft'] = function(block) {\n return `_ab_set_orientation('ORI_LEFT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setFacePositionNormal\nvar __ATOM_Babies_setFacePositionNormal_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の位置を通常にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setFacePositionNormal'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setFacePositionNormal_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setFacePositionNormal'] = function(block) {\n return `_ab_set_face_position('POS_NORMAL')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setFacePositionRight\nvar __ATOM_Babies_setFacePositionRight_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の位置を右にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setFacePositionRight'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setFacePositionRight_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setFacePositionRight'] = function(block) {\n return `_ab_set_face_position('POS_RIGHT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setFacePositionDown\nvar __ATOM_Babies_setFacePositionDown_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の位置を下にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setFacePositionDown'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setFacePositionDown_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setFacePositionDown'] = function(block) {\n return `_ab_set_face_position('POS_DOWN')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setFacePositionLeft\nvar __ATOM_Babies_setFacePositionLeft_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の位置を左にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setFacePositionLeft'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setFacePositionLeft_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setFacePositionLeft'] = function(block) {\n return `_ab_set_face_position('POS_LEFT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setFacePositionUp\nvar __ATOM_Babies_setFacePositionUp_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の位置を上にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setFacePositionUp'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setFacePositionUp_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setFacePositionUp'] = function(block) {\n return `_ab_set_face_position('POS_UP')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setFacePositionTop\nvar __ATOM_Babies_setFacePositionTop_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の位置を真上にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setFacePositionTop'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setFacePositionTop_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setFacePositionTop'] = function(block) {\n return `_ab_set_face_position('POS_TOP')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_setFacePositionBottom\nvar __ATOM_Babies_setFacePositionBottom_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"顔の位置を真下にする\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_setFacePositionBottom'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_setFacePositionBottom_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_setFacePositionBottom'] = function(block) {\n return `_ab_set_face_position('POS_BOTTOM')\n_ab_show_face()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_openEyes\nvar __ATOM_Babies_openEyes_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"目を開ける\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_openEyes'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_openEyes_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_openEyes'] = function(block) {\n return `_ab_open_eyes()` + \"\\n\";\n};\n\n// Block __ATOM_Babies_closeEyes\nvar __ATOM_Babies_closeEyes_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"目を閉じる\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_closeEyes'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_closeEyes_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_closeEyes'] = function(block) {\n return `_ab_close_eyes()\n\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_showCheeks\nvar __ATOM_Babies_showCheeks_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"ほっぺを表示する\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_showCheeks'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_showCheeks_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_showCheeks'] = function(block) {\n return `_ab_set_cheeks(_ab_get_face_position(), _ab_get_cheek_color(), _ab_get_orientation())\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_clearCheeks\nvar __ATOM_Babies_clearCheeks_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"ほっぺを消す\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_clearCheeks'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_clearCheeks_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_clearCheeks'] = function(block) {\n return `_ab_set_cheeks(_ab_get_face_position(), _ab_get_background_color(), _ab_get_orientation())\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_startBlink\nvar __ATOM_Babies_startBlink_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"まばたきを始める\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_startBlink'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_startBlink_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_startBlink'] = function(block) {\n return `_ab_start_blink()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_stopBlink\nvar __ATOM_Babies_stopBlink_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"まばたきを止める\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_stopBlink'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_stopBlink_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_stopBlink'] = function(block) {\n return `_ab_stop_blink()\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_startBlinkWithFunction\nvar __ATOM_Babies_startBlinkWithFunction_json = {\n \"previousStatement\": null,\n \"nextStatement\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"まばたきを始める\"\n }\n ],\n \"message1\": \"%1 %2\",\n \"args1\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_interval_function_name\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_interval_function_name\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_startBlinkWithFunction'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_startBlinkWithFunction_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_startBlinkWithFunction'] = function(block) {\n var _interval_function_name = Blockly.Python.valueToCode(block, '_interval_function_name', Blockly.Python.ORDER_NONE);\n return `_ab_start_blink(${_interval_function_name})\n` + \"\\n\";\n};\n\n// Block __ATOM_Babies_getBlinkIntervalValues\nvar __ATOM_Babies_getBlinkIntervalValues_json = {\n \"output\": null,\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label\",\n \"text\": \"まばたきの設定値\"\n }\n ],\n \"message1\": \"%1 %2\",\n \"args1\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_loop\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_loop\"\n }\n ],\n \"message2\": \"%1 %2\",\n \"args2\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_open\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_open\"\n }\n ],\n \"message3\": \"%1 %2\",\n \"args3\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_close\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_close\"\n }\n ],\n \"message4\": \"%1 %2\",\n \"args4\": [\n {\n \"type\": \"field_label\",\n \"text\": \"_interval\"\n },\n {\n \"type\": \"input_value\",\n \"name\": \"_interval\"\n }\n ],\n \"colour\": \"#115f07\"\n};\n\nwindow['Blockly'].Blocks['__ATOM_Babies_getBlinkIntervalValues'] = {\n init: function() {\n this.jsonInit(__ATOM_Babies_getBlinkIntervalValues_json);\n }\n};\n\nwindow['Blockly'].Python['__ATOM_Babies_getBlinkIntervalValues'] = function(block) {\n var _loop = Blockly.Python.valueToCode(block, '_loop', Blockly.Python.ORDER_NONE);\nvar _open = Blockly.Python.valueToCode(block, '_open', Blockly.Python.ORDER_NONE);\nvar _close = Blockly.Python.valueToCode(block, '_close', Blockly.Python.ORDER_NONE);\nvar _interval = Blockly.Python.valueToCode(block, '_interval', Blockly.Python.ORDER_NONE);\n return [`{\n \"LOOP\": ${_loop},\n \"OPEN\": ${_open},\n \"CLOSE\": ${_close},\n \"INTERVAL\": ${_interval}\n}`, Blockly.Python.ORDER_CONDITIONAL]\n};\n\n","code":{"initAtomBabies":["window['Blockly'].Python['__ATOM_Babies_initAtomBabies'] = function(block) {\n var _eye_color = Blockly.Python.valueToCode(block, '_eye_color', Blockly.Python.ORDER_NONE);\nvar _cheek_color = Blockly.Python.valueToCode(block, '_cheek_color', Blockly.Python.ORDER_NONE);\nvar _background_color = Blockly.Python.valueToCode(block, '_background_color', Blockly.Python.ORDER_NONE);\n return `import _thread as _ab_t\nimport re\nimport time\n\n_ab_const = {\n 'MIN_LED_POS': 1,\n 'MAX_LED_POS': 25,\n 'EYE_POSITIONS': {\n 'POS_TOP': [2, 4],\n 'POS_UP': [7, 9],\n 'POS_NORMAL':[12, 14],\n 'POS_RIGHT': [11, 13],\n 'POS_LEFT': [13, 15],\n 'POS_DOWN': [17, 19],\n 'POS_BOTTOM': [22, 24],\n },\n 'CHEEK_POSITIONS': {\n 'POS_TOP': [6, 10],\n 'POS_UP': [11, 15],\n 'POS_NORMAL': [16, 20],\n 'POS_RIGHT': [19],\n 'POS_LEFT': [17],\n 'POS_DOWN': [21, 25],\n 'POS_BOTTOM': [],\n },\n 'ORIENTATIONS': {\n 'ORI_NORMAL': [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],\n 'ORI_RIGHT': [21, 16, 11, 6, 1, 22, 17, 12, 7, 2, 23, 18, 13, 8, 3, 24, 19, 14, 9, 4, 25, 20, 15, 10, 5],\n 'ORI_UPSIDE_DOWN': [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],\n 'ORI_LEFT': [ 5, 10, 15, 20, 25, 4, 9, 14, 19, 24, 3, 8, 13, 18, 23, 2, 7, 12, 17, 22, 1, 6, 11, 16, 21],\n },\n 'BLINK_INTERVAL': {\n 'LOOP': 1,\n 'OPEN': 500,\n 'CLOSE': 100,\n 'INTERVAL': 1000,\n },\n 'DEFAULT_BLINK_INTERVAL_FUNCTION': '_ab_get_blink_interval'\n}\n\ndef _ab_get_const(key):\n return _ab_const[key]\n\ndef _ab_get_rgb(r, g, b):\n return int('0x{:02x}{:02x}{:02x}'.format(r, g, b))\n\n_ab_global = {\n 'eye_color': ${_eye_color},\n 'cheek_color': ${_cheek_color},\n 'background_color': ${_background_color},\n 'position': 'POS_NORMAL',\n 'orientation': 'ORI_NORMAL',\n 'blink_thread_running': False,\n 'blink_running': False,\n 'blink_interval_function': _ab_get_const('DEFAULT_BLINK_INTERVAL_FUNCTION'),\n}\n\ndef _ab_get_global(key):\n return _ab_global[key]\n\ndef _ab_set_global(key, val):\n _ab_global[key] = val\n\ndef _ab_get_led_position(orientation, position):\n return _ab_get_const('ORIENTATIONS')[orientation][position - 1]\n\ndef _ab_fill(color):\n rgb.setColorFrom(_ab_get_const('MIN_LED_POS'), _ab_get_const('MAX_LED_POS'), color)\n\ndef _ab_set_color(pos, color, orientation):\n rgb.setColor(_ab_get_led_position(orientation, pos), color)\n\ndef _ab_get_eye_position(pos):\n return _ab_get_const('EYE_POSITIONS')[pos]\n\ndef _ab_get_cheek_position(pos):\n return _ab_get_const('CHEEK_POSITIONS')[pos]\n\ndef _ab_set_eyes(pos, color, orientation):\n for _p in _ab_get_eye_position(pos):\n _ab_set_color(_p, color, orientation)\n\ndef _ab_set_cheeks(pos, color, orientation):\n for _p in _ab_get_cheek_position(pos):\n _ab_set_color(_p, color, orientation)\n\ndef _ab_set_face(pos, eye_color, cheek_color, orientation):\n _ab_set_eyes(pos, eye_color, orientation)\n _ab_set_cheeks(pos, cheek_color, orientation)\n\ndef _ab_show_face():\n _ab_fill(_ab_get_background_color())\n _ab_set_face(_ab_get_face_position(), _ab_get_eye_color(), _ab_get_cheek_color(), _ab_get_orientation())\n\ndef _ab_clear_face():\n _bg_color = _ab_get_background_color()\n _ab_set_face(_ab_get_face_position(), _bg_color, _bg_color, _ab_get_orientation())\n\ndef _ab_open_eyes():\n _ab_set_eyes(_ab_get_face_position(), _ab_get_eye_color(), _ab_get_orientation())\n\ndef _ab_close_eyes():\n _ab_set_eyes(_ab_get_face_position(), _ab_get_background_color(), _ab_get_orientation())\n\ndef _ab_set_eye_color(color):\n _ab_set_global('eye_color', color)\n\ndef _ab_get_eye_color():\n return _ab_get_global('eye_color')\n\ndef _ab_set_cheek_color(color):\n _ab_set_global('cheek_color', color)\n\ndef _ab_get_cheek_color():\n return _ab_get_global('cheek_color')\n\ndef _ab_set_background_color(color):\n _ab_set_global('background_color', color)\n\ndef _ab_get_background_color():\n return _ab_get_global('background_color')\n\ndef _ab_set_orientation(orientation):\n _ab_set_global('orientation', orientation)\n\ndef _ab_get_orientation():\n return _ab_get_global('orientation')\n\ndef _ab_set_face_position(position):\n _ab_set_global('position', position)\n\ndef _ab_get_face_position():\n return _ab_get_global('position')\n\ndef _ab_is_ascii(s):\n return all(ord(c) < 128 for c in s)\n\ndef _ab_get_function_name(name):\n if _ab_is_ascii(name):\n return name\n else:\n return ''.join(['_{:02X}'.format(b) for b in name.encode()])\n\n_ab_lock = _ab_t.allocate_lock()\n\ndef _ab_blink_task():\n while _ab_get_global('blink_thread_running'):\n if _ab_get_global('blink_running'):\n with _ab_lock:\n _func = _ab_get_function_name(_ab_get_global('blink_interval_function'))\n _intervals = globals()[_func]()\n for _ in range(_intervals.get('LOOP', 1)):\n time.sleep_ms(_intervals.get('OPEN', 500))\n _ab_close_eyes()\n time.sleep_ms(_intervals.get('CLOSE', 100))\n _ab_open_eyes()\n time.sleep_ms(_intervals.get('INTERVAL', 1000))\n else:\n time.sleep_ms(1)\n\ndef _ab_set_blink_interval(interval):\n _ab_set_global('blink_interval', interval)\n\ndef _ab_start_blink(func = None):\n if not _ab_get_global('blink_thread_running'):\n _ab_set_global('blink_thread_running', True)\n _ab_t.start_new_thread(_ab_blink_task, ())\n _ab_set_global('blink_interval_function', func or '_ab_get_blink_interval')\n _ab_set_global('blink_running', True)\n\ndef _ab_stop_blink():\n _ab_set_global('blink_running', False)\n\ndef _ab_terminate_blink():\n _ab_set_global('blink_thread_running', False)\n\ndef _ab_get_blink_interval():\n return _ab_const('BLINK_INTERVAL')\n` + \"\\n\";\n};\n\n","import _thread as _ab_t\nimport re\nimport time\n\n_ab_const = {\n 'MIN_LED_POS': 1,\n 'MAX_LED_POS': 25,\n 'EYE_POSITIONS': {\n 'POS_TOP': [2, 4],\n 'POS_UP': [7, 9],\n 'POS_NORMAL':[12, 14],\n 'POS_RIGHT': [11, 13],\n 'POS_LEFT': [13, 15],\n 'POS_DOWN': [17, 19],\n 'POS_BOTTOM': [22, 24],\n },\n 'CHEEK_POSITIONS': {\n 'POS_TOP': [6, 10],\n 'POS_UP': [11, 15],\n 'POS_NORMAL': [16, 20],\n 'POS_RIGHT': [19],\n 'POS_LEFT': [17],\n 'POS_DOWN': [21, 25],\n 'POS_BOTTOM': [],\n },\n 'ORIENTATIONS': {\n 'ORI_NORMAL': [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],\n 'ORI_RIGHT': [21, 16, 11, 6, 1, 22, 17, 12, 7, 2, 23, 18, 13, 8, 3, 24, 19, 14, 9, 4, 25, 20, 15, 10, 5],\n 'ORI_UPSIDE_DOWN': [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],\n 'ORI_LEFT': [ 5, 10, 15, 20, 25, 4, 9, 14, 19, 24, 3, 8, 13, 18, 23, 2, 7, 12, 17, 22, 1, 6, 11, 16, 21],\n },\n 'BLINK_INTERVAL': {\n 'LOOP': 1,\n 'OPEN': 500,\n 'CLOSE': 100,\n 'INTERVAL': 1000,\n },\n 'DEFAULT_BLINK_INTERVAL_FUNCTION': '_ab_get_blink_interval'\n}\n\ndef _ab_get_const(key):\n return _ab_const[key]\n\ndef _ab_get_rgb(r, g, b):\n return int('0x{:02x}{:02x}{:02x}'.format(r, g, b))\n\n_ab_global = {\n 'eye_color': ${_eye_color},\n 'cheek_color': ${_cheek_color},\n 'background_color': ${_background_color},\n 'position': 'POS_NORMAL',\n 'orientation': 'ORI_NORMAL',\n 'blink_thread_running': False,\n 'blink_running': False,\n 'blink_interval_function': _ab_get_const('DEFAULT_BLINK_INTERVAL_FUNCTION'),\n}\n\ndef _ab_get_global(key):\n return _ab_global[key]\n\ndef _ab_set_global(key, val):\n _ab_global[key] = val\n\ndef _ab_get_led_position(orientation, position):\n return _ab_get_const('ORIENTATIONS')[orientation][position - 1]\n\ndef _ab_fill(color):\n rgb.setColorFrom(_ab_get_const('MIN_LED_POS'), _ab_get_const('MAX_LED_POS'), color)\n\ndef _ab_set_color(pos, color, orientation):\n rgb.setColor(_ab_get_led_position(orientation, pos), color)\n\ndef _ab_get_eye_position(pos):\n return _ab_get_const('EYE_POSITIONS')[pos]\n\ndef _ab_get_cheek_position(pos):\n return _ab_get_const('CHEEK_POSITIONS')[pos]\n\ndef _ab_set_eyes(pos, color, orientation):\n for _p in _ab_get_eye_position(pos):\n _ab_set_color(_p, color, orientation)\n\ndef _ab_set_cheeks(pos, color, orientation):\n for _p in _ab_get_cheek_position(pos):\n _ab_set_color(_p, color, orientation)\n\ndef _ab_set_face(pos, eye_color, cheek_color, orientation):\n _ab_set_eyes(pos, eye_color, orientation)\n _ab_set_cheeks(pos, cheek_color, orientation)\n\ndef _ab_show_face():\n _ab_fill(_ab_get_background_color())\n _ab_set_face(_ab_get_face_position(), _ab_get_eye_color(), _ab_get_cheek_color(), _ab_get_orientation())\n\ndef _ab_clear_face():\n _bg_color = _ab_get_background_color()\n _ab_set_face(_ab_get_face_position(), _bg_color, _bg_color, _ab_get_orientation())\n\ndef _ab_open_eyes():\n _ab_set_eyes(_ab_get_face_position(), _ab_get_eye_color(), _ab_get_orientation())\n\ndef _ab_close_eyes():\n _ab_set_eyes(_ab_get_face_position(), _ab_get_background_color(), _ab_get_orientation())\n\ndef _ab_set_eye_color(color):\n _ab_set_global('eye_color', color)\n\ndef _ab_get_eye_color():\n return _ab_get_global('eye_color')\n\ndef _ab_set_cheek_color(color):\n _ab_set_global('cheek_color', color)\n\ndef _ab_get_cheek_color():\n return _ab_get_global('cheek_color')\n\ndef _ab_set_background_color(color):\n _ab_set_global('background_color', color)\n\ndef _ab_get_background_color():\n return _ab_get_global('background_color')\n\ndef _ab_set_orientation(orientation):\n _ab_set_global('orientation', orientation)\n\ndef _ab_get_orientation():\n return _ab_get_global('orientation')\n\ndef _ab_set_face_position(position):\n _ab_set_global('position', position)\n\ndef _ab_get_face_position():\n return _ab_get_global('position')\n\ndef _ab_is_ascii(s):\n return all(ord(c) < 128 for c in s)\n\ndef _ab_get_function_name(name):\n if _ab_is_ascii(name):\n return name\n else:\n return ''.join(['_{:02X}'.format(b) for b in name.encode()])\n\n_ab_lock = _ab_t.allocate_lock()\n\ndef _ab_blink_task():\n while _ab_get_global('blink_thread_running'):\n if _ab_get_global('blink_running'):\n with _ab_lock:\n _func = _ab_get_function_name(_ab_get_global('blink_interval_function'))\n _intervals = globals()[_func]()\n for _ in range(_intervals.get('LOOP', 1)):\n time.sleep_ms(_intervals.get('OPEN', 500))\n _ab_close_eyes()\n time.sleep_ms(_intervals.get('CLOSE', 100))\n _ab_open_eyes()\n time.sleep_ms(_intervals.get('INTERVAL', 1000))\n else:\n time.sleep_ms(1)\n\ndef _ab_set_blink_interval(interval):\n _ab_set_global('blink_interval', interval)\n\ndef _ab_start_blink(func = None):\n if not _ab_get_global('blink_thread_running'):\n _ab_set_global('blink_thread_running', True)\n _ab_t.start_new_thread(_ab_blink_task, ())\n _ab_set_global('blink_interval_function', func or '_ab_get_blink_interval')\n _ab_set_global('blink_running', True)\n\ndef _ab_stop_blink():\n _ab_set_global('blink_running', False)\n\ndef _ab_terminate_blink():\n _ab_set_global('blink_thread_running', False)\n\ndef _ab_get_blink_interval():\n return _ab_const('BLINK_INTERVAL')\n"],"showFace":["window['Blockly'].Python['__ATOM_Babies_showFace'] = function(block) {\n return `_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_show_face()\n"],"clearFace":["window['Blockly'].Python['__ATOM_Babies_clearFace'] = function(block) {\n return `_ab_clear_face()\n` + \"\\n\";\n};\n\n","_ab_clear_face()\n"],"RGB":["window['Blockly'].Python['__ATOM_Babies_RGB'] = function(block) {\n var _r = block.getFieldValue('_r');\nvar _g = block.getFieldValue('_g');\nvar _b = block.getFieldValue('_b');\n return [`_ab_get_rgb(${_r}, ${_g}, ${_b})`, Blockly.Python.ORDER_CONDITIONAL]\n};\n\n","_ab_get_rgb(${_r}, ${_g}, ${_b})"],"setOrientationNormal":["window['Blockly'].Python['__ATOM_Babies_setOrientationNormal'] = function(block) {\n return `_ab_set_orientation('ORI_NORMAL')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_orientation('ORI_NORMAL')\n_ab_show_face()\n"],"setOrientationRight":["window['Blockly'].Python['__ATOM_Babies_setOrientationRight'] = function(block) {\n return `_ab_set_orientation('ORI_RIGHT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_orientation('ORI_RIGHT')\n_ab_show_face()\n"],"setOrientationUpsideDown":["window['Blockly'].Python['__ATOM_Babies_setOrientationUpsideDown'] = function(block) {\n return `_ab_set_orientation('ORI_UPSIDE_DOWN')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_orientation('ORI_UPSIDE_DOWN')\n_ab_show_face()\n"],"setOrientationLeft":["window['Blockly'].Python['__ATOM_Babies_setOrientationLeft'] = function(block) {\n return `_ab_set_orientation('ORI_LEFT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_orientation('ORI_LEFT')\n_ab_show_face()\n"],"setFacePositionNormal":["window['Blockly'].Python['__ATOM_Babies_setFacePositionNormal'] = function(block) {\n return `_ab_set_face_position('POS_NORMAL')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_face_position('POS_NORMAL')\n_ab_show_face()\n"],"setFacePositionRight":["window['Blockly'].Python['__ATOM_Babies_setFacePositionRight'] = function(block) {\n return `_ab_set_face_position('POS_RIGHT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_face_position('POS_RIGHT')\n_ab_show_face()\n"],"setFacePositionDown":["window['Blockly'].Python['__ATOM_Babies_setFacePositionDown'] = function(block) {\n return `_ab_set_face_position('POS_DOWN')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_face_position('POS_DOWN')\n_ab_show_face()\n"],"setFacePositionLeft":["window['Blockly'].Python['__ATOM_Babies_setFacePositionLeft'] = function(block) {\n return `_ab_set_face_position('POS_LEFT')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_face_position('POS_LEFT')\n_ab_show_face()\n"],"setFacePositionUp":["window['Blockly'].Python['__ATOM_Babies_setFacePositionUp'] = function(block) {\n return `_ab_set_face_position('POS_UP')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_face_position('POS_UP')\n_ab_show_face()\n"],"setFacePositionTop":["window['Blockly'].Python['__ATOM_Babies_setFacePositionTop'] = function(block) {\n return `_ab_set_face_position('POS_TOP')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_face_position('POS_TOP')\n_ab_show_face()\n"],"setFacePositionBottom":["window['Blockly'].Python['__ATOM_Babies_setFacePositionBottom'] = function(block) {\n return `_ab_set_face_position('POS_BOTTOM')\n_ab_show_face()\n` + \"\\n\";\n};\n\n","_ab_set_face_position('POS_BOTTOM')\n_ab_show_face()\n"],"openEyes":["window['Blockly'].Python['__ATOM_Babies_openEyes'] = function(block) {\n return `_ab_open_eyes()` + \"\\n\";\n};\n\n","_ab_open_eyes()"],"closeEyes":["window['Blockly'].Python['__ATOM_Babies_closeEyes'] = function(block) {\n return `_ab_close_eyes()\n\n` + \"\\n\";\n};\n\n","_ab_close_eyes()\n\n"],"showCheeks":["window['Blockly'].Python['__ATOM_Babies_showCheeks'] = function(block) {\n return `_ab_set_cheeks(_ab_get_face_position(), _ab_get_cheek_color(), _ab_get_orientation())\n` + \"\\n\";\n};\n\n","_ab_set_cheeks(_ab_get_face_position(), _ab_get_cheek_color(), _ab_get_orientation())\n"],"clearCheeks":["window['Blockly'].Python['__ATOM_Babies_clearCheeks'] = function(block) {\n return `_ab_set_cheeks(_ab_get_face_position(), _ab_get_background_color(), _ab_get_orientation())\n` + \"\\n\";\n};\n\n","_ab_set_cheeks(_ab_get_face_position(), _ab_get_background_color(), _ab_get_orientation())\n"],"startBlink":["window['Blockly'].Python['__ATOM_Babies_startBlink'] = function(block) {\n return `_ab_start_blink()\n` + \"\\n\";\n};\n\n","_ab_start_blink()\n"],"stopBlink":["window['Blockly'].Python['__ATOM_Babies_stopBlink'] = function(block) {\n return `_ab_stop_blink()\n` + \"\\n\";\n};\n\n","_ab_stop_blink()\n"],"startBlinkWithFunction":["window['Blockly'].Python['__ATOM_Babies_startBlinkWithFunction'] = function(block) {\n var _interval_function_name = Blockly.Python.valueToCode(block, '_interval_function_name', Blockly.Python.ORDER_NONE);\n return `_ab_start_blink(${_interval_function_name})\n` + \"\\n\";\n};\n\n","_ab_start_blink(${_interval_function_name})\n"],"getBlinkIntervalValues":["window['Blockly'].Python['__ATOM_Babies_getBlinkIntervalValues'] = function(block) {\n var _loop = Blockly.Python.valueToCode(block, '_loop', Blockly.Python.ORDER_NONE);\nvar _open = Blockly.Python.valueToCode(block, '_open', Blockly.Python.ORDER_NONE);\nvar _close = Blockly.Python.valueToCode(block, '_close', Blockly.Python.ORDER_NONE);\nvar _interval = Blockly.Python.valueToCode(block, '_interval', Blockly.Python.ORDER_NONE);\n return [`{\n \"LOOP\": ${_loop},\n \"OPEN\": ${_open},\n \"CLOSE\": ${_close},\n \"INTERVAL\": ${_interval}\n}`, Blockly.Python.ORDER_CONDITIONAL]\n};\n\n","{\n \"LOOP\": ${_loop},\n \"OPEN\": ${_open},\n \"CLOSE\": ${_close},\n \"INTERVAL\": ${_interval}\n}"]}} \ No newline at end of file