Rectangular building block programming

There are many ways to draw rectangles     with Scratch . You can use a "dot+length+width" to draw, you can also use "two diagonal vertices of the rectangle to draw", you can also use "length+flip 90°+width+flip" 90° to draw".

1. "Point + Length + Width" method

1.1 Define the "straight line" building block

  • Click "Add Extension" on the left side of Scratch - "Paint
  • Click "Homemade Building Blocks" in Scratch --"Make a new building block--"Straight Line--" to add 4 parameters, as shown in Figures (1) and (2):
Figure (1) Define "straight line" blocks

Figure (2) "Straight line" building block code

1.2 Define "Rectangular 1" building block

  • Click "Homemade Building Blocks" in Scratch - "Make a new building block --" Rectangle 1 - "Add 4 parameters, as shown in Figures (3) and (4):
Figure (3) Define "Rectangular 1" building block

Figure (4) "Rectangular 1" building block code

2. "Diagonal apex" method

2.1 Define the "rectangular (diagonal)" building block

Figure (5) "Rectangular (diagonal)" building block code

3. "Length and width flip 90°" method

3.1 Define the "rectangular (flip)" building block

Figure (7) Define the "rectangular (flip)" building block

Figure (8) "Rectangular (flip)" building block definition

4. Define "restore" building blocks

Figure (9) Define "restore" building blocks

Figure (10) "Restore" building block code

5. Main function

Figure (11) "Main function" building block code

    The effect is as follows:

Figure (12) Draw 3 rectangles

Guess you like

Origin blog.csdn.net/sanqima/article/details/113801553