From dbd55745f60ca15c3de671473369ba1bed4e4e47 Mon Sep 17 00:00:00 2001 From: LilyMakesThings Date: Wed, 9 Oct 2024 02:41:29 +0100 Subject: [PATCH] zoom blocks --- blocks_vertical/camera.js | 75 +++++++++++++++++++++++++++++++++++++++ media/rotate-left.svg | 2 +- media/rotate-right.svg | 2 +- msg/messages.js | 5 ++- 4 files changed, 81 insertions(+), 3 deletions(-) diff --git a/blocks_vertical/camera.js b/blocks_vertical/camera.js index ef2c0c153a..fedb832947 100644 --- a/blocks_vertical/camera.js +++ b/blocks_vertical/camera.js @@ -236,3 +236,78 @@ Blockly.Blocks['camera_yposition'] = { }); } }; + +Blockly.Blocks['camera_setzoom'] = { + /** + * Block to set the camera's zoom. + * @this Blockly.Block + */ + init: function() { + this.jsonInit({ + "message0": Blockly.Msg.CAMERA_SETZOOM, + "args0": [ + { + "type": "field_image", + "src": Blockly.mainWorkspace.options.pathToMedia + "camera.svg", + "width": 24, + "height": 24 + }, + { + "type": "input_value", + "name": "ZOOM" + } + ], + "category": Blockly.Categories.camera, + "extensions": ["colours_camera", "shape_statement"] + }); + } +}; + +Blockly.Blocks['camera_changezoom'] = { + /** + * Block to change the camera's zoom. + * @this Blockly.Block + */ + init: function() { + this.jsonInit({ + "message0": Blockly.Msg.CAMERA_CHANGEZOOM, + "args0": [ + { + "type": "field_image", + "src": Blockly.mainWorkspace.options.pathToMedia + "camera.svg", + "width": 24, + "height": 24 + }, + { + "type": "input_value", + "name": "ZOOM" + } + ], + "category": Blockly.Categories.camera, + "extensions": ["colours_camera", "shape_statement"] + }); + } +}; + +Blockly.Blocks['camera_zoom'] = { + /** + * Block to report camera's zoom. + * @this Blockly.Block + */ + init: function() { + this.jsonInit({ + "message0": Blockly.Msg.CAMERA_ZOOM, + "args0": [ + { + "type": "field_image", + "src": Blockly.mainWorkspace.options.pathToMedia + "camera.svg", + "width": 24, + "height": 24 + } + ], + "category": Blockly.Categories.camera, + "checkboxInFlyout": true, + "extensions": ["colours_camera", "output_number"] + }); + } +}; diff --git a/media/rotate-left.svg b/media/rotate-left.svg index 42f59191ac..2760118ceb 100644 --- a/media/rotate-left.svg +++ b/media/rotate-left.svg @@ -1 +1 @@ -rotate-clockwise \ No newline at end of file + \ No newline at end of file diff --git a/media/rotate-right.svg b/media/rotate-right.svg index c3f4647045..7632ca11cd 100644 --- a/media/rotate-right.svg +++ b/media/rotate-right.svg @@ -1 +1 @@ -rotate-counter-clockwise \ No newline at end of file + \ No newline at end of file diff --git a/msg/messages.js b/msg/messages.js index 5dd8d2a0a4..0ce7d2ddae 100644 --- a/msg/messages.js +++ b/msg/messages.js @@ -232,7 +232,7 @@ Blockly.Msg.OPERATORS_MATHOP_10EXP = '10 ^'; // String blocks Blockly.Msg.STRING_REVERSE = 'reverse %1'; // usb Blockly.Msg.STRING_REPEAT = 'repeat %1 %2 times'; // usb -Blockly.Msg.STRING_REPLACE = 'replace %1 in %2 with %3'; // usb +Blockly.Msg.STRING_REPLACE = 'replace %1 with %2 in %3'; // usb Blockly.Msg.STRING_ITEMSPLIT = 'item %1 of %2 split by %3'; // usb Blockly.Msg.STRING_TERNARY = 'if %1 then %2 else %3'; // usb Blockly.Msg.STRING_CONVERT = 'convert %1 to %2'; // usb @@ -315,6 +315,9 @@ Blockly.Msg.CAMERA_SETY = 'set %1 y to %2'; Blockly.Msg.CAMERA_CHANGEY = 'change %1 y by %2'; Blockly.Msg.CAMERA_XPOSITION = '%1 x position'; Blockly.Msg.CAMERA_YPOSITION = '%1 y position'; +Blockly.Msg.CAMERA_SETZOOM = 'set %1 zoom to %2'; +Blockly.Msg.CAMERA_CHANGEZOOM = 'change %1 zoom by %2'; +Blockly.Msg.CAMERA_ZOOM = '%1 zoom'; // Sound blocks Blockly.Msg.SOUND_PLAY = 'start sound %1';