Use scratch to build a random art generator
Use Scratch to build a random art generator that creates colorful patterns with sprites, shapes, and code blocks, learning programming and creative experimentation.

About this tutorial
Use Scratch to build a random art generator that creates colorful patterns with sprites, shapes, and code blocks, learning programming and creative experimentation.
What you need
Step by step
- 1
Step 1
Open Scratch and start a new project.
- 2
Step 2
Click the blue Extensions button and add the Pen extension.
- 3
Step 3
Create a brush sprite by clicking Paint and drawing a small filled circle.
- 4
Step 4
Select the brush sprite in the sprites list.
- 5
Step 5
Drag a "when green flag clicked" hat block into the brush sprite’s scripting area.
- 6
Step 6
Attach a "clear" block directly under the hat block.
- 7
Step 7
Attach a "go to x: 0 y: 0" block under the clear block.
- 8
Step 8
Attach a "pen down" block under the go to block.
- 9
Step 9
Attach a "set pen size to 4" block under the pen down block.
- 10
Step 10
Attach a "repeat 200" block under the pen size block.
- 11
Step 11
Put a "set pen color to (pick random 1 to 200)" block inside the repeat loop.
- 12
Step 12
Put a "move (pick random 5 to 20) steps" block inside the repeat loop.
- 13
Step 13
Put a "turn 15 degrees" block inside the repeat loop.
- 14
Step 14
Click the green flag to run your random art generator and watch the colorful pattern form.
- 15
Step 15
Share your finished Scratch project on DIY.org.
Fun facts
How do you build a random art generator in Scratch?
Start a new Scratch project, add the Pen extension, and create a main sprite to control drawing. Use loops and the “create clone of” block to make repeated patterns; set pen color to pick random numbers, and choose random positions, directions, sizes, or shapes. Use broadcasts or clickable sprites to start/stop and the clear command to reset. Test, tweak randomness ranges, and add sliders or buttons so kids can experiment with parameters and see immediate visual feedback.
What materials do I need to make a Scratch random art generator?
You need a computer, Chromebook, or tablet with internet access (or Scratch Desktop offline). Open an account on scratch.mit.edu or use the offline editor, and a mouse or touchscreen for drawing controls. Optionally prepare a simple worksheet with ideas (color palettes, shape lists) and headphones for tutorial videos. No physical craft supplies required unless you want to print results or sketch ideas on paper.
What ages is this Scratch activity suitable for?
This activity suits children about 7–12 years old: younger kids (7–9) benefit from adult guidance for blocks and pen control, while older kids (10–12) can design features, add variables, and debug independently. Teens and beginners of any age can extend it with math, cloning patterns, or sound. Adjust complexity: use simple start/stop buttons for young children and introduce variables, lists, and custom blocks for older learners.
What are the benefits of building a random art generator in Scratch?
Creating a random art generator teaches programming basics—loops, variables, conditionals, and cloning—while fostering creativity and experimentation. Kids learn cause-and-effect by adjusting parameters and seeing visual results, practice problem-solving through debugging, and gain confidence from designing interactive projects. It also reinforces math skills (coordinates, angles, randomness) and encourages iteration: kids improve patterns by testing and tweaking code.
Watch & Learn
Need help?
What can we use instead if we can't add the Pen extension or can't paint a brush sprite?
If you can't add the Pen extension or paint a brush sprite, choose a built‑in round sprite or draw a small filled circle and use the 'stamp' block inside the repeat loop instead of 'pen down' to leave marks.
Why doesn't any art appear when I press the green flag and how do I fix it?
If nothing draws when you click the green flag, make sure you added the Pen extension and that the brush sprite's script starts with 'clear', 'go to x: 0 y: 0', and a 'pen down' and 'set pen size to 4' placed before the 'repeat 200' loop.
How can I change the activity to suit younger or older kids?
For younger kids change 'repeat 200' to 'repeat 50' and fix 'move' to a small number so they see results quickly, while older kids can replace 'turn 15 degrees' with 'turn (pick random -90 to 90) degrees' and add 'change pen size by (pick random 1 to 5)' inside the loop.
How can we make the generator more interesting or personalize our design?
To personalize the generator add a second painted brush sprite with its own script using 'set pen size to 8' and a different 'turn' value or create a stage variable slider that sets the 'set pen size to' or 'repeat' value before clicking the green flag.