Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

4. Esplora le fantasie

Transcript

In this video, you'll learn how to adjust the size and spacing of your printed pattern, and change the sprite used to make the pattern. When a procedure is called, it can send a value. These values are called parameters. For example, the "print prepare" procedure has two parameters called "horizontal space" and "vertical space."

If you adjust the values in the "print prepare" block and run the code, you'll see that the spacing of the pattern changes. Making the first value larger increases the horizontal space between the stamps. Making the second value larger increases the vertical space between the stamps. Experiment with these values until you like the spacing of your pattern. Now that you understand how parameters work, you're going to add another parameter to the "Print Prepare" procedure. Right-click on the "define print prepare" block, and choose "edit" from the menu. Click on the options dropdown, then click the button next to "add number input." The value "number1" will be added to the block, but type the word "size" in this block instead. Click “OK.”

The "define Print Prepare" block now has an extra parameter called "size," and the "Print Prepare" block in the code now has a 3rd parameter value with a "1" showing in it. However, if you run the code, nothing new happens. The parameter for “size” exists, but you also need to instruct the "define" block how to *use* that parameter.

Click the "looks" menu, select the "set size to" block, and place it under the "define" block. Then, drag the "size" parameter block into the "set size to" block. Now, your code will automatically set the size of the sprite to the specifications in the "Print Prepare" block. Test your code. It creates a pattern with tiny versions of the sprite because the "size" parameter is set to 1. Make this parameter a larger number to stamp bigger sprites. Experiment with the horizontal space, vertical space, and size parameters until you get a pattern you like. Using a procedure like "print prepare" makes it easy to experiment with lots of different values and create something you like. Imagine how long it would take to paint each of these different versions of the pattern individually if you didn't know how to create them using computer science! Once again, knowing a little computer science provides you with a way to easily envision your creation.

(say these steps slowly) You can also reuse the "print prepare" procedure to build an entirely new pattern quite easily. To do this, duplicate the code stack, change the keypress event, add a new costume, and set the “switch costume” block to that new costume. The “Print Prepare” procedure allows you to change the size of the sprite and the horizontal and vertical spacing of the new pattern without changing your original pattern.

The Project Page helps other Scratch users get to know your project and how to use it.

Add instructions, key presses, details, and any other information you can think of that will help Scratch community members enjoy and use your project.

Now, it's your turn! Right-click and edit the "define print prepare" block, click the options button, and add “spacing” and "size" parameters. Add a "set size to" block to the "define print parameter" code, and add the "size" parameter to it. Experiment with different parameter values until you have a pattern you like. You can also choose to duplicate the code and use it to create an entirely new pattern.

arrow_backward Indietro
Avanti arrow_forward
Istruzioni
  1. Aggiungi un parametro “dimensione” per modificare la spaziatura del modello.
  2. Usa il parametro “dimensione”.
  3. Aggiungi un nuovo costume allo sprite Fantasia.
  4. Riutilizza la funzione “Prepara stampa” per creare una nuova fantasia.