Introduction: Create a Random Image Generator in Excel
A random image generator created using excel
Make your own pixel style images like CryptoPunks or WierdWhales
Step 1: Setting Up Excel
In excel mark out a grid for your drawing. Resize the rows & columns to be squares.
I made this 63 x 63 cells with the width and height set to 9 pixels.
Select the drawing area and the first column to the right. Go to conditional formatting and add a new rule.
Set the rule type to be:
Format only cells that contain
And set the rule to be:
Cell value – Equal to – 0
Set the fill colour and font colour to black
Repeat the steps for lots of colours increasing the cell value each time
1, 2, 3, 4, 5, 6, 7, …
Check the rules in the column to the right of the drawing area by typing the number in each cell.
Step 2: Starting to Draw
- Start with a simple outline of the picture you want to work from.
(I drew a bear) - Import your picture into excel and position in the grid drawn earlier.
- Make the image slightly transparent so you can see the cells underneath.
- Follow the outline of your shape setting the cells to black by typing “1” in each cell
- Once the outline is complete split the outline up into sections that you want to edit individually
I split my bear into:
Ears
Upper Head (Eyes)
Lower Head (Mouth)
Body
Arms
Feet
Step 3: Add Dynamic Features
- In a new sheet copy just the part of the picture you want to work on.
- Copy and paste down the sheet to make different versions. Leave the first rows blank!
- Once you are happy with your designs we need to be able to pick which leg to use.
Add a box where you can type which legs to pick. - Inside the top cell (B2) of the drawing area add the formula to copy the leg design selected
=INDIRECT(ADDRESS($AL$5*19+ROW(B2),COLUMN(B2)))
- Copy the formula across to the adjacent cells
- Test that the image changes as intended
Step 4: Get Creative
Repeat the process for all other sections of your image creating each part of the picture on its own sheet within the workbook.
Make sure to update the row count in the formula for the actual height of the picture section you are drawing.
=INDIRECT(ADDRESS($AL$5*19+ROW(B2),COLUMN(B2)))
Step 5: Link Everything Together
- Go back to the original image created in the main drawing grid created at the start.
- Link each cell back to the changeable drawing on its part sheet.
- Repeat for all the drawing sections.
- Once your sheet is set-up you should have your full picture as selected by the individual parts.
- Go back to each individual sheet and set the selection for each part of drawing to be picked at random.
=RANDBETWEEN(1,19)
- Change the value based on the number of drawings you have made.
Here I have 19 different leg designs, so I need a random number between 1 and 19. - Refresh the excel page to generate a new image each time.
Step 6: Take It Further
- Experiment further with colours, backgrounds and features
- Instead of defining static colours in the individual components, create random colour schemes for your drawings.
- Set the rarity of different features and build this in to your random number selection.