How to Create an Image Generator in Scratch

Victoria Jul 07, 2026

Creating an image generator in Scratch, a visual programming language, is an engaging and educational project that combines creativity with coding. This step-by-step guide will walk you through the process, from understanding the basics to creating your own unique image generator.

How To Make A Good Scratch Animation
How To Make A Good Scratch Animation

Scratch, developed by MIT, is an excellent platform for beginners to learn programming concepts like conditionals, loops, and variables. By the end of this tutorial, you'll have a solid foundation in these concepts and a cool image generator to showcase your new skills.

Create Stunning Images Instantly with Our Picture Generator!
Create Stunning Images Instantly with Our Picture Generator!

Understanding the Basics of Scratch

Before diving into creating an image generator, let's ensure you're comfortable with Scratch's fundamentals. Scratch uses blocks to represent code, making it easier for beginners to understand and manipulate.

HOW TO MAKE AN ONLINE ANIMATION STORY USING SCRATCH?
HOW TO MAKE AN ONLINE ANIMATION STORY USING SCRATCH?

Key Scratch concepts include:

  • Sprites: These are the characters or objects in your Scratch project. Each sprite has its own set of properties and scripts.
  • Blocks: These are the building blocks of your scripts. They represent different actions, like moving a sprite or changing its appearance.
  • Scripts: A series of blocks stacked on top of each other, connected by the arrow at the bottom of one block to the top of the next, form a script. This is how you tell your sprites what to do.
Click to Explore: Discover Free Tools for Image Generation
Click to Explore: Discover Free Tools for Image Generation

Setting Up Your Workspace

To start, open the Scratch website (https://scratch.mit.edu/) and click on "Create" to open the Scratch editor. You'll see a blank stage and a sprite called "Sprite1" in the sprite list.

Rename "Sprite1" to "Image Generator" by clicking on it and typing the new name in the text box that appears. You can also add more sprites from the sprite library if needed.

Coding and Animation in Scratch Facts & Worksheets
Coding and Animation in Scratch Facts & Worksheets

Creating Your First Image

Let's start by creating a simple image. Click on the "Looks" menu in the block palette and drag the "show" block onto the script area. This block will make your sprite appear on the stage.

To create a simple shape, click on the "Events" menu and drag the "when green flag clicked" block onto the script area. This block will trigger the "show" block when the green flag at the top of the stage is clicked.

Pet Pet Generator
Pet Pet Generator

Generating Random Images

Now that you've created a basic image, let's make your image generator more interesting by adding randomness. Scratch's "Data" menu contains blocks for variables and operators, including the "pick random" block, which generates a random number.

How to Make a Virtual Pet in Scratch | Tutorial
How to Make a Virtual Pet in Scratch | Tutorial
How to Pick a Color in the Scratch Paint Editor
How to Pick a Color in the Scratch Paint Editor
Ultra Fast Colour Image Scanner | Scratch How-to Tutorial
Ultra Fast Colour Image Scanner | Scratch How-to Tutorial
Image Pixelator
Image Pixelator
Free, Ready to Use, Scratch Paint Editor Lesson!
Free, Ready to Use, Scratch Paint Editor Lesson!
an image of a computer screen with many different objects on it, including text and numbers
an image of a computer screen with many different objects on it, including text and numbers
Adjust Graphic Effects in Scratch
Adjust Graphic Effects in Scratch
AI Image Generator Free – Create Stunning Images from Text Instantly
AI Image Generator Free – Create Stunning Images from Text Instantly
Scratch Cutscene Tutorial for Kids – Story Dialogues Made Easy
Scratch Cutscene Tutorial for Kids – Story Dialogues Made Easy
Scratch Tutorial: How to create 3D Minecraft!
Scratch Tutorial: How to create 3D Minecraft!
Free Scratch Mini Lesson
Free Scratch Mini Lesson
How to Make Pacman on Scratch - Create & Learn
How to Make Pacman on Scratch - Create & Learn
Lil Guy Maker | Remastered |
Lil Guy Maker | Remastered |
ChatGPT Image Generator
ChatGPT Image Generator
ITS SO FUN THERES SO MANY FILTERS AND OPTIONS TO TRY
ITS SO FUN THERES SO MANY FILTERS AND OPTIONS TO TRY
How to make a Catch Game in Scratch
How to make a Catch Game in Scratch
an image of a computer screen with the text 3 making our character move on it
an image of a computer screen with the text 3 making our character move on it
AI Image generators
AI Image generators
an image of a computer screen with the text sweet tool on it and a smiley face drawn
an image of a computer screen with the text sweet tool on it and a smiley face drawn
How to Make a Game on Scratch | Step-by-Step [Tutorial] for Beginners
How to Make a Game on Scratch | Step-by-Step [Tutorial] for Beginners

To use this block, you'll need to create a variable to store the random number. Click on the "Data" menu and select "Make a Variable." Name it "Image Number" and set its value to "0."

Using Random Numbers to Change Images

Now, let's use the "Image Number" variable to change the costume of your sprite. Click on the "Control" menu and drag the "forever" block onto the script area. This block will run the blocks inside it repeatedly.

Inside the "forever" block, drag the "set [Image Number] to [pick random (0) to (2)]" block. This will change the value of "Image Number" to a random number between 0 and 2 every time the "forever" block runs.

Switching Costumes Based on the Variable

Next, we'll use the "Image Number" variable to switch between costumes. Click on the "Looks" menu and drag the "switch costume to [Image Number]" block onto the script area. This block will change the costume of your sprite to the one corresponding to the value of "Image Number."

To create multiple costumes, right-click on your sprite in the sprite list and select "Edit." In the costume editor, you can draw or import images for each costume. Name each costume with a number (e.g., "Costume1," "Costume2," etc.) to match the "Image Number" variable.

Adding Interactivity with User Input

Let's make your image generator more engaging by allowing users to control it. We'll add a "when this sprite clicked" block to change the "Image Number" variable when the user clicks on the sprite.

Click on the "Events" menu and drag the "when this sprite clicked" block onto the script area. Inside this block, drag the "change [Image Number] by (-1)" block. This will decrease the value of "Image Number" by 1 each time the sprite is clicked, cycling through the costumes.

Preventing Negative Numbers

Currently, the script will result in a negative number for "Image Number" if the user clicks the sprite while it's displaying the first costume. To fix this, we'll add an "if" block to check if "Image Number" is less than 0 and, if so, set it to the highest possible value (in this case, 2).

Drag the "if [Image Number] < 0" block from the "Control" menu onto the script area. Inside this block, drag the "set [Image Number] to [2]" block. This will ensure that "Image Number" always stays within the range of your costumes.

Resetting the Image Generator

Finally, let's add a way to reset the image generator. Click on the "Events" menu and drag the "when I receive [reset]" block onto the script area. This block will run when your sprite receives the "reset" message.

Inside this block, drag the "set [Image Number] to [0]" block. This will reset the "Image Number" variable to 0, displaying the first costume when the user clicks on the sprite.

Congratulations! You've just created an interactive image generator in Scratch. This project demonstrates essential programming concepts like variables, loops, and user input. As you continue exploring Scratch, you can build upon this project to create even more complex and engaging experiences.

Now that you've mastered the basics of image generation in Scratch, consider challenging yourself to create animations, games, or interactive stories. The possibilities are endless, and each project is an opportunity to learn and grow as a programmer.