An example pen drawing.

Scratch's pen feature can be used to create line drawings, and it can also be used to fill the screen with a picture. This article will show you some examples of how to draw a picture with the pen.

Set Up

Please follow the instructions on this page to create the basic pen drawing script. The only block in the script that we will be interested in is this:

set pen color to (Equation or Source)

Color

Description Image
One of the nice things about the pen feature is that it can draw practically everything if you ensure that you draw the right colors in the right place. For right now, though, we will draw a green screen. In your pen script, use this:
set pen color to (66)
Pen Project 1.png
The above example is plain. To make it more interesting, let's make it change color while drawing. In your pen script, use this:
set pen color to (x position)

Notice how the colors form vertical stripes. That's because all points in a vertical stripe have the same x position.

Pen Project 2.png
Let's say you prefer horizontal stripes instead of vertical stripes. In your pen script, use this:
set pen color to (y position)
Pen Project 3.png
One interesting twist on the above pen scripts is to add x position to y position. This generates slanted stripes. In your pen script, use this:
set pen color to ((x position) + (y position))
Pen Project 4.png
Another option is to draw colored rings. In your pen script, use this:
set pen color to (distance to [origin v])

This method requires that there is a sprite named "origin" at the center of the screen, which is at x=0 and y=0.

Pen Project 5.png

Adding Math

Description Image
Scratch has a lot of mathematical functions. Even if you don't understand what they do, they can produce some fun results! For example, sin creates waves. In your pen script, use this:
set pen color to ((y position) + ((50) * ([sin v] of (x position))))
Pen Project 7.png
The function atan is great for making a color wheel. Here is how:
set pen color to (([atan v] of ((y position) / (x position))) / (0.9))
Pen Project 8.png
Let's try mixing some of the pen drawings. What do you get when you mix a color wheel with rings? Try this to see:
set pen color to ((([atan v] of ((y position) / (x position))) / (0.9)) + (distance to [origin v]))
Pen Project 9.png
Let's go further with mixing some of the pen drawings. What if we want wavy rings? Try this!
set pen color to ((([atan v] of ((y position) / (x position))) / (0.9)) + ((20)* ([sin v] of ((10) * (distance to [origin v])))))
  • Scroll to see the entire equation.
Pen Project 10.png

Examples

There are many more things that you can do with the pen! Below are some relatively simple examples.

Pen Project 12.png

Pen Project 11.png

Pen Project 14.png

Pen Project 13.png

Three example projects can be seen here:

See Also