This project provides two simple Python scripts to generate colorful gradient images either linear or radial using NumPy and Pillow (PIL).
- ✅ Generate linear gradients (vertical or horizontal)
- ✅ Generate radial gradients (with adjustable radius)
- ✅ Fully interactive: you can enter parameters like orientation or radius
- ✅ Automatically saves generated images to an
images/folder next to the script
Make sure you have Python 3.8+ installed. Then, install dependencies:
pip install numpy pillowgradient_generator/
│
├── generate_linear_gradient.py
├── generate_radial_gradient.py
└── images/
├── linear_gradient.png
└── radial_gradient.png
The linear gradient script creates an image that transitions smoothly from a start color to an end color, either vertically or horizontally.
python generate_linear_gradient.pyEnter the orientation of the gradient (horizontal/vertical) : horizontal
The generated image will be saved as:
/images/linear_gradient.png
- Image size:
500 x 300 - Start color: Red
(255, 0, 0) - End color: Blue
(0, 0, 255) - Default orientation: Vertical
The radial gradient script generates a gradient that spreads outward from the center of the image, fading from a start color to an end color. You can control how fast the gradient spreads using the radius.
python generate_radial_gradient.pyPlease enter the radius for the radial gradient(0-1) : 0.5
The generated image will be saved as:
/images/radial_gradient.png
- Image size:
500 x 500 - Start color: Yellow
(255, 255, 0) - End color: Black
(0, 0, 0) - Default radius: 250
Both scripts create an images/ folder automatically if it doesn’t exist and store the generated images inside.
- You can freely modify the width, height, colors, and radius in each script.
- Perfect for generating backgrounds, art assets, or UI design placeholders.
MIT License © 2025 — Created for educational and creative purposes.