Document stub.png 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 intrinsic information present within either the Scratch stage combined with other built-in mathematical formulas and operations.

Set Up

Please 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)

Color

Description Image
This script draws a green screen using the pen:
set pen (color v) to (66)
Pen Project 1.png
The above example is a simple script to draw a plain green screen. However, to create a different outcome where the pen changes color as it moves, use this script, as colors in Scratch are stored as numbers. This script changes the color to whatever the x position of the pen is, which is also stored as a number.
set pen (color v) to (x position)

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

Pen Project 2.png
This script creates horizontal stripes:
set pen (color v) to (y position)
Pen Project 3.png
This script creates slanted stripes by adding the x position to the y position:
set pen (color v) to ((x position) + (y position))
Pen Project 4.png
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))))
Pen Project 5.png

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))))
Pen Project 7.png
The arctangent function (abbreviated "atan") can be used to make a color wheel like so:
set pen (color v) to (([atan v] of ((y position) / (x position))) / (0.9))
Pen Project 8.png
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)))
Pen Project 9.png
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))))))
Pen Project 10.png

Examples

See more examples of pen art: