Skip to content

Please update your browser

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

2. Change la couleur des pixels


In this video, you will create a sprite that stamps each pixel either white or black. To do this, you will learn about the starter code, add a “stamp” block, and add a “next costume” block to the project.

In order to change each pixel, the scanner sprite needs to check every spot on the screen.

The starter code is programmed with two repeat loops. One loop moves the scanner sprite from left to right. This loop is located within the loop that moves it from top to bottom.

This code makes sure the scanner sprite touches every spot on the screen, just like reading a paragraph in a book -- start from the left, finish the line, and go to the next line, until the page is finished.

If you press the green flag, you will see a little white dot move across the top of the screen and travel down to the bottom. In order to speed up the process, click edit and select “turbo mode.” With the program in turbo mode, you may not see the scanner sprite move because it moves so quickly. To begin changing the color of each pixel, you will need to make the scanner sprite stamp itself while it travels across the stage.

Start by placing the “stamp” block within the second repeat loop, after the “change x by 3” block. This allows the scanner sprite program to stamp itself both across and down.

Click on the green flag to test the project. It works! The scanner sprite is a white dot that stamps itself and makes the whole screen white.

If you can make the entire screen white, then you can also make it any other color -- it only depends on the color of the scanner sprite’s costume. In the next video, you will use a conditional statement to make the scanner sprite stamp either white OR black.

Now, it’s your turn. Go to the edit menu, and select turbo mode to speed up the scanner sprite. Make the background white by adding a “stamp” block.

arrow_backward Retour
Suivant arrow_forward
  1. Active le "Mode Turbo".
  2. Ajoute un bloc "Estampiller".