2026年1月25日日曜日

Please show us  how to make and use "Draw Square" custom block using the Pen extension?

 📋

To draw shapes in Scratch, we first need to unlock a "hidden" set of tools called the Pen Extension. This turns your sprite into a virtual pen that leaves a trail wherever it moves.


1. Add the Pen Extension

Since the Pen blocks aren't in the default sidebar:

  1. Click the "Add Extension" button (the blue icon at the very bottom-left corner of the screen).

  2. Select "Pen." 3. You will now see a new green category of blocks!


2. Create the "Draw Square" Block

Now, let's use what we learned about My Blocks to create a custom command.

  1. Go to the pink My Blocks category and click "Make a Block."

  2. Name it Draw Square.

  3. Click "Add an input (number or text)" and name it size. This allows you to draw squares of any size!

  4. Click OK.


3. Define the Logic

A square has four equal sides and four $90^\circ$ turns. Here is how you define that logic under your new pink Define hat:

  1. pen down (Put the pen on the paper)

  2. repeat (4)

    • move (size) steps (Use the size input bubble here)

    • turn clockwise (90) degrees

  3. pen up (Lift the pen so it stops drawing)


4. Using the Block in a Script

Now that you've "taught" Scratch how to draw a square, you can use that command anywhere.

Try this script:

  1. When 🚩 clicked

  2. erase all (Clear the screen from previous attempts)

  3. go to x: (0) y: (0) (Start in the middle)

  4. Draw Square (50) (Draw a small square)

  5. go to x: (100) y: (100)

  6. Draw Square (100) (Draw a larger square)


Pro Tip: The "Rainbow" Square

If you want to make it look cool, add a change pen color by (10) block inside the repeat loop of your definition. This will make each side of the square a different color!

Geometric Math: To draw a triangle instead, you would repeat 3 times and turn $120^\circ$. To draw a circle, you would repeat 360 times and move 1 step while turning $1^\circ$.

Would you like to know how to use the "Ask and Wait" block so the user can type in the size of the square themselves?

📋