This article or section may not have content matching Scratch Wiki editing standards. Please improve it according to Scratch Wiki:Guidelines and Scratch Wiki:Editing Conventions. (July 2019)
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 some pen art examples and their scripts, utilizing the position of the sprite drawing the pixel as an input.

Set Up

Follow the instructions on this page to create the basic pen drawing script. The only block that will be needed is this one:

set pen (color v) to (Equation or Source::grey)
Note Caution: This block sets the color ("hue") property, not to be confused with the one with a color input.

Color

Colors in Scratch are stored as numbers.

Description Image
This script draws a green screen using the pen:
set pen (color v) to (66)
To create a different outcome where the pen changes color as it moves vertically, use this script:
set pen (color v) to (x position)

The script changes the color to whatever the x position of the pen is, which is also stored as a number. The colors form vertical stripes which is because all points in a vertical stripe have the same x position.

This script creates horizontal stripes:
set pen (color v) to (y position)
This script creates slanted stripes by adding the x position to the y position:
set pen (color v) to ((x position) + (y position))
This script draws colored rings:
set pen (color v) to (distance to (origin v))

This method requires that there is a sprite named "origin" at the center of the screen, at x: 0, y: 0. An alternative method is to directly calculate the distance from the origin without a sprite:

set pen (color v) to ([sqrt v] of (((x position) * (x position)) + ((y position) * (y position))))

Adding Math

Scratch has many mathematical functions. Although some seem complicated, using them can produce many different results.

Description Image
This script produces waves:
set pen (color v) to ((y position) + ((50) * ([sin v] of (x position))))
The arctangent function (abbreviated "atan") can be used to make a color wheel:
set pen (color v) to (([atan v] of ((y position) / (x position))) / (0.9))
This script mixes a color wheel with rings:
set pen (color v) to ((([atan v] of ((y position) / (x position))) / (0.9)) + (distance to (origin v)))
This script creates wavy rings:
set pen (color v) to ((([atan v] of ((y position) / (x position))) / (0.9)) + ((20)* ([sin v] of ((10) * (distance to (origin v))))))

Examples

See more examples of pen art:

Cookies help us deliver our services. By using our services, you agree to our use of cookies.