Hands down, this is one of my favorite visual hypnotizing animation around this block. It is also super easy to write a program for it. Start by clicking on the backdrop, then go to its costume tab and paint the canvas completely black by using the paint bucket tool. This will provide a far better line color enhancement over any other color. Next add a new sprite from the Scratch library. Find the Ball sprite and add it to the game. The ball sprite has many different colors in its costume tab, choose the one you would like to see in your animation. Next, I am going to make a simple script for the ball sprite to continuously bounce off the stage edges.
Writing the program for the Scratch animation.
Start by adding the ‘when flag clicked’ block. When the user clicks on the green flag, this block will run the scripts below it. Then go to the motion category and grab one ‘point in direction’ block and place it under the event block. This block sets the direction of the sprite. We want the ball sprite to have a completely random direction each time we run the program. To get this effect, add the ‘pick random’ operators block inside the motion block’s window. And set the range from -180 to 180. This is a range for full circle in Scratch. The sprite will start heading to a different direction each time we run the animation. Go back to the motion category, and add the ‘if on edge, bounce’ block to prohibit the sprite to leave the stage area when it touches the edge. It will always bounce off. The ball sprite should also be moving, therefore, add the ‘move 10 steps’ block. This is the speed of the sprite, and you can adjust it later in the Scratch animation to achieve a different drawing effect. Finally, encompass the last two motion blocks inside the forever loop. This will make the ball go on and on. Then duplicate this ball to make two other balls. They will have the same script too. You can run the program now to check how it works. The balls should be randomly bouncing around the stage. The final step is to duplicate another ball, to make the fourth one. Rename it to something like – line drawing, because this ball will be used to quickly move from ball 1 to ball 2 and 3 while drawing straight lines between them.
Adding the animator.
Alright, in the scripts area add one ‘when flag clicked’ event block. Then from the Pen category add the ‘clear’ block. This block clears any drawing marks when the program starts, bringing a clean stage for every Scratch animation experience. While we are at this category, add the ‘pen down’ and ‘change pen color by 10’ blocks. The pen down block puts down the sprite’s pen, making it draw a line behind it wherever it moves. And the other block changes the pen’s color by the amount you specify in this block’s window. Now, from the operators category, add one forever loop block and place it right under the ‘clear’ block. Finally, from the motion category, add three ‘go to Ball’ blocks after the pen down block. In the drop down menu select Ball 2 for the second block, and Ball 3 for the third. This block makes the sprite go to the specified location. It will happen very fast, you wont even notice it moving between the balls. Here comes the most fun part of the Scratch animation. Test the program by clicking on the flag and enjoy this visual animation show. Try playing around with different magnitudes of color changing or increase the speed of the balls. Feel free to remix it as you wish!